UNPKG

@airbnb/lunar-apollo

Version:

Apollo and GraphQL utilities.

42 lines 1.85 kB
import React from 'react'; import { QueryResult, OperationVariables, ApolloError } from '@apollo/client'; import { QueryComponentOptions } from '@apollo/client/react/components'; import { RenderableProp } from '@airbnb/lunar/lib/utils/renderElementOrFunction'; export declare type QueryProps<Data, Vars> = Omit<QueryComponentOptions<Data, Vars>, 'children' | 'client'> & { /** Child function to render when the data has been received. */ children: (data: Data | null, result: QueryResult<Data, Vars>) => React.ReactNode; /** * Render an element or a function that returns an element when an error occurs. * The function is passed the `ApolloError` as an argument. * When not defined, this defaults to `ErrorMessage`. */ error?: RenderableProp<ApolloError>; /** * Render an element or a function that returns an element while loading. * When not defined, this defaults to `Loader`. */ loading?: RenderableProp; /** * Allow graphql errors to be passed to the render function. If this is true the render function * may receive partial data and is expected to be able to handle `result.error.graphQLErrors` */ ignoreGraphQLErrors?: boolean; }; /** * A declarative component to make GraphQL queries. * Based on Apollo's [Query](https://www.apollographql.com/docs/react/essentials/queries.html#props) component. */ export default class Query<Data = {}, Vars = OperationVariables> extends React.Component<QueryProps<Data, Vars>> { static defaultProps: { ignoreGraphQLErrors: boolean; notifyOnNetworkStatusChange: boolean; partialRefetch: boolean; pollInterval: number; skip: boolean; ssr: boolean; variables: {}; }; private handleRender; render(): JSX.Element; } //# sourceMappingURL=index.d.ts.map