@types/graphql-resolve-batch
TypeScript icon, indicating that this package has built-in type declarations

1.1.11 • Public • Published

Installation

npm install --save @types/graphql-resolve-batch

Summary

This package contains type definitions for graphql-resolve-batch (https://github.com/calebmer/graphql-resolve-batch#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/graphql-resolve-batch.

index.d.ts

import { GraphQLResolveInfo } from "graphql";

/**
 * Creates a GraphQL.js field resolver that batches together multiple resolves
 * together that share the *exact* same GraphQL field selection.
 *
 * Note:
 *  The batchResolveFunction you supply always expects you to return an array of TReturn (or a promise with this array).
 *  This is because you will have to return a TReturn for every source given to you by the batch function.
 *  For an example of this please see the examples in the original project repository:
 *  https://github.com/calebmer/graphql-resolve-batch/tree/master/examples
 *
 * @template TSource The original type of a single source.
 * @template TReturn The return type of the field resolver.
 * @template TArgs The type of supplied arguments.
 * @template TContext The type of the current resolver context.
 * @param batchResolveFn A batch function to resolve all fields for the given sources in a single batch.
 */
export function createBatchResolver<
    TSource,
    TReturn,
    TArgs = any,
    TContext = any,
>(
    batchResolveFn: BatchResolveFunction<TSource, TArgs, TContext, TReturn>,
): ResolverFunction<TSource, TArgs, TContext, TReturn>;

/**
 * The resulting field resolver that batches together multiple resolves.
 * Graphql-resolve-batch will always return a promise for this resulting resolver.
 */
export type ResolverFunction<TSource, TArgs, TContext, TReturn> = (
    source: TSource,
    args: TArgs,
    context: TContext,
    info: GraphQLResolveInfo,
) => Promise<TReturn>;

/**
 * A batch function to resolve all fields for the given sources in a single batch.
 */
export type BatchResolveFunction<TSource, TArgs, TContext, TReturn> = (
    sources: readonly TSource[],
    args: TArgs,
    context: TContext,
    info: GraphQLResolveInfo,
) => TReturn[] | Promise<TReturn[]>;

Additional Details

  • Last updated: Mon, 20 Nov 2023 23:36:24 GMT
  • Dependencies: graphql

Credits

These definitions were written by Rutger Hendrickx.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/graphql-resolve-batch

Weekly Downloads

1,249

Version

1.1.11

License

MIT

Unpacked Size

6.38 kB

Total Files

5

Last publish

Collaborators

  • types