Skip to content

Commit

Permalink
Merge pull request #466 from iwillig/ivan/update-union-syntax
Browse files Browse the repository at this point in the history
Support leading Pipes in Union Synatx
  • Loading branch information
hlship authored Feb 8, 2025
2 parents 99d71e1 + 90105be commit b3d34cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
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

0 comments on commit b3d34cd

Please sign in to comment.