Subscriptions-transport-ws: How to send headers?

Created on 15 Feb 2019  路  5Comments  路  Source: apollographql/subscriptions-transport-ws

Add to README or just comment here and I'll PR to README.

Most helpful comment

For posterity:

const wsLink = new WebSocketLink({
  uri: `wss://xyz.herokuapp.com/v1alpha1/graphql`,
  options: {
    reconnect: true,
    connectionParams: {
      headers: {
        'content-type': 'application/json',
        'x-hasura-admin-secret': 'SUPERPASSWORD',
      },
    },
  },
})

All 5 comments

For posterity:

const wsLink = new WebSocketLink({
  uri: `wss://xyz.herokuapp.com/v1alpha1/graphql`,
  options: {
    reconnect: true,
    connectionParams: {
      headers: {
        'content-type': 'application/json',
        'x-hasura-admin-secret': 'SUPERPASSWORD',
      },
    },
  },
})

Where should I pass token with a Bearer? Please reply I m stuck with this issue

const wsLink = new WebSocketLink({
  uri: `wss://xyz.herokuapp.com/v1alpha1/graphql`,
  options: {
    reconnect: true,
    connectionParams: {
      headers: {
        'content-type': 'application/json', // these are headers
        'x-hasura-admin-secret': 'SUPERPASSWORD',
        'Authorization': 'Bearer iasjdfoias2j34j23i4j23ij1jsdjsa' // i haven't tested this but this is typically how you send a JWT
      },
    },
  },
})

This does not seem to work anymore.

Was this page helpful?
0 / 5 - 0 ratings