2.6.10 • Published 4 years ago

apollo-client v2.6.10

Weekly downloads
1,309,399
License
MIT
Repository
github
Last release
4 years ago

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

@yelm/next-apollo@mochilabs/ra-data-graphql@kikstart-graphql/client@kikstart-graphql/core@pangolindex/components@atomist/automation-clientreact-native-erxeswebapp-userzwap-qrcode-frontendzwap_chatbot_guide@igloo_cloud/shared-uineo-ui-template@graphqlzero/web@fairfx/spend-common@travelshift/webrc-ui-modular@hurumaptest/charts@qlippoth/coretest-srcl-tdk@productfy/common@gqlkit/client-toolscreative-gallery-shonppwa-fegqlkit-clientshipium-auth-service-client@oos-studio/react-connect-graphqllwc-apollo-clientreact-connect-graphqltradesafe-sdk@m8a/quasar-app-extension-graphqlclassdoapp-campusucpa-packagesreact-native-vouchedcpa3single-page-appgintonicfondfoliorc-ui-designerrc-ui-cmp@puzl/puzl-cloud_authorization-modulegamestackbitguild-blockchain-sdk@alyz.tech/alyz-sdk@hurumap/chartsreact-apollo-boilerplaterags-boilerplatenodegen-utils@moonwalker/lifesupport@schm-dt/frontend@schm-dt/ui-componentstestp-cmpshipping-managerdops-client-sharedphoenix-shareddevelapp-regional-frontend@stefancfuchs/firefly-chat-widget-2@jayellul/gatsby-theme-craftcmstg-test-module@apraamcos/apra-amcos-uidecoupled-front-endtest-client-mfa-entrypoint@engine2/efa-apollo@sellics/profitvm-patternlibrary@chargetrip/javascript-sdk@radar/deploy-sdkecp-frontend@huboneo/grand-stack-starter-apireact-auth-testing@aviosgroup/cbr-client@deity/falcon-clientgrand-stack-starter-api@platyplus/hasura-apollo-client@brudi/brudi-toolbox-graphql@conclurer/bricks@conclurer/edel-plugin-apollo@daysmart/frankenstack-cli@incta/feeder-lambdafrankenstack-appsync-clientfrankenstack-clier-prism-web@sanofi-iadc/qc-table@toptal/staff-portal@fatpig0416/storefront-apirootserverchecktest-component-sh@origins/react-graphqlbitcasino-v3@jessitron/automation-client@vouched.id/react-native-vouchedapra-amcos-uicaec-admin-webfloflorico@graphite/react-account-facebook@graphite/react-account-passwordreact-apollo-ssr-starterh2pcli@caisy/cen@gomoko/admin-ui
2.6.10-test.1

4 years ago

2.6.10

4 years ago

2.6.10-test.0

4 years ago

2.6.9

4 years ago

2.6.8

4 years ago

2.6.7

4 years ago

2.6.6

4 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

5 years ago

2.6.0-rc.1

5 years ago

2.6.0-rc.0

5 years ago

2.6.0-beta.8

5 years ago

2.6.0-beta.7

5 years ago

2.6.0-beta.6

5 years ago

2.6.0-beta.5

5 years ago

2.6.0-beta.4

5 years ago

2.6.0-beta.3

5 years ago

2.6.0-beta.2

5 years ago

2.6.0-beta.1

5 years ago

2.6.0-beta.0

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.5.0-rc.3

5 years ago

2.5.0-rc.2

5 years ago

2.5.0-rc.1

5 years ago

2.5.0-rc.0

5 years ago

2.4.13

5 years ago

2.5.0-beta.1

5 years ago

2.5.0-beta.0

5 years ago

2.4.12

5 years ago

2.4.11

5 years ago

2.4.10

5 years ago

2.4.9

5 years ago

2.5.0-alpha.10

5 years ago

2.5.0-alpha.9

5 years ago

2.5.0-alpha.8

5 years ago

2.5.0-alpha.7

5 years ago

2.5.0-alpha.6

5 years ago

2.5.0-alpha.5

5 years ago

2.5.0-alpha.4

5 years ago

2.5.0-alpha.3

5 years ago

2.4.8

5 years ago

2.5.0-alpha.2

5 years ago

2.4.7

5 years ago

2.4.6

5 years ago

2.5.0-alpha.1

5 years ago

2.4.5

5 years ago

2.4.4

5 years ago

2.4.3

5 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

6 years ago

2.3.0

6 years ago

2.2.8

6 years ago

2.2.7

6 years ago

2.2.6

6 years ago

2.2.5

6 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.0.4

6 years ago

2.1.0

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

2.0.0-rc.7

6 years ago

2.0.0-rc.6

6 years ago

2.0.0-rc.5

6 years ago

2.0.0-rc.4

6 years ago

2.0.0-rc.3

6 years ago

2.0.0-rc.2

6 years ago

2.0.0-rc.1

6 years ago

2.0.0-rc.0

6 years ago

2.0.0-beta.8

6 years ago

2.0.0-beta.7

6 years ago

2.0.0-beta.6

6 years ago

2.0.0-beta.5

6 years ago

2.0.0-beta.4

6 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

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

1.0.0-rc.9

7 years ago

1.0.0-rc.8

7 years ago

1.0.0-rc.7

7 years ago

1.0.0-rc.6

7 years ago

1.0.0-rc.5

7 years ago

1.0.0-rc.4

7 years ago

1.0.0-rc.3

7 years ago

1.0.0-rc.2

7 years ago

1.0.0-rc.1

7 years ago

0.10.1

7 years ago

1.0.0-rc.0

7 years ago

0.10.0

7 years ago

0.9.0

7 years ago

0.8.7

7 years ago

0.8.6

7 years ago

0.8.5

7 years ago

0.8.4

7 years ago

0.8.3

7 years ago

0.8.2

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.3

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.26

7 years ago

0.5.25

7 years ago

0.5.24

7 years ago

0.5.23

7 years ago

0.5.22

7 years ago

0.5.21

7 years ago

0.5.21-2

7 years ago

0.5.21-1

7 years ago

0.5.21-0

7 years ago

0.5.20

7 years ago

0.5.19

7 years ago

0.5.18

7 years ago

0.5.17

7 years ago

0.5.16

7 years ago

0.5.15

7 years ago

0.5.14

7 years ago

0.5.13

7 years ago

0.5.12

7 years ago

0.5.11

7 years ago

0.5.10

7 years ago

0.5.9

7 years ago

0.5.8

7 years ago

0.5.7

7 years ago

0.5.6

7 years ago

0.5.5

7 years ago

0.5.4

7 years ago

0.5.3

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.5.0-preview.3

7 years ago

0.5.0-preview.2

7 years ago

0.4.22

7 years ago

0.5.0-1

7 years ago

0.5.0-0

7 years ago

0.4.21

7 years ago

0.4.20

7 years ago

0.4.19

8 years ago

0.4.18

8 years ago

0.4.17

8 years ago

0.4.16

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

8 years ago

0.3.7

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago