Skip to content
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

Syntax error when using dereferencing operator #29

Open
deslee opened this issue Jan 6, 2021 · 1 comment
Open

Syntax error when using dereferencing operator #29

deslee opened this issue Jan 6, 2021 · 1 comment

Comments

@deslee
Copy link

deslee commented Jan 6, 2021

Hi, I spent a few hours fighting this issue when trying to use next-sanity's previewSubscriptionHook. I traced it down to this package. Basically there is a syntax error for this query:

*[_id == 'siteSettings'][0] {
    ...,
    icon {
        ..., 
        asset -> { _id, metadata }
    }
}

Everything works when I remove the spaces in between the deferencing operator ->:

*[_id == 'siteSettings'][0] {
    ...,
    icon {
        ..., 
        asset->{ _id, metadata }
    }
}

This is a problem because the Sanity Studio Vision plugin allows the spaces. Fetching using Sanity Client also allows spaces between the derefencing operator.

This leads me to believe that the spaces between the operator is valid syntax, which means that it's a bug in groq-js.

If it is actually not valid syntax to have the spaces, then I think the aforementioned libraries and studio plugin should reject the syntax or print a warning for the developer.

@judofyr
Copy link
Collaborator

judofyr commented Jan 14, 2021

This is indeed a bug in groq-js and a space should be allowed before and after -> (but not between - and >). I'll look into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants