# hapi-graysql

> Hapi plugin to wrap graysql

Latest version **1.0.7** (published 2016-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install hapi-graysql
pnpm add hapi-graysql
yarn add hapi-graysql
bun add hapi-graysql
```

## 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 | 1.0.7 |
| Published | 2016-09-23 |
| First published | 2016-09-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | David Noreña |
| Maintainers | dabitco |
| Keywords | hapijs, graphql, schema, manager, graysql |

## Links

- npm: https://www.npmjs.com/package/hapi-graysql
- Repository: https://github.com/DabitCo/hapi-graysql
- Homepage: https://github.com/DabitCo/hapi-graysql#readme
- Issues: https://github.com/DabitCo/hapi-graysql/issues
- npm.io page: https://npm.io/package/hapi-graysql

## Dependencies (3)

- [joi](https://npm.io/package/joi.md) ^9.0.4
- [graphql](https://npm.io/package/graphql.md) ^0.7.0
- [graysql](https://npm.io/package/graysql.md) ^0.4.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.7 (latest) — 2016-09-23
- 1.0.6 — 2016-09-22
- 1.0.5 — 2016-09-22
- 1.0.3 — 2016-09-22
- 1.0.0 — 2016-09-22

## README

# GraysQL Hapi Plugin
Use [GraysQL](https://github.com/larsbs/graysql) with HapiJS.

## Why this Plugin ?
You can write reusable plugins that exposes GraphQL queries, and join the full schema before creating a GraphQLHTTP Server.

## Install
```js
npm install --save hapi-graysql
```

### Hapi GraphQL Server Example

For the full Hapi GraphQL Server Example Check the `examples` folder:

```js
import Hapi from 'hapi';
import HapiGraphQL from 'hapi-graphql';
import HapiGraysQL from 'hapi-graysql';
import Path from 'path';

import DB from './graphql/db';

export default async function Server() {
  try {
    const SCHEMAPATH = Path.join(__dirname, 'graphql', 'schema')

    const server = new Hapi.Server();
    server.connection({
      port: 8080
    });

    //Main Plugins
    await server.register({
      register: HapiGraysQL,
      options: {
        extensions: ['load-from-dir'],
        options: {
          DB: DB
        }
      }
    });

    //  load-from-dir extension exposes load method
    //  Load the main schema
    await server.GQL.load(PATHS.schema);

    //  Now every plugin loads its own schema.
    /*  await server.register({
      register: MYPLUGIN-THATUSES-HAPI-GRAYSQL,
      options: {
        option1: 'example opt'
      }
    }); */

    //  Build up the GraphQL Full Schema
    const schema = server.GQL.generateSchema();

    //  Register HapiGraphQL Plugin
    //  Enabling graphiql let us test the Server.
    await server.register({
      register: HapiGraphQL,
      options: {
        query: {
          schema: schema,
          graphiql: true
        },
        route: {
          path: '/graphql',
          config: {}
        }
      }
    });

    await server.start();
    console.log( `Server started at ${ server.info.uri }` );

  } catch(e) {
    console.error(e);
  }
}

```
### Options

The `options` key accepts the following:

* **`extensions`**: An optional array of strings containing a valid `GraysQL` extension name [see more here](https://github.com/larsbs/graysql#extensions).
* **`options`**: Any number of custom keys. This keys will be passed to GraysQL Constructor [see more here](https://github.com/larsbs/graysql#constructor).

## License ##

[MIT](LICENSE)

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