4

I'm struggling to figure out how this should work. I have an application that has a current user, so, the topmost query looks like this:

  query AppQuery {
    currentUser {
      id
      email
      ...Account_currentUser
      ...AccountEdit_currentUser
    }
  }

AccountEdit_currentUser is defined this way:

export default createFragmentContainer(AccountEdit, {
  currentUser: graphql`
    fragment AccountEdit_currentUser on User {
      email
      name
      nickName
    }`
})

on the AccountEdit component. That component commits this mutation:

  mutation AccountEditMutation($email: String!, $name: String!, $nickName: String!) {
    updateAccount(input: {email: $email, name: $name, nickName: $nickName}) {
      accountUpdated
      currentUser {
        id
        email
        name
        nickName
      }
    }
  }

After that happens, the server returns the correct values for email, name, nickName, etc. How should those new values end up in the store? Because it doesn't seem to automatic. Do I need to write a custom updater? and update config? I tried it a few times but I couldn't get anywhere close to something that even throws a reasonable error.

Marta Silva
  • 733
  • 1
  • 6
  • 13

1 Answers1

3

This updating of the store happens automatically and the reason why it wasn't is because the node_ids of the current user in the original query and on the subsequent query were different. Once I made them the same, it started working.

Marta Silva
  • 733
  • 1
  • 6
  • 13