Skip to content

Commit

Permalink
fix directive description lost in extendSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Jul 21, 2017
1 parent 6938c1a commit 68cccd3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/utilities/__tests__/extendSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,17 @@ describe('extendSchema', () => {
expect(newDirective.locations).to.contain('QUERY');
});

it('sets correct description when extends with a new directive', () => {
const ast = parse(`
# new directive
directive @new on QUERY
`);

const extendedSchema = extendSchema(testSchema, ast);
const newDirective = extendedSchema.getDirective('new');
expect(newDirective.description).to.equal('new directive');
});

it('may extend directives with new complex directive', () => {
const ast = parse(`
directive @profile(enable: Boolean! tag: String) on QUERY | FIELD
Expand Down
1 change: 1 addition & 0 deletions src/utilities/extendSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ export function extendSchema(
): GraphQLDirective {
return new GraphQLDirective({
name: directiveNode.name.value,
description: getDescription(directiveNode),
locations: directiveNode.locations.map(
node => ((node.value: any): DirectiveLocationEnum)
),
Expand Down

0 comments on commit 68cccd3

Please sign in to comment.