postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.85k stars 841 forks source link

Ability to set connection_init payload for GraphQL subscriptions #13278

Open CSE-Karl opened 2 days ago

CSE-Karl commented 2 days ago

Is there an existing request for this feature?

Is your feature request related to a problem?

Our GraphQL subscriptions require an auth token in the connection_init payload of the graphql-transport-ws standard to authenticate connections.

The websocket standard doesn't allow setting an authentication header when opening a socket, so the existing GraphQL Authorization options do not reflect real-world authorization options. The connection_init payload is a workaround for this problem allowing an up-front authorization phase before normal traffic begins.

In practice, the payload is currently always sent as null.

Describe the solution you'd like

I would like the ability to specify the payload for connection_init either explicitly through a new tab alongside parameters like header and schema, or I would like to have the headers replicated into the payload automatically which is how the graphql-playground solved this problem.

Describe alternatives you've considered

I have thought about trying to adopt additional code on the server to manually intercept the connect_init payload and inject authorization from the headers of the original websocket handshake (which would only be present when using non-browser clients like postman), but do not want to incur the overhead and complexity of forwarding the headers for every socket handshake.

I also have considered adding the ability to inject a default payload into the server as a fallback for development environments, but that would make regression testing useless against staging servers where I would never want to spoof authorization.

Additional context

No response