Connecting Gatsby to a Strapi CMS Heroku Backend

  • OS: Mac OS 10.14.6
  • Database: Postgres
  • Strapi version: 3.2.3

I’m trying to connect a Gatsby frontend to Strapi on Heroku. In gatsby-config.js I switched the value of apiURL from ‘http://localhost:1337’ to ‘https://[my-app].herokuapp.com’ and this change crashes my page.

Any advice for me?

Can you access your Strapi instance from that URL?

1 Like

Yeah, it works like a charm (https://pure-forest-46690.herokuapp.com/)

What exactly happens when it crashes? Can you please share some error logs?

Failed to compile
GraphQL Error Encountered 2 error(s):
- Unknown field 'allStrapiCategory' on type 'Query'. Source: document `usersHassanabuduDocumentsPersonalCodeProjects100DaysGatsbyBlueBinderSrcComponentsListCategoriesSTsx1901940577` file: `GraphQL request`
  
  GraphQL request (3:13)
  2:           query {
  3:             allStrapiCategory {
                 ^
  4:               edges {
  
- Unknown field 'allStrapiCategory' on type 'Query'. 

      file: /Users/hassanabudu/Documents/_personal/code/_projects/100_days_gatsby/blue-binder/src/components/Nav-S.tsx

But you know what, I fixed it! It’s simply that my local machine had content and the setup on Heroku did not.

2 Likes

I am having the exact same use case and issue, but both my local machine and Heroku have the exact same content yet I get the same error. And I am getting a lot of graphql schema errors.

I think the gatsby-source-strapi plugin isn’t working correctly and is not transofrming the strapi graphql schema to the one gatsby uses. Which, I don’t know why that is happening. It works when the strapi server works on my local machine.

How exactly did you fix this issue? Did you run into it again?