Description
Describe the bug
The workflow I want to use is:
- create an app context in which I parse a client ID from a JWT header
- use the client ID from my app context to dynamically compose the schema (or get a previously composed schema from cache) because each client needs a different schema.
According to the TypeScript typings for graphql-yoga, this should work. The argument passed in to the function I set as the schema
property should receive my custom app context as it's parameter. But it doesn't.
Your Example Website or App
https://codesandbox.io/p/sandbox/tender-elgamal-jgmnm9?file=/src/main.ts:17,59
Steps to Reproduce the Bug or Issue
Run the code sandbox example. Line 17 logs undefined
to the console.
Expected behavior
I expect ctx
to contain the property someNumber
, and the intellisense in the IDE shows me that I am right to expect that, but it isn't there.
Screenshots or Videos

Platform
- OS: [e.g. macOS, Windows, Linux]
- NodeJS: [e.g. 18.1.0]
@graphql-yoga/*
version(s): [e.g. 2.5.1]
Additional context
I can see that my context
creation function is not called before the call to the schema
creation function is made. This means I have no access to the context at schema creation time, which is inconvenient for my purposes. I'm not sure whether this behaviour is intentional, but if so the TypeScript type hints are definitely wrong. The documentation also seems to be wrong, suggesting that the argument passed into the schema
creation function is a request
object, when as far as I can see it is actually of type {req, res, request}
.