Skip to content

Instantly share code, notes, and snippets.

@umutyerebakmaz
Last active October 17, 2022 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umutyerebakmaz/2c7fdc1c4bdfbfa21a74108ad0b14b8b to your computer and use it in GitHub Desktop.
Save umutyerebakmaz/2c7fdc1c4bdfbfa21a74108ad0b14b8b to your computer and use it in GitHub Desktop.
Creating conditional Apollo Client RefetchQueries parameter in Angular applications
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