datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 51 forks source link

Is there a way to enable Strict Mode? #198

Closed dante-blitz closed 2 years ago

dante-blitz commented 2 years ago

Hi there,

I'm recently started working with Gatsby's GraphQL Typegen and types are being generated as expected. However typescript is givieng null error onrequired fields. For example...

Type 'string | null | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.ts(2322)

I've read your Strict Mode announcement post and your Strict Mode docs, but I'm not sure how to enable Strict Mode with this source plugin.

Any guidance is very highly appreciated.

matjack1 commented 2 years ago

@dante-blitz unfortunately the strict mode is for our GraphQL API. Gatsby is using our REST API to fetch data and then exposes it through their internal GraphQL API. So we would need to rewrite the source plugin using our latest JS client that is in Typescript: https://github.com/datocms/js-rest-api-clients

I'm closing this as it's a duplicate of: https://github.com/datocms/gatsby-source-datocms/issues/126