Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gqb

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gqb

graphql schema builder

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

GQB

This package allows you to injects type resolvers directly into GraphQL schema language.

Why

A lot of boilerplate code if write schemas on javascript graphql-js.

This is better graphql-tools but resolvers described after the schema.

How it works

Using tagged template literals we can place resolvers directly inside schema.

import { gqb, getResolvers } from 'gqb';
import { graphql } from 'graphql';
import { makeExecutableSchema } from 'graphql-tools';

const schema = gqb`
  type Query {
    hello: String${ // field resolver source
      () => 'World'
    },
    pic(size: Int): String${
      (_, { size }) => `pic size is: ${size}`
    }
  }

  type Mutation {
    setMessage(message: String): String${ // mutation source
      (_, { message }) => `Mutated ${message}`
    }
  }
`;

const executableSchema = makeExecutableSchema(
  getResolvers(schema)
);

graphql(
  executableSchema,
  '{ hello, pic(size: 20)}'
)
.then(response => console.log(response));

Type fields resolver now are placed directly in the schema, immediatelly after type!!!

It also supports schema inlining, (see tests)

See the source it's small.

FAQs

Package last updated on 05 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc