I'm making a headless Drupal site with Gatsby using paragraphs. I'm experienced with Drupal but relatively new with gatsby/graphql.

The issue I'm running into is that if our database does not actually have any instances of a paragraph, then it generates the schema without that (i guess it generates a minimal schema based on what exists, not what types are actually possible) and it errors out because it's not an allowed type in the schema when it gets to that paragraph in my graphql union type.

enter image description here

I'm getting around this currently by making sure there's a node with content with all the possible paragraphs (or referenced nodes for entity reference fields). Everything works then, but this is a bad solution, especially for a site that'll eventually be handed off to a client. I feel like there's gotta be a way to make them optional in graphql or not break the build if one paragraph doesn't exist in content.

I know I can customize the schema, but some content types have 10-20 possible paragraphs and that'd just get insane if I had to manually maintain the schema when it's so close to what I need automatically.

Any help would be greatly appreciated. Thanks!

1 Answer 1


This may help: https://medium.com/@Zepro/contentful-reference-fields-with-gatsby-js-graphql-9f14ed90bdf9

Just wrap your GraphQL fragments into a Node-type.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.