OS: Windows 10 Pro apollo-boost: "^0.1.16" apollo...
# orm-help
t
OS: Windows 10 Pro apollo-boost: "^0.1.16" apollo-client: "^2.4.2" react": "^16.5.2", react-adopt": "^0.6.0", react-apollo": "^2.2.1", react-dom": "^16.5.2", So, I'm getting the following error (see attached image) when attempting to run a mutation, as follows:
Copy code
const UPDATE_ITEM_MUTATION = gql`
mutation updateItem_mutation($id: ID!, $quantity: Int){
  updateItem(
    data: {
      quantity: $quantity
    }
    where: {
      id: $id
    }
  ) {
    id
    quantity
  }
}
`;

    const { client } = this.props;

    const updateItemMutation = (itemID, quantityValue) => {
      const id = itemID;
      const quantity = quantityValue;

      console.log('item id = ', id);
      console.log('quantity = ', quantity);

      client.mutate({
        mutation: UPDATE_ITEM_MUTATION,
        variables: {
          id,
          quantity,
        },
      }).catch(this.handleSubmitError);
    }
What am I overlooking here?
n
What does your Network tab return for the response of the
400
? Does your terminal output an error when you start the server or on that request?
t
I get the following in network.
n
Click Preview/Response
That’ll show you the response
That’s just your POST payload
t
The preview response reads as follows.
n
What does your schema look like for
updateItem
?
That error is saying there are no such args for data, where etc.
Reading this on my phone so apologies for delay and any misunderstanding
t
My schema.graphql definition for updateItem is as follows:
Copy code
updateItem(id: ID!, title: String, description: String, mainDescription: String, price: Int, quantity: Int): Item!
In playground the mutation runs fine.
In fact my prisma.graphql definition of updateItem reads as follows:
Copy code
updateItem(data: ItemUpdateInput!, where: ItemWhereUniqueInput!): Item
n
Apollo tries to fetch from the server (graphql-yoga | apollo-server) with the syntax of your schema.graphql. With UPDATE_ITEM_MUTATION you try to fetch with the syntax of the graphql database (prisma.graphql). I guess you have Apollo on the client, Prisma on the database and something like graphql-yoga as a server in between these two? On Apollo/Client you have to fetch from the graphql-yoga or Apollo-server via the schema.graphql syntax.
t
"I guess you have Apollo on the client, Prisma on the database and something like graphql-yoga as a server in between these two? " - Absolutely correct. I was thrown by the example of update, which I acquired from here:
<https://www.prisma.io/docs/reference/prisma-api/mutations-ol0yuoz6go#nested-mutations>
Thank you.
fast parrot 1
👍 1