Skip to content

Commit b3d34cd

Browse files
authored
Merge pull request #466 from iwillig/ivan/update-union-syntax
Support leading Pipes in Union Synatx
2 parents 99d71e1 + 90105be commit b3d34cd

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

resources/com/walmartlabs/lacinia/schema.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ unionExtDef
118118
;
119119

120120
unionTypes
121-
: (anyName '|')* anyName
121+
: '|'? ( anyName '|')* anyName
122122
;
123123

124124
enumDef

test/com/walmartlabs/lacinia/parser/schema_test.clj

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,25 @@
181181
(parse-string "interface Flow { ebb : String }"))))
182182

183183
(deftest schema-union
184-
(is (= {:unions
185-
{:Matter
186-
{:members [:Solid :Liquid :Gas :Plasma :INPUT_OBJECT]}}}
187-
(parse-string "union Matter = Solid | Liquid | Gas | Plasma | INPUT_OBJECT")))
184+
185+
(testing "basic union type"
186+
(is (= {:unions
187+
{:Matter
188+
{:members [:Solid :Liquid :Gas :Plasma :INPUT_OBJECT]}}}
189+
(parse-string "union Matter = Solid | Liquid | Gas | Plasma | INPUT_OBJECT"))))
190+
191+
(testing "leading pipe chars in union"
192+
(is (= {:unions
193+
{:Matter
194+
{:members [:Solid :Liquid :Gas :Plasma :INPUT_OBJECT]}}}
195+
(parse-string "union Matter = | Solid | Liquid | Gas | Plasma | INPUT_OBJECT"))))
188196

189197
(testing "extensions"
190-
(is (= {:unions
191-
{:Matter
192-
{:members [:Solid :Liquid :Gas :Plasma :INPUT_OBJECT]}}}
193-
(parse-string (str "union Matter = Solid\n"
194-
"extend union Matter = Liquid | Gas | Plasma | INPUT_OBJECT"))))))
198+
(is (= {:unions
199+
{:Matter
200+
{:members [:Solid :Liquid :Gas :Plasma :INPUT_OBJECT]}}}
201+
(parse-string (str "union Matter = Solid\n"
202+
"extend union Matter = Liquid | Gas | Plasma | INPUT_OBJECT"))))))
195203

196204
(deftest schema-field-args
197205
(is (= {:objects

0 commit comments

Comments
 (0)