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

Commit

Permalink
Rename type MaybePromise to PromiseOrValue
Browse files Browse the repository at this point in the history
  • Loading branch information
kyarik committed Apr 10, 2021
1 parent 2882357 commit 09050f6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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 @@ -50,8 +51,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 @@ -94,7 +95,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 @@ -127,7 +128,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

0 comments on commit 09050f6

Please sign in to comment.