josemarluedke / glimmer-apollo

Ember and Glimmer integration for Apollo Client.
https://glimmer-apollo.com
MIT License
39 stars 15 forks source link

[DOC] Updating a single record using `update` callback #42

Closed villander closed 3 years ago

villander commented 3 years ago

The documentation says that we should use the name of the mutation property if you're using createNode = useMutation, you must use result.data.createNote to add a new record, but the proper way is to call the mutation name defined on the mutation file.

I have a mutation like that:

import { gql } from 'glimmer-apollo';

export const CREATE_USER = gql`
  mutation InsertUsers($name: String, $rocket: String) {
    insert_users(objects: { name: $name, rocket: $rocket }) {
      returning {
        id
        name
        rocket
      }
    }
  }
`;

The unique key inside the result.data is the insert_users object. We have to update the docs to explain how it works properly.

image

cc: @josemarluedke

josemarluedke commented 3 years ago

Hi @villander. I think the docs might have confused you because the name of the mutation and the property in the component is the same. The docs are correct, they just use the same name.

Looking at your mutation, I would expect that insert_users to be the key after data, so data.insert_users.

Feel free to open a PR to the docs to clarify that.