Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/language/__tests__/parser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,9 @@ describe('Parser', () => {
);
});

it('Experimental: parses variable definition directives', () => {
it('parses variable definition directives', () => {
expect(() =>
parse('query Foo($x: Boolean = false @bar) { field }', {
experimentalVariableDefinitionDirectives: true,
}),
parse('query Foo($x: Boolean = false @bar) { field }'),
).to.not.throw();
});

Expand Down
4 changes: 1 addition & 3 deletions src/language/__tests__/printer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ describe('Printer: Query document', () => {
`);
});

it('Experimental: prints query with variable directives', () => {
it('prints query with variable directives', () => {
const queryAstWithVariableDirective = parse(
'query ($foo: TestType = {a: 123} @testDirective(if: true) @test) { id }',
{ experimentalVariableDefinitionDirectives: true },
);
expect(print(queryAstWithVariableDirective)).to.equal(dedent`
query ($foo: TestType = {a: 123} @testDirective(if: true) @test) {
Expand All @@ -94,7 +93,6 @@ describe('Printer: Query document', () => {
'fragment Foo($foo: TestType @test) on TestType @testDirective { id }',
{
experimentalFragmentVariables: true,
experimentalVariableDefinitionDirectives: true,
},
);
expect(print(queryAstWithVariableDirective)).to.equal(dedent`
Expand Down
25 changes: 1 addition & 24 deletions src/language/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,6 @@ export type ParseOptions = {
* future.
*/
experimentalFragmentVariables?: boolean,

/**
* EXPERIMENTAL:
*
* If enabled, the parser understands directives on variable definitions:
*
* query Foo($var: String = "abc" @variable_definition_directive) {
* ...
* }
*/
experimentalVariableDefinitionDirectives?: boolean,
};

/**
Expand Down Expand Up @@ -341,26 +330,14 @@ function parseVariableDefinitions(
*/
function parseVariableDefinition(lexer: Lexer<*>): VariableDefinitionNode {
const start = lexer.token;
if (lexer.options.experimentalVariableDefinitionDirectives) {
return {
kind: Kind.VARIABLE_DEFINITION,
variable: parseVariable(lexer),
type: (expect(lexer, TokenKind.COLON), parseTypeReference(lexer)),
defaultValue: skip(lexer, TokenKind.EQUALS)
? parseValueLiteral(lexer, true)
: undefined,
directives: parseDirectives(lexer, true),
loc: loc(lexer, start),
};
}

return {
kind: Kind.VARIABLE_DEFINITION,
variable: parseVariable(lexer),
type: (expect(lexer, TokenKind.COLON), parseTypeReference(lexer)),
defaultValue: skip(lexer, TokenKind.EQUALS)
? parseValueLiteral(lexer, true)
: undefined,
directives: parseDirectives(lexer, true),
loc: loc(lexer, start),
};
}
Expand Down
6 changes: 2 additions & 4 deletions src/validation/__tests__/KnownDirectives-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,14 @@ describe('Validate: Known directives', () => {
);
});

it('Experimental: with well placed variable definition directive', () => {
it('with well placed variable definition directive', () => {
expectPassesRule(
KnownDirectives,
`
query Foo($var: Boolean @onVariableDefinition) {
name
}
`,
{ experimentalVariableDefinitionDirectives: true },
);
});

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

it('Experimental: with misplaced variable definition directive', () => {
it('with misplaced variable definition directive', () => {
expectFailsRule(
KnownDirectives,
`
Expand All @@ -186,7 +185,6 @@ describe('Validate: Known directives', () => {
}
`,
[misplacedDirective('onField', 'VARIABLE_DEFINITION', 2, 31)],
{ experimentalVariableDefinitionDirectives: true },
);
});

Expand Down