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
74 changes: 1 addition & 73 deletions src/utilities/__tests__/buildClientSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import {
GraphQLString,
GraphQLBoolean,
GraphQLID,
GraphQLDirective,
} from '../../';
import { GraphQLDirective } from '../../type/directives';

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

it('builds a schema with legacy directives', () => {
const oldIntrospection = {
__schema: {
// Minimum required schema.
queryType: {
name: 'Simple',
},
types: [
{
name: 'Simple',
kind: 'OBJECT',
fields: [
{
name: 'simple',
args: [],
type: { name: 'Simple' },
},
],
interfaces: [],
},
],
// Test old directive introspection results.
directives: [
{ name: 'Old1', args: [], onField: true },
{ name: 'Old2', args: [], onFragment: true },
{ name: 'Old3', args: [], onOperation: true },
{ name: 'Old4', args: [], onField: true, onFragment: true },
],
},
};

const clientSchema = buildClientSchema(oldIntrospection);
const secondIntrospection = introspectionFromSchema(clientSchema);

// New introspection produces correct new format.
expect(secondIntrospection).to.deep.nested.property('__schema.directives', [
{
name: 'Old1',
description: null,
args: [],
locations: ['FIELD'],
},
{
name: 'Old2',
description: null,
args: [],
locations: [
'FRAGMENT_DEFINITION',
'FRAGMENT_SPREAD',
'INLINE_FRAGMENT',
],
},
{
name: 'Old3',
description: null,
args: [],
locations: ['QUERY', 'MUTATION', 'SUBSCRIPTION'],
},
{
name: 'Old4',
description: null,
args: [],
locations: [
'FIELD',
'FRAGMENT_DEFINITION',
'FRAGMENT_SPREAD',
'INLINE_FRAGMENT',
],
},
]);
});

it('builds a schema with legacy names', () => {
const introspection = {
__schema: {
Expand Down
25 changes: 1 addition & 24 deletions src/utilities/buildClientSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import { valueFromAST } from './valueFromAST';
import { parseValue } from '../language/parser';
import { GraphQLSchema } from '../type/schema';

import { DirectiveLocation } from '../language/directiveLocation';

import {
isInputType,
isOutputType,
Expand Down Expand Up @@ -340,27 +338,6 @@ export function buildClientSchema(
}

function buildDirective(directiveIntrospection) {
// Support deprecated `on****` fields for building `locations`, as this
// is used by GraphiQL which may need to support outdated servers.
const locations = directiveIntrospection.locations
? directiveIntrospection.locations.slice()
: [].concat(
!directiveIntrospection.onField ? [] : [DirectiveLocation.FIELD],
!directiveIntrospection.onOperation
? []
: [
DirectiveLocation.QUERY,
DirectiveLocation.MUTATION,
DirectiveLocation.SUBSCRIPTION,
],
!directiveIntrospection.onFragment
? []
: [
DirectiveLocation.FRAGMENT_DEFINITION,
DirectiveLocation.FRAGMENT_SPREAD,
DirectiveLocation.INLINE_FRAGMENT,
],
);
if (!directiveIntrospection.args) {
throw new Error(
'Introspection result missing directive args: ' +
Expand All @@ -370,7 +347,7 @@ export function buildClientSchema(
return new GraphQLDirective({
name: directiveIntrospection.name,
description: directiveIntrospection.description,
locations,
locations: directiveIntrospection.locations.slice(),
args: buildInputValueDefMap(directiveIntrospection.args),
});
}
Expand Down