Skip to content

Commit be9b783

Browse files
committed
Set credentials property for Apollo Client
1 parent 296eb1f commit be9b783

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"@typescript-eslint/eslint-plugin": "^2.8.0",
4545
"@typescript-eslint/parser": "^2.8.0",
4646
"apollo-boost": "^0.4.7",
47+
"apollo-link": "^1.2.13",
4748
"aws-lambda": "^1.0.4",
4849
"axios": "^0.19.0",
4950
"babel-eslint": "10.0.3",

src/lib/graphql/client.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
import ApolloClient from 'apollo-boost';
1+
import { ApolloClient } from 'apollo-client';
22
import { InMemoryCache } from 'apollo-cache-inmemory';
3+
import { createHttpLink } from 'apollo-link-http';
34

45
const host =
56
(process.env.NODE_ENV === 'development'
67
? '/'
78
: process.env.REACT_APP_API_HOST) || '/';
89

910
const graphqlURI = host.concat('graphql');
11+
const link = createHttpLink({
12+
uri: graphqlURI,
13+
credentials: 'include',
14+
});
1015

1116
const client = new ApolloClient({
12-
uri: graphqlURI,
17+
link,
1318
cache: new InMemoryCache().restore((window as any).__APOLLO_STATE__),
1419
});
1520

src/server/serverRender.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ const serverRender = async ({ url, loggedIn, cookie }: SSROption) => {
4040
if (!loggedIn) {
4141
const cachedPage = await cacheManager.get(url);
4242
if (cachedPage) {
43-
return cachedPage;
43+
// Temp disable cache
44+
// return cachedPage;
4445
}
4546
}
4647

0 commit comments

Comments
 (0)