We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ac6da2c commit 50b70faCopy full SHA for 50b70fa
src/useQuery.ts
@@ -96,6 +96,8 @@ export function useQuery<
96
? 'cache-first'
97
: actualCachePolicy;
98
99
+ const lastResult = React.useRef();
100
+
101
const watchQueryOptions: WatchQueryOptions<TVariables> = useMemo(
102
() =>
103
compact({
@@ -144,6 +146,12 @@ export function useQuery<
144
146
};
145
147
}
148
149
+ if (result.loading) {
150
+ data = {
151
+ ...(lastResult.current || {}).data,
152
+ };
153
+ }
154
155
return {
156
data,
157
error:
@@ -161,6 +169,7 @@ export function useQuery<
161
169
},
162
170
[shouldSkip, responseId, observableQuery]
163
171
);
172
+ lastResult.current = currentResult;
164
173
165
174
useEffect(
166
175
() => {
0 commit comments