Skip to content

Commit 0d129ff

Browse files
committed
Move variable definition directive off of experimental flag
Replicates graphql/graphql-js@252e737
1 parent f241b36 commit 0d129ff

File tree

4 files changed

+8
-38
lines changed

4 files changed

+8
-38
lines changed

graphql/language/parser.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@
6666

6767

6868
def parse(
69-
source: SourceType,
70-
no_location=False,
71-
experimental_fragment_variables=False,
72-
experimental_variable_definition_directives=False,
69+
source: SourceType, no_location=False, experimental_fragment_variables=False
7370
) -> DocumentNode:
7471
"""Given a GraphQL source, parse it into a Document.
7572
@@ -90,13 +87,6 @@ def parse(
9087
fragment A($var: Boolean = false) on T {
9188
...
9289
}
93-
94-
If `experimental_variable_definition_directives` is set to True, the parser
95-
understands directives on variable definitions::
96-
97-
query Foo($var: String = "abc" @variable_definition_directive) {
98-
...
99-
}
10090
"""
10191
if isinstance(source, str):
10292
source = Source(source)
@@ -106,9 +96,6 @@ def parse(
10696
source,
10797
no_location=no_location,
10898
experimental_fragment_variables=experimental_fragment_variables,
109-
experimental_variable_definition_directives=(
110-
experimental_variable_definition_directives
111-
),
11299
)
113100
return parse_document(lexer)
114101

@@ -246,22 +233,13 @@ def parse_variable_definitions(lexer: Lexer) -> List[VariableDefinitionNode]:
246233
def parse_variable_definition(lexer: Lexer) -> VariableDefinitionNode:
247234
"""VariableDefinition: Variable: Type DefaultValue? Directives[Const]?"""
248235
start = lexer.token
249-
if lexer.experimental_variable_definition_directives:
250-
return VariableDefinitionNode(
251-
variable=parse_variable(lexer),
252-
type=expect(lexer, TokenKind.COLON) and parse_type_reference(lexer),
253-
default_value=parse_value_literal(lexer, True)
254-
if skip(lexer, TokenKind.EQUALS)
255-
else None,
256-
directives=parse_directives(lexer, True),
257-
loc=loc(lexer, start),
258-
)
259236
return VariableDefinitionNode(
260237
variable=parse_variable(lexer),
261238
type=expect(lexer, TokenKind.COLON) and parse_type_reference(lexer),
262239
default_value=parse_value_literal(lexer, True)
263240
if skip(lexer, TokenKind.EQUALS)
264241
else None,
242+
directives=parse_directives(lexer, True),
265243
loc=loc(lexer, start),
266244
)
267245

tests/language/test_parser.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,8 @@ def parses_constant_default_values():
105105
(1, 37),
106106
)
107107

108-
def experimental_parses_variable_definition_directives():
109-
parse(
110-
"query Foo($x: Boolean = false @bar) { field }",
111-
experimental_variable_definition_directives=True,
112-
)
108+
def parses_variable_definition_directives():
109+
parse("query Foo($x: Boolean = false @bar) { field }")
113110

114111
def does_not_accept_fragments_named_on():
115112
assert_syntax_error("fragment on on on { on }", "Unexpected Name 'on'", (1, 10))

tests/language/test_printer.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,9 @@ def correctly_prints_mutation_operation_with_artifacts():
6464
"""
6565
)
6666

67-
def experimental_prints_query_with_variable_directives():
67+
def prints_query_with_variable_directives():
6868
query_ast_with_variable_directive = parse(
69-
"query ($foo: TestType = {a: 123}"
70-
" @testDirective(if: true) @test) { id }",
71-
experimental_variable_definition_directives=True,
69+
"query ($foo: TestType = {a: 123}" " @testDirective(if: true) @test) { id }"
7270
)
7371
assert print_ast(query_ast_with_variable_directive) == dedent(
7472
"""
@@ -82,7 +80,6 @@ def experimental_prints_fragment_with_variable_directives():
8280
query_ast_with_variable_directive = parse(
8381
"fragment Foo($foo: TestType @test) on TestType @testDirective { id }",
8482
experimental_fragment_variables=True,
85-
experimental_variable_definition_directives=True,
8683
)
8784
assert print_ast(query_ast_with_variable_directive) == dedent(
8885
"""

tests/validation/test_known_directives.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,14 @@ def with_well_placed_directives():
127127
""",
128128
)
129129

130-
def experimental_with_well_placed_variable_definition_directive():
130+
def with_well_placed_variable_definition_directive():
131131
expect_passes_rule(
132132
KnownDirectivesRule,
133133
"""
134134
query Foo($var: Boolean @onVariableDefinition) {
135135
name
136136
}
137137
""",
138-
experimental_variable_definition_directives=True,
139138
)
140139

141140
def with_misplaced_directives():
@@ -159,7 +158,7 @@ def with_misplaced_directives():
159158
],
160159
)
161160

162-
def experimental_with_misplaced_variable_definition_directive():
161+
def with_misplaced_variable_definition_directive():
163162
expect_fails_rule(
164163
KnownDirectivesRule,
165164
"""
@@ -168,7 +167,6 @@ def experimental_with_misplaced_variable_definition_directive():
168167
}
169168
""",
170169
[misplaced_directive("onField", "variable definition", 2, 37)],
171-
experimental_variable_definition_directives=True,
172170
)
173171

174172
def describe_within_sdl():

0 commit comments

Comments
 (0)