Answered

How to explicitly type my GraphQL schema?

How do I explicitly type my GraphQL schema? I have optional fields in some of my Content Definitions and if any of them are not being used at least once in the content my CMS users control, then the `gatsby develop` and `gatsby build` will both fail.

The error Gatsby gives me tells me to either create "dummy content" or to explicitly type my GraphQL schema (https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions). I am not sure if the latter of the two options Gatsby gives me is actually doable on my end? Should I just create a dummy content to fix this error?

1

Comments

1 comment
  • Official comment

    Hi John,

    We have an open issue in github for this right now: https://github.com/agility/gatsby-source-agilitycms/issues/3.

    Ideally, the `gatsby-source-agilitycms` plugin should define the types as part of the build process, however, it doesn't have the ability to pull Content/Module definition schemas as of yet - this is a feature we need to add to our API first.

    You could, in theory manually define each type, but I wouldn't recommend that. Their recommendation of creating a dummy item with all the fields is probably the best option right now, if you are using optional fields.

    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post