# think-apollo-graphql

> Graphql extend for ThinkJS

Latest version **1.0.0-alpha.2** (published 2018-03-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install think-apollo-graphql
pnpm add think-apollo-graphql
yarn add think-apollo-graphql
bun add think-apollo-graphql
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.0-alpha.2 |
| Published | 2018-03-01 |
| First published | 2018-03-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | lushijie |
| Maintainers | lushijie |
| Keywords | think-apollo-graphql |

## Links

- npm: https://www.npmjs.com/package/think-apollo-graphql
- Repository: https://github.com/thinkjs/think-apollo-graphql
- Homepage: https://github.com/thinkjs/think-apollo-graphql#readme
- Issues: https://github.com/thinkjs/think-apollo-graphql/issues
- npm.io page: https://npm.io/package/think-apollo-graphql

## Dependencies (2)

- [graphql](https://npm.io/package/graphql.md) ^0.13.1
- [apollo-server-core](https://npm.io/package/apollo-server-core.md) ^1.3.2

## 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

- 1.0.0-alpha.2 (latest) — 2018-03-01
- 1.0.0-alpha.1 — 2018-03-01

## README

# think-apollo-graphql

# think-apollo-graphql
[![npm](https://img.shields.io/npm/v/think-apollo-graphql.svg?style=flat-square)](https://www.npmjs.com/package/think-apollo-graphql)

## Install

```
npm install think-apollo-graphql
```
## How to use

Set the extend in `src/config/extend.js`

```js
const graphql = require('think-apollo-graphql');

module.exports = [
  graphql
];
```

And then the `think`, `controller` will have the method `thinkGraphql`. For
example in `controller` you can use like this:


```js
module.exports = class extends think.Controller {
  constructor(...props) {
    super(...props);
  }

  async indexAction() {
    const graphqlResult = await this.thinkGraphql(graphqlOptions);
    return this.json(graphqlResult);
  }
}
```

Note: `think.thinkGraphql(graphqlOptions, ctx)`, think.thinkGraphql expects exactly ctx.


#### graphqlOptions like:

```js
{
  schema: the GraphQLSchema to be used
  context: the context value passed to resolvers during GraphQL execution
  rootValue: the value passed to the first resolve function
  formatError: a function to apply to every error before sending the response to clients
  validationRules: additional GraphQL validation rules to be applied to client-specified queries
  formatParams: a function applied for each query in a batch to format parameters before execution
  formatResponse: a function applied to each response after execution
  tracing: when set to true, collect and expose trace data in the Apollo Tracing format
}
```

More doc at [apollo-server](https://github.com/apollographql/apollo-server).

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