Merge pull request #28087 from dfreeman/graphql-resolve-batch-info

[graphql-resolve-batch] Batch resolvers receive ResolveInfo
This commit is contained in:
Benjamin Lichtman
2018-08-14 13:11:49 -07:00
committed by GitHub
2 changed files with 7 additions and 2 deletions
@@ -95,13 +95,15 @@ const withSourceAndArgsAndContextTyped = createBatchResolver<
SomeTestResult,
SomeTestArgs,
SomeTestContext
>(async (sources, args, context) => {
>(async (sources, args, context, info) => {
// $ExpectType ReadonlyArray<SomeTestSource>
const verifySources = sources;
// $ExpectType string
const verifyArgs = args.someArg;
// $ExpectType string
const verifyContext = context.someContextProp;
// $ExpectType GraphQLResolveInfo
const verifyInfo = info;
const result = await asyncBatchFunction(sources);
return result;
+4 -1
View File
@@ -4,6 +4,8 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { GraphQLResolveInfo } from 'graphql';
/**
* Creates a GraphQL.js field resolver that batches together multiple resolves
* together that share the *exact* same GraphQL field selection.
@@ -45,5 +47,6 @@ export type ResolverFunction<TSource, TArgs, TContext, TReturn> = (
export type BatchResolveFunction<TSource, TArgs, TContext, TReturn> = (
sources: ReadonlyArray<TSource>,
args: TArgs,
context: TContext
context: TContext,
info: GraphQLResolveInfo
) => TReturn[] | Promise<TReturn[]>;