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

@graphql-tools/batch-execute

Package Overview
Dependencies
Maintainers
3
Versions
496
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/batch-execute

A set of utils for faster development of GraphQL tools

  • 7.0.1-alpha-9e1fc254.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.2M
decreased by-24.3%
Maintainers
3
Weekly downloads
 
Created

What is @graphql-tools/batch-execute?

@graphql-tools/batch-execute is a utility package for batching and executing GraphQL operations. It is part of the GraphQL Tools ecosystem and is designed to optimize the execution of multiple GraphQL operations by batching them together, which can improve performance and reduce the number of network requests.

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

Batch Execution

This feature allows you to batch multiple GraphQL operations and execute them together. The code sample demonstrates creating a simple schema and batching two queries ('{ hello }' and '{ world }') for execution.

const { batchExecute } = require('@graphql-tools/batch-execute');
const { makeExecutableSchema } = require('@graphql-tools/schema');
const { graphql } = require('graphql');

const typeDefs = `
  type Query {
    hello: String
    world: String
  }
`;

const resolvers = {
  Query: {
    hello: () => 'Hello',
    world: () => 'World'
  }
};

const schema = makeExecutableSchema({ typeDefs, resolvers });

const operations = [
  { query: '{ hello }' },
  { query: '{ world }' }
];

batchExecute({ schema, operations }).then(results => {
  console.log(results);
});

Custom Execution Context

This feature allows you to provide a custom execution context for the batched operations. The code sample demonstrates how to pass a context object containing user information to the batchExecute function.

const { batchExecute } = require('@graphql-tools/batch-execute');
const { makeExecutableSchema } = require('@graphql-tools/schema');
const { graphql } = require('graphql');

const typeDefs = `
  type Query {
    hello: String
    world: String
  }
`;

const resolvers = {
  Query: {
    hello: () => 'Hello',
    world: () => 'World'
  }
};

const schema = makeExecutableSchema({ typeDefs, resolvers });

const operations = [
  { query: '{ hello }' },
  { query: '{ world }' }
];

const context = { user: { id: 1, name: 'John Doe' } };

batchExecute({ schema, operations, context }).then(results => {
  console.log(results);
});

Other packages similar to @graphql-tools/batch-execute

FAQs

Package last updated on 20 Dec 2020

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