useMutation with variable

    0

    0

    My JavaScript recipes

    useMutation react hook with variables

    import { useMutation } from '@apollo/react-hooks';
    
    const [triggerMutation, { data, loading, error }] = useMutation(graphqlMutation);
    if (loading) return 'Loading...';
    if (error) return `Error: ${error.message}`;
      return (
        <div>
          <form
            onSubmit={e => {
              e.preventDefault();
              triggerMutation({ variables: { variableName: variableValue } });
              input.value = '';
            }}
          >
          </form>
        </div>
      );
    }
    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.