Skip to content

Commit 920b45a

Browse files
Deprecate fragments with variables and reflect that in naming (#2920)
1 parent 0f9d35c commit 920b45a

File tree

10 files changed

+19
-29
lines changed

10 files changed

+19
-29
lines changed

src/language/__tests__/parser-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,11 @@ describe('Parser', () => {
363363
expect(result.loc).to.equal(undefined);
364364
});
365365

366-
it('Experimental: allows parsing fragment defined variables', () => {
366+
it('Legacy: allows parsing fragment defined variables', () => {
367367
const document = 'fragment a($v: Boolean = false) on t { f(v: $v) }';
368368

369369
expect(() =>
370-
parse(document, { experimentalFragmentVariables: true }),
370+
parse(document, { allowLegacyFragmentVariables: true }),
371371
).to.not.throw();
372372
expect(() => parse(document)).to.throw('Syntax Error');
373373
});

src/language/__tests__/printer-test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,10 @@ describe('Printer: Query document', () => {
117117
);
118118
});
119119

120-
it('Experimental: prints fragment with variable directives', () => {
120+
it('Legacy: prints fragment with variable directives', () => {
121121
const queryASTWithVariableDirective = parse(
122122
'fragment Foo($foo: TestType @test) on TestType @testDirective { id }',
123-
{
124-
experimentalFragmentVariables: true,
125-
},
123+
{ allowLegacyFragmentVariables: true },
126124
);
127125
expect(print(queryASTWithVariableDirective)).to.equal(dedent`
128126
fragment Foo($foo: TestType @test) on TestType @testDirective {
@@ -131,14 +129,14 @@ describe('Printer: Query document', () => {
131129
`);
132130
});
133131

134-
it('Experimental: correctly prints fragment defined variables', () => {
132+
it('Legacy: correctly prints fragment defined variables', () => {
135133
const fragmentWithVariable = parse(
136134
`
137135
fragment Foo($a: ComplexType, $b: Boolean = false) on TestType {
138136
id
139137
}
140138
`,
141-
{ experimentalFragmentVariables: true },
139+
{ allowLegacyFragmentVariables: true },
142140
);
143141
expect(print(fragmentWithVariable)).to.equal(dedent`
144142
fragment Foo($a: ComplexType, $b: Boolean = false) on TestType {

src/language/__tests__/visitor-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,10 @@ describe('Visitor', () => {
438438
]);
439439
});
440440

441-
it('Experimental: visits variables defined in fragments', () => {
441+
it('Legacy: visits variables defined in fragments', () => {
442442
const ast = parse('fragment a($v: Boolean = false) on t { f }', {
443443
noLocation: true,
444-
experimentalFragmentVariables: true,
444+
allowLegacyFragmentVariables: true,
445445
});
446446
const visited = [];
447447

src/language/ast.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ export interface FragmentDefinitionNode {
297297
readonly kind: 'FragmentDefinition';
298298
readonly loc?: Location;
299299
readonly name: NameNode;
300-
// Note: fragment variable definitions are experimental and may be changed
301-
// or removed in the future.
300+
// Note: fragment variable definitions are deprecated and will removed in v17.0.0
302301
readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode>;
303302
readonly typeCondition: NamedTypeNode;
304303
readonly directives?: ReadonlyArray<DirectiveNode>;

src/language/ast.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,7 @@ export type FragmentDefinitionNode = {|
323323
+kind: 'FragmentDefinition',
324324
+loc?: Location,
325325
+name: NameNode,
326-
// Note: fragment variable definitions are experimental and may be changed
327-
// or removed in the future.
326+
// Note: fragment variable definitions are deprecated and will removed in v17.0.0
328327
+variableDefinitions?: $ReadOnlyArray<VariableDefinitionNode>,
329328
+typeCondition: NamedTypeNode,
330329
+directives?: $ReadOnlyArray<DirectiveNode>,

src/language/parser.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface ParseOptions {
1313
noLocation?: boolean;
1414

1515
/**
16-
* EXPERIMENTAL:
16+
* @deprecated will be removed in the v17.0.0
1717
*
1818
* If enabled, the parser will understand and parse variable definitions
1919
* contained in a fragment definition. They'll be represented in the
@@ -25,10 +25,8 @@ export interface ParseOptions {
2525
* ...
2626
* }
2727
*
28-
* Note: this feature is experimental and may change or be removed in the
29-
* future.
3028
*/
31-
experimentalFragmentVariables?: boolean;
29+
allowLegacyFragmentVariables?: boolean;
3230
}
3331

3432
/**

src/language/parser.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export type ParseOptions = {|
6767
noLocation?: boolean,
6868

6969
/**
70-
* EXPERIMENTAL:
70+
* @deprecated will be removed in the v17.0.0
7171
*
7272
* If enabled, the parser will understand and parse variable definitions
7373
* contained in a fragment definition. They'll be represented in the
@@ -79,10 +79,8 @@ export type ParseOptions = {|
7979
* ...
8080
* }
8181
*
82-
* Note: this feature is experimental and may change or be removed in the
83-
* future.
8482
*/
85-
experimentalFragmentVariables?: boolean,
83+
allowLegacyFragmentVariables?: boolean,
8684
|};
8785

8886
/**
@@ -458,10 +456,10 @@ export class Parser {
458456
parseFragmentDefinition(): FragmentDefinitionNode {
459457
const start = this._lexer.token;
460458
this.expectKeyword('fragment');
461-
// Experimental support for defining variables within fragments changes
459+
// Legacy support for defining variables within fragments changes
462460
// the grammar of FragmentDefinition:
463461
// - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
464-
if (this._options?.experimentalFragmentVariables === true) {
462+
if (this._options?.allowLegacyFragmentVariables === true) {
465463
return {
466464
kind: Kind.FRAGMENT_DEFINITION,
467465
name: this.parseFragmentName(),

src/language/visitor.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ export const QueryDocumentKeys: {
7878
// prettier-ignore
7979
FragmentDefinition: [
8080
'name',
81-
// Note: fragment variable definitions are experimental and may be changed
82-
// or removed in the future.
81+
// Note: fragment variable definitions are deprecated and will removed in v17.0.0
8382
'variableDefinitions',
8483
'typeCondition',
8584
'directives',

src/language/visitor.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ export const QueryDocumentKeys: VisitorKeyMap<ASTKindToNode> = {
6767
InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
6868
FragmentDefinition: [
6969
'name',
70-
// Note: fragment variable definitions are experimental and may be changed
71-
// or removed in the future.
70+
// Note: fragment variable definitions are deprecated and will removed in v17.0.0
7271
'variableDefinitions',
7372
'typeCondition',
7473
'directives',

src/utilities/buildASTSchema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function buildSchema(
9898
): GraphQLSchema {
9999
const document = parse(source, {
100100
noLocation: options?.noLocation,
101-
experimentalFragmentVariables: options?.experimentalFragmentVariables,
101+
allowLegacyFragmentVariables: options?.allowLegacyFragmentVariables,
102102
});
103103

104104
return buildASTSchema(document, {

0 commit comments

Comments
 (0)