Skip to content

Instantly share code, notes, and snippets.

@klashxx
Created July 27, 2018 09:49
Show Gist options
  • Save klashxx/c43771ab4f307ea62a6accfe2cc9b96f to your computer and use it in GitHub Desktop.
Save klashxx/c43771ab4f307ea62a6accfe2cc9b96f to your computer and use it in GitHub Desktop.
const httpLink = createHttpLink({
uri: '/graphql',
credentials: 'same-origin',
});
const authLink = setContext((_, { headers }) => {
return {
headers: {
...headers,
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-CSRFToken': Cookies.get('csrftoken'),
}
}
});
const client = new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment