Skip to content

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

Closed
yaacovCR wants to merge 5 commits into
graphql:nextfrom
yaacovCR:use-generic
Closed

polish: unify our formatted and non-formatted execution result types#4504
yaacovCR wants to merge 5 commits into
graphql:nextfrom
yaacovCR:use-generic

Conversation

@yaacovCR

@yaacovCR yaacovCR commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

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:
#4481
#4333

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.
@yaacovCR
yaacovCR requested a review from a team as a code owner October 28, 2025 11:42
@yaacovCR yaacovCR added the PR: polish 💅 PR doesn't change public API or any observed behaviour label Oct 28, 2025
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Feb 15, 2026
at @IvanGoncharov's suggestions
=> allows GraphQLError class to implement GraphQLFormattedError interface

alternative to parts of graphql#4504
@yaacovCR

Copy link
Copy Markdown
Contributor Author

closing for now, see #4557 and #4558

@yaacovCR yaacovCR closed this Feb 15, 2026
@yaacovCR
yaacovCR deleted the use-generic branch March 29, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: polish 💅 PR doesn't change public API or any observed behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant