Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 8a20eaa

Browse files
author
Josh Price
committed
Parse TypeExtensionDefinition
1 parent fe341fa commit 8a20eaa

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/graphql_lexer.xrl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ StringValue = "{StringCharacter}*"
4242
BooleanValue = true|false
4343
4444
% Reserved words
45-
ReservedWord = query|mutation|fragment|on|type|implements|interface|union|scalar|enum|input|null
45+
ReservedWord = query|mutation|fragment|on|type|implements|interface|union|scalar|enum|input|extend|null
4646
4747
Rules.
4848

src/graphql_parser.yrl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Nonterminals
1717
Terminals
1818
'{' '}' '(' ')' '[' ']' '!' ':' '@' '$' '=' '|' '...'
1919
'query' 'mutation' 'fragment' 'on'
20-
'type' 'implements' 'interface' 'union' 'scalar' 'enum' 'input'
20+
'type' 'implements' 'interface' 'union' 'scalar' 'enum' 'input' 'extend'
2121
name int_value float_value string_value boolean_value.
2222

2323
Rootsymbol Document.
@@ -134,7 +134,7 @@ TypeDefinition -> UnionTypeDefinition : '$1'.
134134
TypeDefinition -> ScalarTypeDefinition : '$1'.
135135
TypeDefinition -> EnumTypeDefinition : '$1'.
136136
TypeDefinition -> InputObjectTypeDefinition : '$1'.
137-
% TypeDefinition -> TypeExtensionDefinition : '$1'.
137+
TypeDefinition -> TypeExtensionDefinition : '$1'.
138138

139139
ObjectTypeDefinition -> 'type' Name '{' FieldDefinitionList '}' :
140140
build_ast_node('ObjectTypeDefinition', [{'name', '$2'}, {'fields', '$4'}]).
@@ -181,6 +181,9 @@ EnumValueDefinition -> EnumValue : '$1'.
181181
InputObjectTypeDefinition -> 'input' Name '{' InputValueDefinitionList '}' :
182182
build_ast_node('InputObjectTypeDefinition', [{'name', '$2'}, {'fields', '$4'}]).
183183

184+
TypeExtensionDefinition -> 'extend' ObjectTypeDefinition :
185+
build_ast_node('TypeExtensionDefinition', [{'definition', '$2'}]).
186+
184187
Erlang code.
185188

186189
extract_atom({Value, _Line}) -> Value.

test/graphql_parser_test.exs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,17 @@ defmodule GraphqlParserTest do
410410
[kind: :InputValueDefinition, loc: [start: 0], name: 'y',
411411
type: [kind: :NamedType, loc: [start: 0], name: 'Float']]]]]]
412412
end
413+
414+
test "TypeExtensionDefinition" do
415+
assert_parse 'extend type Story { isHiddenLocally: Boolean }',
416+
[kind: :Document, loc: [start: 0],
417+
definitions: [
418+
[kind: :TypeExtensionDefinition, loc: [start: 0],
419+
definition: [kind: :ObjectTypeDefinition, loc: [start: 0],
420+
name: 'Story',
421+
fields: [
422+
[kind: :FieldDefinition, loc: [start: 0],
423+
name: 'isHiddenLocally',
424+
type: [kind: :NamedType, loc: [start: 0], name: 'Boolean']]]]]]]
425+
end
413426
end

0 commit comments

Comments
 (0)