The @apollo/client library provides the useMutation function which can be used to mutate the GraphQL reply tree. This function takes two arguments: the GraphQL query and an object containing mutate modifier keys and values. The mutate modifier keys are refetchQueries and variables . The mutationFunction object configured above will mutate the GraphQL reply tree by re-fetching the specified query and setting the variableName to the value of the variableValue .

    import { useMutation } from '@apollo/client';
    const [mutationFunction] = useMutation(graphqlQuery, {
      refetchQueries: [{ query: queryToRefetch }],
    // insert your logic code here
      variables: {
        variableName: variableValue,
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.