Skip to content
Merged
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
47 changes: 19 additions & 28 deletions src/utilities/__tests__/extendSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,13 @@ describe('extendSchema', () => {
`;
expect(() => extendTestSchema(typeSDL)).to.throw(existingTypeError('Bar'));

const scalarSDL = `
scalar SomeScalar
`;
expect(() => extendTestSchema(scalarSDL)).to.throw(
existingTypeError('SomeScalar'),
);

const interfaceSDL = `
interface SomeInterface
`;
Expand Down Expand Up @@ -1147,34 +1154,18 @@ describe('extendSchema', () => {
});

it('does not allow extending an unknown type', () => {
const unknownTypeError =
'Cannot extend type "UnknownType" because it does not exist in the ' +
'existing schema.';

const typeSDL = `
extend type UnknownType @foo
`;
expect(() => extendTestSchema(typeSDL)).to.throw(unknownTypeError);

const intefaceSDL = `
extend interface UnknownType @foo
`;
expect(() => extendTestSchema(intefaceSDL)).to.throw(unknownTypeError);

const enumSDL = `
extend enum UnknownType @foo
`;
expect(() => extendTestSchema(enumSDL)).to.throw(unknownTypeError);

const unionSDL = `
extend union UnknownType @foo
`;
expect(() => extendTestSchema(unionSDL)).to.throw(unknownTypeError);

const inputSDL = `
extend input UnknownType @foo
`;
expect(() => extendTestSchema(inputSDL)).to.throw(unknownTypeError);
[
'extend scalar UnknownType @foo',
'extend type UnknownType @foo',
'extend interface UnknownType @foo',
'extend enum UnknownType @foo',
'extend union UnknownType @foo',
'extend input UnknownType @foo',
].forEach(sdl => {
expect(() => extendTestSchema(sdl)).to.throw(
'Cannot extend type "UnknownType" because it does not exist in the existing schema.',
);
});
});

it('maintains configuration of the original schema object', () => {
Expand Down