Skip to content

Commit

Permalink
Fix missing schema's astNode when schema was defined inside extension (
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Jan 29, 2019
1 parent c680b6c commit e2dec84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/utilities/__tests__/extendSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1165,14 +1165,15 @@ describe('extendSchema', () => {
});
expect(schema.getQueryType()).to.equal(undefined);

const ast = parse(`
const extensionSDL = dedent`
schema @foo {
query: Foo
}
`);
schema = extendSchema(schema, ast);
}`;
schema = extendSchema(schema, parse(extensionSDL));

const queryType = schema.getQueryType();
expect(queryType).to.include({ name: 'Foo' });
expect(print(schema.astNode)).to.equal(extensionSDL);
});

it('adds new root types via schema extension', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/extendSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export function extendSchema(

types: objectValues(typeMap),
directives: getMergedDirectives(),
astNode: schemaConfig.astNode,
astNode: schemaDef || schemaConfig.astNode,
extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExts),
allowedLegacyNames,
});
Expand Down

0 comments on commit e2dec84

Please sign in to comment.