actionUserUpsert.js 564 B

123456789101112131415161718192021222324
  1. import { gql } from "../helpers";
  2. import { actionPromise } from "../reducers";
  3. export const actionUserUpsert = (user) => async (dispatch, getState) => {
  4. if (!user?.password?.length) {
  5. delete user.password;
  6. }
  7. await dispatch(
  8. actionPromise(
  9. "userUpsert",
  10. gql(
  11. `mutation userUpsert($user:UserInput!){
  12. UserUpsert(user:$user){
  13. _id username
  14. }
  15. }`,
  16. {
  17. user,
  18. }
  19. )
  20. )
  21. );
  22. };