From 56c2e42d498526efdaad31d163df16a2f979f7a7 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 7 Sep 2017 16:10:30 +0300 Subject: [PATCH 1/3] Add missing ExecutionArgs export --- src/execution/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/execution/index.js b/src/execution/index.js index cf568c1054..1744f18d21 100644 --- a/src/execution/index.js +++ b/src/execution/index.js @@ -10,4 +10,4 @@ export { execute, defaultFieldResolver, responsePathAsArray } from './execute'; export { getDirectiveValues } from './values'; -export type { ExecutionResult } from './execute'; +export type { ExecutionArgs, ExecutionResult } from './execute'; From 3c74e0b1637359d462c30ed9a98e822defe97b5f Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 7 Sep 2017 16:31:36 +0300 Subject: [PATCH 2/3] Add missing '@flow' and unify comments style --- src/execution/index.js | 1 + src/language/lexer.js | 2 +- src/subscription/asyncIteratorReject.js | 3 +-- src/subscription/index.js | 3 +-- src/subscription/mapAsyncIterator.js | 3 +-- src/subscription/subscribe.js | 3 +-- src/validation/index.js | 1 + 7 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/execution/index.js b/src/execution/index.js index 1744f18d21..cef50db613 100644 --- a/src/execution/index.js +++ b/src/execution/index.js @@ -1,3 +1,4 @@ +/* @flow */ /** * Copyright (c) 2015, Facebook, Inc. * All rights reserved. diff --git a/src/language/lexer.js b/src/language/lexer.js index 4f8118588c..094ab72bf2 100644 --- a/src/language/lexer.js +++ b/src/language/lexer.js @@ -1,4 +1,4 @@ -/* @flow / +/* @flow */ /** * Copyright (c) 2015, Facebook, Inc. * All rights reserved. diff --git a/src/subscription/asyncIteratorReject.js b/src/subscription/asyncIteratorReject.js index 4aac773fdd..f5c4664a1e 100644 --- a/src/subscription/asyncIteratorReject.js +++ b/src/subscription/asyncIteratorReject.js @@ -1,3 +1,4 @@ +/* @flow */ /** * Copyright (c) 2017, Facebook, Inc. * All rights reserved. @@ -5,8 +6,6 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. - * - * @flow */ import { $$asyncIterator } from 'iterall'; diff --git a/src/subscription/index.js b/src/subscription/index.js index 2d31f69503..6cddd4790a 100644 --- a/src/subscription/index.js +++ b/src/subscription/index.js @@ -1,3 +1,4 @@ +/* @flow */ /** * Copyright (c) 2017, Facebook, Inc. * All rights reserved. @@ -5,8 +6,6 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. - * - * @flow */ export { subscribe, createSourceEventStream } from './subscribe'; diff --git a/src/subscription/mapAsyncIterator.js b/src/subscription/mapAsyncIterator.js index c31d74c6cd..238150579c 100644 --- a/src/subscription/mapAsyncIterator.js +++ b/src/subscription/mapAsyncIterator.js @@ -1,3 +1,4 @@ +/* @flow */ /** * Copyright (c) 2017, Facebook, Inc. * All rights reserved. @@ -5,8 +6,6 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. - * - * @flow */ import { $$asyncIterator, getAsyncIterator } from 'iterall'; diff --git a/src/subscription/subscribe.js b/src/subscription/subscribe.js index f5367e8bd0..103138de12 100644 --- a/src/subscription/subscribe.js +++ b/src/subscription/subscribe.js @@ -1,3 +1,4 @@ +/* @flow */ /** * Copyright (c) 2017, Facebook, Inc. * All rights reserved. @@ -5,8 +6,6 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. - * - * @flow */ import { isAsyncIterable } from 'iterall'; diff --git a/src/validation/index.js b/src/validation/index.js index c2190f4bbd..e8b5ae1575 100644 --- a/src/validation/index.js +++ b/src/validation/index.js @@ -1,3 +1,4 @@ +/* @flow */ /** * Copyright (c) 2015, Facebook, Inc. * All rights reserved. From 7086160eb3eca1c0e23fe2a0cacd92d8c946b1e0 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 7 Sep 2017 16:40:39 +0300 Subject: [PATCH 3/3] Fix issues uncovered by enabling Flow --- src/validation/rules/KnownArgumentNames.js | 5 ++--- src/validation/rules/PossibleFragmentSpreads.js | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/validation/rules/KnownArgumentNames.js b/src/validation/rules/KnownArgumentNames.js index 9a2f99e4bd..dcf10e7faf 100644 --- a/src/validation/rules/KnownArgumentNames.js +++ b/src/validation/rules/KnownArgumentNames.js @@ -15,17 +15,16 @@ import invariant from '../../jsutils/invariant'; import suggestionList from '../../jsutils/suggestionList'; import quotedOrList from '../../jsutils/quotedOrList'; import * as Kind from '../../language/kinds'; -import type { GraphQLType } from '../../type/definition'; export function unknownArgMessage( argName: string, fieldName: string, - type: GraphQLType, + typeName: string, suggestedArgs: Array ): string { let message = `Unknown argument "${argName}" on field "${fieldName}" of ` + - `type "${String(type)}".`; + `type "${typeName}".`; if (suggestedArgs.length) { message += ` Did you mean ${quotedOrList(suggestedArgs)}?`; } diff --git a/src/validation/rules/PossibleFragmentSpreads.js b/src/validation/rules/PossibleFragmentSpreads.js index a0d66ac42b..b55df025e4 100644 --- a/src/validation/rules/PossibleFragmentSpreads.js +++ b/src/validation/rules/PossibleFragmentSpreads.js @@ -12,6 +12,7 @@ import type { ValidationContext } from '../index'; import { GraphQLError } from '../../error'; import { doTypesOverlap } from '../../utilities/typeComparators'; import { typeFromAST } from '../../utilities/typeFromAST'; +import { isCompositeType } from '../../type/definition'; import type { GraphQLType } from '../../type/definition'; @@ -44,8 +45,8 @@ export function PossibleFragmentSpreads(context: ValidationContext): any { InlineFragment(node) { const fragType = context.getType(); const parentType = context.getParentType(); - if (fragType && - parentType && + if (isCompositeType(fragType) && + isCompositeType(parentType) && !doTypesOverlap(context.getSchema(), fragType, parentType)) { context.reportError(new GraphQLError( typeIncompatibleAnonSpreadMessage(parentType, fragType),