-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scalar JSON always undefined due to default config of JSON set to type never #146
Comments
Hi @mhretab Thanks for the reporting. I quit my job 3 months ago and haven't had a chance to explore the new Gatsby APIs. However, I think I have had enough rest. I will try again soon and this will definitely be included in v3. And please share your work if it is public. It will be very helpful for investigation. |
Also note that some gatsby source plugins set the type of some fields on the sourced node to type Declaring the I think the type of |
I had this exact problem today, where Got around it locally by not using import { GatsbyImage, IGatsbyImageData } from 'gatsby-plugin-image'
import * as React from 'react'
export type ImageData = GatsbyTypes.Maybe<
Pick<GatsbyTypes.ContentfulAsset, 'id' | 'title' | 'description'> & {
gatsbyImageData: IGatsbyImageData
}
> (for reference, this was the before) import { GatsbyImage } from 'gatsby-plugin-image'
import * as React from 'react'
export type ImageData = GatsbyTypes.Maybe<
Pick<GatsbyTypes.ContentfulAsset, 'id' | 'title' | 'description' | 'gatsbyImageData'>
> |
Out of curiosity why is JSON |
1. Renames RichTextParagraph to just RichText 2. Creates an Image component that uses GatsbyImage to render gatsbyImageData 3. Does some fun with typing so that gatsbyImageData isn't undefined (see the bug at cometkim/gatsby-plugin-typegen#146) 4. Loads images for projects & sections' paragraphs & displays them
Because the It was intentional to prevent trying to override it and I thought Gatsby itself doesn't expose JSON type which means unknown. Because basically the Gatsby query compiler can infer the shape from any data. |
typegen plugin provides types strict much as possible unless there is a specific reason, but if |
Thanks! |
@dgattey @cometkim beware
Also, regardless of the gatsby image use case, something like Thus, IMHO |
Or I can manipulate the schema for field name |
This is fixed in v3 (currently RC) As clear solution for most sites, the type of JSON is changed to Support for more precise types for image queries is a major change and will be revisited in v4. |
rc.0 - implemente XState based scheduler - stabilize schema output - bump GCG - upgrade yarn to v3 - rewritten core logics - upgrade eslint to v8 - upgrade plugin's dependencies - pin graphql version - rewrite emitSchema service - rewriten emitPluginDocument service - rewriten codegen service - add TS & Flow examples rc.1 - skip running on cloud build - fix config validation - more contexture reporting - turn `flattenGeneratedTypesIncludeFragments` true - stabilize documents - change maybe type to use `null` instead of `undefined` - update README rc.2 - add mdx example - MDX example to validate regression of [#117] - update dependencies - added support for `GatsbyImageData` scalar Resolves #40 Resolves #103 Resolves #104 Resolves #109 Fixes #113 Fixes #117 Fixes #120 Resolves #122 Fixes #124 Resolves #131 Fixes #139, #99 Resolves #146 Fixes #157 Fixes #159 Fixes #160 Fixes #161 Fixes #162 Resolves #168 Resolves #169 Fixes #171 [#117]: #117
Hi,
in
DEFAULT_SHARED_CONFIG
scalar JSON is set tonever
and this is creating an issue for the generated typegatsbyImageData
when using it withgatsby-source-contentful
. Tried changing JSON type toany
and that seems to fix it.The text was updated successfully, but these errors were encountered: