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

Commit

Permalink
Rename MaybePromise to PromiseOrValue
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnwalraven committed Mar 27, 2019
1 parent 0160812 commit 54fb944
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions types/graphql/execution/execute.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
InlineFragmentNode,
FragmentDefinitionNode,
} from "../language/ast";
import { MaybePromise } from "../jsutils/MaybePromise";
import { PromiseOrValue } from "../jsutils/PromiseOrValue";

/**
* Data that must be available at all points during query execution.
Expand Down Expand Up @@ -73,7 +73,7 @@ export type ExecutionArgs = {
*
* Accepts either an object with named arguments, or individual arguments.
*/
export function execute<TData = ExecutionResultDataDefault>(args: ExecutionArgs): MaybePromise<ExecutionResult<TData>>;
export function execute<TData = ExecutionResultDataDefault>(args: ExecutionArgs): PromiseOrValue<ExecutionResult<TData>>;
export function execute<TData = ExecutionResultDataDefault>(
schema: GraphQLSchema,
document: DocumentNode,
Expand All @@ -82,7 +82,7 @@ export function execute<TData = ExecutionResultDataDefault>(
variableValues?: Maybe<{ [key: string]: any }>,
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
): MaybePromise<ExecutionResult<TData>>;
): PromiseOrValue<ExecutionResult<TData>>;

/**
* Given a ResponsePath (found in the `path` entry in the information provided
Expand Down
1 change: 0 additions & 1 deletion types/graphql/jsutils/MaybePromise.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions types/graphql/jsutils/PromiseOrValue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type PromiseOrValue<T> = Promise<T> | T;
44 changes: 22 additions & 22 deletions types/graphql/type/definition.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Maybe from "../tsutils/Maybe";
import { MaybePromise } from "../jsutils/MaybePromise";
import { PromiseOrValue } from "../jsutils/PromiseOrValue";
import {
ScalarTypeDefinitionNode,
ObjectTypeDefinitionNode,
Expand Down Expand Up @@ -97,13 +97,13 @@ export type GraphQLOutputType =
| GraphQLEnumType
| GraphQLList<any>
| GraphQLNonNull<
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLList<any>
>;
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLList<any>
>;

export function isOutputType(type: any): type is GraphQLOutputType;

Expand Down Expand Up @@ -164,7 +164,7 @@ interface GraphQLList<T extends GraphQLType> {

interface _GraphQLList<T extends GraphQLType> {
(type: T): GraphQLList<T>;
new (type: T): GraphQLList<T>;
new(type: T): GraphQLList<T>;
}

export const GraphQLList: _GraphQLList<GraphQLType>;
Expand Down Expand Up @@ -198,7 +198,7 @@ interface GraphQLNonNull<T extends GraphQLNullableType> {

interface _GraphQLNonNull<T extends GraphQLNullableType> {
(type: T): GraphQLNonNull<T>;
new (type: T): GraphQLNonNull<T>;
new(type: T): GraphQLNonNull<T>;
}

export const GraphQLNonNull: _GraphQLNonNull<GraphQLNullableType>;
Expand Down Expand Up @@ -352,7 +352,7 @@ export class GraphQLObjectType<
TSource = any,
TContext = any,
TArgs = { [key: string]: any }
> {
> {
name: string;
description: Maybe<string>;
astNode: Maybe<ObjectTypeDefinitionNode>;
Expand All @@ -378,7 +378,7 @@ export interface GraphQLObjectTypeConfig<
TSource,
TContext,
TArgs = { [key: string]: any }
> {
> {
name: string;
interfaces?: Thunk<Maybe<GraphQLInterfaceType[]>>;
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext, TArgs>>;
Expand All @@ -392,17 +392,17 @@ export type GraphQLTypeResolver<
TSource,
TContext,
TArgs = { [key: string]: any }
> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo
) => MaybePromise<Maybe<GraphQLObjectType<TSource, TContext, TArgs> | string>>;
> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo
) => PromiseOrValue<Maybe<GraphQLObjectType<TSource, TContext, TArgs> | string>>;

export type GraphQLIsTypeOfFn<TSource, TContext> = (
source: TSource,
context: TContext,
info: GraphQLResolveInfo
) => MaybePromise<boolean>;
) => PromiseOrValue<boolean>;

export type GraphQLFieldResolver<TSource, TContext, TArgs = { [argName: string]: any }> = (
source: TSource,
Expand Down Expand Up @@ -478,9 +478,9 @@ export type GraphQLFieldMap<
TSource,
TContext,
TArgs = { [key: string]: any }
> = {
[key: string]: GraphQLField<TSource, TContext, TArgs>;
};
> = {
[key: string]: GraphQLField<TSource, TContext, TArgs>;
};

/**
* Interface Type Definition
Expand Down Expand Up @@ -525,7 +525,7 @@ export interface GraphQLInterfaceTypeConfig<
TSource,
TContext,
TArgs = { [key: string]: any }
> {
> {
name: string;
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext, TArgs>>;
/**
Expand Down

0 comments on commit 54fb944

Please sign in to comment.