Refetch not working with new variables

Hey all,

I’m using apollo-client and am experiencing a problem where I am trying to refetch some data with new variables and it is only re-running the query with the original query’s variables.

The other potential additional info I think might be relevant is that the refetch is being performed in a child component (react). The code below will run the query with {name: “”} for both. I have confirmed that data is accurately passing into the refetch. I also noticed that even if I change the variable “name” in the refetch, to something random, it doesn’t prevent the refetch. So it’s probably ignoring the variables?

I have tried putting the refetch in the parent and it still ignores the variables.

Any idea why I am unable to use new variables in the refetch? From the Apollo docs:

You can optionally provide a new variables object to the refetch function. If you don’t (as is the case in the following example), the query uses the same variables that it used in its previous execution.

Query (in parent component):

const { data, loading, error, refetch } = useQuery(getExercises, {
    cachePolicy: "cache-first",
    variables: { name: "" },
  });

Refetch (in child component):

const customSubmit = async (data) => {
    try {
      const response = await props.refetch({
        variables: { name: data?.exerciseInput },
      })
      if (response) {
        props.setExerciseArray(response?.data?.getExercises);
        addToast("Exercises Updated", {
          appearance: "success",
          autoDismiss: true,
        });
      }
    } catch (error) {
      addToast(error.message, { appearance: "error", autoDismiss: true });
    }
  };