prismic-gatsby
prismic-gatsby copied to clipboard
Coordinate Fields are incorrectly defined as Non-nullable
Versions
- gatsby-source-prismic: 5.2.2
- gatsby-plugin-prismic-previews: 5.2.1
- node: 16.13.2
Steps to reproduce
- Create a Prismic Custom Type with a Coordinates Field
- Create a record of this type and don't set Coordinates
- Create a GraphQL query that queries for the coordinates
What is expected?
I would expect Gatsby to be able to handle null values for all Prismic fields (except UID) given the fact that Prismic does not have a required feature for fields (except UID)
What is actually happening?
I get an error saying The field "PrismicGeoPointType.latitude" was explicitly defined as non-nullable via the schema customization API
.
I resolved this by adding an infer to my gatsby node:
exports.createSchemaCustomization = ({ actions, schema }) => {
const { createTypes } = actions
const { buildObjectType } = schema
const PrismicGeoPointType = buildObjectType({
name: 'PrismicGeoPointType',
fields: {
latitude: 'Float',
longitude: 'Float'
}
})
createTypes(PrismicGeoPointType)
}
Thanks @TannerJuby1 and @jodiedoubleday. I will include this fix in the next major version (details are available in an RFC here).
In the meantime, @jodiedoubleday's fix should work.