# graphql-document-collector

> Load up smartly, in one location, all of the GraphQL queries/mutations/subscriptions of your project

Latest version **0.2.2** (published 2019-03-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install graphql-document-collector
pnpm add graphql-document-collector
yarn add graphql-document-collector
bun add graphql-document-collector
```

Provides the command `graphql-document-collector`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2019-03-01 |
| First published | 2016-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 73.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Robin Ricard |
| Maintainers | apollo-bot, rricard, sashko, stephen |
| Keywords | graphql, document, project, collector |

## Links

- npm: https://www.npmjs.com/package/graphql-document-collector
- Repository: https://github.com/rricard/graphql-document-collector
- Homepage: https://github.com/rricard/graphql-document-collector#readme
- Issues: https://github.com/rricard/graphql-document-collector/issues
- npm.io page: https://npm.io/package/graphql-document-collector

## Dependencies (3)

- [glob](https://npm.io/package/glob.md) ^7.1.0
- [graphql](https://npm.io/package/graphql.md) ^0.11.7
- [@types/graphql](https://npm.io/package/@types/graphql.md) ^0.11.7

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

- 0.2.2 (latest) — 2019-03-01
- 0.2.1 — 2018-01-22
- 0.2.0 — 2017-12-07
- 0.1.3 — 2017-04-22
- 0.1.2 — 2017-04-22
- 0.1.1 — 2016-12-06
- 0.1.0 — 2016-10-03

## README

# graphql-document-collector
Load up smartly, in one location, all of the GraphQL queries/mutations/subscriptions of your project

[![npm version](https://badge.fury.io/js/graphql-document-collector.svg)](https://badge.fury.io/js/graphql-document-collector) [![Get on Slack](https://img.shields.io/badge/slack-join-orange.svg)](http://www.apollostack.com/#slack)

## Installation

```
npm i -g graphql-document-collector
```

## Usage

`graphql-document-collector` has a straightforward CLI interface to precompile all of your GraphQL documents in one definition file:

```
graphql-document-collector '$glob' > $dest
```

## Example

Collect all `.graphql` files of your project in a single `documents.json` definition file:

```
graphql-document-collector '**/*.graphql' > documents.json
```

This can be exploited afterwards like this:

```js
// Note: if you are using webpack, you will need to setup a 'json-loader'
const graphqlDocs = require('./documents.json');

// You can use any client able to read some graphql document AST
apolloClient.query({query: graphqlDocs['queries/ListMovies.graphql']})
.then(({data}) => {/* ... */});
```

> Note: you don't have to worry about loading fragments, they are already resolved in the document.

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