apollo-client
A simple yet functional GraphQL client.
Last updated 7 years ago by benjamn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install apollo-client 
SYNC missed versions from official npm registry.

Apollo Client npm version Open Source Helpers Join the community on Spectrum

Apollo Client is a fully-featured caching GraphQL client with integrations for React, Angular, and more. It allows you to easily build UI components that fetch data via GraphQL. To get the most value out of apollo-client, you should use it with one of its view layer integrations.

To get started with the React integration, go to our React Apollo documentation website.

Apollo Client also has view layer integrations for all the popular frontend frameworks. For the best experience, make sure to use the view integration layer for your frontend framework of choice.

Apollo Client can be used in any JavaScript frontend where you want to use data from a GraphQL server. It's:

  1. Incrementally adoptable, so that you can drop it into an existing JavaScript app and start using GraphQL for just part of your UI.
  2. Universally compatible, so that Apollo works with any build setup, any GraphQL server, and any GraphQL schema.
  3. Simple to get started with, so you can start loading data right away and learn about advanced features later.
  4. Inspectable and understandable, so that you can have great developer tools to understand exactly what is happening in your app.
  5. Built for interactive apps, so your users can make changes and see them reflected in the UI immediately.
  6. Small and flexible, so you don't get stuff you don't need. The core is under 25kb compressed.
  7. Community driven, because Apollo is driven by the community and serves a variety of use cases. Everything is planned and developed in the open.

Get started on the home page, which has great examples for a variety of frameworks.

Installation

# installing the preset package
npm install apollo-boost graphql-tag graphql --save
# installing each piece independently
npm install apollo-client apollo-cache-inmemory apollo-link-http graphql-tag graphql --save

To use this client in a web browser or mobile app, you'll need a build system capable of loading NPM packages on the client. Some common choices include Browserify, Webpack, and Meteor 1.3+.

Install the Apollo Client Developer tools for Chrome for a great GraphQL developer experience!

Usage

You get started by constructing an instance of the core class ApolloClient. If you load ApolloClient from the apollo-boost package, it will be configured with a few reasonable defaults such as our standard in-memory cache and a link to a GraphQL API at /graphql.

import ApolloClient from 'apollo-boost';

const client = new ApolloClient();

To point ApolloClient at a different URL, add your GraphQL API's URL to the uri config property:

import ApolloClient from 'apollo-boost';

const client = new ApolloClient({
  uri: 'https://graphql.example.com'
});

Most of the time you'll hook up your client to a frontend integration. But if you'd like to directly execute a query with your client, you may now call the client.query method like this:

import gql from 'graphql-tag';

client.query({
  query: gql`
    query TodoApp {
      todos {
        id
        text
        completed
      }
    }
  `,
})
  .then(data => console.log(data))
  .catch(error => console.error(error));

Now your client will be primed with some data in its cache. You can continue to make queries, or you can get your client instance to perform all sorts of advanced tasks on your GraphQL data. Such as reactively watching queries with watchQuery, changing data on your server with mutate, or reading a fragment from your local cache with readFragment.

To learn more about all of the features available to you through the apollo-client package, be sure to read through the apollo-client API reference.

Learn how to use Apollo Client with your favorite framework


Contributing

CircleCI codecov

Read the Apollo Contributor Guidelines.

Running tests locally:

npm install
npm test

This project uses TypeScript for static typing and TSLint for linting. You can get both of these built into your editor with no configuration by opening this project in Visual Studio Code, an open source IDE which is available for free on all platforms.

Important discussions

If you're getting booted up as a contributor, here are some discussions you should take a look at:

  1. Static typing and why we went with TypeScript also covered in the Medium post
  2. Idea for pagination handling
  3. Discussion about interaction with Redux and domain vs. client state
  4. Long conversation about different client options, before this repo existed

Maintainers

Current Tags

  • 2.6.0-rc.3                                ...           beta (5 years ago)
  • 2.6.10                                ...           latest (5 years ago)
  • 2.6.10-test.1                                ...           test (5 years ago)

309 Versions

  • 2.6.10                                ...           5 years ago
  • 2.6.10-test.1                                ...           5 years ago
  • 2.6.10-test.0                                ...           5 years ago
  • 2.6.9                                ...           5 years ago
  • 2.6.8                                ...           5 years ago
  • 2.6.7                                ...           5 years ago
  • 2.6.6                                ...           5 years ago
  • 2.6.4                                ...           5 years ago
  • 2.6.3                                ...           5 years ago
  • 2.6.2                                ...           5 years ago
  • 2.6.1                                ...           5 years ago
  • 2.6.0                                ...           5 years ago
  • 2.6.0-rc.3                                ...           5 years ago
  • 2.6.0-rc.2                                ...           6 years ago
  • 2.6.0-rc.1                                ...           6 years ago
  • 2.6.0-rc.0                                ...           6 years ago
  • 2.6.0-beta.8                                ...           6 years ago
  • 2.6.0-beta.7                                ...           6 years ago
  • 2.6.0-beta.6                                ...           6 years ago
  • 2.6.0-beta.5                                ...           6 years ago
  • 2.6.0-beta.4                                ...           6 years ago
  • 2.6.0-beta.3                                ...           6 years ago
  • 2.6.0-beta.2                                ...           6 years ago
  • 2.6.0-beta.1                                ...           6 years ago
  • 2.6.0-beta.0                                ...           6 years ago
  • 2.5.1                                ...           6 years ago
  • 2.5.0                                ...           6 years ago
  • 2.5.0-rc.3                                ...           6 years ago
  • 2.5.0-rc.2                                ...           6 years ago
  • 2.5.0-rc.1                                ...           6 years ago
  • 2.5.0-rc.0                                ...           6 years ago
  • 2.4.13                                ...           6 years ago
  • 2.5.0-beta.1                                ...           6 years ago
  • 2.5.0-beta.0                                ...           6 years ago
  • 2.4.12                                ...           6 years ago
  • 2.4.11                                ...           6 years ago
  • 2.4.10                                ...           6 years ago
  • 2.4.9                                ...           6 years ago
  • 2.5.0-alpha.10                                ...           6 years ago
  • 2.5.0-alpha.9                                ...           6 years ago
  • 2.5.0-alpha.8                                ...           6 years ago
  • 2.5.0-alpha.7                                ...           6 years ago
  • 2.5.0-alpha.6                                ...           6 years ago
  • 2.5.0-alpha.5                                ...           6 years ago
  • 2.5.0-alpha.4                                ...           6 years ago
  • 2.5.0-alpha.3                                ...           6 years ago
  • 2.4.8                                ...           6 years ago
  • 2.5.0-alpha.2                                ...           6 years ago
  • 2.4.7                                ...           6 years ago
  • 2.4.6                                ...           6 years ago
  • 2.5.0-alpha.1                                ...           6 years ago
  • 2.4.3-local-state-alpha.14                                ...           6 years ago
  • 2.4.3-local-state-alpha.13                                ...           6 years ago
  • 2.4.5                                ...           6 years ago
  • 2.4.4                                ...           6 years ago
  • 2.4.3-local-state-alpha.12                                ...           6 years ago
  • 2.4.3-local-state-alpha.11                                ...           6 years ago
  • 2.4.3-local-state-alpha.10                                ...           6 years ago
  • 2.4.3                                ...           6 years ago
  • 2.4.3-local-state-alpha.9                                ...           6 years ago
  • 2.4.3-local-state-alpha.8                                ...           6 years ago
  • 2.4.3-local-state-alpha.7                                ...           6 years ago
  • 2.4.3-local-state-alpha.6                                ...           6 years ago
  • 2.4.3-local-state-alpha.5                                ...           6 years ago
  • 2.4.3-local-state-alpha.4                                ...           6 years ago
  • 2.4.3-local-state-alpha.3                                ...           6 years ago
  • 2.4.3-local-state-alpha.2                                ...           6 years ago
  • 2.4.3-local-state-alpha.1                                ...           6 years ago
  • 2.4.3-local-state-alpha.0                                ...           6 years ago
  • 2.4.2                                ...           6 years ago
  • 2.4.1                                ...           6 years ago
  • 2.5.0-verify.4                                ...           6 years ago
  • 2.5.0-verify.3                                ...           6 years ago
  • 2.5.0-verify.2                                ...           6 years ago
  • 2.5.0-verify.1                                ...           6 years ago
  • 2.4.0                                ...           6 years ago
  • 2.3.8                                ...           6 years ago
  • 2.4.0-alpha.14                                ...           6 years ago
  • 2.4.0-alpha.13                                ...           6 years ago
  • 2.4.0-alpha.12                                ...           6 years ago
  • 2.4.0-alpha.10                                ...           6 years ago
  • 2.4.0-alpha.9                                ...           6 years ago
  • 2.4.0-alpha.8                                ...           6 years ago
  • 2.4.0-alpha.7                                ...           6 years ago
  • 2.4.0-alpha.6                                ...           6 years ago
  • 2.4.0-alpha.5                                ...           6 years ago
  • 2.3.7                                ...           6 years ago
  • 2.4.0-alpha.4                                ...           6 years ago
  • 2.4.0-alpha.3                                ...           6 years ago
  • 2.3.6                                ...           6 years ago
  • 2.4.0-alpha.2                                ...           6 years ago
  • 2.4.0-alpha.1                                ...           6 years ago
  • 2.3.5                                ...           6 years ago
  • 2.3.4                                ...           6 years ago
  • 2.3.3                                ...           6 years ago
  • 2.3.2                                ...           6 years ago
  • 2.3.1                                ...           7 years ago
  • 2.3.0                                ...           7 years ago
  • 2.2.8                                ...           7 years ago
  • 2.2.7                                ...           7 years ago
  • 2.2.6                                ...           7 years ago
  • 2.2.5                                ...           7 years ago
  • 2.2.4                                ...           7 years ago
  • 2.2.3                                ...           7 years ago
  • 2.2.2                                ...           7 years ago
  • 2.2.1                                ...           7 years ago
  • 2.2.0                                ...           7 years ago
  • 2.0.4                                ...           7 years ago
  • 2.1.0                                ...           7 years ago
  • 2.0.3                                ...           7 years ago
  • 2.0.2                                ...           7 years ago
  • 2.0.1                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 2.0.0-rc.7                                ...           7 years ago
  • 2.0.0-rc.6                                ...           7 years ago
  • 2.0.0-rc.5                                ...           7 years ago
  • 2.0.0-rc.4                                ...           7 years ago
  • 2.0.0-rc.3                                ...           7 years ago
  • 2.0.0-rc.2                                ...           7 years ago
  • 2.0.0-rc.1                                ...           7 years ago
  • 2.0.0-rc.0                                ...           7 years ago
  • 2.0.0-beta.8                                ...           7 years ago
  • 2.0.0-beta.7                                ...           7 years ago
  • 2.0.0-beta.6                                ...           7 years ago
  • 2.0.0-beta.5                                ...           7 years ago
  • 2.0.0-beta.4                                ...           7 years ago
  • 2.0.0-beta.3                                ...           7 years ago
  • 2.0.0-beta.2                                ...           7 years ago
  • 1.9.3                                ...           7 years ago
  • 2.0.0-beta.1                                ...           7 years ago
  • 2.0.0-beta.0                                ...           7 years ago
  • 2.0.0-alpha.28                                ...           7 years ago
  • 2.0.0-alpha.27                                ...           7 years ago
  • 2.0.0-alpha.26                                ...           7 years ago
  • 2.0.0-alpha.25                                ...           7 years ago
  • 2.0.0-alpha.24                                ...           7 years ago
  • 2.0.0-alpha.23                                ...           7 years ago
  • 2.0.0-alpha.22                                ...           7 years ago
  • 2.0.0-alpha.20                                ...           7 years ago
  • 2.0.0-alpha.19                                ...           7 years ago
  • 2.0.0-alpha.18                                ...           7 years ago
  • 2.0.0-alpha.9                                ...           7 years ago
  • 2.0.0-alpha.8                                ...           7 years ago
  • 2.0.0-alpha.7                                ...           7 years ago
  • 2.0.0-alpha.6                                ...           7 years ago
  • 2.0.0-alpha.5                                ...           7 years ago
  • 2.0.0-alpha.4                                ...           7 years ago
  • 2.0.0-alpha.3                                ...           7 years ago
  • 2.0.0-alpha.2                                ...           7 years ago
  • 1.9.2                                ...           7 years ago
  • 2.0.0-0                                ...           7 years ago
  • 1.9.1                                ...           7 years ago
  • 1.9.0                                ...           7 years ago
  • 1.9.0-1                                ...           7 years ago
  • 1.9.0-0                                ...           7 years ago
  • 1.8.1                                ...           7 years ago
  • 1.8.0                                ...           7 years ago
  • 1.7.0                                ...           7 years ago
  • 1.6.1                                ...           7 years ago
  • 1.6.0                                ...           7 years ago
  • 1.5.0                                ...           7 years ago
  • 1.4.2                                ...           7 years ago
  • 1.4.1                                ...           7 years ago
  • 1.4.0                                ...           7 years ago
  • 1.3.0                                ...           7 years ago
  • 1.2.2                                ...           8 years ago
  • 1.2.1                                ...           8 years ago
  • 1.2.0                                ...           8 years ago
  • 1.1.2                                ...           8 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0 [deprecated]           ...           8 years ago
  • 1.0.4                                ...           8 years ago
  • 1.0.3                                ...           8 years ago
  • 1.0.2                                ...           8 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 1.0.0-rc.9                                ...           8 years ago
  • 1.0.0-rc.8                                ...           8 years ago
  • 1.0.0-rc.7                                ...           8 years ago
  • 1.0.0-rc.6                                ...           8 years ago
  • 1.0.0-rc.5                                ...           8 years ago
  • 1.0.0-rc.4                                ...           8 years ago
  • 1.0.0-rc.3                                ...           8 years ago
  • 1.0.0-rc.2                                ...           8 years ago
  • 1.0.0-rc.1                                ...           8 years ago
  • 0.10.1                                ...           8 years ago
  • 1.0.0-rc.0                                ...           8 years ago
  • 0.10.0                                ...           8 years ago
  • 0.9.0                                ...           8 years ago
  • 0.8.7                                ...           8 years ago
  • 0.8.6                                ...           8 years ago
  • 0.8.5                                ...           8 years ago
  • 0.8.4                                ...           8 years ago
  • 0.8.3                                ...           8 years ago
  • 0.8.2                                ...           8 years ago
  • 0.8.1                                ...           8 years ago
  • 0.8.0                                ...           8 years ago
  • 0.7.3                                ...           8 years ago
  • 0.7.2                                ...           8 years ago
  • 0.7.1                                ...           8 years ago
  • 0.7.0                                ...           8 years ago
  • 0.6.0                                ...           8 years ago
  • 0.5.26                                ...           8 years ago
  • 0.5.25                                ...           8 years ago
  • 0.5.24                                ...           8 years ago
  • 0.5.23                                ...           8 years ago
  • 0.5.22                                ...           8 years ago
  • 0.5.21                                ...           8 years ago
  • 0.5.21-2                                ...           8 years ago
  • 0.5.21-1                                ...           8 years ago
  • 0.5.21-0                                ...           8 years ago
  • 0.5.20                                ...           8 years ago
  • 0.5.19                                ...           8 years ago
  • 0.5.18                                ...           8 years ago
  • 0.5.17                                ...           8 years ago
  • 0.5.16                                ...           8 years ago
  • 0.5.15                                ...           8 years ago
  • 0.5.14                                ...           8 years ago
  • 0.5.13                                ...           8 years ago
  • 0.5.13-devtools.0                                ...           8 years ago
  • 0.5.12                                ...           8 years ago
  • 0.5.11                                ...           8 years ago
  • 0.5.10                                ...           8 years ago
  • 0.5.9                                ...           8 years ago
  • 0.5.8                                ...           8 years ago
  • 0.5.7                                ...           8 years ago
  • 0.5.6                                ...           8 years ago
  • 0.5.5                                ...           8 years ago
  • 0.5.4                                ...           8 years ago
  • 0.5.3                                ...           8 years ago
  • 0.5.2                                ...           8 years ago
  • 0.5.1                                ...           8 years ago
  • 0.5.0                                ...           8 years ago
  • 0.5.0-preview.3                                ...           8 years ago
  • 0.5.0-preview.2                                ...           8 years ago
  • 0.4.22                                ...           8 years ago
  • 0.5.0-1                                ...           8 years ago
  • 0.5.0-0                                ...           8 years ago
  • 0.4.21                                ...           8 years ago
  • 0.4.20                                ...           8 years ago
  • 0.4.19                                ...           8 years ago
  • 0.4.18                                ...           8 years ago
  • 0.4.17                                ...           8 years ago
  • 0.4.16 [deprecated]           ...           8 years ago
  • 0.4.15                                ...           8 years ago
  • 0.4.14                                ...           8 years ago
  • 0.4.13                                ...           8 years ago
  • 0.4.12                                ...           8 years ago
  • 0.4.11                                ...           8 years ago
  • 0.4.10                                ...           8 years ago
  • 0.4.9                                ...           8 years ago
  • 0.4.8                                ...           8 years ago
  • 0.4.7                                ...           8 years ago
  • 0.4.6                                ...           8 years ago
  • 0.4.5                                ...           8 years ago
  • 0.4.4                                ...           8 years ago
  • 0.4.3                                ...           8 years ago
  • 0.4.2                                ...           8 years ago
  • 0.4.1                                ...           8 years ago
  • 0.4.0                                ...           8 years ago
  • 0.3.30                                ...           8 years ago
  • 0.3.29                                ...           8 years ago
  • 0.3.28                                ...           8 years ago
  • 0.3.27                                ...           8 years ago
  • 0.3.26                                ...           8 years ago
  • 0.3.25                                ...           8 years ago
  • 0.3.24                                ...           8 years ago
  • 0.3.23                                ...           8 years ago
  • 0.3.22                                ...           8 years ago
  • 0.3.21                                ...           8 years ago
  • 0.3.20                                ...           8 years ago
  • 0.3.19                                ...           8 years ago
  • 0.3.18                                ...           8 years ago
  • 0.3.17                                ...           8 years ago
  • 0.3.16                                ...           8 years ago
  • 0.3.15                                ...           8 years ago
  • 0.3.14                                ...           8 years ago
  • 0.3.13                                ...           8 years ago
  • 0.3.12                                ...           8 years ago
  • 0.3.11                                ...           8 years ago
  • 0.3.10                                ...           8 years ago
  • 0.3.9                                ...           8 years ago
  • 0.3.8                                ...           9 years ago
  • 0.3.7                                ...           9 years ago
  • 0.3.6                                ...           9 years ago
  • 0.3.5                                ...           9 years ago
  • 0.3.4                                ...           9 years ago
  • 0.3.3                                ...           9 years ago
  • 0.3.2                                ...           9 years ago
  • 0.3.1                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.5                                ...           9 years ago
  • 0.2.4                                ...           9 years ago
  • 0.2.3                                ...           9 years ago
  • 0.2.2                                ...           9 years ago
  • 0.2.1                                ...           9 years ago
  • 0.2.0                                ...           9 years ago
  • 0.1.6                                ...           9 years ago
  • 0.1.5                                ...           9 years ago
  • 0.1.4                                ...           9 years ago
  • 0.1.3                                ...           9 years ago
  • 0.1.2                                ...           9 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
  • 0.0.5                                ...           9 years ago
  • 0.0.4                                ...           9 years ago
  • 0.0.3                                ...           9 years ago
  • 0.0.2                                ...           9 years ago
  • 0.0.1                                ...           9 years ago
Downloads
Total 27
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (8)
Dev Dependencies (27)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE