Skip to content

allow defining custom connectionParams for websocket connection #134

@praveenweb

Description

@praveenweb

Currently the connectionParams in subscriptionClient always returns either of authorization or an empty object depending on the availability of the token. Source here

This convention doesn't work with Hasura GraphQL Engine as Hasura expects a header object to be returned in connectionParams with authorization key inside the object.

So this is what works with Hasura:

wsClient = new SubscriptionClient(wsEndpoint, {
  reconnect: true,
  connectionParams: () => {
    const authorization = getAuth(tokenName)
    return authorization ? { headers: { authorization } } : {}
  },
})

Note the authorization object wrapped in a top level headers key.

I think it's better not to assume any convention in the way connectionParams is handled, since different servers will have different ways to handle this.

I would like the plugin to allow the user to define their custom method for connectionParams, similar to getAuth.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions