From 1d5b9127ce0ca63e67e02bbbedcbf4b3e76c036c Mon Sep 17 00:00:00 2001 From: Sebastian Goll <1277035+sgoll@users.noreply.github.com> Date: Mon, 29 Apr 2019 19:43:30 +0200 Subject: [PATCH] Fix fallback of `data` attribute in query result As described in https://www.apollographql.com/docs/react/essentials/queries#props, the `data` object is either the actual query result, or the empty object `{}` when the data is not (yet) available. --- src/useQuery.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/useQuery.ts b/src/useQuery.ts index 17a7c47..a1c0f79 100644 --- a/src/useQuery.ts +++ b/src/useQuery.ts @@ -27,7 +27,7 @@ export interface QueryHookState ApolloCurrentResult, 'error' | 'errors' | 'loading' | 'partial' > { - data?: TData; + data: TData | {}; // networkStatus is undefined for skipped queries or the ones using suspense networkStatus: NetworkStatus | undefined; }