Skip to content
This repository was archived by the owner on Aug 29, 2022. It is now read-only.

This plugin is a fast and easy way to add GraphQL support to your Fastify application. It also includes support for hot reloading of schemas and resolvers, so you can keep your application up to date with the latest changes without having to restart your server.

License

Notifications You must be signed in to change notification settings

webtacular/Fastify-HotQL

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastify-hotql

npm

A plugin for Fastify that adds GraphQL and GraphiQL support, and hot reloading of schemas and resolvers.

History

This project was forked from fastify-apollo as it is no longer being maintained fast enough to keep pace with the rapid changes happening in the GraphQL ecosystem.

And now, this project was forked from from jeromemacias, This is 4 years old and dosent work anymore.

Installation

# Yet to be uploaded
npm install --save fastify-hotql

Usage

import { buildSchema } from 'graphql';
import fastify from "fastify";
import hotQL from 'fastify-hotql';

const app = fastify();

// Initialize hotQL
const gql = new hotQL(app, {
  prefix: '/graphql',

  // You can start graphiql by setting this to true
  // PS: The paramaters below are optional
  graphiql: true,
  graphiql_prefix: '/graphql/explore',
  graphiql_endpoint: '/graphql/explore',
});

// Or you can do this later on the fly
gql.startGraphiQL({
  // PS: Both of these are optional
  prefix: '/graphql/explore',
  endpoint: '/graphql/explore',
});

// And for some reason, you can reload the schema and rootValues
// without having to restart the server
gql.reload();

// Start the server
app.listen(80).then(() => {
  console.log(`server listening on http://localhost:80`);
})

// Add a schema and rootValue to the hotQL instance
// You can do this before we start the server or after
const helloWorld = gql.addSchema(buildSchema(`
  type Query {
      hello: String
  }`,
  { hello: () => 'Hello World!' }
);

// You can also remove a schema
helloWorld.remove();

// You can get the hash of the schema
helloWorld.hash();

// You can get the rootValue
helloWorld.rootValue();

// And you can get the schema
helloWorld.schema();

About

This plugin is a fast and easy way to add GraphQL support to your Fastify application. It also includes support for hot reloading of schemas and resolvers, so you can keep your application up to date with the latest changes without having to restart your server.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%