# @gospime/apollo-client

> Apollo HTTP client with response caching

Latest version **4.0.1** (published 2020-03-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @gospime/apollo-client
pnpm add @gospime/apollo-client
yarn add @gospime/apollo-client
bun add @gospime/apollo-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2020-03-21 |
| First published | 2019-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 9 |
| Unpacked size | 14.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Oleg Kravchuk |
| Maintainers | kolegm |
| Keywords | gospime, graphql, datagraph, apollo, client |

## Links

- npm: https://www.npmjs.com/package/@gospime/apollo-client
- Repository: https://github.com/gospime/apollo-client
- Homepage: https://github.com/gospime/apollo-client#readme
- Issues: https://github.com/gospime/apollo-client/issues
- npm.io page: https://npm.io/package/@gospime/apollo-client

## Dependencies (9)

- [graphql](https://npm.io/package/graphql.md) ^14.6.0
- [minimist](https://npm.io/package/minimist.md) ^1.2.5
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0
- [apollo-link](https://npm.io/package/apollo-link.md) ^1.2.13
- [graphql-tag](https://npm.io/package/graphql-tag.md) ^2.10.3
- [@apollo/client](https://npm.io/package/@apollo/client.md) ^3.0.0-beta.41
- [apollo-link-http](https://npm.io/package/apollo-link-http.md) ^1.5.16
- [apollo-link-error](https://npm.io/package/apollo-link-error.md) ^1.1.12
- [apollo-cache-inmemory](https://npm.io/package/apollo-cache-inmemory.md) ^1.6.5

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 4.0.1 (latest) — 2020-03-21
- 4.0.0 — 2020-03-02
- 3.0.3 — 2020-03-02
- 3.0.2 — 2020-02-19
- 3.0.1 — 2020-02-02
- 3.0.0 — 2020-01-28
- 2.6.4 — 2020-01-13
- 2.6.3 — 2019-12-19
- 2.6.2 — 2019-11-28
- 2.6.1 — 2019-11-27
- 2.6.0 — 2019-11-27
- 2.5.1 — 2019-11-27
- 2.5.0 — 2019-11-26
- 2.4.0 — 2019-11-26
- 2.3.1 — 2019-11-22
- … 9 more at https://npm.io/package/@gospime/apollo-client/versions

## README

# Facade to create apollo client
Apollo HTTP client with response caching

Options:
```node
const uri = `https://${hostname}:${port}${graphqlPath}`;
// options of https.Agent
const options = {
  //rejectUnauthorized: false // Skip SSL-restrictions
};

```

ApolloOptions:
[fetch-policy](https://medium.com/@galen.corey/understanding-apollo-fetch-policies-705b5ad71980)
```node
const apolloOptions = {
  query: {
    // How you want your component to interact with the Apollo cache.
    // Defaults to "cache-first".
    fetchPolicy: 'no-cache',
    // How you want your component to handle network and GraphQL errors.
    // Defaults to "none", which means we treat GraphQL errors as runtime errors.
    errorPolicy: 'all',
  }
};

```

Example: how to execute graphql `query`
```node
const Client = require('@gospime/apollo-client');

const plan = 'userSelect';
const args = { id: 2 }; // criteria to find a user
const fields = { fullname, email }; // fields to select

// calling of `query` method
Client
  .create(uri, options, apolloOptions)
  .query({ plan, args, fields })
  .then(result => console.log(result))
  .catch(error => console.error(error));
```

Example: how to execute graphql `mutation`
```node
const Client = require('@gospime/apollo-client');

const plan = 'userEdit';
const args = { id: 2, fullname: 'new fullname' }; // find user by `id` and update the fullname

// calling of `mutate` method
Client
  .create(uri, options, apolloOptions)
  .mutate({ plan, args })
  .then(result => console.log(result))
  .catch(error => console.error(error));
```
Async/await example:
```node
async () => await Client.create(uri, options, apolloOptions).mutate({ plan, args });
```

---
_Source: https://npm.io/package/@gospime/apollo-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
