Skip to content

Commit 252e737

Browse files
authored
[Spec] Move variable definition directive off of experimental flag (#1540)
1 parent 94b3844 commit 252e737

File tree

4 files changed

+6
-35
lines changed

4 files changed

+6
-35
lines changed

src/language/__tests__/parser-test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,9 @@ describe('Parser', () => {
108108
);
109109
});
110110

111-
it('Experimental: parses variable definition directives', () => {
111+
it('parses variable definition directives', () => {
112112
expect(() =>
113-
parse('query Foo($x: Boolean = false @bar) { field }', {
114-
experimentalVariableDefinitionDirectives: true,
115-
}),
113+
parse('query Foo($x: Boolean = false @bar) { field }'),
116114
).to.not.throw();
117115
});
118116

src/language/__tests__/printer-test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ describe('Printer: Query document', () => {
7777
`);
7878
});
7979

80-
it('Experimental: prints query with variable directives', () => {
80+
it('prints query with variable directives', () => {
8181
const queryAstWithVariableDirective = parse(
8282
'query ($foo: TestType = {a: 123} @testDirective(if: true) @test) { id }',
83-
{ experimentalVariableDefinitionDirectives: true },
8483
);
8584
expect(print(queryAstWithVariableDirective)).to.equal(dedent`
8685
query ($foo: TestType = {a: 123} @testDirective(if: true) @test) {
@@ -94,7 +93,6 @@ describe('Printer: Query document', () => {
9493
'fragment Foo($foo: TestType @test) on TestType @testDirective { id }',
9594
{
9695
experimentalFragmentVariables: true,
97-
experimentalVariableDefinitionDirectives: true,
9896
},
9997
);
10098
expect(print(queryAstWithVariableDirective)).to.equal(dedent`

src/language/parser.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,6 @@ export type ParseOptions = {
115115
* future.
116116
*/
117117
experimentalFragmentVariables?: boolean,
118-
119-
/**
120-
* EXPERIMENTAL:
121-
*
122-
* If enabled, the parser understands directives on variable definitions:
123-
*
124-
* query Foo($var: String = "abc" @variable_definition_directive) {
125-
* ...
126-
* }
127-
*/
128-
experimentalVariableDefinitionDirectives?: boolean,
129118
};
130119

131120
/**
@@ -341,26 +330,14 @@ function parseVariableDefinitions(
341330
*/
342331
function parseVariableDefinition(lexer: Lexer<*>): VariableDefinitionNode {
343332
const start = lexer.token;
344-
if (lexer.options.experimentalVariableDefinitionDirectives) {
345-
return {
346-
kind: Kind.VARIABLE_DEFINITION,
347-
variable: parseVariable(lexer),
348-
type: (expect(lexer, TokenKind.COLON), parseTypeReference(lexer)),
349-
defaultValue: skip(lexer, TokenKind.EQUALS)
350-
? parseValueLiteral(lexer, true)
351-
: undefined,
352-
directives: parseDirectives(lexer, true),
353-
loc: loc(lexer, start),
354-
};
355-
}
356-
357333
return {
358334
kind: Kind.VARIABLE_DEFINITION,
359335
variable: parseVariable(lexer),
360336
type: (expect(lexer, TokenKind.COLON), parseTypeReference(lexer)),
361337
defaultValue: skip(lexer, TokenKind.EQUALS)
362338
? parseValueLiteral(lexer, true)
363339
: undefined,
340+
directives: parseDirectives(lexer, true),
364341
loc: loc(lexer, start),
365342
};
366343
}

src/validation/__tests__/KnownDirectives-test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,14 @@ describe('Validate: Known directives', () => {
143143
);
144144
});
145145

146-
it('Experimental: with well placed variable definition directive', () => {
146+
it('with well placed variable definition directive', () => {
147147
expectPassesRule(
148148
KnownDirectives,
149149
`
150150
query Foo($var: Boolean @onVariableDefinition) {
151151
name
152152
}
153153
`,
154-
{ experimentalVariableDefinitionDirectives: true },
155154
);
156155
});
157156

@@ -177,7 +176,7 @@ describe('Validate: Known directives', () => {
177176
);
178177
});
179178

180-
it('Experimental: with misplaced variable definition directive', () => {
179+
it('with misplaced variable definition directive', () => {
181180
expectFailsRule(
182181
KnownDirectives,
183182
`
@@ -186,7 +185,6 @@ describe('Validate: Known directives', () => {
186185
}
187186
`,
188187
[misplacedDirective('onField', 'VARIABLE_DEFINITION', 2, 31)],
189-
{ experimentalVariableDefinitionDirectives: true },
190188
);
191189
});
192190

0 commit comments

Comments
 (0)