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 Jun 1, 2021
1 parent 28e4c29 commit 01fb10d
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 @@ -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

0 comments on commit 01fb10d

Please sign in to comment.