In my scheme users belong to a location: ``` type...
# orm-help
j
In my scheme users belong to a location:
Copy code
type Location {
  id: ID! @unique
  name: String!
  users: [User!]!
}

type User {
  id: ID! @unique
  name: String!
  location: Location
}
Im displaying the users at each location:
Copy code
export const LOCATION_QUERY = gql`
  query LocationQuery($machineName: String!) {
    location(machineName: $machineName) {
      id
      name
      machineName
      users {
        id
      }
    }
  }
`;
When a user joins a location the previous query gets updated automatically:
Copy code
const JOIN_LOCATION = gql`
  mutation joinLocation($userId: ID!, $locationMachine: String!) {
    joinLocation(userId: $userId, locationMachine: $locationMachine) {
      id
      location {
        id
        users {
          id
        }
      }
    }
  }
`;
But when they leave a location the query doesnt update:
Copy code
const LEAVE_LOCATION = gql`
  mutation leaveLocation($userId: ID!) {
    leaveLocation(userId: $userId) {
      id
      location {
        id
        users {
          id
        }
      }
    }
  }
`;
I think this is because the location field returns emptry so Apollo doesnt know that the number of users has changed. Is there an elegant solution to this? I could manually write to the store but I thoguth id check if there was a better way first.
n
Please consider to post such questions in the Forum instead, this will significantly increase the chance of getting a reply 🙂