MessagesForMacintosh/JS/node_modules/apollo-boost/lib/bundle.esm.js.map

1 line
8.8 KiB
Plaintext
Raw Normal View History

{"version":3,"file":"bundle.esm.js","sources":["../src/index.ts"],"sourcesContent":["/* necessary for backward compat */\nexport * from 'apollo-client';\nexport * from 'apollo-link';\nexport * from 'apollo-cache-inmemory';\n\nimport { Operation, ApolloLink, Observable } from 'apollo-link';\nimport { HttpLink, UriFunction } from 'apollo-link-http';\nimport { onError, ErrorLink } from 'apollo-link-error';\nimport { ApolloCache } from 'apollo-cache';\nimport { InMemoryCache, CacheResolverMap } from 'apollo-cache-inmemory';\nimport gql from 'graphql-tag';\nimport ApolloClient, {\n Resolvers,\n LocalStateFragmentMatcher,\n} from 'apollo-client';\nimport { DocumentNode } from 'graphql';\nimport { invariant } from 'ts-invariant';\n\nexport { gql, HttpLink };\n\ntype ClientStateConfig = {\n cache?: ApolloCache<any>;\n defaults?: Record<string, any>;\n resolvers?: Resolvers | Resolvers[];\n typeDefs?: string | string[] | DocumentNode | DocumentNode[];\n fragmentMatcher?: LocalStateFragmentMatcher;\n};\n\nexport interface PresetConfig {\n request?: (operation: Operation) => Promise<void> | void;\n uri?: string | UriFunction;\n credentials?: string;\n headers?: any;\n fetch?: WindowOrWorkerGlobalScope['fetch'];\n fetchOptions?: HttpLink.Options;\n clientState?: ClientStateConfig;\n onError?: ErrorLink.ErrorHandler;\n cacheRedirects?: CacheResolverMap;\n cache?: ApolloCache<any>;\n name?: string;\n version?: string;\n resolvers?: Resolvers | Resolvers[];\n typeDefs?: string | string[] | DocumentNode | DocumentNode[];\n fragmentMatcher?: LocalStateFragmentMatcher;\n assumeImmutableResults?: boolean;\n}\n\n// Yes, these are the exact same as the `PresetConfig` interface. We're\n// defining these again so they can be used to verify that valid config\n// options are being used in the `DefaultClient` constructor, for clients\n// that aren't using Typescript. This duplication is unfortunate, and at\n// some point can likely be adjusted so these items are inferred from\n// the `PresetConfig` interface using a Typescript transform at compilation\n// time. Unfortunately, TS transforms with rollup don't appear to be quite\n// working properly, so this will have to be re-visited at some point.\n// For now, when updating the properties of the `PresetConfig` interface,\n// please also update this constant.\nconst PRESET_CONFIG_KEYS = [\n 'request',\n 'uri',\n 'credentials',\n 'headers',\n 'fetch',\n 'fetchOptions',\n 'clientState',\n 'onError',\n 'cacheRedirects',\n 'cache',\n 'name',\n 'version',\n 'resolvers',\n 'typeDefs',\n 'fragmentMatcher',\n];\n\nexport default class DefaultClient<TCache> extends ApolloClient<TCache> {\n constructor(config: PresetConfig = {}) {\n if (config) {\n const diff = Object.keys(config).filter(\n key => PRESET_CONFIG_KEYS.indexOf(key) === -1,\n );\n\n if (diff.length > 0) {\n invariant.warn(\n 'ApolloBoost was initialized with unsupported options: ' +\n `${diff.join(' ')}`,\n );\n }\n }\n\n const {\n request,\n uri,\n credentials,\n headers,\n fetch,\n fetchOptions,\n clientState,\n cacheRedirects,\n onError: errorCallback,\n name,\n version,\n resolvers,\n typeDefs,\n fragmentMatcher,\n } = config;\n\n let { cache } = config;\n\n invariant(\n !cache || !cacheRedirects,\n 'Incompatible cache configuration. When not providing `cache`, ' +\n 'configure the provided instance with `cacheRedirects` instead.',\n );\n\n if (!cache) {\n cache = cacheRedirects\n ? new InMemoryCache({ cacheRedirects })\n : new InMemoryCache();\n }\n\n const errorLink = errorCallback\n ? onError(errorCallback)\n : onError(({ graphQLErrors, networkError }) => {\n if (graphQLErrors) {\n graphQLErrors.forEach(({ message, locations, path }) =>\n // tslint:disable-next-line\n invariant.warn(\n `[GraphQL error]: Message: ${message}, Location: `