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

Fix parser bug with sequential selection sets #9

Merged
merged 7 commits into from
May 22, 2024
Merged

Conversation

ilmoraunio
Copy link
Collaborator

@ilmoraunio ilmoraunio commented Apr 26, 2024

It was possible to write:

(oksa.core/gql [[:foo {} [:qux :baz]] [:basho]])
; or
(oksa.core/gql
  (oksa.alpha.api/select (oksa.alpha.api/field :foo
                                (oksa.alpha.api/select :qux :baz))
                         (oksa.alpha.api/select :basho)))

resulting in incorrect GraphQL:

{foo{qux baz}{basho}}

This PR fixes the parser to consider sequential selection sets as invalid. We also remove an API test case that was invalid to begin with. (Edit: removed, see explanation.)

@ilmoraunio
Copy link
Collaborator Author

Well, apparently the removed test did make some sense after all. You can have a special case when you can have a (non-naked) field without a containing selection set + a subsequent selection set.

Case in point:

(unparse-and-validate [[:foo {}] [:bar]])
; or
(unparse-and-validate
               (api/select
                 (api/field :foo)
                 (api/select :bar)))
; => "{foo{bar}}"

I've made some changes to accommodate this.

@ilmoraunio ilmoraunio merged commit e784eec into main May 22, 2024
9 checks passed
@ilmoraunio ilmoraunio deleted the fix-parse-bug branch May 22, 2024 20:02
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

Successfully merging this pull request may close these issues.

1 participant