Closed byronwilliams closed 1 year ago
See this: https://community.datocms.com/t/make-required-fields-non-nullable-in-graphql-schema/1873/3?u=s.verna
(btw, the same situation is present on the CMS explorer as well)
In Gatsby-land, this sentence:
The only way to provide non-null GraphQL types would be to have different GraphQL queries that only return valid records, while the current allArticles queries return both valid and invalid records.
Would become:
The only way to provide non-null GraphQL types would be to have a global configuration option that only returns valid records, while the current allDatoCmsArticles queries return both valid and invalid records.
Both of the graphql + typescript plugins for Gatsby
gatsby-plugin-graphql-config
andgatsby-plugin-graphql-codegen
declare that Required fields in DatoCMS are typed asMaybe
ornull | undefined
.This means that typescript files have to be peppered with ternary statements for "correctness". Using the DatoCMS explorer I can see that everything is typed correctly.
Can this plugin be updated so that it generates a schema inside Gatsby which marks the fields correct as required or optional?