graphql-js
graphql-js copied to clipboard
polish: unify our formatted and non-formatted execution result types
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