graphql-mesh
graphql-mesh copied to clipboard
Pass WebSocket `connectionParams` to downstream also in `connectionParams`
Continuation task of #4040.
Currently the WebSocket connectionParams
are spread to request headers and passed through the extensions
field of GraphQL request parameters. This is a tad confusing, see https://github.com/Urigo/graphql-mesh/issues/4040#issuecomment-1214938039.
Instead, it would be great if we could make the connectionParams
be in connectionParams
downstream.
You probably already know that but I am adding this just to clarify the issue; GraphQL Mesh's runtime has nothing to do with HTTP actually, because the runtime only generates a schema (and an executor), then that schema/executor is used as a standalone artifact, an SDK or by an HTTP server(Yoga, Apollo etc). We don't forward HTTP requests as they are in GraphQL Mesh, because the consumer might not be an HTTP server.
Then how can we pass connectionParams
from the gateway to the underlying WS sources?
We can basically have an additional field in the configuration like operationHeaders
that passes connectionParams
dynamically to graphql-ws
client.
connectionParams:
x-foo: `some-static-prefix-{context.connectionParams['my-foo']}` # String interpolation