Last active
October 17, 2022 12:19
-
-
Save umutyerebakmaz/2c7fdc1c4bdfbfa21a74108ad0b14b8b to your computer and use it in GitHub Desktop.
Creating conditional Apollo Client RefetchQueries parameter in Angular applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
refetchHander(appState: AppState): MutationBaseOptions { | |
const refetchQueries = [ | |
{ | |
query: this.coordinatesTableGQL.document, | |
variables: { | |
filter: { | |
skip: 0, | |
take: 10, | |
}, | |
}, | |
}, | |
{ | |
query: this.coordinatesCountGQL.document, | |
variables: { | |
filter: { | |
skip: 0, | |
take: 10, | |
}, | |
}, | |
}, | |
] as any; | |
if (appState?.request) { | |
refetchQueries?.push({ | |
query: this.requestDetailGQL.document, | |
variables: { | |
id: appState.request.id, | |
}, | |
}); | |
} | |
if (appState?.activity) { | |
refetchQueries?.push({ | |
query: this.activityDetailGQL.document, | |
variables: { | |
id: appState.activity.id, | |
}, | |
}); | |
} | |
return { | |
refetchQueries, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment