You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
importgqlfrom'graphql-tag';import{SurveyNavigatorFragments}from'../SurveyNavigator';exportconstsurveyTemplateFragment=gql` fragment SurveyQueryContainer_surveyTemplate on SurveyTemplate { id name ...SurveyNavigator_surveyTemplate }${SurveyNavigatorFragments.surveyTemplate}`;exportconstsurveyResponseFragment=gql` fragment SurveyQueryContainer_surveyResponse on SurveyResponse { id ...SurveyNavigator_surveyResponse }${SurveyNavigatorFragments.surveyResponse}`;exportconstSurveyQueryContainerQuery=gql` query SurveyQueryContainerQuery($surveyTemplateId: ID!, $surveyResponseId: ID!) { getSurveyTemplate(id: $surveyTemplateId) { ...SurveyQueryContainer_surveyTemplate } getSurveyResponse(id: $surveyResponseId) { ...SurveyQueryContainer_surveyResponse } }${surveyTemplateFragment}${surveyResponseFragment}`;
I know the getSurveyTemplate field is in the cache since I've visited this screen before and the data for that field is always the same (the surveyTemplateId variable is always the same). The only thing in the SurveyQueryContainerQuery that changes each time is the surveyResponseId variable and therefore the SurveyResponse. Given this setup, if I fire my createSurveyResponse mutation before visiting the screen with SurveyQueryContainer in it, I would expect the query component to render immediately because I have optimistically updated the cache with the correct SurveyQueryContainer_surveyResponse fragment. I should have all the data needed to satisfy SurveyQueryContainerQuery present in the cache, so it shouldn't need to do a network fetch, yet it is still doing this. Am I doing something wrong here? Why can't it find the fragment I've written?
Here's a mutation config I have that uses writeFragment in the updater:
Here's the component using the query I want to update:
And here's the query:
I know the
getSurveyTemplate
field is in the cache since I've visited this screen before and the data for that field is always the same (thesurveyTemplateId
variable is always the same). The only thing in theSurveyQueryContainerQuery
that changes each time is thesurveyResponseId
variable and therefore theSurveyResponse
. Given this setup, if I fire mycreateSurveyResponse
mutation before visiting the screen withSurveyQueryContainer
in it, I would expect the query component to render immediately because I have optimistically updated the cache with the correctSurveyQueryContainer_surveyResponse
fragment. I should have all the data needed to satisfySurveyQueryContainerQuery
present in the cache, so it shouldn't need to do a network fetch, yet it is still doing this. Am I doing something wrong here? Why can't it find the fragment I've written?This seems to work when I change my updater to:
But this is quite a bit more verbose, and seems like it shouldn't be necessary.
The text was updated successfully, but these errors were encountered: