Socket
Socket
Sign inDemoInstall

graphql-tools

Package Overview
Dependencies
Maintainers
5
Versions
1462
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-tools

A set of useful tools for GraphQL


Version published
Weekly downloads
695K
increased by4.91%
Maintainers
5
Weekly downloads
 
Created

What is graphql-tools?

The graphql-tools package is a set of utilities that help in the development of GraphQL schemas and resolvers in JavaScript. It provides tools for schema stitching, schema delegation, and schema transformation, among other functionalities.

What are graphql-tools's main functionalities?

Schema Stitching

Schema stitching allows you to combine multiple GraphQL schemas into a single schema. This is useful for modularizing your GraphQL API and for integrating multiple services.

const { makeExecutableSchema, mergeSchemas } = require('graphql-tools');

const schemaA = makeExecutableSchema({ typeDefs: `type Query { hello: String }`, resolvers: { Query: { hello: () => 'Hello from schema A' } } });
const schemaB = makeExecutableSchema({ typeDefs: `type Query { world: String }`, resolvers: { Query: { world: () => 'World from schema B' } } });

const mergedSchema = mergeSchemas({ schemas: [schemaA, schemaB] });

Schema Delegation

Schema delegation allows you to forward a query from one schema to another. This is useful for creating a unified API that delegates parts of the query to different underlying services.

const { delegateToSchema } = require('graphql-tools');

const schemaA = makeExecutableSchema({ typeDefs: `type Query { hello: String }`, resolvers: { Query: { hello: () => 'Hello from schema A' } } });

const resolvers = {
  Query: {
    helloFromA: (parent, args, context, info) => delegateToSchema({ schema: schemaA, operation: 'query', fieldName: 'hello', context, info })
  }
};

Schema Transformation

Schema transformation allows you to modify an existing schema. This can include renaming types, adding or removing fields, and other modifications. This is useful for adapting third-party schemas to fit your needs.

const { transformSchema, RenameTypes } = require('graphql-tools');

const schema = makeExecutableSchema({ typeDefs: `type Query { hello: String }`, resolvers: { Query: { hello: () => 'Hello' } } });

const transformedSchema = transformSchema(schema, [new RenameTypes(name => `New_${name}`)]);

Other packages similar to graphql-tools

Keywords

FAQs

Package last updated on 22 Sep 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