Contentful logo

Contentful Community

Why do required fields appear as nullable in the GraphQL graph?

If I set a field as required and create content for it I would expect that it would appear as non-nullable in the graph and yet it doesn’t. Any idea why that would be?

1 Like

We’re dealing with the same issue. Basically we’d like “required” on Contentful to equate to non-nullable in terms of the graphql schema, but that’s not how it works.

We are using gatsby-source-contentful, and the issue is on the Contentful side here… Context:

Same boat here – can anyone from Contentful chime in?


The reason why all fields (even those that are required) are nullable is that the preview content is served through the same schema, and in preview mode, there are no validations (a required fields might be empty).

Is it possible, that you return the production schema only?
Maybe with a header parameter “production=true”?
This would be a massive improvement!

Edit: As an alternative it could help, to generate and make it possible to download a production schema file.