-
Notifications
You must be signed in to change notification settings - Fork 426
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
Typegen not reading => @
correctly.
#6555
Comments
Hi, thanks for reporting. I'm struggling a bit to reproduce this case. What version of the API are you using to execute the groq query? What does the schema definition for type |
Thank You for looking into it. Sanity API version: 2023-03-30 The
The issue seems to happen with the narrowing of Hero and Cta when generating the type for the groq query response. This is the
Please let me know if you'd like more information. Or if you suggest any other way to write the query in order for the TypeGen to read it correctly for the time being. |
Thanks! with the Page schema definition I'm able to reproduce 🙂 |
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread. |
If you find a security vulnerability, do NOT open an issue. Email security@sanity.io instead.
Describe the bug
I need to use a component based approach in my app.
Every page has a
components
field that is an array of different possible objects ((Hero | Cta)[]
).I want to resolve the image asset references for the
Hero
component and get the rest of my components without any modifier applied.The generated type QUERYResult type contains only part of the queried
Hero
component and no types for all the other components (Cta
)To Reproduce
Steps to reproduce the behavior:
Groq query
Generated types (components) ✅
Generated type (homepage query) ❌
Expected behavior
HOMEPAGE_QUERYResult['components']
should match the value returned by the API.Hero
should have atitle
,subtitle
,_type
and the resolvedimageDesktop
andimageDesktop
references. Since all the orher components are returned in full (_type != 'hero' => @)HOMEPAGE_QUERYResult['components']
should contain all the other component types (Cta
).Screenshots
N/A
Which versions of Sanity are you using?
@sanity/cli (global) 3.40.0 (up to date)
@sanity/eslint-config-studio 4.0.0 (up to date)
@sanity/vision 3.40.0 (up to date)
sanity 3.40.0 (up to date)
What operating system are you using?
iOS
Which versions of Node.js / npm are you running?
10.2.4
v20.11.1
Additional context
The types from the schema are being generated correctly, the only issue is in the GROQ query.
Security issue?
Any security issues should be submitted directly to security@sanity.io. In order to determine whether you are dealing with a security issue, ask yourself these two questions:
The text was updated successfully, but these errors were encountered: