next-with-apollo
Version:
Apollo HOC for Next.js
31 lines (30 loc) • 1.29 kB
TypeScript
/// <reference types="react" />
import ApolloClient from 'apollo-client';
import { AppContext, default as NextApp } from 'next/app';
import PropTypes from 'prop-types';
import React from 'react';
import { InitApolloOptions, WithApolloProps, WithApolloState } from './types';
export default function withApollo<TCache = any>(options: InitApolloOptions<TCache>): (App: typeof NextApp) => {
new (props: WithApolloProps<TCache>): {
apollo: ApolloClient<TCache>;
render(): JSX.Element;
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: WithApolloProps<TCache>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
forceUpdate(callBack?: (() => void) | undefined): void;
props: Readonly<{
children?: React.ReactNode;
}> & Readonly<WithApolloProps<TCache>>;
state: Readonly<{}>;
context: any;
refs: {
[key: string]: React.ReactInstance;
};
};
displayName: string;
propTypes: {
apolloState: PropTypes.Requireable<any>;
apollo: PropTypes.Requireable<any>;
};
getInitialProps: (appCtx: AppContext) => Promise<{
apolloState: WithApolloState<TCache>;
}>;
};