craftcms / gatsby-source-craft

Gatsby source plugin for Craft CMS.
MIT License
54 stars 13 forks source link

Empty string to createTypes action #15

Closed mcclaskiem closed 3 years ago

mcclaskiem commented 3 years ago

Description

I just set up a fresh install of Craft and Gatsby. After configuring both the front-end and back end and starting up the server I get the below error:

Encountered an error parsing the provided GraphQL type definitions:
Syntax Error: Unexpected <EOF>

> 1 |
    | ^

not finished createSchemaCustomization - 0.042s

I checked out the plugin code and it looks like the createTypes(typeDefs) is getting an empty string as an argument. I currently have no queries set up in Gatsby so not sure if this is an issue here. Was hoping I could spin it up and use the Graphiql tool to make sure things were set up correctly.

Steps to reproduce

  1. run gatsby develop
  2. Observe error

Additional info

For some reason I have never had the routes config setting work on my graphql apis, not sure if it is something that Laravel Forge prevents or not. But I have gatsby pointing at the /actions/graphql/api endpoint. Happy to provide any other info as well!

mcclaskiem commented 3 years ago

Ended up being an issue with not having the discover types enabled. 🤦

brianjhanson commented 3 years ago

@mcclaskiem I'm running into the same issue, and noticed this in the Readme

Once your endpoint and schema are established, be sure to enable Allow discovery of sourcing data for Gatsby in the Gatsby section of the schema you’d like to query with the gatsby-source-craft Gatsby plugin.

But I'm not really sure how to enable type discovery. I searched the Craft docs and the Gatsby docs (although I'm guessing it's a Craft setting).

How did you enable this?

mcclaskiem commented 3 years ago

Need to make sure you have the Gatsby Helper plugin installed and then within the Gatsby Schema section where you check off what is available there should be an option above the mutate section that says allow discovery

brianjhanson commented 3 years ago

@mcclaskiem Thank you! I had completely missed the helper plugin section of the readme 🤦