# gqlc

> GraphQL Schema Compiler

Latest version **0.0.3** (published 2016-01-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install gqlc
pnpm add gqlc
yarn add gqlc
bun add gqlc
```

## 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.0.3 |
| Published | 2016-01-15 |
| First published | 2016-01-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Joseph Werle |
| Maintainers | werle |
| Keywords | graphql, gql, compiler, schema |

## Links

- npm: https://www.npmjs.com/package/gqlc
- Repository: https://github.com/jwerle/gqlc
- Homepage: https://github.com/jwerle/gqlc#readme
- Issues: https://github.com/jwerle/gqlc/issues
- npm.io page: https://npm.io/package/gqlc

## Dependencies (4)

- [extend](https://npm.io/package/extend.md) ^3.0.0
- [graphql](https://npm.io/package/graphql.md) ^0.4.14
- [invariant](https://npm.io/package/invariant.md) ^2.2.0
- [babel-core](https://npm.io/package/babel-core.md) ^6.4.0

## 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.0.3 (latest) — 2016-01-15
- 0.0.2 — 2016-01-13
- 0.0.1 — 2016-01-13

## README

# gqlc

GraphQL Schema Compiler

**GraphQLC** (or GQLC) is built on
[GraphQL.js](https://github.com/graphql/graphql-js) and
leverages the schema language parser built into GraphQL. GQLC allows users
to define their schemas using the language defined by the [GraphQL
Spec](https://facebook.github.io/graphql), bind implementations for
routines for resolving data, and get a `GraphQLSchema` object to pass
directly to the `graphql()` function. This allows authors to focus on the
implementation details of their graph data set.

## Supported schema language features

* InterfaceTypeDefinition
* ObjectTypeDefinition
* EnumTypeDefinition
* UnionTypeDefinition
* InputObjectTypeDefinition
* TypeExtensionDefinition

## Installation

GQLC is written in ES6 and intended to be used with
[GraphQL.js](https://github.com/graphql/graphql-js) in a Node.js
environment.

```sh
$ npm install --save gqlc
```

## Hello World

Below is a simple hello world that query the graph for a fixed resolved value.

```js
import { graphql } from 'graphql'
import gqlc from 'gqlc'

const implementation = {
  Query: {
    fields: () => ({
      hello: { resolve () { return 'world' } }
    })
  }
}

const Schema = `type Query { hello: String }`
const query = `query { hello }`

gqlc(implementation)
.compile(Schema)
.then((schema) => graphql(schema, query))
.then((result) => console.log(result)) // { data: { hello: 'world' } }
.catch((error) => console.error(error))
```

## Examples

* [Basic](examples/basic)
* [Advanced](examples/advanced)

## Usage

The `gqlc()` function accepts an optional initial state object and a
required implementation object. The return value of the `gqlc()` function
represents the current state of the schema definition. A GraphQL schema can
be compiled by calling the `.compile()` method on the state object returned
by the `gqlc()` function. A `Promise` providing an instance the `GraphQLSchema`
object is returned. It can be used directly with the `graphql()`
function.

```js
const state = gqlc([initialState,]implementation)
state.compile(schemaSource).then((schema) => graphql(schema, query))
```

## License

MIT

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