/
Launch Graph Manager

@apollo/react-common

API reference


Installation

npm install @apollo/react-common

ApolloProvider

PropertyTypeDescription
dataTDataAn object containing the result of your GraphQL subscription. Defaults to an empty object.
loadingbooleanA boolean that indicates whether any initial data has been returned
errorApolloErrorA runtime error with graphQLErrors and networkError properties

ApolloConsumer

One way to access the configured Apollo Client instance directly is to create an ApolloConsumer component and provide a render prop function as its child. The render prop function will be called with your ApolloClient instance as its only argument. You can think of the ApolloConsumer component as similar to the Consumer component from the React Context API.

Example

import React from 'react';
import { ApolloConsumer } from '@apollo/react-common';
// or from the hooks, components, hoc packages:
// import { ApolloConsumer } from "@apollo/react-hooks";

const WithApolloClient = () => (
  <ApolloConsumer>
    {client => 'We have access to the client!' /* do stuff here */}
  </ApolloConsumer>
);
Edit on GitHub