Apollo-client (react) - Update on create mutation - "Can't find field Fund({}) on object (ROOT_QUERY)" Apollo-client (react) - Update on create mutation - "Can't find field Fund({}) on object (ROOT_QUERY)" reactjs reactjs

Apollo-client (react) - Update on create mutation - "Can't find field Fund({}) on object (ROOT_QUERY)"


The Apollo docs do a poor job of stressing this fact, but when you call readQuery to get a previously fetched query from the store, if that query took any variables, you need to pass in those same variables to retrieve it. Assuming the id returned by mutation is the fund's id, you should be able to just modify this line:

const data = proxy.readQuery({    query: FundQL.fundPageQuery,    variables: { id: createFundMetrics.id },});