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

Support leading Pipes in Union Synatx #466

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/com/walmartlabs/lacinia/schema.g4
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ unionExtDef
;

unionTypes
: (anyName '|')* anyName
: '|'? ( anyName '|')* anyName
;

enumDef
Expand Down
26 changes: 17 additions & 9 deletions test/com/walmartlabs/lacinia/parser/schema_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,25 @@
(parse-string "interface Flow { ebb : String }"))))

(deftest schema-union
(is (= {:unions
{:Matter
{:members [:Solid :Liquid :Gas :Plasma :INPUT_OBJECT]}}}
(parse-string "union Matter = Solid | Liquid | Gas | Plasma | INPUT_OBJECT")))

(testing "basic union type"
(is (= {:unions
{:Matter
{:members [:Solid :Liquid :Gas :Plasma :INPUT_OBJECT]}}}
(parse-string "union Matter = Solid | Liquid | Gas | Plasma | INPUT_OBJECT"))))

(testing "leading pipe chars in union"
(is (= {:unions
{:Matter
{:members [:Solid :Liquid :Gas :Plasma :INPUT_OBJECT]}}}
(parse-string "union Matter = | Solid | Liquid | Gas | Plasma | INPUT_OBJECT"))))

(testing "extensions"
(is (= {:unions
{:Matter
{:members [:Solid :Liquid :Gas :Plasma :INPUT_OBJECT]}}}
(parse-string (str "union Matter = Solid\n"
"extend union Matter = Liquid | Gas | Plasma | INPUT_OBJECT"))))))
(is (= {:unions
{:Matter
{:members [:Solid :Liquid :Gas :Plasma :INPUT_OBJECT]}}}
(parse-string (str "union Matter = Solid\n"
"extend union Matter = Liquid | Gas | Plasma | INPUT_OBJECT"))))))

(deftest schema-field-args
(is (= {:objects
Expand Down