Hello. How do I access `headers` or `connectionPar...
# orm-help
p
Hello. How do I access
headers
or
connectionParams
in subscriptions in graphql bindings... My code in Apollo:
Copy code
wsLink.subscriptionClient.use([{
  async applyMiddleware(options, next) {
    // get the authentication token from local storage if it exists
    const token = cookie.load('access_token');

    options.connectionParams = { 
      authorization: token ? `Bearer ${token}` : "",
    };
    next();
  },
}]);

const authLink = setContext((_, { headers }) => {
  // get the authentication token from local storage if it exists
  const token = cookie.load('access_token');
  // return the headers to the context so httpLink can read them
  return {
    headers: {
      ...headers,
      authorization: token ? `Bearer ${token}` : "",
    }
  }
});