Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Calder committed May 12, 2022
1 parent 2e1aa4b commit a6d2283
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions packages/schema/tests/merge-schemas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,60 @@ describe('Merge Schemas', () => {
expect(data['bar']).toBe('BAR');
expect(data['qux']).toBe('QUX');
});
it('should override resolver in schema with resolver passed into config', async () => {
const fooSchema = makeExecutableSchema({
typeDefs: /* GraphQL */ `
type Query {
foo: String
}
`,
resolvers: {
Query: {
foo: () => 'FOO',
},
},
});
const barSchema = makeExecutableSchema({
typeDefs: /* GraphQL */ `
type Query {
bar: String
}
`,
resolvers: {
Query: {
bar: () => 'BAR',
},
},
});
const { errors, data } = await graphql({
schema: mergeSchemas({
schemas: [fooSchema, barSchema],
typeDefs: /* GraphQL */ `
type Query {
qux: String
}
`,
resolvers: {
Query: {
qux: () => 'QUX',
foo: () => 'FOO_BAR_QUX',
},
},
}),
source: `
{
foo
bar
qux
}
`,
});
expect(errors).toBeFalsy();
assertSome(data);
expect(data['foo']).toBe('FOO_BAR_QUX');
expect(data['bar']).toBe('BAR');
expect(data['qux']).toBe('QUX');
});
it('should merge two valid executable schemas with extra typeDefs and resolvers', async () => {
const fooSchema = makeExecutableSchema({
typeDefs: /* GraphQL */ `
Expand Down

0 comments on commit a6d2283

Please sign in to comment.