Skip to content

Commit ec2352a

Browse files
Drop support for long deprecated comments as descriptions (#2900)
1 parent 5d9b5bb commit ec2352a

13 files changed

+55
-593
lines changed

src/index.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,6 @@ export {
382382
buildASTSchema,
383383
// Build a GraphQLSchema from a GraphQL schema language document.
384384
buildSchema,
385-
// @deprecated: Get the description from a schema AST node and supports legacy
386-
// syntax for specifying descriptions - will be removed in v16.
387-
getDescription,
388385
// Extends an existing GraphQLSchema from a parsed GraphQL Schema
389386
// language AST.
390387
extendSchema,

src/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,6 @@ export {
371371
buildASTSchema,
372372
// Build a GraphQLSchema from a GraphQL schema language document.
373373
buildSchema,
374-
// @deprecated: Get the description from a schema AST node and supports legacy
375-
// syntax for specifying descriptions - will be removed in v16.
376-
getDescription,
377374
// Extends an existing GraphQLSchema from a parsed GraphQL Schema
378375
// language AST.
379376
extendSchema,

src/utilities/__tests__/buildASTSchema-test.js

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,8 @@ import { buildASTSchema, buildSchema } from '../buildASTSchema';
4747
* the SDL, parsed in a schema AST, materializing that schema AST into an
4848
* in-memory GraphQLSchema, and then finally printing that object into the SDL
4949
*/
50-
function cycleSDL(sdl: string, options): string {
51-
const ast = parse(sdl);
52-
const schema = buildASTSchema(ast, options);
53-
54-
const commentDescriptions = options?.commentDescriptions;
55-
return printSchema(schema, { commentDescriptions });
50+
function cycleSDL(sdl: string): string {
51+
return printSchema(buildSchema(sdl));
5652
}
5753

5854
function printASTNode(obj: ?{ +astNode: ?ASTNode, ... }): string {
@@ -225,32 +221,6 @@ describe('Schema Builder', () => {
225221
expect(cycleSDL(sdl)).to.equal(sdl);
226222
});
227223

228-
it('Supports option for comment descriptions', () => {
229-
const sdl = dedent`
230-
# This is a directive
231-
directive @foo(
232-
# It has an argument
233-
arg: Int
234-
) on FIELD
235-
236-
# With an enum
237-
enum Color {
238-
RED
239-
240-
# Not a creative color
241-
GREEN
242-
BLUE
243-
}
244-
245-
# What a great type
246-
type Query {
247-
# And a field to boot
248-
str: String
249-
}
250-
`;
251-
expect(cycleSDL(sdl, { commentDescriptions: true })).to.equal(sdl);
252-
});
253-
254224
it('Maintains @include, @skip & @specifiedBy', () => {
255225
const schema = buildSchema('type Query');
256226

src/utilities/__tests__/extendSchema-test.js

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -132,70 +132,6 @@ describe('extendSchema', () => {
132132
`);
133133
});
134134

135-
it('can describe the extended fields with legacy comments', () => {
136-
const schema = buildSchema('type Query');
137-
const extendAST = parse(`
138-
extend type Query {
139-
# New field description.
140-
newField: String
141-
}
142-
`);
143-
const extendedSchema = extendSchema(schema, extendAST, {
144-
commentDescriptions: true,
145-
});
146-
147-
expect(validateSchema(extendedSchema)).to.deep.equal([]);
148-
expect(printSchemaChanges(schema, extendedSchema)).to.equal(dedent`
149-
type Query {
150-
"""New field description."""
151-
newField: String
152-
}
153-
`);
154-
});
155-
156-
it('describes extended fields with strings when present', () => {
157-
const schema = buildSchema('type Query');
158-
const extendAST = parse(`
159-
extend type Query {
160-
# New field description.
161-
"Actually use this description."
162-
newField: String
163-
}
164-
`);
165-
const extendedSchema = extendSchema(schema, extendAST, {
166-
commentDescriptions: true,
167-
});
168-
169-
expect(validateSchema(extendedSchema)).to.deep.equal([]);
170-
expect(printSchemaChanges(schema, extendedSchema)).to.equal(dedent`
171-
type Query {
172-
"""Actually use this description."""
173-
newField: String
174-
}
175-
`);
176-
});
177-
178-
it('ignores comment description on extended fields if location is not provided', () => {
179-
const schema = buildSchema('type Query');
180-
const extendSDL = `
181-
extend type Query {
182-
# New field description.
183-
newField: String
184-
}
185-
`;
186-
const extendAST = parse(extendSDL, { noLocation: true });
187-
const extendedSchema = extendSchema(schema, extendAST, {
188-
commentDescriptions: true,
189-
});
190-
191-
expect(validateSchema(extendedSchema)).to.deep.equal([]);
192-
expect(printSchemaChanges(schema, extendedSchema)).to.equal(dedent`
193-
type Query {
194-
newField: String
195-
}
196-
`);
197-
});
198-
199135
it('extends objects with standard type fields', () => {
200136
const schema = buildSchema('type Query');
201137

@@ -1197,24 +1133,6 @@ describe('extendSchema', () => {
11971133
expect(printSchemaChanges(schema, extendedSchema)).to.equal(extensionSDL);
11981134
});
11991135

1200-
it('sets correct description using legacy comments', () => {
1201-
const schema = buildSchema(`
1202-
type Query {
1203-
foo: String
1204-
}
1205-
`);
1206-
const extendAST = parse(`
1207-
# new directive
1208-
directive @new on QUERY
1209-
`);
1210-
const extendedSchema = extendSchema(schema, extendAST, {
1211-
commentDescriptions: true,
1212-
});
1213-
1214-
const newDirective = extendedSchema.getDirective('new');
1215-
expect(newDirective).to.include({ description: 'new directive' });
1216-
});
1217-
12181136
it('Rejects invalid SDL', () => {
12191137
const schema = new GraphQLSchema({});
12201138
const extendAST = parse('extend schema @unknown');

src/utilities/__tests__/printSchema-test.js

Lines changed: 0 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -832,201 +832,4 @@ describe('Type System Printer', () => {
832832
}
833833
`);
834834
});
835-
836-
it('Print Introspection Schema with comment descriptions', () => {
837-
const schema = new GraphQLSchema({});
838-
const output = printIntrospectionSchema(schema, {
839-
commentDescriptions: true,
840-
});
841-
842-
expect(output).to.equal(dedent`
843-
# Directs the executor to include this field or fragment only when the \`if\` argument is true.
844-
directive @include(
845-
# Included when true.
846-
if: Boolean!
847-
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
848-
849-
# Directs the executor to skip this field or fragment when the \`if\` argument is true.
850-
directive @skip(
851-
# Skipped when true.
852-
if: Boolean!
853-
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
854-
855-
# Marks an element of a GraphQL schema as no longer supported.
856-
directive @deprecated(
857-
# Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).
858-
reason: String = "No longer supported"
859-
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE
860-
861-
# Exposes a URL that specifies the behaviour of this scalar.
862-
directive @specifiedBy(
863-
# The URL that specifies the behaviour of this scalar.
864-
url: String!
865-
) on SCALAR
866-
867-
# A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.
868-
type __Schema {
869-
description: String
870-
871-
# A list of all types supported by this server.
872-
types: [__Type!]!
873-
874-
# The type that query operations will be rooted at.
875-
queryType: __Type!
876-
877-
# If this server supports mutation, the type that mutation operations will be rooted at.
878-
mutationType: __Type
879-
880-
# If this server support subscription, the type that subscription operations will be rooted at.
881-
subscriptionType: __Type
882-
883-
# A list of all directives supported by this server.
884-
directives: [__Directive!]!
885-
}
886-
887-
# The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the \`__TypeKind\` enum.
888-
#
889-
# Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional \`specifiedByUrl\`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.
890-
type __Type {
891-
kind: __TypeKind!
892-
name: String
893-
description: String
894-
specifiedByUrl: String
895-
fields(includeDeprecated: Boolean = false): [__Field!]
896-
interfaces: [__Type!]
897-
possibleTypes: [__Type!]
898-
enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
899-
inputFields(includeDeprecated: Boolean = false): [__InputValue!]
900-
ofType: __Type
901-
}
902-
903-
# An enum describing what kind of type a given \`__Type\` is.
904-
enum __TypeKind {
905-
# Indicates this type is a scalar.
906-
SCALAR
907-
908-
# Indicates this type is an object. \`fields\` and \`interfaces\` are valid fields.
909-
OBJECT
910-
911-
# Indicates this type is an interface. \`fields\`, \`interfaces\`, and \`possibleTypes\` are valid fields.
912-
INTERFACE
913-
914-
# Indicates this type is a union. \`possibleTypes\` is a valid field.
915-
UNION
916-
917-
# Indicates this type is an enum. \`enumValues\` is a valid field.
918-
ENUM
919-
920-
# Indicates this type is an input object. \`inputFields\` is a valid field.
921-
INPUT_OBJECT
922-
923-
# Indicates this type is a list. \`ofType\` is a valid field.
924-
LIST
925-
926-
# Indicates this type is a non-null. \`ofType\` is a valid field.
927-
NON_NULL
928-
}
929-
930-
# Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.
931-
type __Field {
932-
name: String!
933-
description: String
934-
args(includeDeprecated: Boolean = false): [__InputValue!]!
935-
type: __Type!
936-
isDeprecated: Boolean!
937-
deprecationReason: String
938-
}
939-
940-
# Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.
941-
type __InputValue {
942-
name: String!
943-
description: String
944-
type: __Type!
945-
946-
# A GraphQL-formatted string representing the default value for this input value.
947-
defaultValue: String
948-
isDeprecated: Boolean!
949-
deprecationReason: String
950-
}
951-
952-
# One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.
953-
type __EnumValue {
954-
name: String!
955-
description: String
956-
isDeprecated: Boolean!
957-
deprecationReason: String
958-
}
959-
960-
# A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
961-
#
962-
# In some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.
963-
type __Directive {
964-
name: String!
965-
description: String
966-
isRepeatable: Boolean!
967-
locations: [__DirectiveLocation!]!
968-
args: [__InputValue!]!
969-
}
970-
971-
# A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.
972-
enum __DirectiveLocation {
973-
# Location adjacent to a query operation.
974-
QUERY
975-
976-
# Location adjacent to a mutation operation.
977-
MUTATION
978-
979-
# Location adjacent to a subscription operation.
980-
SUBSCRIPTION
981-
982-
# Location adjacent to a field.
983-
FIELD
984-
985-
# Location adjacent to a fragment definition.
986-
FRAGMENT_DEFINITION
987-
988-
# Location adjacent to a fragment spread.
989-
FRAGMENT_SPREAD
990-
991-
# Location adjacent to an inline fragment.
992-
INLINE_FRAGMENT
993-
994-
# Location adjacent to a variable definition.
995-
VARIABLE_DEFINITION
996-
997-
# Location adjacent to a schema definition.
998-
SCHEMA
999-
1000-
# Location adjacent to a scalar definition.
1001-
SCALAR
1002-
1003-
# Location adjacent to an object type definition.
1004-
OBJECT
1005-
1006-
# Location adjacent to a field definition.
1007-
FIELD_DEFINITION
1008-
1009-
# Location adjacent to an argument definition.
1010-
ARGUMENT_DEFINITION
1011-
1012-
# Location adjacent to an interface definition.
1013-
INTERFACE
1014-
1015-
# Location adjacent to a union definition.
1016-
UNION
1017-
1018-
# Location adjacent to an enum definition.
1019-
ENUM
1020-
1021-
# Location adjacent to an enum value definition.
1022-
ENUM_VALUE
1023-
1024-
# Location adjacent to an input object type definition.
1025-
INPUT_OBJECT
1026-
1027-
# Location adjacent to an input object field definition.
1028-
INPUT_FIELD_DEFINITION
1029-
}
1030-
`);
1031-
});
1032835
});

src/utilities/buildASTSchema.d.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ import { GraphQLSchema, GraphQLSchemaValidationOptions } from '../type/schema';
44
import { ParseOptions } from '../language/parser';
55

66
export interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {
7-
/**
8-
* Descriptions are defined as preceding string literals, however an older
9-
* experimental version of the SDL supported preceding comments as
10-
* descriptions. Set to true to enable this deprecated behavior.
11-
* This option is provided to ease adoption and will be removed in v16.
12-
*
13-
* Default: false
14-
*/
15-
commentDescriptions?: boolean;
16-
177
/**
188
* Set to true to assume the SDL is valid.
199
*
@@ -31,12 +21,6 @@ export interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {
3121
*
3222
* Given that AST it constructs a GraphQLSchema. The resulting schema
3323
* has no resolve methods, so execution will use default resolvers.
34-
*
35-
* Accepts options as a second argument:
36-
*
37-
* - commentDescriptions:
38-
* Provide true to use preceding comments as the description.
39-
*
4024
*/
4125
export function buildASTSchema(
4226
documentAST: DocumentNode,

0 commit comments

Comments
 (0)