Closed as not planned
Closed as not planned
Description
Right now, we provide the fieldNodes
as part of the info
parameter for resolvers, but the fields are not collected, because the type is not yet known until the resolver returns. Since the type resolver logic may be known, resolvers can include that logic and collect fields manually based on that known type, and then perform whatever logic necessary => but that means that fields are collected twice, once by the framework, and once by the resolver. It would be great if there was a hook that could provide access to the collected fields and allow modification of the result.
The proposal: add a refine
method to GraphQLObjectTypes with signature:
export type GraphQLFieldRefiner<
TSource,
TContext,
TArgs = { [argument: string]: any },
TInitialResult = unknown,
TFinalResult = unknown,
> = (
source: TSource,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo,
initialResult: TInitialResult,
collectedFields: Map<string, ReadonlyArray<FieldNode>>,
) => TFinalResult;
Any thoughts?