thompsonsj / gatbsy-source-payload-cms

MIT License
5 stars 0 forks source link

feat(*): replace schema validation with customization #17

Closed thompsonsj closed 1 year ago

thompsonsj commented 1 year ago

Replace the Schema validation function with the possibility to pass a GraphQL Schema Definition Language string to createTypes in Gatsby's onSchemaCustomization.

Details

Schema validation introduced in https://github.com/thompsonsj/gatbsy-source-payload-cms/pull/8 was a way of avoiding build errors caused by Gatsby being unable to infer types.

An example of when this can happen is if a relation is deleted in Payload - instead of an object, an id string is returned. If other articles in the collection have objects on that field, Gatsby will struggle to infer types.

Schema validation excluded entities which didn't pass this validation. This was always a quick fix to get the build working again - it makes more sense to explicitly define types for Gatsby.