From d73eac827bbc142bc84bf804d97305fbd59819ac Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Sun, 1 Dec 2019 17:14:15 +0100 Subject: [PATCH] feat(useQuery): fetchMore --- .../vue-apollo-composable/src/useQuery.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/vue-apollo-composable/src/useQuery.ts b/packages/vue-apollo-composable/src/useQuery.ts index 158b3d1..3fae975 100644 --- a/packages/vue-apollo-composable/src/useQuery.ts +++ b/packages/vue-apollo-composable/src/useQuery.ts @@ -1,7 +1,15 @@ import { ref, watch, onUnmounted, Ref, isRef, computed } from '@vue/composition-api' import Vue from 'vue' import { DocumentNode } from 'graphql' -import { OperationVariables, WatchQueryOptions, ObservableQuery, ApolloQueryResult, SubscribeToMoreOptions } from 'apollo-client' +import { + OperationVariables, + WatchQueryOptions, + ObservableQuery, + ApolloQueryResult, + SubscribeToMoreOptions, + FetchMoreQueryOptions, + FetchMoreOptions, +} from 'apollo-client' import { Subscription } from 'apollo-client/util/Observable' import { useApolloClient } from './useApolloClient' import { ReactiveFunction } from './util/ReactiveFunction' @@ -221,6 +229,14 @@ export function useQuery< } } + // Fetch more + + function fetchMore (options: FetchMoreQueryOptions & FetchMoreOptions) { + if (query.value) { + return query.value.fetchMore(options) + } + } + // Subscribe to more const subscribeToMoreItems: SubscribeToMoreItem[] = [] @@ -303,6 +319,7 @@ export function useQuery< options: optionsRef, query, refetch, + fetchMore, subscribeToMore, onResult: resultEvent.on, onError: errorEvent.on,