awslabs / aws-mobile-appsync-sdk-js

JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Apache License 2.0
920 stars 266 forks source link

Instead of graphqlMutation, what package need to used from apollo/client. #612

Open savita-malaghan opened 3 years ago

savita-malaghan commented 3 years ago

Instead of graphqlMutation, what package need to used from apollo/client. I dont want to add "aws-appsync-react".

randomslap commented 3 years ago

Make sure you have "aws-amplify" installed and configured.

Do import { gql, useMutation } from "@apollo/client" and then establish const [makeToDo] = useMutation(gql(createToDo))

makeToDo() is the function that executes the mutation so you can execute the following example as the first argument is the input for the mutation makeToDo({ variables: { input: { task: "ToDo" } } })

https://www.apollographql.com/docs/react/data/mutations/