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

前端 未结 1 542
北海茫月
北海茫月 2021-02-05 13:35

Using: \"react-apollo\": \"^1.4.3\"

In the parent component I query using GraphQL a parent node \'Fund\' with children \'fundQuarterlyMetric\'. This returns data in the

1条回答
  •  北海茫月
    2021-02-05 13:40

    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 },
    });
    

    0 讨论(0)
提交回复
热议问题