Remove apollo link state

This commit is contained in:
Chocobozzz
2019-08-12 16:04:16 +02:00
parent 3fa2bd35d8
commit 6d221212ef
22 changed files with 415 additions and 148 deletions

View File

@@ -1,27 +1,32 @@
export const currentUser = {
defaults: {
currentUser: {
__typename: 'CurrentUser',
id: null,
email: null,
isLoggedIn: false,
},
},
import { ApolloCache } from 'apollo-cache';
import { NormalizedCacheObject } from 'apollo-cache-inmemory';
resolvers: {
Mutation: {
updateCurrentUser: (_, { id, email, isLoggedIn }, { cache }) => {
const data = {
export function buildCurrentUserResolver(cache: ApolloCache<NormalizedCacheObject>) {
cache.writeData({
data: {
currentUser: {
__typename: 'CurrentUser',
id: null,
email: null,
isLoggedIn: false,
},
},
});
return {
updateCurrentUser: (_, { id, email, isLoggedIn }, { cache }) => {
const data = {
Mutation: {
currentUser: {
id,
email,
isLoggedIn,
__typename: 'CurrentUser',
},
};
},
};
cache.writeData({ data });
},
cache.writeData({ data });
},
},
};
};