/*! * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the License. A copy of * the License is located at * http://aws.amazon.com/asl/ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, express or implied. See the License for the specific language governing permissions and limitations under the License. */ import 'setimmediate'; import ApolloClient, { ApolloClientOptions, MutationOptions, OperationVariables, MutationUpdaterFn } from 'apollo-client'; import { ApolloReducerConfig, NormalizedCacheObject } from 'apollo-cache-inmemory'; import { ApolloLink, FetchResult } from 'apollo-link'; import { Store } from 'redux'; import { defaultDataIdFromObject } from './cache/index'; import { OfflineCache as OfflineCacheType } from './cache/offline-cache'; import { AuthLink, AUTH_TYPE } from './link'; import { ApolloCache } from 'apollo-cache'; import { AuthOptions } from './link/auth-link'; import { Credentials, CredentialsOptions } from 'aws-sdk/lib/credentials'; import { DocumentNode } from 'graphql'; import { buildSync } from "./deltaSync"; import { Subscription } from 'apollo-client/util/Observable'; export { defaultDataIdFromObject }; export declare const createSubscriptionHandshakeLink: (url: string, resultsFetcherLink?: ApolloLink) => ApolloLink; export declare const createAuthLink: ({ url, region, auth }: { url: string; region: string; auth: AuthOptions; }) => AuthLink; export declare const createAppSyncLink: ({ url, region, auth, complexObjectsCredentials, resultsFetcherLink, conflictResolver, }: { url: string; region: string; auth: AuthOptions; complexObjectsCredentials: CredentialsGetter; resultsFetcherLink?: ApolloLink; conflictResolver?: ConflictResolver; }) => ApolloLink; export declare const createLinkWithCache: (createLinkFunc?: (cache: ApolloCache) => ApolloLink) => ApolloLink; export interface CacheWithStore extends ApolloCache { store: Store; } declare type CredentialsGetter = () => (Credentials | CredentialsOptions | null) | Credentials | CredentialsOptions | null; export interface AWSAppSyncClientOptions { url: string; region: string; auth: AuthOptions; conflictResolver?: ConflictResolver; complexObjectsCredentials?: CredentialsGetter; cacheOptions?: ApolloReducerConfig; disableOffline?: boolean; offlineConfig?: OfflineConfig; } export interface OfflineConfig { storage?: any; callback?: OfflineCallback; storeCacheRootMutation?: boolean; } export declare type OfflineCallback = (err: any, success: any) => void; export interface ConflictResolutionInfo { mutation: DocumentNode; mutationName: string; operationType: string; variables: any; data: any; retries: number; } export declare type ConflictResolver = (obj: ConflictResolutionInfo) => 'DISCARD' | any; declare class AWSAppSyncClient extends ApolloClient { private _store; private hydratedPromise; hydrated(): Promise>; private _disableOffline; constructor({ url, region, auth, conflictResolver, complexObjectsCredentials, cacheOptions, disableOffline, offlineConfig: { storage, callback, storeCacheRootMutation, }, }: AWSAppSyncClientOptions, options?: Partial>); isOfflineEnabled(): boolean; mutate(options: MutationOptions): Promise>; sync(options: SubscribeWithSyncOptions): Subscription; } export declare type QuerySyncOptions = { query: DocumentNode; variables: TVariables; update: MutationUpdaterFn; }; export declare type BaseQuerySyncOptions = QuerySyncOptions & { baseRefreshIntervalInSeconds?: number; }; export declare type SubscribeWithSyncOptions = { baseQuery?: BaseQuerySyncOptions; subscriptionQuery?: QuerySyncOptions; deltaQuery?: QuerySyncOptions; }; export default AWSAppSyncClient; export { AWSAppSyncClient }; export { AUTH_TYPE, buildSync };