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
If you find a security vulnerability, do NOT open an issue. Email [email protected] instead.
Describe the bug
Based on the Groq cheat sheet and the reference, I understand the coalesce() function to go over all its arguments and return the first one that isn't null. Passing in a string as final argument should therefore result in a value always being available.
When executing queries and also in the vision area of the studio, this works as expected. However, the typgen will still generate null as part of the type for such fields. Possibly in cases where the field one of the params references does not exist?
For ease of looping I've added this field to all of the models (blocks, images, documents, ...) in our queries: "id": coalesce(_id, _key, "id_unknown").
Depending on the model & circumstances (e.g. included in rich text or not) the _id and/or _key fields might not be present.
When executing queries both in our FE and in the vision, this neatly falls back to "id_unknown".
But in typegen this results in cases like this:
Steps to reproduce the behavior:
Already mentione in description
Expected behavior
If the coalesce function is provided a non-dynamic fallback value, typegen should not include null in the possible types of the field to which coalesce is applied.
Screenshots
If applicable, add screenshots to help explain your problem.
Which versions of Sanity are you using?
Run sanity versions in the terminal and copy-paste the result here.
What operating system are you using?
Which versions of Node.js / npm are you running?
Run npm -v && node -v in the terminal and copy-paste the result here.
Additional context
Add any other context about the problem here.
Security issue?
no
The text was updated successfully, but these errors were encountered:
If you find a security vulnerability, do NOT open an issue. Email [email protected] instead.
Describe the bug
Based on the Groq cheat sheet and the reference, I understand the
coalesce()
function to go over all its arguments and return the first one that isn'tnull
. Passing in a string as final argument should therefore result in a value always being available.When executing queries and also in the vision area of the studio, this works as expected. However, the typgen will still generate
null
as part of the type for such fields. Possibly in cases where the field one of the params references does not exist?For ease of looping I've added this field to all of the models (blocks, images, documents, ...) in our queries:
"id": coalesce(_id, _key, "id_unknown")
.Depending on the model & circumstances (e.g. included in rich text or not) the
_id
and/or_key
fields might not be present.When executing queries both in our FE and in the vision, this neatly falls back to
"id_unknown"
.But in typegen this results in cases like this:
To Reproduce
Steps to reproduce the behavior:
Already mentione in description
Expected behavior
If the coalesce function is provided a non-dynamic fallback value, typegen should not include
null
in the possible types of the field to which coalesce is applied.Screenshots
If applicable, add screenshots to help explain your problem.
Which versions of Sanity are you using?
Run
sanity versions
in the terminal and copy-paste the result here.What operating system are you using?
Which versions of Node.js / npm are you running?
Run
npm -v && node -v
in the terminal and copy-paste the result here.Additional context
Add any other context about the problem here.
Security issue?
no
The text was updated successfully, but these errors were encountered: