import React from 'react'; import type { ApolloClientOptions, setLogVerbosity, ApolloCache, InMemoryCacheConfig, HttpOptions, DocumentNode } from '@apollo/client'; import { ApolloLink } from '@apollo/client'; import type { HttpLink } from '@apollo/client/link/http/http.cjs'; import type { UseAuth } from '@redwoodjs/auth'; import './typeOverride.js'; import { fragmentRegistry, registerFragment, registerFragments } from './fragmentRegistry.js'; import { useCache } from './useCache.js'; export type { CacheKey, FragmentIdentifier, RegisterFragmentResult, } from './fragmentRegistry.js'; export { useCache }; export { fragmentRegistry, registerFragment, registerFragments }; export type ApolloClientCacheConfig = InMemoryCacheConfig; export type RedwoodApolloLinkName = 'withToken' | 'authMiddleware' | 'updateDataApolloLink' | 'httpLink'; export type RedwoodApolloLink = { name: Name; link: Link; }; export type RedwoodApolloLinks = [ RedwoodApolloLink<'withToken'>, RedwoodApolloLink<'authMiddleware'>, RedwoodApolloLink<'updateDataApolloLink'>, RedwoodApolloLink<'httpLink', ApolloLink | HttpLink> ]; export type RedwoodApolloLinkFactory = (links: RedwoodApolloLinks) => ApolloLink; export type GraphQLClientConfigProp = Omit, 'cache' | 'link'> & { cache?: ApolloCache; /** * Configuration for Apollo Client's `InMemoryCache`. * See https://www.apollographql.com/docs/react/caching/cache-configuration/. */ cacheConfig?: ApolloClientCacheConfig; /** * Configuration for the terminating `HttpLink`. * See https://www.apollographql.com/docs/react/api/link/apollo-link-http/#httplink-constructor-options. * * For example, you can use this prop to set the credentials policy so that cookies can be sent to other domains: * * ```js * * ``` */ httpLinkConfig?: HttpOptions; /** * Extend or overwrite `RedwoodApolloProvider`'s Apollo Link. * * To overwrite Redwood's Apollo Link, just provide your own `ApolloLink`. * * To extend Redwood's Apollo Link, provide a function—it'll get passed an array of Redwood's Apollo Links * which are objects with a name and link property: * * ```js * const link = (redwoodApolloLinks) => { * const consoleLink = new ApolloLink((operation, forward) => { * console.log(operation.operationName) * return forward(operation) * }) * * return ApolloLink.from([consoleLink, ...redwoodApolloLinks.map(({ link }) => link)]) * } * ``` * * If you do this, there's a few things you should keep in mind: * - your function should return a single link (e.g., using `ApolloLink.from`; see https://www.apollographql.com/docs/react/api/link/introduction/#additive-composition) * - the `HttpLink` should come last (https://www.apollographql.com/docs/react/api/link/introduction/#the-terminating-link) */ link?: ApolloLink | RedwoodApolloLinkFactory; }; export declare const RedwoodApolloProvider: React.FunctionComponent<{ graphQLClientConfig?: GraphQLClientConfigProp; fragments?: DocumentNode[]; useAuth?: UseAuth; logLevel?: ReturnType; children: React.ReactNode; }>; //# sourceMappingURL=index.d.ts.map