Skip to content

Commit 007407d

Browse files
committed
Include test that printSchema includes non-spec directives. Closes #1072
1 parent a56e6ab commit 007407d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/utilities/__tests__/schemaPrinter-test.js

+29
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {
2626
GraphQLList,
2727
GraphQLNonNull,
2828
} from '../../';
29+
import { GraphQLDirective } from '../../type/directives';
30+
import { DirectiveLocation } from '../../language/directiveLocation';
2931

3032
function printForTest(schema) {
3133
return printSchema(schema);
@@ -564,6 +566,33 @@ describe('Type System Printer', () => {
564566
`);
565567
});
566568

569+
it('Prints custom directives', () => {
570+
const Query = new GraphQLObjectType({
571+
name: 'Query',
572+
fields: {
573+
field: { type: GraphQLString },
574+
},
575+
});
576+
577+
const CustomDirective = new GraphQLDirective({
578+
name: 'customDirective',
579+
locations: [DirectiveLocation.FIELD],
580+
});
581+
582+
const Schema = new GraphQLSchema({
583+
query: Query,
584+
directives: [CustomDirective],
585+
});
586+
const output = printForTest(Schema);
587+
expect(output).to.equal(dedent`
588+
directive @customDirective on FIELD
589+
590+
type Query {
591+
field: String
592+
}
593+
`);
594+
});
595+
567596
it('Print Introspection Schema', () => {
568597
const Root = new GraphQLObjectType({
569598
name: 'Root',

0 commit comments

Comments
 (0)