-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i want to pass the params through getClient #175
Comments
Hi @VolcanoDiver :) Most likely, you shouldn't go about it that way. If you want to specify your authentication headers at call site, you can do so by providing getClient().query({
query,
context: { headers: { authentication: "..." } },
}); Or (and this is probably what you will do instead in most cases), you can just call export const { getClient } = registerApolloClient(() => {
const httpLink = createHttpLink({
uri: "/graphql",
});
const authLink = setContext((_, { headers }) => {
const token = cookies().get("myCookie");
return {
headers: {
...headers,
authorization: token ? `Bearer ${token}` : "",
},
};
});
return new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache(),
});
}); |
I'm doing some housekeeping so I'm closing some older issues that haven't seen activity in a while. |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
how do i pass the token data to getClient so that i can add auth headers to ApolloLink?
The text was updated successfully, but these errors were encountered: