/** * React higher-order component (HoC) which wraps the App component and: * - Performs the page's initial GraphQL request on the server, and serializes the result to be used * as the initial Apollo state once the client mounts. * - Passes the Apollo client to the wrapped App component. * * See also: * - https://reactjs.org/docs/higher-order-components.html * - https://github.com/zeit/next.js/blob/1babde1026a89b538d2caebd5d74ef6351871566/examples/with-apollo/lib/with-apollo-client.js */ import ApolloClient from 'apollo-client'; import { NormalizedCacheObject } from 'apollo-cache-inmemory'; import { NextComponentType } from 'next'; import { AppInitialProps } from 'next/app'; export interface AppWithApolloClientInitialProps extends AppInitialProps { apolloState: NormalizedCacheObject; wrappedAppInitialProps: TWrappedAppInitialProps; } /** * Additional parameters passed by AppWithApolloClient to WrappedApp. */ interface AppWithApolloClientParams { apolloClient: ApolloClient; } /** * @template TWrappedAppParams * The parameters which WrappedApp expects via props _and_ getInitialProps context. For example, * WrappedApp may expect a `cookies` parameter as `ctx.cookies` and `props.cookies`. * @template TWrappedAppInitialProps * The initial props returned by WrappedApp.getInitialProps(). By default, this is DefaultAppIProps, * but may be extended by WrappedApp. */ declare const appWithApolloClient: (createApolloClient: (params: TWrappedAppParams, initialState?: NormalizedCacheObject | undefined) => ApolloClient) => (WrappedApp: NextComponentType & TWrappedAppParams & AppWithApolloClientParams, TWrappedAppInitialProps, AppInitialProps & { Component: NextComponentType; router: import("next/router").Router; } & TWrappedAppParams & TWrappedAppInitialProps & AppWithApolloClientParams>) => NextComponentType & TWrappedAppParams, AppWithApolloClientInitialProps, AppInitialProps & { Component: NextComponentType; router: import("next/router").Router; } & TWrappedAppParams & AppWithApolloClientInitialProps>; export default appWithApolloClient;