2 years ago
#48816
kl123
graphQL useQuery refetch
I have multiple queries combined in one request.
Later, when user make some changes I need to refetch only one of those combined queries with new variables.
I added directives @include on those queries that I don't need to fetch again.
The problem is, on refetch, my cache is overwritten with new data from that single query.
How can I persist my cache, and only update it on refetch with new data and not overwrite it?
const { loading, error, data, refetch } = useQuery(GET_DATA, {
fetchPolicy: 'network-only',
variables: {
something,
includeSummary: true,
},
});
refetch(
{
...variables,
includeSummary: false,
}
);
export const GET_DATA = gql`
query Something(
$args: DataInput
$includeSummary: Boolean!
) {
summary @include(if: $includeSummary) {
.......
}
dynamicData(args: $args) {
........
}
}
`;
graphql
react-apollo
0 Answers
Your Answer