Skip to content

Commit

Permalink
Properly merge SiteInfo in Apollo cache
Browse files Browse the repository at this point in the history
This solves #146
  • Loading branch information
viktorstrate committed Dec 9, 2020
1 parent d4900b7 commit 4980a77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion api/.vscode/launch.json
Expand Up @@ -11,7 +11,9 @@
"mode": "auto",
"program": "${workspaceRoot}/server.go",
"cwd": "${workspaceRoot}",
"env": {},
"env": {
"PATH": "${env:PATH}:/Applications/darktable.app/Contents/MacOS/"
},
"args": []
}
]
Expand Down
12 changes: 11 additions & 1 deletion ui/src/apolloClient.js
Expand Up @@ -104,10 +104,20 @@ const linkError = onError(({ graphQLErrors, networkError }) => {
}
})

const memoryCache = new InMemoryCache({
typePolicies: {
// There only exists one global instance of SiteInfo,
// therefore it can always be merged
SiteInfo: {
merge: true,
},
},
})

const client = new ApolloClient({
// link: ApolloLink.from([linkError, authLink.concat(link)]),
link: ApolloLink.from([linkError, link]),
cache: new InMemoryCache(),
cache: memoryCache,
})

export default client

0 comments on commit 4980a77

Please sign in to comment.