33 lines
523 B
JavaScript
33 lines
523 B
JavaScript
import { gql } from "apollo-boost";
|
|
|
|
export const typeDefs = gql`
|
|
extend type Mutation {
|
|
SetCurrentUser(user: User!): User!
|
|
}
|
|
|
|
type User {
|
|
displayName: String!,
|
|
email: String!,
|
|
photoUrl: String!
|
|
}
|
|
`;
|
|
|
|
const GET_CURRENT_USER = gql`
|
|
{
|
|
currentUser @client
|
|
}
|
|
`;
|
|
|
|
export const resolvers = {
|
|
Mutation: {
|
|
setCurrentUser: (_root, { user }, { cache }) => {
|
|
cache.writeQuery({
|
|
query: GET_CURRENT_USER,
|
|
data: { currentUser: user }
|
|
});
|
|
|
|
return user;
|
|
}
|
|
}
|
|
};
|