import { ApolloClient, ApolloQueryResult, FetchMoreOptions, FetchMoreQueryOptions, MutationOptions, ObservableQuery, OperationVariables, QueryOptions, } from 'apollo-client'; import { DataProxy } from 'apollo-cache'; import { DocumentNode, ExecutionResult } from 'graphql'; import * as React from 'react'; type Omit = Pick>; type FetchResult< C = Record, E = Record > = ExecutionResult & { extensions?: E; context?: C; }; export function ApolloProvider(props: { children: React.ReactNode; client: ApolloClient; }): JSX.Element; export function useApolloClient(): ApolloClient< CacheShape > | null; type QueryHookOptions = Omit, 'query'> & { // watch query options from apollo client notifyOnNetworkStatusChange?: boolean; pollInterval?: number; // custom options of `useQuery` hook suspend?: boolean; }; export function useQuery( query: DocumentNode, options?: QueryHookOptions ): ApolloQueryResult & Pick< ObservableQuery, 'refetch' | 'startPolling' | 'stopPolling' | 'updateQuery' > & { fetchMore( fetchMoreOptions: FetchMoreQueryOptions & FetchMoreOptions ): Promise>; }; // We have to redefine MutationUpdaterFn and `update` option of `useMutation` // hook because we want them to use our custom parametrized version // of `FetchResult` type. Please look at // https://github.com/trojanowski/react-apollo-hooks/issues/25 export type MutationUpdaterFn< T = { [key: string]: any; } > = (proxy: DataProxy, mutationResult: FetchResult) => void; type MutationHookOptions = Omit< MutationOptions, 'mutation' | 'update' > & { update?: MutationUpdaterFn; }; export function useMutation( mutation: DocumentNode, options?: MutationHookOptions ): (( localOptions?: MutationHookOptions ) => Promise>); /** * @deprecated use useQuery instead */ export const useApolloQuery: typeof useQuery; /** * @deprecated use useMutation instead */ export const useApolloMutation: typeof useMutation;