your recipe card header background

    Apollo React useMutation with refetchQueries

    0

    18

    Jose Romero

    reactapollohook•••
    React TypeScript Recipes

    One of the most common use cases front-end developers face is re-render the UI after executing a mutation and changing something in the backend.

    To solve this problem, a lot of developers like to use the refetchQueries API.

    Library: react

    Shortcut: apollo.hook.mutation.use.refetch.use

    import { useMutation } from '@apollo/client';
    
    const [runMutation, {data, loading, error}] = useMutation<TypeResponse, TypeVariables>(GRAPHQL_MUTATION, {
      refetchQueries: [
        { query: GRAPHQL_QUERY,
          variables: {
        		
        	} },
      ]
    });
    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.