Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@airbnb/lunar-apollo

3.0.2 • Public • Published

Lunar Apollo

Provides out of the box support for GraphQL, powered by Apollo.

yarn add @airbnb/lunar-apollo

This package relies on GraphQL related packages to also be installed.

yarn add graphql graphql-tag

Setup

Initialize the package to create an Apollo client. The following option settings may be passed to customize this package.

  • links (ApolloLink[]) - Collection of Apollo links (middleware) to apply to the client.
import Apollo, { HttpLink } from '@airbnb/lunar-apollo';
 
const httpLink = new HttpLink({
  uri: '/api/graphql',
  credentials: 'same-origin',
});
 
Apollo.initialize({
  links: [httpLink],
});

The client can be accessed with Apollo.getClient().

Usage

Once the Apollo client has been created, we can make it available to our queries and mutations by wrapping our application in a provider.

import { Provider } from '@airbnb/lunar-apollo';
 
function Root() {
  return (
    <Provider>
      <App />
    </Provider>
  );
}

Keywords

none

Install

npm i @airbnb/lunar-apollo

DownloadsWeekly Downloads

37

Version

3.0.2

License

MIT

Unpacked Size

50.2 kB

Total Files

48

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar