1.1.11 • Published 6 months ago

@types/graphql-resolve-batch v1.1.11

Weekly downloads
1,418
License
MIT
Repository
github
Last release
6 months ago

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

// Type definitions for graphql-resolve-batch 1.1
// Project: https://github.com/calebmer/graphql-resolve-batch#readme
// Definitions by: Rutger Hendrickx <https://github.com/nayni>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 4.1

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: ReadonlyArray<TSource>,
    args: TArgs,
    context: TContext,
    info: GraphQLResolveInfo
) => TReturn[] | Promise<TReturn[]>;

Additional Details

  • Last updated: Thu, 12 May 2022 00:31:35 GMT
  • Dependencies: @types/graphql
  • Global values: none

Credits

These definitions were written by Rutger Hendrickx.

1.1.9

7 months ago

1.1.8

7 months ago

1.1.7

8 months ago

1.1.11

6 months ago

1.1.10

6 months ago

1.1.6

2 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago