Skip to content

```Β #525

@Sonyashines

Description

@Sonyashines
const createApolloClient = authToken => {
  return new ApolloClient({
    link: new WebSocketLink({
      uri: "wss://url/v1/graphql",
      options: {
        reconnect: true,
        connectionParams: {
          headers: {
             Authorization: `Bearer ${authToken}`
          }
        }
      }
    }),
    cache: new InMemoryCache()
  });
};

@k96white This is working for me with subscriptions and ws subscription but carrefull with http link instead of ws link, syntax is not the same:

const createApolloClient = (authToken) => {
  return new ApolloClient({
    link: new HttpLink({
      uri: "https://hasura.cairncross.ovh/v1/graphql",
      headers: {
         Authorization: `Bearer ${authToken}`
      },
    }),
    cache: new InMemoryCache(),
  });
};

Originally posted by @clementvp in hasura/nodejs-graphql-subscriptions-boilerplate#3 (comment)

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