@comity/graphql
TypeScript icon, indicating that this package has built-in type declarations

0.4.8 • Public • Published

Comity Graphql Handler

A Hono middleware for handling GraphQL requests, seamlessly integrated with Envelop to provide enhanced GraphQL server capabilities.

Features

  • High Performance: Built on Hono, ensuring minimal overhead and blazing-fast performance.
  • Extensible: Leverage Envelop plugins to enhance your GraphQL server with features like caching, tracing, error handling, and more.
  • Lightweight: Designed to be simple and efficient, with a focus on developer experience.

Installation

# with NPM
npm install @comity/graphql
# or with YARN
yarn add @comity/graphql
# or with PNPM
pnpm add @comity/graphql

Usage

import { Hono, type Context } from 'hono';
import {
  buildSchema,
  execute,
  parse,
  subscribe,
  validate,
  specifiedRules,
} from 'graphql';
import { graphqlHandler } from '@comity/graphql';
import { useLogger, useEngine, useSchema } from '@envelop/core';

const app = new Hono();
const schema = buildSchema(`
  type Query {
    hello: String
  }
`);

const rootResolver = (c: Context) => {
  return {
    hello: () => 'Hello World!',
  };
};

app.use(
  '/graphql',
  graphqlHandler({
    schema,
    rootResolver,
    plugins: [
      useLogger(),
      useEngine({ parse, validate, specifiedRules, execute, subscribe }),
      useSchema(schema),
    ],
  })
);

app.fire();

Credits

Based on the original work by Minghe Huang.

Readme

Keywords

Package Sidebar

Install

npm i @comity/graphql

Weekly Downloads

17

Version

0.4.8

License

MIT

Unpacked Size

15.1 kB

Total Files

18

Last publish

Collaborators

  • fbovo
  • hobot
  • pirosauro