Skip to content

Commit 9d3aed5

Browse files
committed
fix createSchema tests
1 parent bc0e3f4 commit 9d3aed5

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

packages/graphql-yoga/__tests__/schema.spec.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,22 @@ describe('schema', () => {
3939
});
4040

4141
it('schema factory function', async () => {
42-
const schemaFactory = async (ctx: { request: Request }) => {
43-
const strFromContext = ctx.request.headers.get('str');
44-
return createSchema({
45-
typeDefs: /* GraphQL */ `
46-
type Query {
47-
foo: String
48-
}
49-
`,
50-
resolvers: {
51-
Query: {
52-
foo: () => strFromContext,
53-
},
54-
},
55-
});
56-
};
5742
const yoga = createYoga({
58-
schema: schemaFactory,
43+
async schema(ctx) {
44+
const strFromContext = ctx.request.headers.get('str');
45+
return createSchema({
46+
typeDefs: /* GraphQL */ `
47+
type Query {
48+
foo: String
49+
}
50+
`,
51+
resolvers: {
52+
Query: {
53+
foo: () => strFromContext,
54+
},
55+
},
56+
});
57+
},
5958
});
6059
const query = `{foo}`;
6160
let result = await yoga.fetch('http://yoga/graphql', {

0 commit comments

Comments
 (0)