removeTypenameFromVariables is not removing __typeName from variables

Hello!
I am using the data from a GraphQL query as an argument for a mutation and I am seeing errors because __typename is not recognized. This is a known issue and is meant to be addressed by the function RemoveTypenameFromVariables

I followed the instructions in the apollo article, and called

import { removeTypenameFromVariables } from '@apollo/client/link/remove-typename';

// Inside my JSX component, I called
const removeTypenameLink = removeTypenameFromVariables();

After calling this function, I am still seeing the same error related to __typename not being recognized. Curious to know if there is an additional step missing in the apollo docs.

I am using “@apollo/client”: “^3.8.3”

Error

Message: Variable “$input” got invalid value { __typename: “MeasurementObservationValue”, measurement: 85804, units: “cm” } at “input.patientObservations.fundalHeight”; Field “__typename” is not defined by type “MeasurementObservationValueInput”.

removeTypenameFromVariables gives you a Link - just calling it by itself in a component will not do anything. You will have to add that Link to your link chain when creating your ApolloClient instance:

const removeTypenameLink = removeTypenameFromVariables();

const client = new ApolloClient({
  // ... cache, etc
  link: ApolloLink.from([
    removeTypenameLink,
    // your other links
    yourHttpLink
  ])
})

Thanks for the clarification! This makes more sense now.