graphql-js icon indicating copy to clipboard operation
graphql-js copied to clipboard

polish: unify our formatted and non-formatted execution result types

Open yaacovCR opened this issue 1 month ago • 0 comments

via using a new generic type parameter with this pattern:

export interface ExecutionResult<
  TData = ObjMap<unknown>,
  TExtensions = ObjMap<unknown>,
  TError extends GraphQLError | GraphQLFormattedError = GraphQLError,
> {
  errors?: ReadonlyArray<TError>;
  data?: TData | null;
  extensions?: TExtensions;
}

export interface FormattedExecutionResult<
  TData = ObjMap<unknown>,
  TExtensions = ObjMap<unknown>,
> extends ExecutionResult<TData, TExtensions, GraphQLFormattedError> {}

This should remove maintenance burden, as we explicitly say that the formatted types only differ from the unformatted in that they have a formatted error type.

See: https://github.com/graphql/graphql-js/pull/4481/ https://github.com/graphql/graphql-js/issues/4333

yaacovCR avatar Oct 28 '25 11:10 yaacovCR