Scalar JSON always undefined due to default config of JSON set to type never
See original GitHub issueIssue Description
Hi,
in DEFAULT_SHARED_CONFIG
scalar JSON is set to never
and this is creating an issue for the generated type gatsbyImageData
when using it with gatsby-source-contentful
. Tried changing JSON type to any
and that seems to fix it.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:10 (5 by maintainers)
Top Results From Across the Web
What is "not assignable to parameter of type never" error in ...
Disclaimer: This is just a workaround. This error appears only when the null checks are not handled properly which in any case is...
Read more >Define type of content of Json field · Issue #3219 - GitHub
Problem Right now if you have the following schema with Json field: model User { id Int @default(autoincrement()) @id name String?
Read more >Documentation - Everyday Types - TypeScript
In this chapter, we'll cover some of the most common types of values you'll find in JavaScript code, and explain the corresponding ways...
Read more >Resolvers - Apollo GraphQL Docs
We want to define resolvers for the numberSix and numberSeven fields of the root Query type so that they always return 6 and...
Read more >Solve common issues with JSON in SQL Server
Question. I want to create a JSON text result from a simple SQL query on a single table. FOR JSON PATH and FOR...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@dgattey @cometkim beware
Record<string, any>
might not improve things/not work for the gatsbyImage use case, as helper functions from gatsby-plugin-image (likegetImage
) expect to get aImageDataLike
type passed as argument.JSON: any
would work without the need for a cast in this case, as all types can be casted to any (and vice versa).JSON: Record<string, any>
on the other hand is not structurally equal toImageDataLike
and it cannot be casted to any type, thus Typescript will throw a type error sinceRecord<string, any>
is not guaranteed to have the required fields fromImageDataLike
Also, regardless of the gatsby image use case, something like
[1,2,3]
would also be valid JSON, so in this caseRecord<string, any>
wouldn’t be the correct type either.Thus, IMHO
JSON: any
seems to be IMHO the better type to useHi @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.