Skip to content

Commit 84f901a

Browse files
committed
Removed parser support for legacy syntax
1 parent edff2e9 commit 84f901a

File tree

4 files changed

+3
-96
lines changed

4 files changed

+3
-96
lines changed

src/language/__tests__/schema-parser-test.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,29 +1106,4 @@ input Hello {
11061106
it('parses kitchen sink schema', () => {
11071107
expect(() => parse(kitchenSinkSDL)).to.not.throw();
11081108
});
1109-
1110-
it('Option: allowLegacySDLEmptyFields supports type with empty fields', () => {
1111-
const body = 'type Hello { }';
1112-
expectSyntaxError(body).to.include({
1113-
message: 'Syntax Error: Expected Name, found "}".',
1114-
});
1115-
1116-
const doc = parse(body, { allowLegacySDLEmptyFields: true });
1117-
expect(doc).to.have.deep.nested.property('definitions[0].fields', []);
1118-
});
1119-
1120-
it('Option: allowLegacySDLImplementsInterfaces', () => {
1121-
const body = 'type Hello implements Wo rld { field: String }';
1122-
expectSyntaxError(body).to.include({
1123-
message: 'Syntax Error: Unexpected Name "rld".',
1124-
});
1125-
1126-
const doc = parse(body, { allowLegacySDLImplementsInterfaces: true });
1127-
expect(
1128-
toJSONDeep(doc),
1129-
).to.have.deep.nested.property('definitions[0].interfaces', [
1130-
typeNode('Wo', { start: 22, end: 24 }),
1131-
typeNode('rld', { start: 25, end: 28 }),
1132-
]);
1133-
});
11341109
});

src/language/parser.d.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,6 @@ export interface ParseOptions {
1212
*/
1313
noLocation?: boolean;
1414

15-
/**
16-
* If enabled, the parser will parse empty fields sets in the Schema
17-
* Definition Language. Otherwise, the parser will follow the current
18-
* specification.
19-
*
20-
* This option is provided to ease adoption of the final SDL specification
21-
* and will be removed in v16.
22-
*/
23-
allowLegacySDLEmptyFields?: boolean;
24-
25-
/**
26-
* If enabled, the parser will parse implemented interfaces with no `&`
27-
* character between each interface. Otherwise, the parser will follow the
28-
* current specification.
29-
*
30-
* This option is provided to ease adoption of the final SDL specification
31-
* and will be removed in v16.
32-
*/
33-
allowLegacySDLImplementsInterfaces?: boolean;
34-
3515
/**
3616
* EXPERIMENTAL:
3717
*

src/language/parser.js

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,6 @@ export type ParseOptions = {|
6666
*/
6767
noLocation?: boolean,
6868

69-
/**
70-
* If enabled, the parser will parse empty fields sets in the Schema
71-
* Definition Language. Otherwise, the parser will follow the current
72-
* specification.
73-
*
74-
* This option is provided to ease adoption of the final SDL specification
75-
* and will be removed in v16.
76-
*/
77-
allowLegacySDLEmptyFields?: boolean,
78-
79-
/**
80-
* If enabled, the parser will parse implemented interfaces with no `&`
81-
* character between each interface. Otherwise, the parser will follow the
82-
* current specification.
83-
*
84-
* This option is provided to ease adoption of the final SDL specification
85-
* and will be removed in v16.
86-
*/
87-
allowLegacySDLImplementsInterfaces?: boolean,
88-
8969
/**
9070
* EXPERIMENTAL:
9171
*
@@ -855,40 +835,15 @@ export class Parser {
855835
* - ImplementsInterfaces & NamedType
856836
*/
857837
parseImplementsInterfaces(): Array<NamedTypeNode> {
858-
if (!this.expectOptionalKeyword('implements')) {
859-
return [];
860-
}
861-
862-
if (this._options?.allowLegacySDLImplementsInterfaces === true) {
863-
const types = [];
864-
// Optional leading ampersand
865-
this.expectOptionalToken(TokenKind.AMP);
866-
do {
867-
types.push(this.parseNamedType());
868-
} while (
869-
this.expectOptionalToken(TokenKind.AMP) ||
870-
this.peek(TokenKind.NAME)
871-
);
872-
return types;
873-
}
874-
875-
return this.delimitedMany(TokenKind.AMP, this.parseNamedType);
838+
return this.expectOptionalKeyword('implements')
839+
? this.delimitedMany(TokenKind.AMP, this.parseNamedType)
840+
: [];
876841
}
877842

878843
/**
879844
* FieldsDefinition : { FieldDefinition+ }
880845
*/
881846
parseFieldsDefinition(): Array<FieldDefinitionNode> {
882-
// Legacy support for the SDL?
883-
if (
884-
this._options?.allowLegacySDLEmptyFields === true &&
885-
this.peek(TokenKind.BRACE_L) &&
886-
this._lexer.lookahead().kind === TokenKind.BRACE_R
887-
) {
888-
this._lexer.advance();
889-
this._lexer.advance();
890-
return [];
891-
}
892847
return this.optionalMany(
893848
TokenKind.BRACE_L,
894849
this.parseFieldDefinition,

src/utilities/buildASTSchema.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ export function buildSchema(
9898
): GraphQLSchema {
9999
const document = parse(source, {
100100
noLocation: options?.noLocation,
101-
allowLegacySDLEmptyFields: options?.allowLegacySDLEmptyFields,
102-
allowLegacySDLImplementsInterfaces:
103-
options?.allowLegacySDLImplementsInterfaces,
104101
experimentalFragmentVariables: options?.experimentalFragmentVariables,
105102
});
106103

0 commit comments

Comments
 (0)