Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Incorrect groq codegened types when using array projection #261

Open
itsHabib opened this issue Mar 23, 2022 · 0 comments
Open

Incorrect groq codegened types when using array projection #261

itsHabib opened this issue Mar 23, 2022 · 0 comments

Comments

@itsHabib
Copy link

Version: @sanity-codegen/groq-codegen": "1.0.0-alpha.26".

👋 Hello I've been noticing some behavior from the groq-codegen tool that doesn't look quite right. I've noticed when I have a query that uses an array projection, the type of the first field determines the rest of the types of the fields. For example, if I have a query like so:

 *[_type == 'my-type' && _id == $typeId]{
          "outer": outer[]-> {
            field-1
           field-2
        }

Assume that field-1 is type string and field-2 is a number. When the groq-codegen completes the query type will say that both field-1andfield-2` are strings. If i switched the query around to look like this:

 *[_type == 'my-type' && _id == $typeId]{
          "outer": outer[]-> {
            field-2 <------ field-2 is first now
           field-1
        }

the generated query type will say that the types of both field-1 and field-2 are numbers. This also seems to be true if I put any other type first. Am I missing something in my query, or is this an actual issue?

@itsHabib itsHabib changed the title Incorrect Groq Codegened Types when using array projection Incorrect groq codegened types when using array projection Mar 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant