Skip to content

Commit 183c532

Browse files
IvanGoncharovmjmahone
authored andcommitted
BREAKING: Remove support for deprecated directive locations (#1429)
Continuation of #1385
1 parent fec220b commit 183c532

File tree

2 files changed

+2
-97
lines changed

2 files changed

+2
-97
lines changed

src/utilities/__tests__/buildClientSchema-test.js

+1-73
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import {
2525
GraphQLString,
2626
GraphQLBoolean,
2727
GraphQLID,
28+
GraphQLDirective,
2829
} from '../../';
29-
import { GraphQLDirective } from '../../type/directives';
3030

3131
// Test property:
3232
// Given a server's schema, a client may query that server with introspection,
@@ -587,78 +587,6 @@ describe('Type System: build schema from introspection', () => {
587587
testSchema(schema);
588588
});
589589

590-
it('builds a schema with legacy directives', () => {
591-
const oldIntrospection = {
592-
__schema: {
593-
// Minimum required schema.
594-
queryType: {
595-
name: 'Simple',
596-
},
597-
types: [
598-
{
599-
name: 'Simple',
600-
kind: 'OBJECT',
601-
fields: [
602-
{
603-
name: 'simple',
604-
args: [],
605-
type: { name: 'Simple' },
606-
},
607-
],
608-
interfaces: [],
609-
},
610-
],
611-
// Test old directive introspection results.
612-
directives: [
613-
{ name: 'Old1', args: [], onField: true },
614-
{ name: 'Old2', args: [], onFragment: true },
615-
{ name: 'Old3', args: [], onOperation: true },
616-
{ name: 'Old4', args: [], onField: true, onFragment: true },
617-
],
618-
},
619-
};
620-
621-
const clientSchema = buildClientSchema(oldIntrospection);
622-
const secondIntrospection = introspectionFromSchema(clientSchema);
623-
624-
// New introspection produces correct new format.
625-
expect(secondIntrospection).to.deep.nested.property('__schema.directives', [
626-
{
627-
name: 'Old1',
628-
description: null,
629-
args: [],
630-
locations: ['FIELD'],
631-
},
632-
{
633-
name: 'Old2',
634-
description: null,
635-
args: [],
636-
locations: [
637-
'FRAGMENT_DEFINITION',
638-
'FRAGMENT_SPREAD',
639-
'INLINE_FRAGMENT',
640-
],
641-
},
642-
{
643-
name: 'Old3',
644-
description: null,
645-
args: [],
646-
locations: ['QUERY', 'MUTATION', 'SUBSCRIPTION'],
647-
},
648-
{
649-
name: 'Old4',
650-
description: null,
651-
args: [],
652-
locations: [
653-
'FIELD',
654-
'FRAGMENT_DEFINITION',
655-
'FRAGMENT_SPREAD',
656-
'INLINE_FRAGMENT',
657-
],
658-
},
659-
]);
660-
});
661-
662590
it('builds a schema with legacy names', () => {
663591
const introspection = {
664592
__schema: {

src/utilities/buildClientSchema.js

+1-24
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import { valueFromAST } from './valueFromAST';
1414
import { parseValue } from '../language/parser';
1515
import { GraphQLSchema } from '../type/schema';
1616

17-
import { DirectiveLocation } from '../language/directiveLocation';
18-
1917
import {
2018
isInputType,
2119
isOutputType,
@@ -340,27 +338,6 @@ export function buildClientSchema(
340338
}
341339

342340
function buildDirective(directiveIntrospection) {
343-
// Support deprecated `on****` fields for building `locations`, as this
344-
// is used by GraphiQL which may need to support outdated servers.
345-
const locations = directiveIntrospection.locations
346-
? directiveIntrospection.locations.slice()
347-
: [].concat(
348-
!directiveIntrospection.onField ? [] : [DirectiveLocation.FIELD],
349-
!directiveIntrospection.onOperation
350-
? []
351-
: [
352-
DirectiveLocation.QUERY,
353-
DirectiveLocation.MUTATION,
354-
DirectiveLocation.SUBSCRIPTION,
355-
],
356-
!directiveIntrospection.onFragment
357-
? []
358-
: [
359-
DirectiveLocation.FRAGMENT_DEFINITION,
360-
DirectiveLocation.FRAGMENT_SPREAD,
361-
DirectiveLocation.INLINE_FRAGMENT,
362-
],
363-
);
364341
if (!directiveIntrospection.args) {
365342
throw new Error(
366343
'Introspection result missing directive args: ' +
@@ -370,7 +347,7 @@ export function buildClientSchema(
370347
return new GraphQLDirective({
371348
name: directiveIntrospection.name,
372349
description: directiveIntrospection.description,
373-
locations,
350+
locations: directiveIntrospection.locations.slice(),
374351
args: buildInputValueDefMap(directiveIntrospection.args),
375352
});
376353
}

0 commit comments

Comments
 (0)