Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Tutorial: always use the most recent token value for authorization #749

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/source/tutorial/local-state.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ const client: ApolloClient<NormalizedCacheObject> = new ApolloClient({
link: new HttpLink({
uri: 'http://localhost:4000/graphql',
headers: {
authorization: localStorage.getItem('token'),
get authorization() {
return localStorage.getItem('token')
},
},
}),
typeDefs,
Expand Down
12 changes: 9 additions & 3 deletions docs/source/tutorial/mutations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ const client: ApolloClient<NormalizedCacheObject> = new ApolloClient({
link: new HttpLink({
uri: 'http://localhost:4000/graphql',
headers: {
authorization: localStorage.getItem('token'),
},
get authorization() {
return localStorage.getItem('token')
},
},
}),
});

Expand All @@ -123,7 +125,11 @@ cache.writeData({
const client = new ApolloClient({
cache,
link: new HttpLink({
headers: { authorization: localStorage.getItem('token') },
headers: {
get authorization() {
return localStorage.getItem('token')
},
},
uri: "http://localhost:4000/graphql",
}),
});
Expand Down