Skip to content

Commit 682be73

Browse files
committed
feat(useQuery): returns stale as a part of useQuery.
Closes #91
1 parent 4a5a38a commit 682be73

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/useQuery.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ApolloClient, {
2-
ApolloCurrentResult,
2+
ApolloCurrentQueryResult,
33
ApolloError,
44
ApolloQueryResult,
55
FetchMoreOptions,
@@ -23,8 +23,8 @@ import { Omit, compact, objToKey } from './utils';
2323

2424
export interface QueryHookState<TData>
2525
extends Pick<
26-
ApolloCurrentResult<undefined | TData>,
27-
'error' | 'errors' | 'loading' | 'partial'
26+
ApolloCurrentQueryResult<undefined | TData>,
27+
'error' | 'errors' | 'loading' | 'partial' | 'stale'
2828
> {
2929
data?: TData;
3030
// networkStatus is undefined for skipped queries or the ones using suspense
@@ -140,7 +140,7 @@ export function useQuery<
140140
updateQuery: observableQuery.updateQuery.bind(observableQuery),
141141
};
142142

143-
const result = observableQuery.currentResult();
143+
const result = observableQuery.getCurrentResult();
144144

145145
// return the old result data when there is an error
146146
let data = result.data as TData;
@@ -176,6 +176,7 @@ export function useQuery<
176176
// https://github.com/trojanowski/react-apollo-hooks/pull/68
177177
networkStatus: suspend ? undefined : result.networkStatus,
178178
partial: result.partial,
179+
stale: result.stale,
179180
};
180181
},
181182
[shouldSkip, responseId, observableQuery]

0 commit comments

Comments
 (0)