Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Rename type MaybePromise to PromiseOrValue as in graphql-js #752

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import { renderGraphiQL } from './renderGraphiQL';
type Request = IncomingMessage & { url: string };

type Response = ServerResponse & { json?: (data: unknown) => void };
type MaybePromise<T> = Promise<T> | T;

type PromiseOrValue<T> = Promise<T> | T;

/**
* Used to configure the graphqlHTTP middleware by providing a schema
Expand All @@ -47,8 +48,8 @@ export type Options =
request: Request,
response: Response,
params?: GraphQLParams,
) => MaybePromise<OptionsData>)
| MaybePromise<OptionsData>;
) => PromiseOrValue<OptionsData>)
| PromiseOrValue<OptionsData>;

export interface OptionsData {
/**
Expand Down Expand Up @@ -91,7 +92,7 @@ export interface OptionsData {
* An optional function which will be used to execute instead of default `execute`
* from `graphql-js`.
*/
customExecuteFn?: (args: ExecutionArgs) => MaybePromise<ExecutionResult>;
customExecuteFn?: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>;

/**
* An optional function which will be used to format any errors produced by
Expand Down Expand Up @@ -124,7 +125,7 @@ export interface OptionsData {
*/
extensions?: (
info: RequestInfo,
) => MaybePromise<undefined | { [key: string]: unknown }>;
) => PromiseOrValue<undefined | { [key: string]: unknown }>;

/**
* A boolean to optionally enable GraphiQL mode.
Expand Down