You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am facing some issues with TypeScript types definition when retrieving data using GraphQL:
The type definition of prismicClient.graphQLFetch is not corresponding to the type definition of GraphQLClient
Some type data, like for Slice or LinkField (they may be others - those are the ones I discovered in my implementation) are different between Rest API and GraphQL, and the current types doesn't contain the GraphQL props
Additional Details for GraphQLClient type issue
I am using GraphQLClient from graphql-request as written in your documentation here. My project is using TypeScript. When I do the following to create the GraphQLClient:
on the line fetch: prismicClient.graphQLFetch, I get the following TS error:
Additional Details for graphql types
The data I receive from graphql (compared to what is in the TypeScript types you defined), I get different props, like:
On Slice: `items` (for rest API) is `fields` (for graphql)
On LinkField: `link_type` (for rest API) is `_linkType` (for graphql) - here even with different content!
To make it work with TypeScript, I would have to extend the types you provide by including the GraphQL props.
Steps to reproduce
Configure prismic client to query on the GraphQL endpoint
Do a query which returns a slice and containing, for example, a LinkField
Note that the response from graphql contains "fields" prop for the slice, and _linkType for the LinkField
What is expected?
Types for objects returned from the GraphQL endpoint are provided
prismicClient.graphQLFetch returns the same type as requested by GraphQLClient
What is actually happening?
Actually, the types are only returning the props that we receive through the Rest API. And since props are different than the ones returned by GraphQL, they are then missing.
The text was updated successfully, but these errors were encountered:
This issue has been labeled as a bug since it was created using the 🚨 Bug Report Template.
Hi there, thank you so much for the report!
Following our Maintenance Process, we will review your bug report and get back to you next Wednesday. To ensure a smooth review of your issue and avoid unnecessary delays, please make sure your issue includes the following:
Information about your environment and packages you use (Node.js version, package names and their versions, etc.) Feel free to attach a copy of your package.json file.
Any troubleshooting steps you already went through
A minimal reproduction of the issue, and/or instructions on how to reproduce it
If you have identified the cause of the bug described in your report and know how to fix it, you're more than welcome to open a pull request addressing it. Check out our quick start guide for a simple contribution process.
If you think your issue is a question (not a bug) and would like quicker support, please close this issue and forward it to an appropriate section on our community forum: https://community.prismic.io
Versions
Reproduction
I am facing some issues with TypeScript types definition when retrieving data using GraphQL:
Additional Details for GraphQLClient type issue
I am using
GraphQLClient
fromgraphql-request
as written in your documentation here. My project is using TypeScript. When I do the following to create the GraphQLClient:on the line
fetch: prismicClient.graphQLFetch
, I get the following TS error:Additional Details for graphql types
The data I receive from graphql (compared to what is in the TypeScript types you defined), I get different props, like: On Slice: `items` (for rest API) is `fields` (for graphql) On LinkField: `link_type` (for rest API) is `_linkType` (for graphql) - here even with different content!
To make it work with TypeScript, I would have to extend the types you provide by including the GraphQL props.
Steps to reproduce
What is expected?
What is actually happening?
Actually, the types are only returning the props that we receive through the Rest API. And since props are different than the ones returned by GraphQL, they are then missing.
The text was updated successfully, but these errors were encountered: