Socket
Socket
Sign inDemoInstall

@graphql-tools/schema

Package Overview
Dependencies
8
Maintainers
3
Versions
1101
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @graphql-tools/schema

A set of utils for faster development of GraphQL tools


Version published
Maintainers
3
Install size
779 kB
Created

Package description

What is @graphql-tools/schema?

The @graphql-tools/schema package is a utility library that helps with the creation and manipulation of GraphQL schemas. It provides functions to make it easier to work with GraphQL schema definitions, including merging type definitions, adding resolvers, and more.

What are @graphql-tools/schema's main functionalities?

makeExecutableSchema

This feature allows you to combine type definitions and resolvers to create an executable GraphQL schema.

const { makeExecutableSchema } = require('@graphql-tools/schema');
const typeDefs = `
  type Query {
    hello: String
  }
`;
const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
};
const schema = makeExecutableSchema({
  typeDefs,
  resolvers,
});

addResolversToSchema

This feature enables you to add new resolvers to an existing GraphQL schema.

const { addResolversToSchema } = require('@graphql-tools/schema');
const schema = makeExecutableSchema({ typeDefs });
const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
};
addResolversToSchema({ schema, resolvers });

addSchemaLevelResolver

This feature allows you to add a resolver function that runs before any other resolvers for each operation.

const { addSchemaLevelResolver } = require('@graphql-tools/schema');
const schema = makeExecutableSchema({ typeDefs, resolvers });
const rootResolver = (root, args, context, info) => { /*...*/ };
addSchemaLevelResolver(schema, rootResolver);

Other packages similar to @graphql-tools/schema

Readme

Source

Check API Reference for more information about this package; https://www.graphql-tools.com/docs/api/modules/schema_src

You can also learn more about Generating Executable Schemas in this chapter; https://www.graphql-tools.com/docs/generate-schema

FAQs

Last updated on 23 Feb 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc