Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a4718b7

Browse files
author
Travis CI
committed
Deploy 63a9488 to NPM branch
1 parent db23d74 commit a4718b7

File tree

13 files changed

+52
-22
lines changed

13 files changed

+52
-22
lines changed

execution/execute.js.flow

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import invariant from '../jsutils/invariant';
1313
import isInvalid from '../jsutils/isInvalid';
1414
import isNullish from '../jsutils/isNullish';
1515
import type { ObjMap } from '../jsutils/ObjMap';
16+
import type { MaybePromise } from '../jsutils/MaybePromise';
1617

1718
import { typeFromAST } from '../utilities/typeFromAST';
1819
import * as Kind from '../language/kinds';
@@ -133,7 +134,7 @@ export type ExecutionArgs = {|
133134
declare function execute(
134135
ExecutionArgs,
135136
..._: []
136-
): Promise<ExecutionResult> | ExecutionResult;
137+
): MaybePromise<ExecutionResult>;
137138
/* eslint-disable no-redeclare */
138139
declare function execute(
139140
schema: GraphQLSchema,
@@ -143,7 +144,7 @@ declare function execute(
143144
variableValues?: ?{ [variable: string]: mixed },
144145
operationName?: ?string,
145146
fieldResolver?: ?GraphQLFieldResolver<any, any>,
146-
): Promise<ExecutionResult> | ExecutionResult;
147+
): MaybePromise<ExecutionResult>;
147148
export function execute(
148149
argsOrSchema,
149150
document,
@@ -222,7 +223,7 @@ function executeImpl(
222223
*/
223224
function buildResponse(
224225
context: ExecutionContext,
225-
data: Promise<ObjMap<mixed> | null> | ObjMap<mixed> | null,
226+
data: MaybePromise<ObjMap<mixed> | null>,
226227
) {
227228
const promise = getPromise(data);
228229
if (promise) {
@@ -376,7 +377,7 @@ function executeOperation(
376377
exeContext: ExecutionContext,
377378
operation: OperationDefinitionNode,
378379
rootValue: mixed,
379-
): Promise<ObjMap<mixed> | null> | ObjMap<mixed> | null {
380+
): MaybePromise<ObjMap<mixed> | null> {
380381
const type = getOperationRootType(exeContext.schema, operation);
381382
const fields = collectFields(
382383
exeContext,
@@ -503,7 +504,7 @@ function executeFields(
503504
sourceValue: mixed,
504505
path: ResponsePath | void,
505506
fields: ObjMap<Array<FieldNode>>,
506-
): Promise<ObjMap<mixed>> | ObjMap<mixed> {
507+
): MaybePromise<ObjMap<mixed>> {
507508
let containsPromise = false;
508509

509510
const finalResults = Object.keys(fields).reduce((results, responseName) => {

graphql.js.flow

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type { Source } from './language/source';
1616
import type { GraphQLFieldResolver } from './type/definition';
1717
import type { GraphQLSchema } from './type/schema';
1818
import type { ExecutionResult } from './execution/execute';
19+
import type { MaybePromise } from './jsutils/MaybePromise';
1920

2021
/**
2122
* This is the primary entry point function for fulfilling GraphQL operations
@@ -168,7 +169,7 @@ function graphqlImpl(
168169
variableValues,
169170
operationName,
170171
fieldResolver,
171-
): Promise<ExecutionResult> | ExecutionResult {
172+
): MaybePromise<ExecutionResult> {
172173
// Validate Schema
173174
const schemaValidationErrors = validateSchema(schema);
174175
if (schemaValidationErrors.length > 0) {

jsutils/MaybePromise.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"use strict";

jsutils/MaybePromise.js.flow

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
export type MaybePromise<T> = Promise<T> | T;

module/execution/execute.js.flow

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import invariant from '../jsutils/invariant';
1313
import isInvalid from '../jsutils/isInvalid';
1414
import isNullish from '../jsutils/isNullish';
1515
import type { ObjMap } from '../jsutils/ObjMap';
16+
import type { MaybePromise } from '../jsutils/MaybePromise';
1617

1718
import { typeFromAST } from '../utilities/typeFromAST';
1819
import * as Kind from '../language/kinds';
@@ -133,7 +134,7 @@ export type ExecutionArgs = {|
133134
declare function execute(
134135
ExecutionArgs,
135136
..._: []
136-
): Promise<ExecutionResult> | ExecutionResult;
137+
): MaybePromise<ExecutionResult>;
137138
/* eslint-disable no-redeclare */
138139
declare function execute(
139140
schema: GraphQLSchema,
@@ -143,7 +144,7 @@ declare function execute(
143144
variableValues?: ?{ [variable: string]: mixed },
144145
operationName?: ?string,
145146
fieldResolver?: ?GraphQLFieldResolver<any, any>,
146-
): Promise<ExecutionResult> | ExecutionResult;
147+
): MaybePromise<ExecutionResult>;
147148
export function execute(
148149
argsOrSchema,
149150
document,
@@ -222,7 +223,7 @@ function executeImpl(
222223
*/
223224
function buildResponse(
224225
context: ExecutionContext,
225-
data: Promise<ObjMap<mixed> | null> | ObjMap<mixed> | null,
226+
data: MaybePromise<ObjMap<mixed> | null>,
226227
) {
227228
const promise = getPromise(data);
228229
if (promise) {
@@ -376,7 +377,7 @@ function executeOperation(
376377
exeContext: ExecutionContext,
377378
operation: OperationDefinitionNode,
378379
rootValue: mixed,
379-
): Promise<ObjMap<mixed> | null> | ObjMap<mixed> | null {
380+
): MaybePromise<ObjMap<mixed> | null> {
380381
const type = getOperationRootType(exeContext.schema, operation);
381382
const fields = collectFields(
382383
exeContext,
@@ -503,7 +504,7 @@ function executeFields(
503504
sourceValue: mixed,
504505
path: ResponsePath | void,
505506
fields: ObjMap<Array<FieldNode>>,
506-
): Promise<ObjMap<mixed>> | ObjMap<mixed> {
507+
): MaybePromise<ObjMap<mixed>> {
507508
let containsPromise = false;
508509

509510
const finalResults = Object.keys(fields).reduce((results, responseName) => {

module/graphql.js.flow

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type { Source } from './language/source';
1616
import type { GraphQLFieldResolver } from './type/definition';
1717
import type { GraphQLSchema } from './type/schema';
1818
import type { ExecutionResult } from './execution/execute';
19+
import type { MaybePromise } from './jsutils/MaybePromise';
1920

2021
/**
2122
* This is the primary entry point function for fulfilling GraphQL operations
@@ -168,7 +169,7 @@ function graphqlImpl(
168169
variableValues,
169170
operationName,
170171
fieldResolver,
171-
): Promise<ExecutionResult> | ExecutionResult {
172+
): MaybePromise<ExecutionResult> {
172173
// Validate Schema
173174
const schemaValidationErrors = validateSchema(schema);
174175
if (schemaValidationErrors.length > 0) {

module/jsutils/MaybePromise.js

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
export type MaybePromise<T> = Promise<T> | T;

module/subscription/mapAsyncIterator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
1111

1212
import { $$asyncIterator, getAsyncIterator } from 'iterall';
1313

14+
1415
/**
1516
* Given an AsyncIterable and a callback function, return an AsyncIterator
1617
* which produces values mapped via calling the callback function.

module/subscription/mapAsyncIterator.js.flow

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
*/
99

1010
import { $$asyncIterator, getAsyncIterator } from 'iterall';
11+
import type { MaybePromise } from '../jsutils/MaybePromise';
1112

1213
/**
1314
* Given an AsyncIterable and a callback function, return an AsyncIterator
1415
* which produces values mapped via calling the callback function.
1516
*/
1617
export default function mapAsyncIterator<T, U>(
1718
iterable: AsyncIterable<T>,
18-
callback: T => Promise<U> | U,
19-
rejectCallback?: any => Promise<U> | U,
19+
callback: T => MaybePromise<U>,
20+
rejectCallback?: any => MaybePromise<U>,
2021
): AsyncGenerator<U, void, void> {
2122
const iterator = getAsyncIterator(iterable);
2223
let $return;
@@ -68,7 +69,7 @@ export default function mapAsyncIterator<T, U>(
6869

6970
function asyncMapValue<T, U>(
7071
value: T,
71-
callback: T => Promise<U> | U,
72+
callback: T => MaybePromise<U>,
7273
): Promise<U> {
7374
return new Promise(resolve => resolve(callback(value)));
7475
}

0 commit comments

Comments
 (0)