File size: 1,151 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
// @flow
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
import userInfoFragment from '../../fragments/user/userInfo';
import type { UserInfoType } from '../../fragments/user/userInfo';
import type { EditUserInput } from 'shared/db/queries/user';
import { getUserByUsernameQuery } from '../../queries/user/getUser';
export type EditUserType = {
...$Exact<UserInfoType>,
};
export type EditUserProps = {
editUser: (
input: $PropertyType<EditUserInput, 'input'>
) => Promise<EditUserType>,
};
export const editUserMutation = gql`
mutation editUser($input: EditUserInput!) {
editUser(input: $input) {
...userInfo
}
}
${userInfoFragment}
`;
const editUserOptions = {
options: {
refetchQueries: ['getCurrentUser'],
},
props: ({ mutate }) => ({
editUser: input =>
mutate({
variables: {
input,
},
refetchQueries: [
{
query: getUserByUsernameQuery,
variables: {
id: input.username,
},
},
],
}),
}),
};
export default graphql(editUserMutation, editUserOptions);
|