mobilizon/js/src/apollo/user.ts
Thomas Citharel 27f2597b07
Add admin dashboard, event reporting, moderation report screens, moderation log
Close #156 and #158

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2019-09-09 20:53:16 +02:00

36 lines
823 B
TypeScript

import { ApolloCache } from 'apollo-cache';
import { NormalizedCacheObject } from 'apollo-cache-inmemory';
import { ICurrentUserRole } from '@/types/current-user.model';
export function buildCurrentUserResolver(cache: ApolloCache<NormalizedCacheObject>) {
cache.writeData({
data: {
currentUser: {
__typename: 'CurrentUser',
id: null,
email: null,
isLoggedIn: false,
role: ICurrentUserRole.USER,
},
},
});
return {
Mutation: {
updateCurrentUser: (_, { id, email, isLoggedIn, role }, { cache }) => {
const data = {
currentUser: {
id,
email,
isLoggedIn,
role,
__typename: 'CurrentUser',
},
};
cache.writeData({ data });
},
},
};
}