From a6c964089c4384c83e9a7caa0236287c39efa3ff Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Sun, 28 Jul 2019 15:40:47 +0300 Subject: [PATCH] Sort imports in all JS files --- src/__tests__/starWarsIntrospection-test.js | 4 +- src/__tests__/starWarsQuery-test.js | 4 +- src/__tests__/starWarsValidation-test.js | 7 +- src/__tests__/version-test.js | 1 + src/error/GraphQLError.js | 1 + src/error/__tests__/GraphQLError-test.js | 1 + src/error/formatError.js | 4 +- src/error/locatedError.js | 3 +- src/error/syntaxError.js | 1 + .../__tests__/abstract-promise-test.js | 1 + src/execution/__tests__/abstract-test.js | 1 + src/execution/__tests__/directives-test.js | 4 +- src/execution/__tests__/executor-test.js | 5 +- src/execution/__tests__/lists-test.js | 4 +- src/execution/__tests__/mutations-test.js | 4 +- src/execution/__tests__/nonnull-test.js | 6 +- src/execution/__tests__/schema-test.js | 4 +- src/execution/__tests__/sync-test.js | 6 +- .../__tests__/union-interface-test.js | 3 +- src/execution/__tests__/variables-test.js | 7 +- src/execution/execute.js | 65 ++++++++++--------- src/execution/values.js | 31 +++++---- src/graphql.js | 14 ++-- src/jsutils/__tests__/dedent-test.js | 1 + src/jsutils/__tests__/didYouMean-test.js | 1 + src/jsutils/__tests__/identityFunc-test.js | 1 + src/jsutils/__tests__/inspect-test.js | 1 + src/jsutils/__tests__/instanceOf-test.js | 1 + src/jsutils/__tests__/suggestionList-test.js | 1 + src/jsutils/mapValue.js | 3 +- src/language/__tests__/blockString-test.js | 1 + src/language/__tests__/lexer-test.js | 3 + src/language/__tests__/parser-benchmark.js | 3 +- src/language/__tests__/parser-test.js | 11 ++-- src/language/__tests__/printLocation-test.js | 2 + src/language/__tests__/printer-test.js | 5 +- src/language/__tests__/schema-parser-test.js | 3 + src/language/__tests__/schema-printer-test.js | 5 +- src/language/__tests__/source-test.js | 1 + src/language/__tests__/visitor-test.js | 11 ++-- src/language/lexer.js | 6 +- src/language/parser.js | 13 ++-- src/language/predicates.js | 2 +- src/language/printLocation.js | 2 +- src/language/printer.js | 2 +- src/language/visitor.js | 4 +- .../eventEmitterAsyncIterator-test.js | 3 +- .../__tests__/mapAsyncIterator-test.js | 1 + src/subscription/__tests__/subscribe-test.js | 12 ++-- src/subscription/mapAsyncIterator.js | 1 + src/subscription/subscribe.js | 12 +++- src/type/__tests__/definition-test.js | 4 +- src/type/__tests__/directive-test.js | 2 +- src/type/__tests__/enumType-test.js | 3 +- src/type/__tests__/introspection-test.js | 1 + src/type/__tests__/predicate-test.js | 2 +- src/type/__tests__/scalars-test.js | 5 +- src/type/__tests__/schema-test.js | 6 +- src/type/__tests__/serialization-test.js | 6 +- src/type/__tests__/validation-test.js | 13 ++-- src/type/definition.js | 24 ++++--- src/type/directives.js | 25 +++---- src/type/index.js | 1 - src/type/introspection.js | 13 ++-- src/type/scalars.js | 5 +- src/type/schema.js | 35 +++++----- src/type/validate.js | 21 +++--- src/utilities/TypeInfo.js | 9 ++- .../__tests__/assertValidName-test.js | 3 +- src/utilities/__tests__/astFromValue-test.js | 6 +- .../__tests__/buildASTSchema-benchmark.js | 5 +- .../__tests__/buildASTSchema-test.js | 10 ++- .../__tests__/buildClientSchema-benchmark.js | 4 +- .../__tests__/buildClientSchema-test.js | 9 ++- src/utilities/__tests__/coerceValue-test.js | 8 ++- src/utilities/__tests__/concatAST-test.js | 7 +- src/utilities/__tests__/extendSchema-test.js | 15 +++-- .../__tests__/findBreakingChanges-test.js | 12 ++-- .../__tests__/findDeprecatedUsages-test.js | 4 +- .../__tests__/getOperationAST-test.js | 2 + .../__tests__/getOperationRootType-test.js | 5 +- .../introspectionFromSchema-benchmark.js | 5 +- .../__tests__/introspectionFromSchema-test.js | 4 +- .../__tests__/isValidLiteralValue-test.js | 4 +- .../__tests__/lexicographicSortSchema-test.js | 4 +- src/utilities/__tests__/schemaPrinter-test.js | 12 ++-- .../__tests__/separateOperations-test.js | 7 +- .../__tests__/stripIgnoredCharacters-test.js | 5 +- .../__tests__/typeComparators-test.js | 4 +- src/utilities/__tests__/valueFromAST-test.js | 8 ++- .../__tests__/valueFromASTUntyped-test.js | 6 +- src/utilities/assertValidName.js | 3 +- src/utilities/astFromValue.js | 7 +- src/utilities/buildASTSchema.js | 49 +++++++------- src/utilities/buildClientSchema.js | 15 ++--- src/utilities/coerceValue.js | 3 + src/utilities/concatAST.js | 1 + src/utilities/extendSchema.js | 39 +++++------ src/utilities/findBreakingChanges.js | 6 +- src/utilities/findDeprecatedUsages.js | 5 +- src/utilities/getOperationRootType.js | 2 + src/utilities/introspectionFromSchema.js | 6 +- src/utilities/isValidJSValue.js | 3 +- src/utilities/isValidLiteralValue.js | 12 ++-- src/utilities/lexicographicSortSchema.js | 4 +- src/utilities/schemaPrinter.js | 20 +++--- src/utilities/separateOperations.js | 3 +- src/utilities/stripIgnoredCharacters.js | 1 + src/utilities/typeComparators.js | 2 +- src/utilities/typeFromAST.js | 4 +- src/utilities/valueFromAST.js | 7 +- src/utilities/valueFromASTUntyped.js | 1 + src/validation/ValidationContext.js | 8 ++- .../__tests__/ExecutableDefinitions-test.js | 4 +- .../__tests__/FieldsOnCorrectType-test.js | 4 +- .../FragmentsOnCompositeTypes-test.js | 4 +- .../__tests__/KnownArgumentNames-test.js | 5 +- .../__tests__/KnownDirectives-test.js | 4 +- .../__tests__/KnownFragmentNames-test.js | 4 +- .../__tests__/KnownTypeNames-test.js | 5 +- .../__tests__/LoneAnonymousOperation-test.js | 4 +- .../__tests__/LoneSchemaDefinition-test.js | 7 +- .../__tests__/NoFragmentCycles-test.js | 4 +- .../__tests__/NoUndefinedVariables-test.js | 4 +- .../__tests__/NoUnusedFragments-test.js | 4 +- .../__tests__/NoUnusedVariables-test.js | 4 +- .../OverlappingFieldsCanBeMerged-test.js | 10 +-- .../__tests__/PossibleFragmentSpreads-test.js | 4 +- .../__tests__/PossibleTypeExtensions-test.js | 5 +- .../ProvidedRequiredArguments-test.js | 5 +- src/validation/__tests__/ScalarLeafs-test.js | 4 +- .../SingleFieldSubscriptions-test.js | 4 +- .../__tests__/UniqueArgumentNames-test.js | 4 +- .../__tests__/UniqueDirectiveNames-test.js | 5 +- .../UniqueDirectivesPerLocation-test.js | 12 ++-- .../__tests__/UniqueEnumValueNames-test.js | 5 +- .../UniqueFieldDefinitionNames-test.js | 5 +- .../__tests__/UniqueFragmentNames-test.js | 4 +- .../__tests__/UniqueInputFieldNames-test.js | 4 +- .../__tests__/UniqueOperationNames-test.js | 4 +- .../__tests__/UniqueOperationTypes-test.js | 5 +- .../__tests__/UniqueTypeNames-test.js | 5 +- .../__tests__/UniqueVariableNames-test.js | 4 +- .../__tests__/ValuesOfCorrectType-test.js | 4 +- .../__tests__/VariablesAreInputTypes-test.js | 4 +- .../VariablesInAllowedPosition-test.js | 4 +- src/validation/__tests__/harness.js | 22 ++++--- .../__tests__/validateGQL-benchmark.js | 5 +- .../__tests__/validateSDL-benchmark.js | 5 +- src/validation/__tests__/validation-test.js | 9 ++- src/validation/rules/ExecutableDefinitions.js | 6 +- src/validation/rules/FieldsOnCorrectType.js | 10 ++- .../rules/FragmentsOnCompositeTypes.js | 6 +- src/validation/rules/KnownArgumentNames.js | 16 +++-- src/validation/rules/KnownDirectives.js | 13 ++-- src/validation/rules/KnownFragmentNames.js | 3 +- src/validation/rules/KnownTypeNames.js | 16 +++-- .../rules/LoneAnonymousOperation.js | 4 +- src/validation/rules/LoneSchemaDefinition.js | 3 +- src/validation/rules/NoFragmentCycles.js | 6 +- src/validation/rules/NoUndefinedVariables.js | 3 +- src/validation/rules/NoUnusedFragments.js | 3 +- src/validation/rules/NoUnusedVariables.js | 3 +- .../rules/OverlappingFieldsCanBeMerged.js | 16 +++-- .../rules/PossibleFragmentSpreads.js | 11 +++- .../rules/PossibleTypeExtensions.js | 8 ++- .../rules/ProvidedRequiredArguments.js | 20 +++--- src/validation/rules/ScalarLeafs.js | 8 ++- .../rules/SingleFieldSubscriptions.js | 6 +- src/validation/rules/UniqueArgumentNames.js | 3 +- src/validation/rules/UniqueDirectiveNames.js | 3 +- .../rules/UniqueDirectivesPerLocation.js | 11 ++-- src/validation/rules/UniqueEnumValueNames.js | 3 +- .../rules/UniqueFieldDefinitionNames.js | 3 +- src/validation/rules/UniqueFragmentNames.js | 3 +- src/validation/rules/UniqueInputFieldNames.js | 3 +- src/validation/rules/UniqueOperationNames.js | 3 +- src/validation/rules/UniqueOperationTypes.js | 3 +- src/validation/rules/UniqueTypeNames.js | 4 +- src/validation/rules/UniqueVariableNames.js | 6 +- src/validation/rules/ValuesOfCorrectType.js | 17 +++-- .../rules/VariablesAreInputTypes.js | 8 ++- .../rules/VariablesInAllowedPosition.js | 11 +++- src/validation/validate.js | 7 +- 184 files changed, 831 insertions(+), 435 deletions(-) diff --git a/src/__tests__/starWarsIntrospection-test.js b/src/__tests__/starWarsIntrospection-test.js index 39d4ba1142..cbd9749188 100644 --- a/src/__tests__/starWarsIntrospection-test.js +++ b/src/__tests__/starWarsIntrospection-test.js @@ -2,9 +2,11 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { StarWarsSchema } from './starWarsSchema'; + import { graphqlSync } from '../graphql'; +import { StarWarsSchema } from './starWarsSchema'; + describe('Star Wars Introspection Tests', () => { describe('Basic Introspection', () => { it('Allows querying the schema for types', () => { diff --git a/src/__tests__/starWarsQuery-test.js b/src/__tests__/starWarsQuery-test.js index d49cbde572..bdac9ed02d 100644 --- a/src/__tests__/starWarsQuery-test.js +++ b/src/__tests__/starWarsQuery-test.js @@ -2,9 +2,11 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { StarWarsSchema } from './starWarsSchema'; + import { graphql } from '../graphql'; +import { StarWarsSchema } from './starWarsSchema'; + describe('Star Wars Query Tests', () => { describe('Basic Queries', () => { it('Correctly identifies R2-D2 as the hero of the Star Wars Saga', async () => { diff --git a/src/__tests__/starWarsValidation-test.js b/src/__tests__/starWarsValidation-test.js index ff1fd58b7e..e746b60688 100644 --- a/src/__tests__/starWarsValidation-test.js +++ b/src/__tests__/starWarsValidation-test.js @@ -2,11 +2,14 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { StarWarsSchema } from './starWarsSchema'; -import { Source } from '../language/source'; + import { parse } from '../language/parser'; +import { Source } from '../language/source'; + import { validate } from '../validation/validate'; +import { StarWarsSchema } from './starWarsSchema'; + /** * Helper function to test a query and the expected response. */ diff --git a/src/__tests__/version-test.js b/src/__tests__/version-test.js index 671d3709bc..0d6cb0d88a 100644 --- a/src/__tests__/version-test.js +++ b/src/__tests__/version-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import { version, versionInfo } from '../version'; describe('Version', () => { diff --git a/src/error/GraphQLError.js b/src/error/GraphQLError.js index 1d0681e6e6..2c4c17836a 100644 --- a/src/error/GraphQLError.js +++ b/src/error/GraphQLError.js @@ -1,6 +1,7 @@ // @flow strict import isObjectLike from '../jsutils/isObjectLike'; + import { type ASTNode } from '../language/ast'; import { type Source } from '../language/source'; import { type SourceLocation, getLocation } from '../language/location'; diff --git a/src/error/__tests__/GraphQLError-test.js b/src/error/__tests__/GraphQLError-test.js index f63feca215..beb12c7a7a 100644 --- a/src/error/__tests__/GraphQLError-test.js +++ b/src/error/__tests__/GraphQLError-test.js @@ -5,6 +5,7 @@ import { describe, it } from 'mocha'; import dedent from '../../jsutils/dedent'; import invariant from '../../jsutils/invariant'; + import { Kind, parse, diff --git a/src/error/formatError.js b/src/error/formatError.js index 6990b6b001..714c2ab0d4 100644 --- a/src/error/formatError.js +++ b/src/error/formatError.js @@ -1,9 +1,11 @@ // @flow strict import invariant from '../jsutils/invariant'; -import { type GraphQLError } from './GraphQLError'; + import { type SourceLocation } from '../language/location'; +import { type GraphQLError } from './GraphQLError'; + /** * Given a GraphQLError, format it according to the rules described by the * Response Format, Errors section of the GraphQL Specification. diff --git a/src/error/locatedError.js b/src/error/locatedError.js index 955772e67e..6e7b292202 100644 --- a/src/error/locatedError.js +++ b/src/error/locatedError.js @@ -1,8 +1,9 @@ // @flow strict -import { GraphQLError } from './GraphQLError'; import { type ASTNode } from '../language/ast'; +import { GraphQLError } from './GraphQLError'; + /** * Given an arbitrary Error, presumably thrown while attempting to execute a * GraphQL operation, produce a new GraphQLError aware of the location in the diff --git a/src/error/syntaxError.js b/src/error/syntaxError.js index a0b88cb01e..c5eeb1d9c0 100644 --- a/src/error/syntaxError.js +++ b/src/error/syntaxError.js @@ -1,6 +1,7 @@ // @flow strict import { type Source } from '../language/source'; + import { GraphQLError } from './GraphQLError'; /** diff --git a/src/execution/__tests__/abstract-promise-test.js b/src/execution/__tests__/abstract-promise-test.js index eb1c5c382b..0e057194e8 100644 --- a/src/execution/__tests__/abstract-promise-test.js +++ b/src/execution/__tests__/abstract-promise-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import { graphql, GraphQLSchema, diff --git a/src/execution/__tests__/abstract-test.js b/src/execution/__tests__/abstract-test.js index 9f75d705bf..a248b93fb3 100644 --- a/src/execution/__tests__/abstract-test.js +++ b/src/execution/__tests__/abstract-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import { graphqlSync, GraphQLSchema, diff --git a/src/execution/__tests__/directives-test.js b/src/execution/__tests__/directives-test.js index 3bafa0a430..18ca401beb 100644 --- a/src/execution/__tests__/directives-test.js +++ b/src/execution/__tests__/directives-test.js @@ -1,11 +1,13 @@ // @flow strict import { expect } from 'chai'; -import { execute } from '../execute'; import { describe, it } from 'mocha'; + import { parse } from '../../language'; import { GraphQLSchema, GraphQLObjectType, GraphQLString } from '../../type'; +import { execute } from '../execute'; + const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'TestType', diff --git a/src/execution/__tests__/executor-test.js b/src/execution/__tests__/executor-test.js index 7a0fb9750a..4f39b13297 100644 --- a/src/execution/__tests__/executor-test.js +++ b/src/execution/__tests__/executor-test.js @@ -2,9 +2,10 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import inspect from '../../jsutils/inspect'; import invariant from '../../jsutils/invariant'; -import { execute } from '../execute'; + import { Kind, parse } from '../../language'; import { GraphQLSchema, @@ -17,6 +18,8 @@ import { GraphQLNonNull, } from '../../type'; +import { execute } from '../execute'; + describe('Execute: Handles basic execution tasks', () => { it('throws if no document is provided', () => { const schema = new GraphQLSchema({ diff --git a/src/execution/__tests__/lists-test.js b/src/execution/__tests__/lists-test.js index 2e9966b1dd..e56a209d96 100644 --- a/src/execution/__tests__/lists-test.js +++ b/src/execution/__tests__/lists-test.js @@ -2,7 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { execute } from '../execute'; + import { parse } from '../../language'; import { GraphQLSchema, @@ -13,6 +13,8 @@ import { GraphQLNonNull, } from '../../type'; +import { execute } from '../execute'; + // resolved() is shorthand for Promise.resolve() const resolved = Promise.resolve.bind(Promise); diff --git a/src/execution/__tests__/mutations-test.js b/src/execution/__tests__/mutations-test.js index d9f548b945..940259eb5e 100644 --- a/src/execution/__tests__/mutations-test.js +++ b/src/execution/__tests__/mutations-test.js @@ -2,10 +2,12 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { execute } from '../execute'; + import { parse } from '../../language'; import { GraphQLSchema, GraphQLObjectType, GraphQLInt } from '../../type'; +import { execute } from '../execute'; + class NumberHolder { theNumber: number; diff --git a/src/execution/__tests__/nonnull-test.js b/src/execution/__tests__/nonnull-test.js index f85f22a198..9186d8a2e4 100644 --- a/src/execution/__tests__/nonnull-test.js +++ b/src/execution/__tests__/nonnull-test.js @@ -2,15 +2,17 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { execute } from '../execute'; + import { parse } from '../../language'; -import { buildSchema } from '../../utilities/buildASTSchema'; import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull, } from '../../type'; +import { buildSchema } from '../../utilities/buildASTSchema'; + +import { execute } from '../execute'; const syncError = new Error('sync'); const syncNonNullError = new Error('syncNonNull'); diff --git a/src/execution/__tests__/schema-test.js b/src/execution/__tests__/schema-test.js index a6d56989ff..4017cff7c3 100644 --- a/src/execution/__tests__/schema-test.js +++ b/src/execution/__tests__/schema-test.js @@ -3,8 +3,8 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { execute } from '../execute'; import { parse } from '../../language'; + import { GraphQLSchema, GraphQLObjectType, @@ -16,6 +16,8 @@ import { GraphQLID, } from '../../type'; +import { execute } from '../execute'; + describe('Execute: Handles execution with a complex schema', () => { it('executes using a schema', () => { const BlogImage = new GraphQLObjectType({ diff --git a/src/execution/__tests__/sync-test.js b/src/execution/__tests__/sync-test.js index c489e8d684..84d7f0f21b 100644 --- a/src/execution/__tests__/sync-test.js +++ b/src/execution/__tests__/sync-test.js @@ -2,11 +2,13 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { graphqlSync } from '../../graphql'; -import { execute } from '../execute'; + import { parse } from '../../language'; import { validate } from '../../validation/validate'; import { GraphQLSchema, GraphQLObjectType, GraphQLString } from '../../type'; +import { graphqlSync } from '../../graphql'; + +import { execute } from '../execute'; describe('Execute: synchronously when possible', () => { const schema = new GraphQLSchema({ diff --git a/src/execution/__tests__/union-interface-test.js b/src/execution/__tests__/union-interface-test.js index e462eb52f0..86e6e54c01 100644 --- a/src/execution/__tests__/union-interface-test.js +++ b/src/execution/__tests__/union-interface-test.js @@ -3,7 +3,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { execute } from '../execute'; import { parse } from '../../language'; import { GraphQLSchema, @@ -15,6 +14,8 @@ import { GraphQLBoolean, } from '../../type'; +import { execute } from '../execute'; + class Dog { name: string; barks: boolean; diff --git a/src/execution/__tests__/variables-test.js b/src/execution/__tests__/variables-test.js index 336ecfed2b..0a5952d889 100644 --- a/src/execution/__tests__/variables-test.js +++ b/src/execution/__tests__/variables-test.js @@ -1,9 +1,10 @@ // @flow strict -import inspect from '../../jsutils/inspect'; import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { execute } from '../execute'; + +import inspect from '../../jsutils/inspect'; + import { parse } from '../../language'; import { GraphQLSchema, @@ -16,6 +17,8 @@ import { GraphQLEnumType, } from '../../type'; +import { execute } from '../execute'; + const TestComplexScalar = new GraphQLScalarType({ name: 'ComplexScalar', serialize(value) { diff --git a/src/execution/execute.js b/src/execution/execute.js index 69d4248648..679fa27cba 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -1,29 +1,45 @@ // @flow strict import { forEach, isCollection } from 'iterall'; -import { GraphQLError } from '../error/GraphQLError'; -import { locatedError } from '../error/locatedError'; + import inspect from '../jsutils/inspect'; +import memoize3 from '../jsutils/memoize3'; import invariant from '../jsutils/invariant'; import isInvalid from '../jsutils/isInvalid'; import isNullish from '../jsutils/isNullish'; import isPromise from '../jsutils/isPromise'; +import { type ObjMap } from '../jsutils/ObjMap'; import isObjectLike from '../jsutils/isObjectLike'; -import memoize3 from '../jsutils/memoize3'; -import promiseForObject from '../jsutils/promiseForObject'; import promiseReduce from '../jsutils/promiseReduce'; -import { type ObjMap } from '../jsutils/ObjMap'; +import promiseForObject from '../jsutils/promiseForObject'; import { type PromiseOrValue } from '../jsutils/PromiseOrValue'; import { type Path, addPath, pathToArray } from '../jsutils/Path'; -import { getOperationRootType } from '../utilities/getOperationRootType'; -import { typeFromAST } from '../utilities/typeFromAST'; +import { GraphQLError } from '../error/GraphQLError'; +import { locatedError } from '../error/locatedError'; + import { Kind } from '../language/kinds'; import { - getVariableValues, - getArgumentValues, - getDirectiveValues, -} from './values'; + type DocumentNode, + type OperationDefinitionNode, + type SelectionSetNode, + type FieldNode, + type FragmentSpreadNode, + type InlineFragmentNode, + type FragmentDefinitionNode, +} from '../language/ast'; + +import { assertValidSchema } from '../type/validate'; +import { type GraphQLSchema } from '../type/schema'; +import { + SchemaMetaFieldDef, + TypeMetaFieldDef, + TypeNameMetaFieldDef, +} from '../type/introspection'; +import { + GraphQLIncludeDirective, + GraphQLSkipDirective, +} from '../type/directives'; import { type GraphQLObjectType, type GraphQLOutputType, @@ -40,26 +56,15 @@ import { isListType, isNonNullType, } from '../type/definition'; -import { type GraphQLSchema } from '../type/schema'; -import { - SchemaMetaFieldDef, - TypeMetaFieldDef, - TypeNameMetaFieldDef, -} from '../type/introspection'; -import { - GraphQLIncludeDirective, - GraphQLSkipDirective, -} from '../type/directives'; -import { assertValidSchema } from '../type/validate'; + +import { typeFromAST } from '../utilities/typeFromAST'; +import { getOperationRootType } from '../utilities/getOperationRootType'; + import { - type DocumentNode, - type OperationDefinitionNode, - type SelectionSetNode, - type FieldNode, - type FragmentSpreadNode, - type InlineFragmentNode, - type FragmentDefinitionNode, -} from '../language/ast'; + getVariableValues, + getArgumentValues, + getDirectiveValues, +} from './values'; /** * Terminology diff --git a/src/execution/values.js b/src/execution/values.js index 681500fcab..e12b828b8d 100644 --- a/src/execution/values.js +++ b/src/execution/values.js @@ -1,28 +1,33 @@ // @flow strict import find from '../polyfills/find'; -import { GraphQLError } from '../error/GraphQLError'; -import inspect from '../jsutils/inspect'; + import keyMap from '../jsutils/keyMap'; -import { coerceValue } from '../utilities/coerceValue'; -import { typeFromAST } from '../utilities/typeFromAST'; -import { valueFromAST } from '../utilities/valueFromAST'; +import inspect from '../jsutils/inspect'; +import { type ObjMap } from '../jsutils/ObjMap'; + +import { GraphQLError } from '../error/GraphQLError'; + import { Kind } from '../language/kinds'; import { print } from '../language/printer'; -import { - type GraphQLField, - isInputType, - isNonNullType, -} from '../type/definition'; -import { type GraphQLDirective } from '../type/directives'; -import { type ObjMap } from '../jsutils/ObjMap'; -import { type GraphQLSchema } from '../type/schema'; import { type FieldNode, type DirectiveNode, type VariableDefinitionNode, } from '../language/ast'; +import { type GraphQLSchema } from '../type/schema'; +import { type GraphQLDirective } from '../type/directives'; +import { + type GraphQLField, + isInputType, + isNonNullType, +} from '../type/definition'; + +import { coerceValue } from '../utilities/coerceValue'; +import { typeFromAST } from '../utilities/typeFromAST'; +import { valueFromAST } from '../utilities/valueFromAST'; + type CoercedVariableValues = {| errors: $ReadOnlyArray | void, coerced: { [variable: string]: mixed, ... } | void, diff --git a/src/graphql.js b/src/graphql.js index 05a5bb91c8..a49f032166 100644 --- a/src/graphql.js +++ b/src/graphql.js @@ -1,17 +1,21 @@ // @flow strict import isPromise from './jsutils/isPromise'; -import { validateSchema } from './type/validate'; +import { type PromiseOrValue } from './jsutils/PromiseOrValue'; + import { parse } from './language/parser'; -import { validate } from './validation/validate'; -import { type ExecutionResult, execute } from './execution/execute'; import { type Source } from './language/source'; + +import { validate } from './validation/validate'; + +import { validateSchema } from './type/validate'; +import { type GraphQLSchema } from './type/schema'; import { type GraphQLFieldResolver, type GraphQLTypeResolver, } from './type/definition'; -import { type GraphQLSchema } from './type/schema'; -import { type PromiseOrValue } from './jsutils/PromiseOrValue'; + +import { type ExecutionResult, execute } from './execution/execute'; /** * This is the primary entry point function for fulfilling GraphQL operations diff --git a/src/jsutils/__tests__/dedent-test.js b/src/jsutils/__tests__/dedent-test.js index 55591c83c9..2aa11bf56a 100644 --- a/src/jsutils/__tests__/dedent-test.js +++ b/src/jsutils/__tests__/dedent-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import dedent from '../dedent'; describe('dedent', () => { diff --git a/src/jsutils/__tests__/didYouMean-test.js b/src/jsutils/__tests__/didYouMean-test.js index e9097db77d..ae3d5a42e0 100644 --- a/src/jsutils/__tests__/didYouMean-test.js +++ b/src/jsutils/__tests__/didYouMean-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import didYouMean from '../didYouMean'; describe('didYouMean', () => { diff --git a/src/jsutils/__tests__/identityFunc-test.js b/src/jsutils/__tests__/identityFunc-test.js index ecab946dd7..438f02b2c9 100644 --- a/src/jsutils/__tests__/identityFunc-test.js +++ b/src/jsutils/__tests__/identityFunc-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import identityFunc from '../identityFunc'; describe('identityFunc', () => { diff --git a/src/jsutils/__tests__/inspect-test.js b/src/jsutils/__tests__/inspect-test.js index 36058ff065..bd2e5ee0ee 100644 --- a/src/jsutils/__tests__/inspect-test.js +++ b/src/jsutils/__tests__/inspect-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import inspect from '../inspect'; import nodejsCustomInspectSymbol from '../nodejsCustomInspectSymbol'; diff --git a/src/jsutils/__tests__/instanceOf-test.js b/src/jsutils/__tests__/instanceOf-test.js index 01d24bac8e..b91f03f9ce 100644 --- a/src/jsutils/__tests__/instanceOf-test.js +++ b/src/jsutils/__tests__/instanceOf-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import instanceOf from '../instanceOf'; describe('instanceOf', () => { diff --git a/src/jsutils/__tests__/suggestionList-test.js b/src/jsutils/__tests__/suggestionList-test.js index 4a70272e1f..7dfa158e16 100644 --- a/src/jsutils/__tests__/suggestionList-test.js +++ b/src/jsutils/__tests__/suggestionList-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import suggestionList from '../suggestionList'; describe('suggestionList', () => { diff --git a/src/jsutils/mapValue.js b/src/jsutils/mapValue.js index 1f2d4aae38..4390b4f693 100644 --- a/src/jsutils/mapValue.js +++ b/src/jsutils/mapValue.js @@ -1,8 +1,9 @@ // @flow strict -import { type ObjMap } from './ObjMap'; import objectEntries from '../polyfills/objectEntries'; +import { type ObjMap } from './ObjMap'; + /** * Creates an object map with the same keys as `map` and values generated by * running each value of `map` thru `fn`. diff --git a/src/language/__tests__/blockString-test.js b/src/language/__tests__/blockString-test.js index ed478d6812..dced428f3a 100644 --- a/src/language/__tests__/blockString-test.js +++ b/src/language/__tests__/blockString-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import { dedentBlockStringValue, getBlockStringIndentation, diff --git a/src/language/__tests__/lexer-test.js b/src/language/__tests__/lexer-test.js index 2ad6c7987b..5161af302a 100644 --- a/src/language/__tests__/lexer-test.js +++ b/src/language/__tests__/lexer-test.js @@ -4,9 +4,12 @@ import { inspect as nodeInspect } from 'util'; import { expect } from 'chai'; import { describe, it } from 'mocha'; + import dedent from '../../jsutils/dedent'; import inspect from '../../jsutils/inspect'; + import { GraphQLError } from '../../error'; + import { Source } from '../source'; import { TokenKind } from '../tokenKind'; import { createLexer, isPunctuatorToken } from '../lexer'; diff --git a/src/language/__tests__/parser-benchmark.js b/src/language/__tests__/parser-benchmark.js index 36cf68582c..3a9dc8f579 100644 --- a/src/language/__tests__/parser-benchmark.js +++ b/src/language/__tests__/parser-benchmark.js @@ -1,8 +1,9 @@ // @flow strict -import { kitchenSinkQuery } from '../../__fixtures__'; import { parse } from '../parser'; +import { kitchenSinkQuery } from '../../__fixtures__'; + export const name = 'Parse kitchen sink'; export const count = 1000; export function measure() { diff --git a/src/language/__tests__/parser-test.js b/src/language/__tests__/parser-test.js index dbc68aa651..b704cded4f 100644 --- a/src/language/__tests__/parser-test.js +++ b/src/language/__tests__/parser-test.js @@ -4,14 +4,17 @@ import { inspect as nodeInspect } from 'util'; import { expect } from 'chai'; import { describe, it } from 'mocha'; + +import dedent from '../../jsutils/dedent'; +import inspect from '../../jsutils/inspect'; + import { Kind } from '../kinds'; +import { Source } from '../source'; import { TokenKind } from '../tokenKind'; import { parse, parseValue, parseType } from '../parser'; -import { Source } from '../source'; -import dedent from '../../jsutils/dedent'; -import inspect from '../../jsutils/inspect'; -import toJSONDeep from './toJSONDeep'; + import { kitchenSinkQuery } from '../../__fixtures__'; +import toJSONDeep from './toJSONDeep'; function expectSyntaxError(text, message, location) { expect(() => parse(text)) diff --git a/src/language/__tests__/printLocation-test.js b/src/language/__tests__/printLocation-test.js index 129a872a52..4df39eb7e1 100644 --- a/src/language/__tests__/printLocation-test.js +++ b/src/language/__tests__/printLocation-test.js @@ -4,7 +4,9 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import dedent from '../../jsutils/dedent'; + import { Source } from '../../language'; + import { printSourceLocation } from '../printLocation'; describe('printSourceLocation', () => { diff --git a/src/language/__tests__/printer-test.js b/src/language/__tests__/printer-test.js index 4c8a236b9f..92e2c405df 100644 --- a/src/language/__tests__/printer-test.js +++ b/src/language/__tests__/printer-test.js @@ -2,9 +2,12 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + +import dedent from '../../jsutils/dedent'; + import { parse } from '../parser'; import { print } from '../printer'; -import dedent from '../../jsutils/dedent'; + import { kitchenSinkQuery } from '../../__fixtures__'; describe('Printer: Query document', () => { diff --git a/src/language/__tests__/schema-parser-test.js b/src/language/__tests__/schema-parser-test.js index f25749406d..fb48b7c71c 100644 --- a/src/language/__tests__/schema-parser-test.js +++ b/src/language/__tests__/schema-parser-test.js @@ -2,8 +2,11 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import dedent from '../../jsutils/dedent'; + import { parse } from '../parser'; + import toJSONDeep from './toJSONDeep'; import { kitchenSinkSDL } from '../../__fixtures__'; diff --git a/src/language/__tests__/schema-printer-test.js b/src/language/__tests__/schema-printer-test.js index 08224de981..407445f216 100644 --- a/src/language/__tests__/schema-printer-test.js +++ b/src/language/__tests__/schema-printer-test.js @@ -2,9 +2,12 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + +import dedent from '../../jsutils/dedent'; + import { parse } from '../parser'; import { print } from '../printer'; -import dedent from '../../jsutils/dedent'; + import { kitchenSinkSDL } from '../../__fixtures__'; describe('Printer: SDL document', () => { diff --git a/src/language/__tests__/source-test.js b/src/language/__tests__/source-test.js index f287d12168..a397ef5614 100644 --- a/src/language/__tests__/source-test.js +++ b/src/language/__tests__/source-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import { Source } from '../source'; describe('Source', () => { diff --git a/src/language/__tests__/visitor-test.js b/src/language/__tests__/visitor-test.js index b488ea2d45..8f8ef2c02f 100644 --- a/src/language/__tests__/visitor-test.js +++ b/src/language/__tests__/visitor-test.js @@ -2,14 +2,17 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + +import { getNamedType, isCompositeType } from '../../type'; +import { TypeInfo } from '../../utilities/TypeInfo'; + +import { Kind } from '../kinds'; import { parse } from '../parser'; import { print } from '../printer'; import { visit, visitInParallel, visitWithTypeInfo, BREAK } from '../visitor'; -import { TypeInfo } from '../../utilities/TypeInfo'; -import { testSchema } from '../../validation/__tests__/harness'; -import { getNamedType, isCompositeType } from '../../type'; -import { Kind } from '../kinds'; + import { kitchenSinkQuery } from '../../__fixtures__'; +import { testSchema } from '../../validation/__tests__/harness'; function checkVisitorFnArgs(ast, args, isEdited) { const [node, key, parent, path, ancestors] = args; diff --git a/src/language/lexer.js b/src/language/lexer.js index 57efd1011b..ea29105d69 100644 --- a/src/language/lexer.js +++ b/src/language/lexer.js @@ -1,11 +1,13 @@ // @flow strict import defineToJSON from '../jsutils/defineToJSON'; + +import { syntaxError } from '../error/syntaxError'; + import { type Token } from './ast'; import { type Source } from './source'; -import { type TokenKindEnum, TokenKind } from './tokenKind'; -import { syntaxError } from '../error/syntaxError'; import { dedentBlockStringValue } from './blockString'; +import { type TokenKindEnum, TokenKind } from './tokenKind'; /** * Given a Source object, this returns a Lexer for that source. diff --git a/src/language/parser.js b/src/language/parser.js index 6e3831b2e4..8d06f4d93c 100644 --- a/src/language/parser.js +++ b/src/language/parser.js @@ -3,11 +3,15 @@ import inspect from '../jsutils/inspect'; import invariant from '../jsutils/invariant'; import defineToJSON from '../jsutils/defineToJSON'; -import { Source } from './source'; -import { type GraphQLError } from '../error/GraphQLError'; + import { syntaxError } from '../error/syntaxError'; -import { type TokenKindEnum, TokenKind } from './tokenKind'; +import { type GraphQLError } from '../error/GraphQLError'; + +import { Kind } from './kinds'; +import { Source } from './source'; import { type Lexer, createLexer } from './lexer'; +import { DirectiveLocation } from './directiveLocation'; +import { type TokenKindEnum, TokenKind } from './tokenKind'; import { type Location, type Token, @@ -57,9 +61,6 @@ import { type InputObjectTypeExtensionNode, } from './ast'; -import { Kind } from './kinds'; -import { DirectiveLocation } from './directiveLocation'; - /** * Configuration options to control parser behavior */ diff --git a/src/language/predicates.js b/src/language/predicates.js index 02583c6b88..9cdef3d541 100644 --- a/src/language/predicates.js +++ b/src/language/predicates.js @@ -1,7 +1,7 @@ // @flow strict -import { type ASTNode } from './ast'; import { Kind } from './kinds'; +import { type ASTNode } from './ast'; export function isDefinitionNode(node: ASTNode): boolean %checks { return ( diff --git a/src/language/printLocation.js b/src/language/printLocation.js index 5180fec10c..52a97f2bde 100644 --- a/src/language/printLocation.js +++ b/src/language/printLocation.js @@ -1,7 +1,7 @@ // @flow strict -import { type Source } from '../language/source'; import { type Location } from '../language/ast'; +import { type Source } from '../language/source'; import { type SourceLocation, getLocation } from '../language/location'; /** diff --git a/src/language/printer.js b/src/language/printer.js index b4c2636b4b..a96ff3f3d8 100644 --- a/src/language/printer.js +++ b/src/language/printer.js @@ -1,7 +1,7 @@ // @flow strict -import { type ASTNode } from './ast'; import { visit } from './visitor'; +import { type ASTNode } from './ast'; import { printBlockString } from './blockString'; /** diff --git a/src/language/visitor.js b/src/language/visitor.js index 4665259bae..21189bc56f 100644 --- a/src/language/visitor.js +++ b/src/language/visitor.js @@ -1,9 +1,11 @@ // @flow strict import inspect from '../jsutils/inspect'; -import { type ASTNode, type ASTKindToNode } from './ast'; + import { type TypeInfo } from '../utilities/TypeInfo'; +import { type ASTNode, type ASTKindToNode } from './ast'; + /** * A visitor is provided to visit, it contains the collection of * relevant functions to be called during the visitor's traversal. diff --git a/src/subscription/__tests__/eventEmitterAsyncIterator-test.js b/src/subscription/__tests__/eventEmitterAsyncIterator-test.js index 23a38a1545..6ebbe0c265 100644 --- a/src/subscription/__tests__/eventEmitterAsyncIterator-test.js +++ b/src/subscription/__tests__/eventEmitterAsyncIterator-test.js @@ -1,9 +1,10 @@ // @flow strict +import EventEmitter from 'events'; + import { expect } from 'chai'; import { describe, it } from 'mocha'; -import EventEmitter from 'events'; import eventEmitterAsyncIterator from './eventEmitterAsyncIterator'; describe('eventEmitterAsyncIterator', () => { diff --git a/src/subscription/__tests__/mapAsyncIterator-test.js b/src/subscription/__tests__/mapAsyncIterator-test.js index 91caad28d2..3821917970 100644 --- a/src/subscription/__tests__/mapAsyncIterator-test.js +++ b/src/subscription/__tests__/mapAsyncIterator-test.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import mapAsyncIterator from '../mapAsyncIterator'; describe('mapAsyncIterator', () => { diff --git a/src/subscription/__tests__/subscribe-test.js b/src/subscription/__tests__/subscribe-test.js index 008d1c333a..a6363d4eb9 100644 --- a/src/subscription/__tests__/subscribe-test.js +++ b/src/subscription/__tests__/subscribe-test.js @@ -1,12 +1,12 @@ // @flow strict +import EventEmitter from 'events'; + import { expect } from 'chai'; import { describe, it } from 'mocha'; -import EventEmitter from 'events'; -import eventEmitterAsyncIterator from './eventEmitterAsyncIterator'; -import { createSourceEventStream, subscribe } from '../subscribe'; -import { GraphQLError } from '../../error'; + import { parse } from '../../language'; +import { GraphQLError } from '../../error'; import { GraphQLSchema, GraphQLObjectType, @@ -16,6 +16,10 @@ import { GraphQLString, } from '../../type'; +import { createSourceEventStream, subscribe } from '../subscribe'; + +import eventEmitterAsyncIterator from './eventEmitterAsyncIterator'; + const EmailType = new GraphQLObjectType({ name: 'Email', fields: { diff --git a/src/subscription/mapAsyncIterator.js b/src/subscription/mapAsyncIterator.js index d28bcd7895..e8cb4363c7 100644 --- a/src/subscription/mapAsyncIterator.js +++ b/src/subscription/mapAsyncIterator.js @@ -1,6 +1,7 @@ // @flow strict import { $$asyncIterator, getAsyncIterator } from 'iterall'; + import { type PromiseOrValue } from '../jsutils/PromiseOrValue'; /** diff --git a/src/subscription/subscribe.js b/src/subscription/subscribe.js index 82910b31e1..8958e74952 100644 --- a/src/subscription/subscribe.js +++ b/src/subscription/subscribe.js @@ -1,10 +1,15 @@ // @flow strict import { isAsyncIterable } from 'iterall'; + import inspect from '../jsutils/inspect'; import { addPath, pathToArray } from '../jsutils/Path'; + import { GraphQLError } from '../error/GraphQLError'; import { locatedError } from '../error/locatedError'; + +import { type DocumentNode } from '../language/ast'; + import { type ExecutionResult, assertValidExecutionArguments, @@ -15,13 +20,14 @@ import { getFieldDef, resolveFieldValueOrError, } from '../execution/execute'; -import { type GraphQLSchema } from '../type/schema'; -import mapAsyncIterator from './mapAsyncIterator'; -import { type DocumentNode } from '../language/ast'; +import { type GraphQLSchema } from '../type/schema'; import { type GraphQLFieldResolver } from '../type/definition'; + import { getOperationRootType } from '../utilities/getOperationRootType'; +import mapAsyncIterator from './mapAsyncIterator'; + export type SubscriptionArgs = {| schema: GraphQLSchema, document: DocumentNode, diff --git a/src/type/__tests__/definition-test.js b/src/type/__tests__/definition-test.js index 5f5b9bf717..658c26a974 100644 --- a/src/type/__tests__/definition-test.js +++ b/src/type/__tests__/definition-test.js @@ -1,11 +1,13 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; import inspect from '../../jsutils/inspect'; import identityFunc from '../../jsutils/identityFunc'; + import { parseValue } from '../../language/parser'; + import { type GraphQLType, type GraphQLNullableType, diff --git a/src/type/__tests__/directive-test.js b/src/type/__tests__/directive-test.js index a69817d69a..fd1ea2d02b 100644 --- a/src/type/__tests__/directive-test.js +++ b/src/type/__tests__/directive-test.js @@ -1,7 +1,7 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; import { GraphQLDirective, GraphQLString, GraphQLInt } from '../'; diff --git a/src/type/__tests__/enumType-test.js b/src/type/__tests__/enumType-test.js index 88e36c2c95..a125cb7d88 100644 --- a/src/type/__tests__/enumType-test.js +++ b/src/type/__tests__/enumType-test.js @@ -1,7 +1,8 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; + import { graphqlSync, GraphQLSchema, diff --git a/src/type/__tests__/introspection-test.js b/src/type/__tests__/introspection-test.js index d7863e61a7..857571e249 100644 --- a/src/type/__tests__/introspection-test.js +++ b/src/type/__tests__/introspection-test.js @@ -4,6 +4,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { missingFieldArgMessage } from '../../validation/rules/ProvidedRequiredArguments'; + import { graphqlSync, GraphQLSchema, diff --git a/src/type/__tests__/predicate-test.js b/src/type/__tests__/predicate-test.js index 460c5f0b4a..ab50388b22 100644 --- a/src/type/__tests__/predicate-test.js +++ b/src/type/__tests__/predicate-test.js @@ -1,7 +1,7 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; import { GraphQLScalarType, diff --git a/src/type/__tests__/scalars-test.js b/src/type/__tests__/scalars-test.js index 6ca79e6646..1d2d5a143f 100644 --- a/src/type/__tests__/scalars-test.js +++ b/src/type/__tests__/scalars-test.js @@ -1,7 +1,9 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; + +import { parseValue as parseValueToAST } from '../../language/parser'; import { GraphQLID, @@ -10,7 +12,6 @@ import { GraphQLString, GraphQLBoolean, } from '../scalars'; -import { parseValue as parseValueToAST } from '../../language/parser'; describe('Type System: Specified scalar types', () => { describe('GraphQLInt', () => { diff --git a/src/type/__tests__/schema-test.js b/src/type/__tests__/schema-test.js index e9b91f90fa..2cb5a00816 100644 --- a/src/type/__tests__/schema-test.js +++ b/src/type/__tests__/schema-test.js @@ -1,10 +1,10 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; import dedent from '../../jsutils/dedent'; -import { printSchema } from '../../utilities/schemaPrinter'; + import { GraphQLSchema, GraphQLScalarType, @@ -18,6 +18,8 @@ import { GraphQLList, } from '../'; +import { printSchema } from '../../utilities/schemaPrinter'; + describe('Type System: Schema', () => { it('Define sample schema', () => { const BlogImage = new GraphQLObjectType({ diff --git a/src/type/__tests__/serialization-test.js b/src/type/__tests__/serialization-test.js index 40e6cd46a6..3fc16cda3d 100644 --- a/src/type/__tests__/serialization-test.js +++ b/src/type/__tests__/serialization-test.js @@ -1,5 +1,8 @@ // @flow strict +import { expect } from 'chai'; +import { describe, it } from 'mocha'; + import { GraphQLInt, GraphQLID, @@ -8,9 +11,6 @@ import { GraphQLBoolean, } from '../'; -import { describe, it } from 'mocha'; -import { expect } from 'chai'; - describe('Type System: Scalar coercion', () => { it('serializes output as Int', () => { expect(GraphQLInt.serialize(1)).to.equal(1); diff --git a/src/type/__tests__/validation-test.js b/src/type/__tests__/validation-test.js index 938c2314b3..d0438f032c 100644 --- a/src/type/__tests__/validation-test.js +++ b/src/type/__tests__/validation-test.js @@ -1,8 +1,12 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; + import inspect from '../../jsutils/inspect'; + +import { parse } from '../../language/parser'; + import { type GraphQLNamedType, type GraphQLInputType, @@ -18,10 +22,11 @@ import { GraphQLNonNull, GraphQLString, } from '../../'; -import { parse } from '../../language/parser'; -import { validateSchema } from '../validate'; -import { buildSchema } from '../../utilities/buildASTSchema'; + import { extendSchema } from '../../utilities/extendSchema'; +import { buildSchema } from '../../utilities/buildASTSchema'; + +import { validateSchema } from '../validate'; const SomeScalarType = new GraphQLScalarType({ name: 'SomeScalar' }); diff --git a/src/type/definition.js b/src/type/definition.js index 1501f79b4b..53776274d8 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -4,20 +4,22 @@ // flowlint deprecated-type:off import objectEntries from '../polyfills/objectEntries'; -import defineToJSON from '../jsutils/defineToJSON'; -import defineToStringTag from '../jsutils/defineToStringTag'; -import identityFunc from '../jsutils/identityFunc'; -import instanceOf from '../jsutils/instanceOf'; + import inspect from '../jsutils/inspect'; -import invariant from '../jsutils/invariant'; import keyMap from '../jsutils/keyMap'; -import keyValMap from '../jsutils/keyValMap'; import mapValue from '../jsutils/mapValue'; -import isObjectLike from '../jsutils/isObjectLike'; -import { type ObjMap } from '../jsutils/ObjMap'; import { type Path } from '../jsutils/Path'; +import keyValMap from '../jsutils/keyValMap'; +import { type ObjMap } from '../jsutils/ObjMap'; +import invariant from '../jsutils/invariant'; +import instanceOf from '../jsutils/instanceOf'; +import isObjectLike from '../jsutils/isObjectLike'; +import identityFunc from '../jsutils/identityFunc'; +import defineToJSON from '../jsutils/defineToJSON'; +import defineToStringTag from '../jsutils/defineToStringTag'; +import { type PromiseOrValue } from '../jsutils/PromiseOrValue'; + import { Kind } from '../language/kinds'; -import { valueFromASTUntyped } from '../utilities/valueFromASTUntyped'; import { type ScalarTypeDefinitionNode, type ObjectTypeDefinitionNode, @@ -39,8 +41,10 @@ import { type FragmentDefinitionNode, type ValueNode, } from '../language/ast'; + +import { valueFromASTUntyped } from '../utilities/valueFromASTUntyped'; + import { type GraphQLSchema } from './schema'; -import { type PromiseOrValue } from '../jsutils/PromiseOrValue'; // Predicates & Assertions diff --git a/src/type/directives.js b/src/type/directives.js index 62f0a186ff..46d8c76770 100644 --- a/src/type/directives.js +++ b/src/type/directives.js @@ -1,25 +1,28 @@ // @flow strict import objectEntries from '../polyfills/objectEntries'; + +import inspect from '../jsutils/inspect'; +import invariant from '../jsutils/invariant'; +import instanceOf from '../jsutils/instanceOf'; +import defineToJSON from '../jsutils/defineToJSON'; import isObjectLike from '../jsutils/isObjectLike'; -import { - type GraphQLFieldConfigArgumentMap, - type GraphQLArgument, - argsToArgsConfig, - GraphQLNonNull, -} from './definition'; -import { GraphQLString, GraphQLBoolean } from './scalars'; import defineToStringTag from '../jsutils/defineToStringTag'; -import defineToJSON from '../jsutils/defineToJSON'; -import instanceOf from '../jsutils/instanceOf'; -import invariant from '../jsutils/invariant'; -import inspect from '../jsutils/inspect'; + import { type DirectiveDefinitionNode } from '../language/ast'; import { DirectiveLocation, type DirectiveLocationEnum, } from '../language/directiveLocation'; +import { GraphQLString, GraphQLBoolean } from './scalars'; +import { + type GraphQLFieldConfigArgumentMap, + type GraphQLArgument, + argsToArgsConfig, + GraphQLNonNull, +} from './definition'; + /** * Test if the given value is a GraphQL directive. */ diff --git a/src/type/index.js b/src/type/index.js index 2ec7d3dfb9..ec87a1c7b0 100644 --- a/src/type/index.js +++ b/src/type/index.js @@ -10,7 +10,6 @@ export { // GraphQL Schema definition GraphQLSchema, } from './schema'; - export type { GraphQLSchemaConfig } from './schema'; export { diff --git a/src/type/introspection.js b/src/type/introspection.js index 3bb6a62105..bc5821cacf 100644 --- a/src/type/introspection.js +++ b/src/type/introspection.js @@ -1,9 +1,16 @@ // @flow strict import objectValues from '../polyfills/objectValues'; + import inspect from '../jsutils/inspect'; -import { astFromValue } from '../utilities/astFromValue'; + import { print } from '../language/printer'; +import { DirectiveLocation } from '../language/directiveLocation'; +import { astFromValue } from '../utilities/astFromValue'; + +import { type GraphQLSchema } from './schema'; +import { type GraphQLDirective } from './directives'; +import { GraphQLString, GraphQLBoolean } from './scalars'; import { type GraphQLType, type GraphQLInputField, @@ -25,10 +32,6 @@ import { isAbstractType, isNamedType, } from './definition'; -import { type GraphQLSchema } from './schema'; -import { type GraphQLDirective } from './directives'; -import { GraphQLString, GraphQLBoolean } from './scalars'; -import { DirectiveLocation } from '../language/directiveLocation'; export const __Schema = new GraphQLObjectType({ name: '__Schema', diff --git a/src/type/scalars.js b/src/type/scalars.js index 05f60c63c1..bea0c17964 100644 --- a/src/type/scalars.js +++ b/src/type/scalars.js @@ -2,11 +2,14 @@ import isFinite from '../polyfills/isFinite'; import isInteger from '../polyfills/isInteger'; + import inspect from '../jsutils/inspect'; import isObjectLike from '../jsutils/isObjectLike'; -import { GraphQLScalarType, isScalarType } from './definition'; + import { Kind } from '../language/kinds'; +import { GraphQLScalarType, isScalarType } from './definition'; + // As per the GraphQL Spec, Integers are only treated as valid when a valid // 32-bit signed integer, providing the broadest support across platforms. // diff --git a/src/type/schema.js b/src/type/schema.js index 4608b5f659..3a5343361e 100644 --- a/src/type/schema.js +++ b/src/type/schema.js @@ -2,7 +2,26 @@ import find from '../polyfills/find'; import objectValues from '../polyfills/objectValues'; + +import inspect from '../jsutils/inspect'; +import invariant from '../jsutils/invariant'; +import instanceOf from '../jsutils/instanceOf'; +import { type ObjMap } from '../jsutils/ObjMap'; import isObjectLike from '../jsutils/isObjectLike'; +import defineToStringTag from '../jsutils/defineToStringTag'; + +import { type GraphQLError } from '../error/GraphQLError'; +import { + type SchemaDefinitionNode, + type SchemaExtensionNode, +} from '../language/ast'; + +import { __Schema } from './introspection'; +import { + GraphQLDirective, + isDirective, + specifiedDirectives, +} from './directives'; import { type GraphQLType, type GraphQLNamedType, @@ -15,22 +34,6 @@ import { isInputObjectType, isWrappingType, } from './definition'; -import { - type SchemaDefinitionNode, - type SchemaExtensionNode, -} from '../language/ast'; -import { - GraphQLDirective, - isDirective, - specifiedDirectives, -} from './directives'; -import { type GraphQLError } from '../error/GraphQLError'; -import inspect from '../jsutils/inspect'; -import { __Schema } from './introspection'; -import defineToStringTag from '../jsutils/defineToStringTag'; -import instanceOf from '../jsutils/instanceOf'; -import invariant from '../jsutils/invariant'; -import { type ObjMap } from '../jsutils/ObjMap'; /** * Test if the given value is a GraphQL schema. diff --git a/src/type/validate.js b/src/type/validate.js index 3224a95e79..c4e9b0dc6f 100644 --- a/src/type/validate.js +++ b/src/type/validate.js @@ -4,6 +4,19 @@ import find from '../polyfills/find'; import flatMap from '../polyfills/flatMap'; import objectValues from '../polyfills/objectValues'; import objectEntries from '../polyfills/objectEntries'; + +import inspect from '../jsutils/inspect'; + +import { GraphQLError } from '../error/GraphQLError'; + +import { type ASTNode, type NamedTypeNode } from '../language/ast'; + +import { isValidNameError } from '../utilities/assertValidName'; +import { isEqualType, isTypeSubTypeOf } from '../utilities/typeComparators'; + +import { isDirective } from './directives'; +import { isIntrospectionType } from './introspection'; +import { type GraphQLSchema, assertSchema } from './schema'; import { type GraphQLObjectType, type GraphQLInterfaceType, @@ -21,14 +34,6 @@ import { isOutputType, isRequiredArgument, } from './definition'; -import { isDirective } from './directives'; -import { isIntrospectionType } from './introspection'; -import { type GraphQLSchema, assertSchema } from './schema'; -import inspect from '../jsutils/inspect'; -import { GraphQLError } from '../error/GraphQLError'; -import { type ASTNode, type NamedTypeNode } from '../language/ast'; -import { isValidNameError } from '../utilities/assertValidName'; -import { isEqualType, isTypeSubTypeOf } from '../utilities/typeComparators'; /** * Implements the "Type Validation" sub-sections of the specification's diff --git a/src/utilities/TypeInfo.js b/src/utilities/TypeInfo.js index 0bea95e50d..5675915228 100644 --- a/src/utilities/TypeInfo.js +++ b/src/utilities/TypeInfo.js @@ -1,7 +1,12 @@ // @flow strict import find from '../polyfills/find'; + import { Kind } from '../language/kinds'; +import { type ASTNode, type FieldNode } from '../language/ast'; + +import { type GraphQLSchema } from '../type/schema'; +import { type GraphQLDirective } from '../type/directives'; import { type GraphQLType, type GraphQLInputType, @@ -22,14 +27,12 @@ import { getNullableType, getNamedType, } from '../type/definition'; -import { type GraphQLDirective } from '../type/directives'; import { SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, } from '../type/introspection'; -import { type GraphQLSchema } from '../type/schema'; -import { type ASTNode, type FieldNode } from '../language/ast'; + import { typeFromAST } from './typeFromAST'; /** diff --git a/src/utilities/__tests__/assertValidName-test.js b/src/utilities/__tests__/assertValidName-test.js index c2f3d5b14d..c08b1f723b 100644 --- a/src/utilities/__tests__/assertValidName-test.js +++ b/src/utilities/__tests__/assertValidName-test.js @@ -1,7 +1,8 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; + import { assertValidName } from '../assertValidName'; describe('assertValidName()', () => { diff --git a/src/utilities/__tests__/astFromValue-test.js b/src/utilities/__tests__/astFromValue-test.js index fa4dde3743..0476b99556 100644 --- a/src/utilities/__tests__/astFromValue-test.js +++ b/src/utilities/__tests__/astFromValue-test.js @@ -1,8 +1,8 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; -import { astFromValue } from '../astFromValue'; +import { describe, it } from 'mocha'; + import { GraphQLEnumType, GraphQLInputObjectType, @@ -15,6 +15,8 @@ import { GraphQLNonNull, } from '../../type'; +import { astFromValue } from '../astFromValue'; + describe('astFromValue', () => { it('converts boolean values to ASTs', () => { expect(astFromValue(true, GraphQLBoolean)).to.deep.equal({ diff --git a/src/utilities/__tests__/buildASTSchema-benchmark.js b/src/utilities/__tests__/buildASTSchema-benchmark.js index 5ccd40e238..6a25fafbe3 100644 --- a/src/utilities/__tests__/buildASTSchema-benchmark.js +++ b/src/utilities/__tests__/buildASTSchema-benchmark.js @@ -1,10 +1,11 @@ // @flow strict -import { bigSchemaSDL } from '../../__fixtures__'; - import { parse } from '../../'; + import { buildASTSchema } from '../buildASTSchema'; +import { bigSchemaSDL } from '../../__fixtures__'; + const schemaAST = parse(bigSchemaSDL); export const name = 'Build Schema from AST'; diff --git a/src/utilities/__tests__/buildASTSchema-test.js b/src/utilities/__tests__/buildASTSchema-test.js index 65a0a014cb..fb4d1b6431 100644 --- a/src/utilities/__tests__/buildASTSchema-test.js +++ b/src/utilities/__tests__/buildASTSchema-test.js @@ -2,12 +2,13 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + +import dedent from '../../jsutils/dedent'; import invariant from '../../jsutils/invariant'; + import { parse, print } from '../../language'; -import { printSchema } from '../schemaPrinter'; -import { buildASTSchema, buildSchema } from '../buildASTSchema'; -import dedent from '../../jsutils/dedent'; import { Kind } from '../../language/kinds'; + import { assertDirective, assertObjectType, @@ -28,6 +29,9 @@ import { GraphQLDeprecatedDirective, } from '../../'; +import { printSchema } from '../schemaPrinter'; +import { buildASTSchema, buildSchema } from '../buildASTSchema'; + /** * This function does a full cycle of going from a string with the contents of * the SDL, parsed in a schema AST, materializing that schema AST into an diff --git a/src/utilities/__tests__/buildClientSchema-benchmark.js b/src/utilities/__tests__/buildClientSchema-benchmark.js index 39872f4c5c..d7d9500ed3 100644 --- a/src/utilities/__tests__/buildClientSchema-benchmark.js +++ b/src/utilities/__tests__/buildClientSchema-benchmark.js @@ -1,9 +1,9 @@ // @flow strict -import { bigSchemaIntrospectionResult } from '../../__fixtures__'; - import { buildClientSchema } from '../buildClientSchema'; +import { bigSchemaIntrospectionResult } from '../../__fixtures__'; + export const name = 'Build Schema from Introspection'; export const count = 10; export function measure() { diff --git a/src/utilities/__tests__/buildClientSchema-test.js b/src/utilities/__tests__/buildClientSchema-test.js index 8b5e835292..370e16a09c 100644 --- a/src/utilities/__tests__/buildClientSchema-test.js +++ b/src/utilities/__tests__/buildClientSchema-test.js @@ -1,10 +1,10 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; + import dedent from '../../jsutils/dedent'; -import { buildClientSchema } from '../buildClientSchema'; -import { introspectionFromSchema } from '../introspectionFromSchema'; + import { buildSchema, printSchema, @@ -20,6 +20,9 @@ import { GraphQLID, } from '../../'; +import { buildClientSchema } from '../buildClientSchema'; +import { introspectionFromSchema } from '../introspectionFromSchema'; + /** * This function does a full cycle of going from a string with the contents of * the SDL, build in-memory GraphQLSchema from it, produce a client-side diff --git a/src/utilities/__tests__/coerceValue-test.js b/src/utilities/__tests__/coerceValue-test.js index f23ad0972b..be6953299c 100644 --- a/src/utilities/__tests__/coerceValue-test.js +++ b/src/utilities/__tests__/coerceValue-test.js @@ -1,17 +1,19 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; import invariant from '../../jsutils/invariant'; + +import { GraphQLInt } from '../../type/scalars'; import { - GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLScalarType, GraphQLEnumType, GraphQLInputObjectType, -} from '../../type'; +} from '../../type/definition'; + import { coerceValue } from '../coerceValue'; function expectValue(result) { diff --git a/src/utilities/__tests__/concatAST-test.js b/src/utilities/__tests__/concatAST-test.js index 3b8e47f6a3..8cf8d7f0a9 100644 --- a/src/utilities/__tests__/concatAST-test.js +++ b/src/utilities/__tests__/concatAST-test.js @@ -1,11 +1,14 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; + import dedent from '../../jsutils/dedent'; -import { concatAST } from '../concatAST'; + import { Source, parse, print } from '../../language'; +import { concatAST } from '../concatAST'; + describe('concatAST', () => { it('concats two ASTs together', () => { const sourceA = new Source(` diff --git a/src/utilities/__tests__/extendSchema-test.js b/src/utilities/__tests__/extendSchema-test.js index fb4944506e..836effcac5 100644 --- a/src/utilities/__tests__/extendSchema-test.js +++ b/src/utilities/__tests__/extendSchema-test.js @@ -1,15 +1,16 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; + import dedent from '../../jsutils/dedent'; import invariant from '../../jsutils/invariant'; -import { buildSchema } from '../buildASTSchema'; -import { extendSchema } from '../extendSchema'; -import { parse, print, DirectiveLocation } from '../../language'; -import { printSchema } from '../schemaPrinter'; + import { Kind } from '../../language/kinds'; +import { parse, print, DirectiveLocation } from '../../language'; + import { graphqlSync } from '../../'; + import { assertDirective, assertObjectType, @@ -37,6 +38,10 @@ import { specifiedDirectives, } from '../../type'; +import { printSchema } from '../schemaPrinter'; +import { extendSchema } from '../extendSchema'; +import { buildSchema } from '../buildASTSchema'; + // Test schema. const SomeScalarType = new GraphQLScalarType({ name: 'SomeScalar' }); diff --git a/src/utilities/__tests__/findBreakingChanges-test.js b/src/utilities/__tests__/findBreakingChanges-test.js index b2073dbafe..789d71e9a5 100644 --- a/src/utilities/__tests__/findBreakingChanges-test.js +++ b/src/utilities/__tests__/findBreakingChanges-test.js @@ -4,9 +4,13 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { GraphQLSchema } from '../../type'; +import { + GraphQLSkipDirective, + GraphQLIncludeDirective, + GraphQLDeprecatedDirective, +} from '../../type/directives'; import { buildSchema } from '../buildASTSchema'; - import { BreakingChangeType, DangerousChangeType, @@ -14,12 +18,6 @@ import { findDangerousChanges, } from '../findBreakingChanges'; -import { - GraphQLSkipDirective, - GraphQLIncludeDirective, - GraphQLDeprecatedDirective, -} from '../../type/directives'; - describe('findBreakingChanges', () => { it('should detect if a type was removed or not', () => { const oldSchema = buildSchema(` diff --git a/src/utilities/__tests__/findDeprecatedUsages-test.js b/src/utilities/__tests__/findDeprecatedUsages-test.js index a59571b52e..d0da589f8d 100644 --- a/src/utilities/__tests__/findDeprecatedUsages-test.js +++ b/src/utilities/__tests__/findDeprecatedUsages-test.js @@ -2,9 +2,11 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { findDeprecatedUsages } from '../findDeprecatedUsages'; + import { parse } from '../../language'; + import { buildSchema } from '../buildASTSchema'; +import { findDeprecatedUsages } from '../findDeprecatedUsages'; describe('findDeprecatedUsages', () => { const schema = buildSchema(` diff --git a/src/utilities/__tests__/getOperationAST-test.js b/src/utilities/__tests__/getOperationAST-test.js index 96719de334..7ddf293d37 100644 --- a/src/utilities/__tests__/getOperationAST-test.js +++ b/src/utilities/__tests__/getOperationAST-test.js @@ -2,7 +2,9 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import { parse } from '../../language'; + import { getOperationAST } from '../getOperationAST'; describe('getOperationAST', () => { diff --git a/src/utilities/__tests__/getOperationRootType-test.js b/src/utilities/__tests__/getOperationRootType-test.js index cfaa617397..d7709be92f 100644 --- a/src/utilities/__tests__/getOperationRootType-test.js +++ b/src/utilities/__tests__/getOperationRootType-test.js @@ -2,8 +2,9 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import invariant from '../../jsutils/invariant'; -import { getOperationRootType } from '../getOperationRootType'; + import { Kind, parse, @@ -12,6 +13,8 @@ import { GraphQLString, } from '../../'; +import { getOperationRootType } from '../getOperationRootType'; + const queryType = new GraphQLObjectType({ name: 'FooQuery', fields: () => ({ diff --git a/src/utilities/__tests__/introspectionFromSchema-benchmark.js b/src/utilities/__tests__/introspectionFromSchema-benchmark.js index 3f681019cd..517e13a5b0 100644 --- a/src/utilities/__tests__/introspectionFromSchema-benchmark.js +++ b/src/utilities/__tests__/introspectionFromSchema-benchmark.js @@ -1,11 +1,12 @@ // @flow strict -import { bigSchemaSDL } from '../../__fixtures__'; - import { execute, parse } from '../../'; + import { buildSchema } from '../buildASTSchema'; import { getIntrospectionQuery } from '../introspectionQuery'; +import { bigSchemaSDL } from '../../__fixtures__'; + const queryAST = parse(getIntrospectionQuery()); const schema = buildSchema(bigSchemaSDL, { assumeValid: true }); diff --git a/src/utilities/__tests__/introspectionFromSchema-test.js b/src/utilities/__tests__/introspectionFromSchema-test.js index d237ef2745..5bd1a18bf8 100644 --- a/src/utilities/__tests__/introspectionFromSchema-test.js +++ b/src/utilities/__tests__/introspectionFromSchema-test.js @@ -1,10 +1,12 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; import dedent from '../../jsutils/dedent'; + import { GraphQLSchema, GraphQLObjectType, GraphQLString } from '../../type'; + import { printSchema } from '../schemaPrinter'; import { buildClientSchema } from '../buildClientSchema'; import { introspectionFromSchema } from '../introspectionFromSchema'; diff --git a/src/utilities/__tests__/isValidLiteralValue-test.js b/src/utilities/__tests__/isValidLiteralValue-test.js index 83cf49f09f..1f2b30e8a4 100644 --- a/src/utilities/__tests__/isValidLiteralValue-test.js +++ b/src/utilities/__tests__/isValidLiteralValue-test.js @@ -2,10 +2,12 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { isValidLiteralValue } from '../isValidLiteralValue'; + import { parseValue } from '../../language'; import { GraphQLInt } from '../../type'; +import { isValidLiteralValue } from '../isValidLiteralValue'; + describe('isValidLiteralValue', () => { it('Returns no errors for a valid value', () => { expect(isValidLiteralValue(GraphQLInt, parseValue('123'))).to.deep.equal( diff --git a/src/utilities/__tests__/lexicographicSortSchema-test.js b/src/utilities/__tests__/lexicographicSortSchema-test.js index 739a36ef33..01839ce88b 100644 --- a/src/utilities/__tests__/lexicographicSortSchema-test.js +++ b/src/utilities/__tests__/lexicographicSortSchema-test.js @@ -1,8 +1,10 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; + import dedent from '../../jsutils/dedent'; + import { printSchema } from '../schemaPrinter'; import { buildSchema } from '../buildASTSchema'; import { lexicographicSortSchema } from '../lexicographicSortSchema'; diff --git a/src/utilities/__tests__/schemaPrinter-test.js b/src/utilities/__tests__/schemaPrinter-test.js index 51470111cd..f937483953 100644 --- a/src/utilities/__tests__/schemaPrinter-test.js +++ b/src/utilities/__tests__/schemaPrinter-test.js @@ -1,10 +1,12 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; + import dedent from '../../jsutils/dedent'; -import { printSchema, printIntrospectionSchema } from '../schemaPrinter'; -import { buildSchema } from '../buildASTSchema'; + +import { DirectiveLocation } from '../../language/directiveLocation'; + import { assertObjectType, GraphQLSchema, @@ -21,7 +23,9 @@ import { GraphQLNonNull, } from '../../'; import { GraphQLDirective } from '../../type/directives'; -import { DirectiveLocation } from '../../language/directiveLocation'; + +import { buildSchema } from '../buildASTSchema'; +import { printSchema, printIntrospectionSchema } from '../schemaPrinter'; function printForTest(schema) { const schemaText = printSchema(schema); diff --git a/src/utilities/__tests__/separateOperations-test.js b/src/utilities/__tests__/separateOperations-test.js index 3ed8d61774..d7c943ef0e 100644 --- a/src/utilities/__tests__/separateOperations-test.js +++ b/src/utilities/__tests__/separateOperations-test.js @@ -1,11 +1,14 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; + import dedent from '../../jsutils/dedent'; -import { separateOperations } from '../separateOperations'; + import { parse, print } from '../../language'; +import { separateOperations } from '../separateOperations'; + describe('separateOperations', () => { it('separates one AST into multiple, maintaining document order', () => { const ast = parse(` diff --git a/src/utilities/__tests__/stripIgnoredCharacters-test.js b/src/utilities/__tests__/stripIgnoredCharacters-test.js index 35c9f6cf13..81c226b417 100644 --- a/src/utilities/__tests__/stripIgnoredCharacters-test.js +++ b/src/utilities/__tests__/stripIgnoredCharacters-test.js @@ -5,10 +5,13 @@ import { describe, it } from 'mocha'; import dedent from '../../jsutils/dedent'; import invariant from '../../jsutils/invariant'; + import { parse, createLexer, Source } from '../../language'; -import { kitchenSinkQuery, kitchenSinkSDL } from '../../__fixtures__'; + import { stripIgnoredCharacters } from '../stripIgnoredCharacters'; +import { kitchenSinkQuery, kitchenSinkSDL } from '../../__fixtures__'; + const ignoredTokens = [ // UnicodeBOM :: '\uFEFF', // Byte Order Mark (U+FEFF) diff --git a/src/utilities/__tests__/typeComparators-test.js b/src/utilities/__tests__/typeComparators-test.js index f6b3c80d6f..8068ce263b 100644 --- a/src/utilities/__tests__/typeComparators-test.js +++ b/src/utilities/__tests__/typeComparators-test.js @@ -1,7 +1,8 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; +import { describe, it } from 'mocha'; + import { GraphQLSchema, GraphQLString, @@ -13,6 +14,7 @@ import { GraphQLInterfaceType, GraphQLUnionType, } from '../../type'; + import { isEqualType, isTypeSubTypeOf } from '../typeComparators'; describe('typeComparators', () => { diff --git a/src/utilities/__tests__/valueFromAST-test.js b/src/utilities/__tests__/valueFromAST-test.js index b937d42708..34d1d36e63 100644 --- a/src/utilities/__tests__/valueFromAST-test.js +++ b/src/utilities/__tests__/valueFromAST-test.js @@ -1,8 +1,9 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; -import { valueFromAST } from '../valueFromAST'; +import { describe, it } from 'mocha'; + +import { parseValue } from '../../language'; import { GraphQLEnumType, GraphQLInputObjectType, @@ -14,7 +15,8 @@ import { GraphQLID, GraphQLNonNull, } from '../../type'; -import { parseValue } from '../../language'; + +import { valueFromAST } from '../valueFromAST'; describe('valueFromAST', () => { function testCase(type, valueText, expected) { diff --git a/src/utilities/__tests__/valueFromASTUntyped-test.js b/src/utilities/__tests__/valueFromASTUntyped-test.js index d18e4e877c..061850d801 100644 --- a/src/utilities/__tests__/valueFromASTUntyped-test.js +++ b/src/utilities/__tests__/valueFromASTUntyped-test.js @@ -1,10 +1,12 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; -import { valueFromASTUntyped } from '../valueFromASTUntyped'; +import { describe, it } from 'mocha'; + import { parseValue } from '../../language'; +import { valueFromASTUntyped } from '../valueFromASTUntyped'; + describe('valueFromASTUntyped', () => { function testCase(valueText, expected) { expect(valueFromASTUntyped(parseValue(valueText))).to.deep.equal(expected); diff --git a/src/utilities/assertValidName.js b/src/utilities/assertValidName.js index 632b2230d8..7a132d944d 100644 --- a/src/utilities/assertValidName.js +++ b/src/utilities/assertValidName.js @@ -1,8 +1,9 @@ // @flow strict +import invariant from '../jsutils/invariant'; + import { GraphQLError } from '../error/GraphQLError'; import { type ASTNode } from '../language/ast'; -import invariant from '../jsutils/invariant'; const NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/; diff --git a/src/utilities/astFromValue.js b/src/utilities/astFromValue.js index a697cbcca9..82f47c7005 100644 --- a/src/utilities/astFromValue.js +++ b/src/utilities/astFromValue.js @@ -3,12 +3,16 @@ import { forEach, isCollection } from 'iterall'; import objectValues from '../polyfills/objectValues'; + import inspect from '../jsutils/inspect'; import isNullish from '../jsutils/isNullish'; import isInvalid from '../jsutils/isInvalid'; import isObjectLike from '../jsutils/isObjectLike'; -import { type ValueNode } from '../language/ast'; + import { Kind } from '../language/kinds'; +import { type ValueNode } from '../language/ast'; + +import { GraphQLID } from '../type/scalars'; import { type GraphQLInputType, isLeafType, @@ -17,7 +21,6 @@ import { isListType, isNonNullType, } from '../type/definition'; -import { GraphQLID } from '../type/scalars'; /** * Produces a GraphQL Value AST given a JavaScript value. diff --git a/src/utilities/buildASTSchema.js b/src/utilities/buildASTSchema.js index 3694e81cfe..16fcac87f3 100644 --- a/src/utilities/buildASTSchema.js +++ b/src/utilities/buildASTSchema.js @@ -1,20 +1,20 @@ // @flow strict import objectValues from '../polyfills/objectValues'; + +import keyMap from '../jsutils/keyMap'; import inspect from '../jsutils/inspect'; import invariant from '../jsutils/invariant'; -import keyMap from '../jsutils/keyMap'; import keyValMap from '../jsutils/keyValMap'; import { type ObjMap } from '../jsutils/ObjMap'; -import { valueFromAST } from './valueFromAST'; -import { assertValidSDL } from '../validation/validate'; -import { dedentBlockStringValue } from '../language/blockString'; + +import { Kind } from '../language/kinds'; +import { type Source } from '../language/source'; import { TokenKind } from '../language/tokenKind'; import { type ParseOptions, parse } from '../language/parser'; -import { type Source } from '../language/source'; -import { getDirectiveValues } from '../execution/values'; -import { Kind } from '../language/kinds'; - +import { isTypeDefinitionNode } from '../language/predicates'; +import { dedentBlockStringValue } from '../language/blockString'; +import { type DirectiveLocationEnum } from '../language/directiveLocation'; import { type DocumentNode, type NameNode, @@ -35,10 +35,23 @@ import { type StringValueNode, type Location, } from '../language/ast'; -import { isTypeDefinitionNode } from '../language/predicates'; -import { type DirectiveLocationEnum } from '../language/directiveLocation'; +import { assertValidSDL } from '../validation/validate'; +import { getDirectiveValues } from '../execution/values'; + +import { specifiedScalarTypes } from '../type/scalars'; +import { introspectionTypes } from '../type/introspection'; +import { + type GraphQLSchemaValidationOptions, + GraphQLSchema, +} from '../type/schema'; +import { + GraphQLDirective, + GraphQLSkipDirective, + GraphQLIncludeDirective, + GraphQLDeprecatedDirective, +} from '../type/directives'; import { type GraphQLType, type GraphQLNamedType, @@ -56,21 +69,7 @@ import { GraphQLNonNull, } from '../type/definition'; -import { - GraphQLDirective, - GraphQLSkipDirective, - GraphQLIncludeDirective, - GraphQLDeprecatedDirective, -} from '../type/directives'; - -import { introspectionTypes } from '../type/introspection'; - -import { specifiedScalarTypes } from '../type/scalars'; - -import { - type GraphQLSchemaValidationOptions, - GraphQLSchema, -} from '../type/schema'; +import { valueFromAST } from './valueFromAST'; export type BuildSchemaOptions = { ...GraphQLSchemaValidationOptions, diff --git a/src/utilities/buildClientSchema.js b/src/utilities/buildClientSchema.js index fb1d236090..b9f4df119d 100644 --- a/src/utilities/buildClientSchema.js +++ b/src/utilities/buildClientSchema.js @@ -1,17 +1,21 @@ // @flow strict import objectValues from '../polyfills/objectValues'; + import inspect from '../jsutils/inspect'; import invariant from '../jsutils/invariant'; import keyValMap from '../jsutils/keyValMap'; import isObjectLike from '../jsutils/isObjectLike'; -import { valueFromAST } from './valueFromAST'; + import { parseValue } from '../language/parser'; + +import { GraphQLDirective } from '../type/directives'; +import { specifiedScalarTypes } from '../type/scalars'; +import { introspectionTypes, TypeKind } from '../type/introspection'; import { type GraphQLSchemaValidationOptions, GraphQLSchema, } from '../type/schema'; - import { type GraphQLType, type GraphQLInputType, @@ -32,12 +36,7 @@ import { assertInterfaceType, } from '../type/definition'; -import { GraphQLDirective } from '../type/directives'; - -import { introspectionTypes, TypeKind } from '../type/introspection'; - -import { specifiedScalarTypes } from '../type/scalars'; - +import { valueFromAST } from './valueFromAST'; import { type IntrospectionQuery, type IntrospectionType, diff --git a/src/utilities/coerceValue.js b/src/utilities/coerceValue.js index b8e424b1c0..08a0b92c65 100644 --- a/src/utilities/coerceValue.js +++ b/src/utilities/coerceValue.js @@ -1,12 +1,15 @@ // @flow strict import { forEach, isCollection } from 'iterall'; + import objectValues from '../polyfills/objectValues'; + import inspect from '../jsutils/inspect'; import didYouMean from '../jsutils/didYouMean'; import isObjectLike from '../jsutils/isObjectLike'; import suggestionList from '../jsutils/suggestionList'; import { type Path, addPath, pathToArray } from '../jsutils/Path'; + import { GraphQLError } from '../error/GraphQLError'; import { type ASTNode } from '../language/ast'; import { diff --git a/src/utilities/concatAST.js b/src/utilities/concatAST.js index bc9904eed8..aedc27e474 100644 --- a/src/utilities/concatAST.js +++ b/src/utilities/concatAST.js @@ -1,6 +1,7 @@ // @flow strict import flatMap from '../polyfills/flatMap'; + import { type DocumentNode } from '../language/ast'; /** diff --git a/src/utilities/extendSchema.js b/src/utilities/extendSchema.js index 123a1c0ab0..14b78cbc77 100644 --- a/src/utilities/extendSchema.js +++ b/src/utilities/extendSchema.js @@ -2,20 +2,34 @@ import flatMap from '../polyfills/flatMap'; import objectValues from '../polyfills/objectValues'; + import inspect from '../jsutils/inspect'; -import invariant from '../jsutils/invariant'; import mapValue from '../jsutils/mapValue'; +import invariant from '../jsutils/invariant'; import keyValMap from '../jsutils/keyValMap'; -import { ASTDefinitionBuilder } from './buildASTSchema'; + +import { Kind } from '../language/kinds'; +import { + isTypeDefinitionNode, + isTypeExtensionNode, +} from '../language/predicates'; +import { + type DocumentNode, + type DirectiveDefinitionNode, + type SchemaExtensionNode, + type SchemaDefinitionNode, +} from '../language/ast'; + import { assertValidSDLExtension } from '../validation/validate'; + +import { GraphQLDirective } from '../type/directives'; +import { isSpecifiedScalarType } from '../type/scalars'; +import { isIntrospectionType } from '../type/introspection'; import { type GraphQLSchemaValidationOptions, assertSchema, GraphQLSchema, } from '../type/schema'; -import { isIntrospectionType } from '../type/introspection'; -import { isSpecifiedScalarType } from '../type/scalars'; - import { type GraphQLNamedType, isScalarType, @@ -36,20 +50,7 @@ import { GraphQLInputObjectType, } from '../type/definition'; -import { GraphQLDirective } from '../type/directives'; - -import { Kind } from '../language/kinds'; - -import { - type DocumentNode, - type DirectiveDefinitionNode, - type SchemaExtensionNode, - type SchemaDefinitionNode, -} from '../language/ast'; -import { - isTypeDefinitionNode, - isTypeExtensionNode, -} from '../language/predicates'; +import { ASTDefinitionBuilder } from './buildASTSchema'; type Options = {| ...GraphQLSchemaValidationOptions, diff --git a/src/utilities/findBreakingChanges.js b/src/utilities/findBreakingChanges.js index dd7a4630ab..f3cb01dfe7 100644 --- a/src/utilities/findBreakingChanges.js +++ b/src/utilities/findBreakingChanges.js @@ -1,10 +1,14 @@ // @flow strict import objectValues from '../polyfills/objectValues'; + import keyMap from '../jsutils/keyMap'; import inspect from '../jsutils/inspect'; import invariant from '../jsutils/invariant'; + import { print } from '../language/printer'; + +import { type GraphQLSchema } from '../type/schema'; import { type GraphQLField, type GraphQLType, @@ -27,7 +31,7 @@ import { isRequiredArgument, isRequiredInputField, } from '../type/definition'; -import { type GraphQLSchema } from '../type/schema'; + import { astFromValue } from './astFromValue'; export const BreakingChangeType = Object.freeze({ diff --git a/src/utilities/findDeprecatedUsages.js b/src/utilities/findDeprecatedUsages.js index 7be101eaee..bc3dbaadc8 100644 --- a/src/utilities/findDeprecatedUsages.js +++ b/src/utilities/findDeprecatedUsages.js @@ -1,10 +1,13 @@ // @flow strict import { GraphQLError } from '../error/GraphQLError'; -import { visit, visitWithTypeInfo } from '../language/visitor'; + import { type DocumentNode } from '../language/ast'; +import { visit, visitWithTypeInfo } from '../language/visitor'; + import { getNamedType } from '../type/definition'; import { type GraphQLSchema } from '../type/schema'; + import { TypeInfo } from './TypeInfo'; /** diff --git a/src/utilities/getOperationRootType.js b/src/utilities/getOperationRootType.js index 9ac9c03130..107c6de8b8 100644 --- a/src/utilities/getOperationRootType.js +++ b/src/utilities/getOperationRootType.js @@ -1,10 +1,12 @@ // @flow strict import { GraphQLError } from '../error/GraphQLError'; + import { type OperationDefinitionNode, type OperationTypeDefinitionNode, } from '../language/ast'; + import { type GraphQLSchema } from '../type/schema'; import { type GraphQLObjectType } from '../type/definition'; diff --git a/src/utilities/introspectionFromSchema.js b/src/utilities/introspectionFromSchema.js index c67ec78b0a..48b39819ba 100644 --- a/src/utilities/introspectionFromSchema.js +++ b/src/utilities/introspectionFromSchema.js @@ -2,9 +2,11 @@ import invariant from '../jsutils/invariant'; import isPromise from '../jsutils/isPromise'; -import { type GraphQLSchema } from '../type/schema'; -import { execute } from '../execution/execute'; + import { parse } from '../language/parser'; +import { execute } from '../execution/execute'; +import { type GraphQLSchema } from '../type/schema'; + import { type IntrospectionQuery, type IntrospectionOptions, diff --git a/src/utilities/isValidJSValue.js b/src/utilities/isValidJSValue.js index 5d0a84bf36..fb172ad9d9 100644 --- a/src/utilities/isValidJSValue.js +++ b/src/utilities/isValidJSValue.js @@ -1,9 +1,10 @@ // @flow strict /* istanbul ignore file */ -import { coerceValue } from './coerceValue'; import { type GraphQLInputType } from '../type/definition'; +import { coerceValue } from './coerceValue'; + /** * Deprecated. Use coerceValue() directly for richer information. * diff --git a/src/utilities/isValidLiteralValue.js b/src/utilities/isValidLiteralValue.js index 24cdefd007..d0d13d3d90 100644 --- a/src/utilities/isValidLiteralValue.js +++ b/src/utilities/isValidLiteralValue.js @@ -1,15 +1,19 @@ // @flow strict -import { TypeInfo } from './TypeInfo'; import { type GraphQLError } from '../error/GraphQLError'; -import { type ValueNode } from '../language/ast'; + import { Kind } from '../language/kinds'; +import { type ValueNode } from '../language/ast'; import { visit, visitWithTypeInfo } from '../language/visitor'; -import { type GraphQLInputType } from '../type/definition'; -import { GraphQLSchema } from '../type/schema'; + import { ValuesOfCorrectType } from '../validation/rules/ValuesOfCorrectType'; import { ValidationContext } from '../validation/ValidationContext'; +import { type GraphQLInputType } from '../type/definition'; +import { GraphQLSchema } from '../type/schema'; + +import { TypeInfo } from './TypeInfo'; + /** * Utility which determines if a value literal node is valid for an input type. * diff --git a/src/utilities/lexicographicSortSchema.js b/src/utilities/lexicographicSortSchema.js index cf6675e840..67b31f281c 100644 --- a/src/utilities/lexicographicSortSchema.js +++ b/src/utilities/lexicographicSortSchema.js @@ -1,11 +1,14 @@ // @flow strict import objectValues from '../polyfills/objectValues'; + import inspect from '../jsutils/inspect'; import keyValMap from '../jsutils/keyValMap'; import { type ObjMap } from '../jsutils/ObjMap'; + import { GraphQLSchema } from '../type/schema'; import { GraphQLDirective } from '../type/directives'; +import { isIntrospectionType } from '../type/introspection'; import { type GraphQLNamedType, GraphQLObjectType, @@ -24,7 +27,6 @@ import { isEnumType, isInputObjectType, } from '../type/definition'; -import { isIntrospectionType } from '../type/introspection'; /** * Sort GraphQLSchema. diff --git a/src/utilities/schemaPrinter.js b/src/utilities/schemaPrinter.js index 634712ea81..437737cb93 100644 --- a/src/utilities/schemaPrinter.js +++ b/src/utilities/schemaPrinter.js @@ -2,11 +2,20 @@ import flatMap from '../polyfills/flatMap'; import objectValues from '../polyfills/objectValues'; + import inspect from '../jsutils/inspect'; -import { astFromValue } from '../utilities/astFromValue'; + import { print } from '../language/printer'; import { printBlockString } from '../language/blockString'; + import { type GraphQLSchema } from '../type/schema'; +import { isIntrospectionType } from '../type/introspection'; +import { GraphQLString, isSpecifiedScalarType } from '../type/scalars'; +import { + GraphQLDirective, + DEFAULT_DEPRECATION_REASON, + isSpecifiedDirective, +} from '../type/directives'; import { type GraphQLNamedType, type GraphQLScalarType, @@ -22,13 +31,8 @@ import { isEnumType, isInputObjectType, } from '../type/definition'; -import { GraphQLString, isSpecifiedScalarType } from '../type/scalars'; -import { - GraphQLDirective, - DEFAULT_DEPRECATION_REASON, - isSpecifiedDirective, -} from '../type/directives'; -import { isIntrospectionType } from '../type/introspection'; + +import { astFromValue } from '../utilities/astFromValue'; type Options = {| /** diff --git a/src/utilities/separateOperations.js b/src/utilities/separateOperations.js index 8961396a1a..8c73e37672 100644 --- a/src/utilities/separateOperations.js +++ b/src/utilities/separateOperations.js @@ -1,7 +1,8 @@ // @flow strict -import { visit } from '../language/visitor'; import { type ObjMap } from '../jsutils/ObjMap'; + +import { visit } from '../language/visitor'; import { type DocumentNode, type OperationDefinitionNode, diff --git a/src/utilities/stripIgnoredCharacters.js b/src/utilities/stripIgnoredCharacters.js index a5be9337bb..caaea78354 100644 --- a/src/utilities/stripIgnoredCharacters.js +++ b/src/utilities/stripIgnoredCharacters.js @@ -1,6 +1,7 @@ // @flow strict import inspect from '../jsutils/inspect'; + import { Source } from '../language/source'; import { TokenKind } from '../language/tokenKind'; import { createLexer, isPunctuatorToken } from '../language/lexer'; diff --git a/src/utilities/typeComparators.js b/src/utilities/typeComparators.js index cab64d1e3a..9b70895bf0 100644 --- a/src/utilities/typeComparators.js +++ b/src/utilities/typeComparators.js @@ -1,5 +1,6 @@ // @flow strict +import { type GraphQLSchema } from '../type/schema'; import { type GraphQLType, type GraphQLCompositeType, @@ -8,7 +9,6 @@ import { isNonNullType, isAbstractType, } from '../type/definition'; -import { type GraphQLSchema } from '../type/schema'; /** * Provided two types, return true if the types are equal (invariant). diff --git a/src/utilities/typeFromAST.js b/src/utilities/typeFromAST.js index 76dd137f0e..30a2dbea45 100644 --- a/src/utilities/typeFromAST.js +++ b/src/utilities/typeFromAST.js @@ -1,18 +1,20 @@ // @flow strict import inspect from '../jsutils/inspect'; + import { Kind } from '../language/kinds'; import { type NamedTypeNode, type ListTypeNode, type NonNullTypeNode, } from '../language/ast'; + +import { type GraphQLSchema } from '../type/schema'; import { type GraphQLNamedType, GraphQLList, GraphQLNonNull, } from '../type/definition'; -import { type GraphQLSchema } from '../type/schema'; /** * Given a Schema and an AST node describing a type, return a GraphQLType diff --git a/src/utilities/valueFromAST.js b/src/utilities/valueFromAST.js index f2c2fb4769..402a9c676e 100644 --- a/src/utilities/valueFromAST.js +++ b/src/utilities/valueFromAST.js @@ -1,11 +1,15 @@ // @flow strict import objectValues from '../polyfills/objectValues'; -import inspect from '../jsutils/inspect'; + import keyMap from '../jsutils/keyMap'; +import inspect from '../jsutils/inspect'; import isInvalid from '../jsutils/isInvalid'; import { type ObjMap } from '../jsutils/ObjMap'; + import { Kind } from '../language/kinds'; +import { type ValueNode } from '../language/ast'; + import { type GraphQLInputType, isScalarType, @@ -14,7 +18,6 @@ import { isListType, isNonNullType, } from '../type/definition'; -import { type ValueNode } from '../language/ast'; /** * Produces a JavaScript value given a GraphQL Value AST. diff --git a/src/utilities/valueFromASTUntyped.js b/src/utilities/valueFromASTUntyped.js index d57583b263..52b824c9ae 100644 --- a/src/utilities/valueFromASTUntyped.js +++ b/src/utilities/valueFromASTUntyped.js @@ -4,6 +4,7 @@ import inspect from '../jsutils/inspect'; import keyValMap from '../jsutils/keyValMap'; import isInvalid from '../jsutils/isInvalid'; import { type ObjMap } from '../jsutils/ObjMap'; + import { Kind } from '../language/kinds'; import { type ValueNode } from '../language/ast'; diff --git a/src/validation/ValidationContext.js b/src/validation/ValidationContext.js index 35a594996d..26400c33f1 100644 --- a/src/validation/ValidationContext.js +++ b/src/validation/ValidationContext.js @@ -1,9 +1,11 @@ // @flow strict import { type ObjMap } from '../jsutils/ObjMap'; + import { type GraphQLError } from '../error/GraphQLError'; -import { type ASTVisitor, visit, visitWithTypeInfo } from '../language/visitor'; + import { Kind } from '../language/kinds'; +import { type ASTVisitor, visit, visitWithTypeInfo } from '../language/visitor'; import { type DocumentNode, type OperationDefinitionNode, @@ -12,7 +14,9 @@ import { type FragmentSpreadNode, type FragmentDefinitionNode, } from '../language/ast'; + import { type GraphQLSchema } from '../type/schema'; +import { type GraphQLDirective } from '../type/directives'; import { type GraphQLInputType, type GraphQLOutputType, @@ -20,7 +24,7 @@ import { type GraphQLField, type GraphQLArgument, } from '../type/definition'; -import { type GraphQLDirective } from '../type/directives'; + import { TypeInfo } from '../utilities/TypeInfo'; type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode; diff --git a/src/validation/__tests__/ExecutableDefinitions-test.js b/src/validation/__tests__/ExecutableDefinitions-test.js index 07f5e83f54..beb71ac04f 100644 --- a/src/validation/__tests__/ExecutableDefinitions-test.js +++ b/src/validation/__tests__/ExecutableDefinitions-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { ExecutableDefinitions, nonExecutableDefinitionMessage, } from '../rules/ExecutableDefinitions'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(ExecutableDefinitions, queryStr); } diff --git a/src/validation/__tests__/FieldsOnCorrectType-test.js b/src/validation/__tests__/FieldsOnCorrectType-test.js index 9a0dcd4f0c..7d833b7df4 100644 --- a/src/validation/__tests__/FieldsOnCorrectType-test.js +++ b/src/validation/__tests__/FieldsOnCorrectType-test.js @@ -2,12 +2,14 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { FieldsOnCorrectType, undefinedFieldMessage, } from '../rules/FieldsOnCorrectType'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(FieldsOnCorrectType, queryStr); } diff --git a/src/validation/__tests__/FragmentsOnCompositeTypes-test.js b/src/validation/__tests__/FragmentsOnCompositeTypes-test.js index 47159dccd2..76eef0a8af 100644 --- a/src/validation/__tests__/FragmentsOnCompositeTypes-test.js +++ b/src/validation/__tests__/FragmentsOnCompositeTypes-test.js @@ -1,13 +1,15 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { FragmentsOnCompositeTypes, inlineFragmentOnNonCompositeErrorMessage, fragmentOnNonCompositeErrorMessage, } from '../rules/FragmentsOnCompositeTypes'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(FragmentsOnCompositeTypes, queryStr); } diff --git a/src/validation/__tests__/KnownArgumentNames-test.js b/src/validation/__tests__/KnownArgumentNames-test.js index ad02219ec3..7fea8e7b8e 100644 --- a/src/validation/__tests__/KnownArgumentNames-test.js +++ b/src/validation/__tests__/KnownArgumentNames-test.js @@ -1,8 +1,9 @@ // @flow strict import { describe, it } from 'mocha'; + import { buildSchema } from '../../utilities'; -import { expectValidationErrors, expectSDLValidationErrors } from './harness'; + import { KnownArgumentNames, KnownArgumentNamesOnDirectives, @@ -10,6 +11,8 @@ import { unknownDirectiveArgMessage, } from '../rules/KnownArgumentNames'; +import { expectValidationErrors, expectSDLValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(KnownArgumentNames, queryStr); } diff --git a/src/validation/__tests__/KnownDirectives-test.js b/src/validation/__tests__/KnownDirectives-test.js index e3b4fae401..837dbb5504 100644 --- a/src/validation/__tests__/KnownDirectives-test.js +++ b/src/validation/__tests__/KnownDirectives-test.js @@ -1,8 +1,8 @@ // @flow strict import { describe, it } from 'mocha'; + import { buildSchema } from '../../utilities'; -import { expectValidationErrors, expectSDLValidationErrors } from './harness'; import { KnownDirectives, @@ -10,6 +10,8 @@ import { misplacedDirectiveMessage, } from '../rules/KnownDirectives'; +import { expectValidationErrors, expectSDLValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(KnownDirectives, queryStr); } diff --git a/src/validation/__tests__/KnownFragmentNames-test.js b/src/validation/__tests__/KnownFragmentNames-test.js index 28b5bfb8f0..0af503075e 100644 --- a/src/validation/__tests__/KnownFragmentNames-test.js +++ b/src/validation/__tests__/KnownFragmentNames-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { KnownFragmentNames, unknownFragmentMessage, } from '../rules/KnownFragmentNames'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(KnownFragmentNames, queryStr); } diff --git a/src/validation/__tests__/KnownTypeNames-test.js b/src/validation/__tests__/KnownTypeNames-test.js index 914f596948..78db470e79 100644 --- a/src/validation/__tests__/KnownTypeNames-test.js +++ b/src/validation/__tests__/KnownTypeNames-test.js @@ -1,13 +1,16 @@ // @flow strict import { describe, it } from 'mocha'; + import { buildSchema } from '../../utilities'; + +import { KnownTypeNames, unknownTypeMessage } from '../rules/KnownTypeNames'; + import { expectValidationErrors, expectValidationErrorsWithSchema, expectSDLValidationErrors, } from './harness'; -import { KnownTypeNames, unknownTypeMessage } from '../rules/KnownTypeNames'; function expectErrors(queryStr) { return expectValidationErrors(KnownTypeNames, queryStr); diff --git a/src/validation/__tests__/LoneAnonymousOperation-test.js b/src/validation/__tests__/LoneAnonymousOperation-test.js index 725727ecac..ef39e4a2c6 100644 --- a/src/validation/__tests__/LoneAnonymousOperation-test.js +++ b/src/validation/__tests__/LoneAnonymousOperation-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { LoneAnonymousOperation, anonOperationNotAloneMessage, } from '../rules/LoneAnonymousOperation'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(LoneAnonymousOperation, queryStr); } diff --git a/src/validation/__tests__/LoneSchemaDefinition-test.js b/src/validation/__tests__/LoneSchemaDefinition-test.js index 1948274980..5dfcdb7699 100644 --- a/src/validation/__tests__/LoneSchemaDefinition-test.js +++ b/src/validation/__tests__/LoneSchemaDefinition-test.js @@ -1,13 +1,16 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectSDLValidationErrors } from './harness'; + +import { buildSchema } from '../../utilities'; + import { LoneSchemaDefinition, schemaDefinitionNotAloneMessage, canNotDefineSchemaWithinExtensionMessage, } from '../rules/LoneSchemaDefinition'; -import { buildSchema } from '../../utilities'; + +import { expectSDLValidationErrors } from './harness'; function expectSDLErrors(sdlStr, schema) { return expectSDLValidationErrors(schema, LoneSchemaDefinition, sdlStr); diff --git a/src/validation/__tests__/NoFragmentCycles-test.js b/src/validation/__tests__/NoFragmentCycles-test.js index 92faafcb4f..6a40a49eaf 100644 --- a/src/validation/__tests__/NoFragmentCycles-test.js +++ b/src/validation/__tests__/NoFragmentCycles-test.js @@ -1,9 +1,11 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { NoFragmentCycles, cycleErrorMessage } from '../rules/NoFragmentCycles'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(NoFragmentCycles, queryStr); } diff --git a/src/validation/__tests__/NoUndefinedVariables-test.js b/src/validation/__tests__/NoUndefinedVariables-test.js index 6d97b3d1cb..b3b3ec7ac7 100644 --- a/src/validation/__tests__/NoUndefinedVariables-test.js +++ b/src/validation/__tests__/NoUndefinedVariables-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { NoUndefinedVariables, undefinedVarMessage, } from '../rules/NoUndefinedVariables'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(NoUndefinedVariables, queryStr); } diff --git a/src/validation/__tests__/NoUnusedFragments-test.js b/src/validation/__tests__/NoUnusedFragments-test.js index 10f3b3d1c9..cafc50e678 100644 --- a/src/validation/__tests__/NoUnusedFragments-test.js +++ b/src/validation/__tests__/NoUnusedFragments-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { NoUnusedFragments, unusedFragMessage, } from '../rules/NoUnusedFragments'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(NoUnusedFragments, queryStr); } diff --git a/src/validation/__tests__/NoUnusedVariables-test.js b/src/validation/__tests__/NoUnusedVariables-test.js index da202e73fa..29ccbd8e26 100644 --- a/src/validation/__tests__/NoUnusedVariables-test.js +++ b/src/validation/__tests__/NoUnusedVariables-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { NoUnusedVariables, unusedVariableMessage, } from '../rules/NoUnusedVariables'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(NoUnusedVariables, queryStr); } diff --git a/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js b/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js index 97f708ea79..eb7bf9d800 100644 --- a/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js +++ b/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js @@ -2,17 +2,19 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; + import { buildSchema } from '../../'; -import { - expectValidationErrors, - expectValidationErrorsWithSchema, -} from './harness'; import { OverlappingFieldsCanBeMerged, fieldsConflictMessage, } from '../rules/OverlappingFieldsCanBeMerged'; +import { + expectValidationErrors, + expectValidationErrorsWithSchema, +} from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(OverlappingFieldsCanBeMerged, queryStr); } diff --git a/src/validation/__tests__/PossibleFragmentSpreads-test.js b/src/validation/__tests__/PossibleFragmentSpreads-test.js index 42bc11ac60..e9dda2ffcf 100644 --- a/src/validation/__tests__/PossibleFragmentSpreads-test.js +++ b/src/validation/__tests__/PossibleFragmentSpreads-test.js @@ -1,13 +1,15 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { PossibleFragmentSpreads, typeIncompatibleSpreadMessage, typeIncompatibleAnonSpreadMessage, } from '../rules/PossibleFragmentSpreads'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(PossibleFragmentSpreads, queryStr); } diff --git a/src/validation/__tests__/PossibleTypeExtensions-test.js b/src/validation/__tests__/PossibleTypeExtensions-test.js index 8bf63a4651..f752f48ff9 100644 --- a/src/validation/__tests__/PossibleTypeExtensions-test.js +++ b/src/validation/__tests__/PossibleTypeExtensions-test.js @@ -1,14 +1,17 @@ // @flow strict import { describe, it } from 'mocha'; + import { buildSchema } from '../../utilities'; -import { expectSDLValidationErrors } from './harness'; + import { PossibleTypeExtensions, extendingUnknownTypeMessage, extendingDifferentTypeKindMessage, } from '../rules/PossibleTypeExtensions'; +import { expectSDLValidationErrors } from './harness'; + function expectSDLErrors(sdlStr, schema) { return expectSDLValidationErrors(schema, PossibleTypeExtensions, sdlStr); } diff --git a/src/validation/__tests__/ProvidedRequiredArguments-test.js b/src/validation/__tests__/ProvidedRequiredArguments-test.js index 5e7ca7cdc0..8c37c809f4 100644 --- a/src/validation/__tests__/ProvidedRequiredArguments-test.js +++ b/src/validation/__tests__/ProvidedRequiredArguments-test.js @@ -1,8 +1,9 @@ // @flow strict import { describe, it } from 'mocha'; + import { buildSchema } from '../../utilities'; -import { expectValidationErrors, expectSDLValidationErrors } from './harness'; + import { ProvidedRequiredArguments, ProvidedRequiredArgumentsOnDirectives, @@ -10,6 +11,8 @@ import { missingDirectiveArgMessage, } from '../rules/ProvidedRequiredArguments'; +import { expectValidationErrors, expectSDLValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(ProvidedRequiredArguments, queryStr); } diff --git a/src/validation/__tests__/ScalarLeafs-test.js b/src/validation/__tests__/ScalarLeafs-test.js index 9ce8f29f85..8b9a75808e 100644 --- a/src/validation/__tests__/ScalarLeafs-test.js +++ b/src/validation/__tests__/ScalarLeafs-test.js @@ -1,13 +1,15 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { ScalarLeafs, noSubselectionAllowedMessage, requiredSubselectionMessage, } from '../rules/ScalarLeafs'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(ScalarLeafs, queryStr); } diff --git a/src/validation/__tests__/SingleFieldSubscriptions-test.js b/src/validation/__tests__/SingleFieldSubscriptions-test.js index 603d5d96e4..b100509e0b 100644 --- a/src/validation/__tests__/SingleFieldSubscriptions-test.js +++ b/src/validation/__tests__/SingleFieldSubscriptions-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { SingleFieldSubscriptions, singleFieldOnlyMessage, } from '../rules/SingleFieldSubscriptions'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(SingleFieldSubscriptions, queryStr); } diff --git a/src/validation/__tests__/UniqueArgumentNames-test.js b/src/validation/__tests__/UniqueArgumentNames-test.js index 56d9130fca..269fd1fcec 100644 --- a/src/validation/__tests__/UniqueArgumentNames-test.js +++ b/src/validation/__tests__/UniqueArgumentNames-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { UniqueArgumentNames, duplicateArgMessage, } from '../rules/UniqueArgumentNames'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(UniqueArgumentNames, queryStr); } diff --git a/src/validation/__tests__/UniqueDirectiveNames-test.js b/src/validation/__tests__/UniqueDirectiveNames-test.js index a724e24760..fb67a722eb 100644 --- a/src/validation/__tests__/UniqueDirectiveNames-test.js +++ b/src/validation/__tests__/UniqueDirectiveNames-test.js @@ -1,14 +1,17 @@ // @flow strict import { describe, it } from 'mocha'; + import { buildSchema } from '../../utilities'; -import { expectSDLValidationErrors } from './harness'; + import { UniqueDirectiveNames, existedDirectiveNameMessage, duplicateDirectiveNameMessage, } from '../rules/UniqueDirectiveNames'; +import { expectSDLValidationErrors } from './harness'; + function expectSDLErrors(sdlStr, schema) { return expectSDLValidationErrors(schema, UniqueDirectiveNames, sdlStr); } diff --git a/src/validation/__tests__/UniqueDirectivesPerLocation-test.js b/src/validation/__tests__/UniqueDirectivesPerLocation-test.js index 8b72d97595..a18ae01f97 100644 --- a/src/validation/__tests__/UniqueDirectivesPerLocation-test.js +++ b/src/validation/__tests__/UniqueDirectivesPerLocation-test.js @@ -1,19 +1,21 @@ // @flow strict import { describe, it } from 'mocha'; -import { - testSchema, - expectValidationErrorsWithSchema, - expectSDLValidationErrors, -} from './harness'; import { parse } from '../../language/parser'; import { extendSchema } from '../../utilities/extendSchema'; + import { UniqueDirectivesPerLocation, duplicateDirectiveMessage, } from '../rules/UniqueDirectivesPerLocation'; +import { + testSchema, + expectValidationErrorsWithSchema, + expectSDLValidationErrors, +} from './harness'; + const extensionSDL = ` directive @directive on FIELD | FRAGMENT_DEFINITION directive @directiveA on FIELD | FRAGMENT_DEFINITION diff --git a/src/validation/__tests__/UniqueEnumValueNames-test.js b/src/validation/__tests__/UniqueEnumValueNames-test.js index 4d92894672..375ff38ebe 100644 --- a/src/validation/__tests__/UniqueEnumValueNames-test.js +++ b/src/validation/__tests__/UniqueEnumValueNames-test.js @@ -1,14 +1,17 @@ // @flow strict import { describe, it } from 'mocha'; + import { buildSchema } from '../../utilities'; -import { expectSDLValidationErrors } from './harness'; + import { UniqueEnumValueNames, duplicateEnumValueNameMessage, existedEnumValueNameMessage, } from '../rules/UniqueEnumValueNames'; +import { expectSDLValidationErrors } from './harness'; + function expectSDLErrors(sdlStr, schema) { return expectSDLValidationErrors(schema, UniqueEnumValueNames, sdlStr); } diff --git a/src/validation/__tests__/UniqueFieldDefinitionNames-test.js b/src/validation/__tests__/UniqueFieldDefinitionNames-test.js index cb2b8ca8a8..c4d8bb348e 100644 --- a/src/validation/__tests__/UniqueFieldDefinitionNames-test.js +++ b/src/validation/__tests__/UniqueFieldDefinitionNames-test.js @@ -1,14 +1,17 @@ // @flow strict import { describe, it } from 'mocha'; + import { buildSchema } from '../../utilities'; -import { expectSDLValidationErrors } from './harness'; + import { UniqueFieldDefinitionNames, duplicateFieldDefinitionNameMessage, existedFieldDefinitionNameMessage, } from '../rules/UniqueFieldDefinitionNames'; +import { expectSDLValidationErrors } from './harness'; + function expectSDLErrors(sdlStr, schema) { return expectSDLValidationErrors(schema, UniqueFieldDefinitionNames, sdlStr); } diff --git a/src/validation/__tests__/UniqueFragmentNames-test.js b/src/validation/__tests__/UniqueFragmentNames-test.js index 1abfe4d2ff..a799736f82 100644 --- a/src/validation/__tests__/UniqueFragmentNames-test.js +++ b/src/validation/__tests__/UniqueFragmentNames-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { UniqueFragmentNames, duplicateFragmentNameMessage, } from '../rules/UniqueFragmentNames'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(UniqueFragmentNames, queryStr); } diff --git a/src/validation/__tests__/UniqueInputFieldNames-test.js b/src/validation/__tests__/UniqueInputFieldNames-test.js index efbdc14948..cace6cf9d7 100644 --- a/src/validation/__tests__/UniqueInputFieldNames-test.js +++ b/src/validation/__tests__/UniqueInputFieldNames-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { UniqueInputFieldNames, duplicateInputFieldMessage, } from '../rules/UniqueInputFieldNames'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(UniqueInputFieldNames, queryStr); } diff --git a/src/validation/__tests__/UniqueOperationNames-test.js b/src/validation/__tests__/UniqueOperationNames-test.js index c2bc2020e8..fbb56bcae9 100644 --- a/src/validation/__tests__/UniqueOperationNames-test.js +++ b/src/validation/__tests__/UniqueOperationNames-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { UniqueOperationNames, duplicateOperationNameMessage, } from '../rules/UniqueOperationNames'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(UniqueOperationNames, queryStr); } diff --git a/src/validation/__tests__/UniqueOperationTypes-test.js b/src/validation/__tests__/UniqueOperationTypes-test.js index b69a46f226..7b87a08cc1 100644 --- a/src/validation/__tests__/UniqueOperationTypes-test.js +++ b/src/validation/__tests__/UniqueOperationTypes-test.js @@ -1,14 +1,17 @@ // @flow strict import { describe, it } from 'mocha'; + import { buildSchema } from '../../utilities'; -import { expectSDLValidationErrors } from './harness'; + import { UniqueOperationTypes, existedOperationTypeMessage, duplicateOperationTypeMessage, } from '../rules/UniqueOperationTypes'; +import { expectSDLValidationErrors } from './harness'; + function expectSDLErrors(sdlStr, schema) { return expectSDLValidationErrors(schema, UniqueOperationTypes, sdlStr); } diff --git a/src/validation/__tests__/UniqueTypeNames-test.js b/src/validation/__tests__/UniqueTypeNames-test.js index b153ab1065..8c6afe43e9 100644 --- a/src/validation/__tests__/UniqueTypeNames-test.js +++ b/src/validation/__tests__/UniqueTypeNames-test.js @@ -1,14 +1,17 @@ // @flow strict import { describe, it } from 'mocha'; + import { buildSchema } from '../../utilities'; -import { expectSDLValidationErrors } from './harness'; + import { UniqueTypeNames, existedTypeNameMessage, duplicateTypeNameMessage, } from '../rules/UniqueTypeNames'; +import { expectSDLValidationErrors } from './harness'; + function expectSDLErrors(sdlStr, schema) { return expectSDLValidationErrors(schema, UniqueTypeNames, sdlStr); } diff --git a/src/validation/__tests__/UniqueVariableNames-test.js b/src/validation/__tests__/UniqueVariableNames-test.js index 5a3ecc83b6..8f555f6410 100644 --- a/src/validation/__tests__/UniqueVariableNames-test.js +++ b/src/validation/__tests__/UniqueVariableNames-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { UniqueVariableNames, duplicateVariableMessage, } from '../rules/UniqueVariableNames'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(UniqueVariableNames, queryStr); } diff --git a/src/validation/__tests__/ValuesOfCorrectType-test.js b/src/validation/__tests__/ValuesOfCorrectType-test.js index 44dde4b150..19dcf33659 100644 --- a/src/validation/__tests__/ValuesOfCorrectType-test.js +++ b/src/validation/__tests__/ValuesOfCorrectType-test.js @@ -1,7 +1,7 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { ValuesOfCorrectType, badValueMessage, @@ -10,6 +10,8 @@ import { unknownFieldMessage, } from '../rules/ValuesOfCorrectType'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(ValuesOfCorrectType, queryStr); } diff --git a/src/validation/__tests__/VariablesAreInputTypes-test.js b/src/validation/__tests__/VariablesAreInputTypes-test.js index 5cbe35dc86..1039f24fdd 100644 --- a/src/validation/__tests__/VariablesAreInputTypes-test.js +++ b/src/validation/__tests__/VariablesAreInputTypes-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { VariablesAreInputTypes, nonInputTypeOnVarMessage, } from '../rules/VariablesAreInputTypes'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(VariablesAreInputTypes, queryStr); } diff --git a/src/validation/__tests__/VariablesInAllowedPosition-test.js b/src/validation/__tests__/VariablesInAllowedPosition-test.js index 7cc06b7a2d..2be79e0daf 100644 --- a/src/validation/__tests__/VariablesInAllowedPosition-test.js +++ b/src/validation/__tests__/VariablesInAllowedPosition-test.js @@ -1,12 +1,14 @@ // @flow strict import { describe, it } from 'mocha'; -import { expectValidationErrors } from './harness'; + import { VariablesInAllowedPosition, badVarPosMessage, } from '../rules/VariablesInAllowedPosition'; +import { expectValidationErrors } from './harness'; + function expectErrors(queryStr) { return expectValidationErrors(VariablesInAllowedPosition, queryStr); } diff --git a/src/validation/__tests__/harness.js b/src/validation/__tests__/harness.js index 7529c9ce6e..0289f243bf 100644 --- a/src/validation/__tests__/harness.js +++ b/src/validation/__tests__/harness.js @@ -1,13 +1,17 @@ // @flow strict import { expect } from 'chai'; + import inspect from '../../jsutils/inspect'; + import { parse } from '../../language'; -import { validate, validateSDL } from '../validate'; + +import { GraphQLScalarType } from '../../type/definition'; import { - type ValidationRule, - type SDLValidationRule, -} from '../ValidationContext'; + GraphQLDirective, + GraphQLIncludeDirective, + GraphQLSkipDirective, +} from '../../type/directives'; import { GraphQLSchema, GraphQLObjectType, @@ -23,12 +27,12 @@ import { GraphQLBoolean, GraphQLID, } from '../../type'; + +import { validate, validateSDL } from '../validate'; import { - GraphQLDirective, - GraphQLIncludeDirective, - GraphQLSkipDirective, -} from '../../type/directives'; -import { GraphQLScalarType } from '../../type/definition'; + type ValidationRule, + type SDLValidationRule, +} from '../ValidationContext'; const Being = new GraphQLInterfaceType({ name: 'Being', diff --git a/src/validation/__tests__/validateGQL-benchmark.js b/src/validation/__tests__/validateGQL-benchmark.js index 90f6271d25..8516467a73 100644 --- a/src/validation/__tests__/validateGQL-benchmark.js +++ b/src/validation/__tests__/validateGQL-benchmark.js @@ -1,10 +1,11 @@ // @flow strict -import { bigSchemaSDL } from '../../__fixtures__'; - import { parse, getIntrospectionQuery, buildSchema } from '../../'; + import { validate } from '../validate'; +import { bigSchemaSDL } from '../../__fixtures__'; + const schema = buildSchema(bigSchemaSDL, { assumeValid: true }); const queryAST = parse(getIntrospectionQuery()); diff --git a/src/validation/__tests__/validateSDL-benchmark.js b/src/validation/__tests__/validateSDL-benchmark.js index 7087d832d8..601d267f10 100644 --- a/src/validation/__tests__/validateSDL-benchmark.js +++ b/src/validation/__tests__/validateSDL-benchmark.js @@ -1,10 +1,11 @@ // @flow strict -import { bigSchemaSDL } from '../../__fixtures__'; - import { parse } from '../../'; + import { validateSDL } from '../validate'; +import { bigSchemaSDL } from '../../__fixtures__'; + const sdlAST = parse(bigSchemaSDL); export const name = 'Validate SDL Document'; diff --git a/src/validation/__tests__/validation-test.js b/src/validation/__tests__/validation-test.js index 60329601b4..e28668183c 100644 --- a/src/validation/__tests__/validation-test.js +++ b/src/validation/__tests__/validation-test.js @@ -1,12 +1,15 @@ // @flow strict -import { describe, it } from 'mocha'; import { expect } from 'chai'; -import { testSchema } from './harness'; -import { validate, specifiedRules } from '../'; +import { describe, it } from 'mocha'; + import { parse } from '../../language'; import { TypeInfo } from '../../utilities/TypeInfo'; +import { validate, specifiedRules } from '../'; + +import { testSchema } from './harness'; + describe('Validate: Supports full validation', () => { it('validates queries', () => { const doc = parse(` diff --git a/src/validation/rules/ExecutableDefinitions.js b/src/validation/rules/ExecutableDefinitions.js index 9b070d2cbb..83da1fd8f5 100644 --- a/src/validation/rules/ExecutableDefinitions.js +++ b/src/validation/rules/ExecutableDefinitions.js @@ -1,10 +1,12 @@ // @flow strict -import { type ASTValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; + import { Kind } from '../../language/kinds'; -import { isExecutableDefinitionNode } from '../../language/predicates'; import { type ASTVisitor } from '../../language/visitor'; +import { isExecutableDefinitionNode } from '../../language/predicates'; + +import { type ASTValidationContext } from '../ValidationContext'; export function nonExecutableDefinitionMessage(defName: string): string { return `The ${defName} definition is not executable.`; diff --git a/src/validation/rules/FieldsOnCorrectType.js b/src/validation/rules/FieldsOnCorrectType.js index 889976953c..bc628a961f 100644 --- a/src/validation/rules/FieldsOnCorrectType.js +++ b/src/validation/rules/FieldsOnCorrectType.js @@ -1,11 +1,13 @@ // @flow strict -import { type ValidationContext } from '../ValidationContext'; -import { GraphQLError } from '../../error/GraphQLError'; -import suggestionList from '../../jsutils/suggestionList'; import didYouMean from '../../jsutils/didYouMean'; +import suggestionList from '../../jsutils/suggestionList'; + +import { GraphQLError } from '../../error/GraphQLError'; + import { type FieldNode } from '../../language/ast'; import { type ASTVisitor } from '../../language/visitor'; + import { type GraphQLSchema } from '../../type/schema'; import { type GraphQLOutputType, @@ -14,6 +16,8 @@ import { isAbstractType, } from '../../type/definition'; +import { type ValidationContext } from '../ValidationContext'; + export function undefinedFieldMessage( fieldName: string, type: string, diff --git a/src/validation/rules/FragmentsOnCompositeTypes.js b/src/validation/rules/FragmentsOnCompositeTypes.js index d9a75033c2..5eb3f22a66 100644 --- a/src/validation/rules/FragmentsOnCompositeTypes.js +++ b/src/validation/rules/FragmentsOnCompositeTypes.js @@ -1,12 +1,16 @@ // @flow strict -import { type ValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; + import { print } from '../../language/printer'; import { type ASTVisitor } from '../../language/visitor'; + import { isCompositeType } from '../../type/definition'; + import { typeFromAST } from '../../utilities/typeFromAST'; +import { type ValidationContext } from '../ValidationContext'; + export function inlineFragmentOnNonCompositeErrorMessage(type: string): string { return `Fragment cannot condition on non composite type "${type}".`; } diff --git a/src/validation/rules/KnownArgumentNames.js b/src/validation/rules/KnownArgumentNames.js index 97978ec8a9..af68d93764 100644 --- a/src/validation/rules/KnownArgumentNames.js +++ b/src/validation/rules/KnownArgumentNames.js @@ -1,15 +1,19 @@ // @flow strict +import didYouMean from '../../jsutils/didYouMean'; +import suggestionList from '../../jsutils/suggestionList'; + +import { GraphQLError } from '../../error/GraphQLError'; + +import { Kind } from '../../language/kinds'; +import { type ASTVisitor } from '../../language/visitor'; + +import { specifiedDirectives } from '../../type/directives'; + import { type ValidationContext, type SDLValidationContext, } from '../ValidationContext'; -import { GraphQLError } from '../../error/GraphQLError'; -import { type ASTVisitor } from '../../language/visitor'; -import suggestionList from '../../jsutils/suggestionList'; -import didYouMean from '../../jsutils/didYouMean'; -import { Kind } from '../../language/kinds'; -import { specifiedDirectives } from '../../type/directives'; export function unknownArgMessage( argName: string, diff --git a/src/validation/rules/KnownDirectives.js b/src/validation/rules/KnownDirectives.js index b787f93100..4506c31dc0 100644 --- a/src/validation/rules/KnownDirectives.js +++ b/src/validation/rules/KnownDirectives.js @@ -1,15 +1,18 @@ // @flow strict -import { - type ValidationContext, - type SDLValidationContext, -} from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; + import { Kind } from '../../language/kinds'; -import { DirectiveLocation } from '../../language/directiveLocation'; import { type ASTVisitor } from '../../language/visitor'; +import { DirectiveLocation } from '../../language/directiveLocation'; + import { specifiedDirectives } from '../../type/directives'; +import { + type ValidationContext, + type SDLValidationContext, +} from '../ValidationContext'; + export function unknownDirectiveMessage(directiveName: string): string { return `Unknown directive "${directiveName}".`; } diff --git a/src/validation/rules/KnownFragmentNames.js b/src/validation/rules/KnownFragmentNames.js index 4fd79361f0..81b607d322 100644 --- a/src/validation/rules/KnownFragmentNames.js +++ b/src/validation/rules/KnownFragmentNames.js @@ -1,9 +1,10 @@ // @flow strict -import { type ValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; +import { type ValidationContext } from '../ValidationContext'; + export function unknownFragmentMessage(fragName: string): string { return `Unknown fragment "${fragName}".`; } diff --git a/src/validation/rules/KnownTypeNames.js b/src/validation/rules/KnownTypeNames.js index 22c01c1de8..f6b491ed7c 100644 --- a/src/validation/rules/KnownTypeNames.js +++ b/src/validation/rules/KnownTypeNames.js @@ -1,12 +1,10 @@ // @flow strict -import { - type ValidationContext, - type SDLValidationContext, -} from '../ValidationContext'; -import { GraphQLError } from '../../error/GraphQLError'; -import suggestionList from '../../jsutils/suggestionList'; import didYouMean from '../../jsutils/didYouMean'; +import suggestionList from '../../jsutils/suggestionList'; + +import { GraphQLError } from '../../error/GraphQLError'; + import { type ASTNode } from '../../language/ast'; import { type ASTVisitor } from '../../language/visitor'; import { @@ -14,8 +12,14 @@ import { isTypeSystemDefinitionNode, isTypeSystemExtensionNode, } from '../../language/predicates'; + import { specifiedScalarTypes } from '../../type/scalars'; +import { + type ValidationContext, + type SDLValidationContext, +} from '../ValidationContext'; + export function unknownTypeMessage( typeName: string, suggestedTypes: $ReadOnlyArray, diff --git a/src/validation/rules/LoneAnonymousOperation.js b/src/validation/rules/LoneAnonymousOperation.js index 0b3001bbdf..363d7c45ad 100644 --- a/src/validation/rules/LoneAnonymousOperation.js +++ b/src/validation/rules/LoneAnonymousOperation.js @@ -1,10 +1,12 @@ // @flow strict -import { type ASTValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; + import { Kind } from '../../language/kinds'; import { type ASTVisitor } from '../../language/visitor'; +import { type ASTValidationContext } from '../ValidationContext'; + export function anonOperationNotAloneMessage(): string { return 'This anonymous operation must be the only defined operation.'; } diff --git a/src/validation/rules/LoneSchemaDefinition.js b/src/validation/rules/LoneSchemaDefinition.js index 0fd6e8e245..38edd610fe 100644 --- a/src/validation/rules/LoneSchemaDefinition.js +++ b/src/validation/rules/LoneSchemaDefinition.js @@ -1,9 +1,10 @@ // @flow strict -import { type SDLValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; +import { type SDLValidationContext } from '../ValidationContext'; + export function schemaDefinitionNotAloneMessage(): string { return 'Must provide only one schema definition.'; } diff --git a/src/validation/rules/NoFragmentCycles.js b/src/validation/rules/NoFragmentCycles.js index 4792968eb9..1e62a4a6b0 100644 --- a/src/validation/rules/NoFragmentCycles.js +++ b/src/validation/rules/NoFragmentCycles.js @@ -1,9 +1,11 @@ // @flow strict -import { type ASTValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; -import { type FragmentDefinitionNode } from '../../language/ast'; + import { type ASTVisitor } from '../../language/visitor'; +import { type FragmentDefinitionNode } from '../../language/ast'; + +import { type ASTValidationContext } from '../ValidationContext'; export function cycleErrorMessage( fragName: string, diff --git a/src/validation/rules/NoUndefinedVariables.js b/src/validation/rules/NoUndefinedVariables.js index 2fe80b1efa..aee4f9ef06 100644 --- a/src/validation/rules/NoUndefinedVariables.js +++ b/src/validation/rules/NoUndefinedVariables.js @@ -1,9 +1,10 @@ // @flow strict -import { type ValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; +import { type ValidationContext } from '../ValidationContext'; + export function undefinedVarMessage(varName: string, opName: ?string): string { return opName ? `Variable "$${varName}" is not defined by operation "${opName}".` diff --git a/src/validation/rules/NoUnusedFragments.js b/src/validation/rules/NoUnusedFragments.js index 7845e6d84b..5c0847da20 100644 --- a/src/validation/rules/NoUnusedFragments.js +++ b/src/validation/rules/NoUnusedFragments.js @@ -1,9 +1,10 @@ // @flow strict -import { type ASTValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; +import { type ASTValidationContext } from '../ValidationContext'; + export function unusedFragMessage(fragName: string): string { return `Fragment "${fragName}" is never used.`; } diff --git a/src/validation/rules/NoUnusedVariables.js b/src/validation/rules/NoUnusedVariables.js index 72ed34d8a6..a8055de4bc 100644 --- a/src/validation/rules/NoUnusedVariables.js +++ b/src/validation/rules/NoUnusedVariables.js @@ -1,9 +1,10 @@ // @flow strict -import { type ValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; +import { type ValidationContext } from '../ValidationContext'; + export function unusedVariableMessage( varName: string, opName: ?string, diff --git a/src/validation/rules/OverlappingFieldsCanBeMerged.js b/src/validation/rules/OverlappingFieldsCanBeMerged.js index 093942d58d..76aa3f3129 100644 --- a/src/validation/rules/OverlappingFieldsCanBeMerged.js +++ b/src/validation/rules/OverlappingFieldsCanBeMerged.js @@ -2,19 +2,22 @@ import find from '../../polyfills/find'; import objectEntries from '../../polyfills/objectEntries'; -import { type ValidationContext } from '../ValidationContext'; -import { GraphQLError } from '../../error/GraphQLError'; + import inspect from '../../jsutils/inspect'; import { type ObjMap } from '../../jsutils/ObjMap'; + +import { GraphQLError } from '../../error/GraphQLError'; + +import { Kind } from '../../language/kinds'; +import { print } from '../../language/printer'; +import { type ASTVisitor } from '../../language/visitor'; import { type SelectionSetNode, type FieldNode, type ArgumentNode, type FragmentDefinitionNode, } from '../../language/ast'; -import { Kind } from '../../language/kinds'; -import { print } from '../../language/printer'; -import { type ASTVisitor } from '../../language/visitor'; + import { type GraphQLNamedType, type GraphQLOutputType, @@ -27,8 +30,11 @@ import { isListType, isInterfaceType, } from '../../type/definition'; + import { typeFromAST } from '../../utilities/typeFromAST'; +import { type ValidationContext } from '../ValidationContext'; + export function fieldsConflictMessage( responseName: string, reason: ConflictReasonMessage, diff --git a/src/validation/rules/PossibleFragmentSpreads.js b/src/validation/rules/PossibleFragmentSpreads.js index 4367d70fe9..29f5a3e26f 100644 --- a/src/validation/rules/PossibleFragmentSpreads.js +++ b/src/validation/rules/PossibleFragmentSpreads.js @@ -1,13 +1,18 @@ // @flow strict import inspect from '../../jsutils/inspect'; -import { type ValidationContext } from '../ValidationContext'; + import { GraphQLError } from '../../error/GraphQLError'; + import { type ASTVisitor } from '../../language/visitor'; -import { doTypesOverlap } from '../../utilities/typeComparators'; -import { typeFromAST } from '../../utilities/typeFromAST'; + import { isCompositeType } from '../../type/definition'; +import { typeFromAST } from '../../utilities/typeFromAST'; +import { doTypesOverlap } from '../../utilities/typeComparators'; + +import { type ValidationContext } from '../ValidationContext'; + export function typeIncompatibleSpreadMessage( fragName: string, parentType: string, diff --git a/src/validation/rules/PossibleTypeExtensions.js b/src/validation/rules/PossibleTypeExtensions.js index c70909786b..9d6f68efeb 100644 --- a/src/validation/rules/PossibleTypeExtensions.js +++ b/src/validation/rules/PossibleTypeExtensions.js @@ -2,11 +2,13 @@ import didYouMean from '../../jsutils/didYouMean'; import suggestionList from '../../jsutils/suggestionList'; -import { type SDLValidationContext } from '../ValidationContext'; + import { GraphQLError } from '../../error/GraphQLError'; + import { Kind } from '../../language/kinds'; -import { isTypeDefinitionNode } from '../../language/predicates'; import { type ASTVisitor } from '../../language/visitor'; +import { isTypeDefinitionNode } from '../../language/predicates'; + import { isScalarType, isObjectType, @@ -16,6 +18,8 @@ import { isInputObjectType, } from '../../type/definition'; +import { type SDLValidationContext } from '../ValidationContext'; + export function extendingUnknownTypeMessage( typeName: string, suggestedTypes: $ReadOnlyArray, diff --git a/src/validation/rules/ProvidedRequiredArguments.js b/src/validation/rules/ProvidedRequiredArguments.js index a23fe83735..c8d0a2320c 100644 --- a/src/validation/rules/ProvidedRequiredArguments.js +++ b/src/validation/rules/ProvidedRequiredArguments.js @@ -1,17 +1,21 @@ // @flow strict -import { - type ValidationContext, - type SDLValidationContext, -} from '../ValidationContext'; -import { GraphQLError } from '../../error/GraphQLError'; -import { Kind } from '../../language/kinds'; import inspect from '../../jsutils/inspect'; import keyMap from '../../jsutils/keyMap'; -import { isType, isRequiredArgument } from '../../type/definition'; -import { type ASTVisitor } from '../../language/visitor'; + +import { GraphQLError } from '../../error/GraphQLError'; + +import { Kind } from '../../language/kinds'; import { print } from '../../language/printer'; +import { type ASTVisitor } from '../../language/visitor'; + import { specifiedDirectives } from '../../type/directives'; +import { isType, isRequiredArgument } from '../../type/definition'; + +import { + type ValidationContext, + type SDLValidationContext, +} from '../ValidationContext'; export function missingFieldArgMessage( fieldName: string, diff --git a/src/validation/rules/ScalarLeafs.js b/src/validation/rules/ScalarLeafs.js index 373367ca78..13a71b69b8 100644 --- a/src/validation/rules/ScalarLeafs.js +++ b/src/validation/rules/ScalarLeafs.js @@ -1,12 +1,16 @@ // @flow strict import inspect from '../../jsutils/inspect'; -import { type ValidationContext } from '../ValidationContext'; + import { GraphQLError } from '../../error/GraphQLError'; + import { type FieldNode } from '../../language/ast'; -import { getNamedType, isLeafType } from '../../type/definition'; import { type ASTVisitor } from '../../language/visitor'; +import { getNamedType, isLeafType } from '../../type/definition'; + +import { type ValidationContext } from '../ValidationContext'; + export function noSubselectionAllowedMessage( fieldName: string, type: string, diff --git a/src/validation/rules/SingleFieldSubscriptions.js b/src/validation/rules/SingleFieldSubscriptions.js index 1bc3c5bb90..3714d3412b 100644 --- a/src/validation/rules/SingleFieldSubscriptions.js +++ b/src/validation/rules/SingleFieldSubscriptions.js @@ -1,9 +1,11 @@ // @flow strict -import { type ASTValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; -import { type OperationDefinitionNode } from '../../language/ast'; + import { type ASTVisitor } from '../../language/visitor'; +import { type OperationDefinitionNode } from '../../language/ast'; + +import { type ASTValidationContext } from '../ValidationContext'; export function singleFieldOnlyMessage(name: ?string): string { return name diff --git a/src/validation/rules/UniqueArgumentNames.js b/src/validation/rules/UniqueArgumentNames.js index a3a2a51c4b..c0372ef3aa 100644 --- a/src/validation/rules/UniqueArgumentNames.js +++ b/src/validation/rules/UniqueArgumentNames.js @@ -1,9 +1,10 @@ // @flow strict -import { type ASTValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; +import { type ASTValidationContext } from '../ValidationContext'; + export function duplicateArgMessage(argName: string): string { return `There can be only one argument named "${argName}".`; } diff --git a/src/validation/rules/UniqueDirectiveNames.js b/src/validation/rules/UniqueDirectiveNames.js index 11f9bf0aa6..7e4458d3a4 100644 --- a/src/validation/rules/UniqueDirectiveNames.js +++ b/src/validation/rules/UniqueDirectiveNames.js @@ -1,9 +1,10 @@ // @flow strict -import { type SDLValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; +import { type SDLValidationContext } from '../ValidationContext'; + export function duplicateDirectiveNameMessage(directiveName: string): string { return `There can be only one directive named "${directiveName}".`; } diff --git a/src/validation/rules/UniqueDirectivesPerLocation.js b/src/validation/rules/UniqueDirectivesPerLocation.js index f93fb2303a..32cbce3003 100644 --- a/src/validation/rules/UniqueDirectivesPerLocation.js +++ b/src/validation/rules/UniqueDirectivesPerLocation.js @@ -1,15 +1,18 @@ // @flow strict -import { - type SDLValidationContext, - type ValidationContext, -} from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; + import { Kind } from '../../language/kinds'; import { type DirectiveNode } from '../../language/ast'; import { type ASTVisitor } from '../../language/visitor'; + import { specifiedDirectives } from '../../type/directives'; +import { + type SDLValidationContext, + type ValidationContext, +} from '../ValidationContext'; + export function duplicateDirectiveMessage(directiveName: string): string { return `The directive "${directiveName}" can only be used once at this location.`; } diff --git a/src/validation/rules/UniqueEnumValueNames.js b/src/validation/rules/UniqueEnumValueNames.js index 19d5f106be..a2a64e6251 100644 --- a/src/validation/rules/UniqueEnumValueNames.js +++ b/src/validation/rules/UniqueEnumValueNames.js @@ -1,10 +1,11 @@ // @flow strict -import { type SDLValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; import { isEnumType } from '../../type/definition'; +import { type SDLValidationContext } from '../ValidationContext'; + export function duplicateEnumValueNameMessage( typeName: string, valueName: string, diff --git a/src/validation/rules/UniqueFieldDefinitionNames.js b/src/validation/rules/UniqueFieldDefinitionNames.js index 6eaa3c97b2..5b78913dea 100644 --- a/src/validation/rules/UniqueFieldDefinitionNames.js +++ b/src/validation/rules/UniqueFieldDefinitionNames.js @@ -1,6 +1,5 @@ // @flow strict -import { type SDLValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; import { @@ -9,6 +8,8 @@ import { isInputObjectType, } from '../../type/definition'; +import { type SDLValidationContext } from '../ValidationContext'; + export function duplicateFieldDefinitionNameMessage( typeName: string, fieldName: string, diff --git a/src/validation/rules/UniqueFragmentNames.js b/src/validation/rules/UniqueFragmentNames.js index 6d256a706b..1dc86432fb 100644 --- a/src/validation/rules/UniqueFragmentNames.js +++ b/src/validation/rules/UniqueFragmentNames.js @@ -1,9 +1,10 @@ // @flow strict -import { type ASTValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; +import { type ASTValidationContext } from '../ValidationContext'; + export function duplicateFragmentNameMessage(fragName: string): string { return `There can be only one fragment named "${fragName}".`; } diff --git a/src/validation/rules/UniqueInputFieldNames.js b/src/validation/rules/UniqueInputFieldNames.js index b43adce0c6..2c42ce40b7 100644 --- a/src/validation/rules/UniqueInputFieldNames.js +++ b/src/validation/rules/UniqueInputFieldNames.js @@ -1,9 +1,10 @@ // @flow strict -import { type ASTValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; +import { type ASTValidationContext } from '../ValidationContext'; + export function duplicateInputFieldMessage(fieldName: string): string { return `There can be only one input field named "${fieldName}".`; } diff --git a/src/validation/rules/UniqueOperationNames.js b/src/validation/rules/UniqueOperationNames.js index cd3cf2a55c..1f615f29f4 100644 --- a/src/validation/rules/UniqueOperationNames.js +++ b/src/validation/rules/UniqueOperationNames.js @@ -1,9 +1,10 @@ // @flow strict -import { type ASTValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; +import { type ASTValidationContext } from '../ValidationContext'; + export function duplicateOperationNameMessage(operationName: string): string { return `There can be only one operation named "${operationName}".`; } diff --git a/src/validation/rules/UniqueOperationTypes.js b/src/validation/rules/UniqueOperationTypes.js index 393b916c83..c49b551594 100644 --- a/src/validation/rules/UniqueOperationTypes.js +++ b/src/validation/rules/UniqueOperationTypes.js @@ -1,9 +1,10 @@ // @flow strict -import { type SDLValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; import { type ASTVisitor } from '../../language/visitor'; +import { type SDLValidationContext } from '../ValidationContext'; + export function duplicateOperationTypeMessage(operation: string): string { return `There can be only one ${operation} type in schema.`; } diff --git a/src/validation/rules/UniqueTypeNames.js b/src/validation/rules/UniqueTypeNames.js index 0ede9dc889..6986336e71 100644 --- a/src/validation/rules/UniqueTypeNames.js +++ b/src/validation/rules/UniqueTypeNames.js @@ -1,10 +1,12 @@ // @flow strict -import { type SDLValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; + import { type ASTVisitor } from '../../language/visitor'; import { type TypeDefinitionNode } from '../../language/ast'; +import { type SDLValidationContext } from '../ValidationContext'; + export function duplicateTypeNameMessage(typeName: string): string { return `There can be only one type named "${typeName}".`; } diff --git a/src/validation/rules/UniqueVariableNames.js b/src/validation/rules/UniqueVariableNames.js index 42fb16688c..850091aef8 100644 --- a/src/validation/rules/UniqueVariableNames.js +++ b/src/validation/rules/UniqueVariableNames.js @@ -1,9 +1,11 @@ // @flow strict -import { type ASTValidationContext } from '../ValidationContext'; -import { type VariableDefinitionNode } from '../../language/ast'; import { GraphQLError } from '../../error/GraphQLError'; + import { type ASTVisitor } from '../../language/visitor'; +import { type VariableDefinitionNode } from '../../language/ast'; + +import { type ASTValidationContext } from '../ValidationContext'; export function duplicateVariableMessage(variableName: string): string { return `There can be only one variable named "${variableName}".`; diff --git a/src/validation/rules/ValuesOfCorrectType.js b/src/validation/rules/ValuesOfCorrectType.js index 1ea88a7a8b..05de195111 100644 --- a/src/validation/rules/ValuesOfCorrectType.js +++ b/src/validation/rules/ValuesOfCorrectType.js @@ -1,11 +1,19 @@ // @flow strict import objectValues from '../../polyfills/objectValues'; -import { type ValidationContext } from '../ValidationContext'; + +import keyMap from '../../jsutils/keyMap'; +import inspect from '../../jsutils/inspect'; +import isInvalid from '../../jsutils/isInvalid'; +import didYouMean from '../../jsutils/didYouMean'; +import suggestionList from '../../jsutils/suggestionList'; + import { GraphQLError } from '../../error/GraphQLError'; + import { type ValueNode } from '../../language/ast'; import { print } from '../../language/printer'; import { type ASTVisitor } from '../../language/visitor'; + import { isScalarType, isEnumType, @@ -16,11 +24,8 @@ import { getNullableType, getNamedType, } from '../../type/definition'; -import inspect from '../../jsutils/inspect'; -import isInvalid from '../../jsutils/isInvalid'; -import keyMap from '../../jsutils/keyMap'; -import didYouMean from '../../jsutils/didYouMean'; -import suggestionList from '../../jsutils/suggestionList'; + +import { type ValidationContext } from '../ValidationContext'; export function badValueMessage( typeName: string, diff --git a/src/validation/rules/VariablesAreInputTypes.js b/src/validation/rules/VariablesAreInputTypes.js index 92ede76741..3230d44bbb 100644 --- a/src/validation/rules/VariablesAreInputTypes.js +++ b/src/validation/rules/VariablesAreInputTypes.js @@ -1,13 +1,17 @@ // @flow strict -import { type ValidationContext } from '../ValidationContext'; import { GraphQLError } from '../../error/GraphQLError'; -import { type VariableDefinitionNode } from '../../language/ast'; + import { print } from '../../language/printer'; import { type ASTVisitor } from '../../language/visitor'; +import { type VariableDefinitionNode } from '../../language/ast'; + import { isInputType } from '../../type/definition'; + import { typeFromAST } from '../../utilities/typeFromAST'; +import { type ValidationContext } from '../ValidationContext'; + export function nonInputTypeOnVarMessage( variableName: string, typeName: string, diff --git a/src/validation/rules/VariablesInAllowedPosition.js b/src/validation/rules/VariablesInAllowedPosition.js index b29c5665fa..f61d2cb5a5 100644 --- a/src/validation/rules/VariablesInAllowedPosition.js +++ b/src/validation/rules/VariablesInAllowedPosition.js @@ -1,15 +1,20 @@ // @flow strict import inspect from '../../jsutils/inspect'; -import { type ValidationContext } from '../ValidationContext'; + import { GraphQLError } from '../../error/GraphQLError'; + import { Kind } from '../../language/kinds'; import { type ValueNode } from '../../language/ast'; import { type ASTVisitor } from '../../language/visitor'; + +import { type GraphQLSchema } from '../../type/schema'; import { type GraphQLType, isNonNullType } from '../../type/definition'; -import { isTypeSubTypeOf } from '../../utilities/typeComparators'; + import { typeFromAST } from '../../utilities/typeFromAST'; -import { type GraphQLSchema } from '../../type/schema'; +import { isTypeSubTypeOf } from '../../utilities/typeComparators'; + +import { type ValidationContext } from '../ValidationContext'; export function badVarPosMessage( varName: string, diff --git a/src/validation/validate.js b/src/validation/validate.js index 8df811a4b4..4f17c2a66e 100644 --- a/src/validation/validate.js +++ b/src/validation/validate.js @@ -1,12 +1,17 @@ // @flow strict import invariant from '../jsutils/invariant'; + import { type GraphQLError } from '../error/GraphQLError'; -import { visit, visitInParallel, visitWithTypeInfo } from '../language/visitor'; + import { type DocumentNode } from '../language/ast'; +import { visit, visitInParallel, visitWithTypeInfo } from '../language/visitor'; + import { type GraphQLSchema } from '../type/schema'; import { assertValidSchema } from '../type/validate'; + import { TypeInfo } from '../utilities/TypeInfo'; + import { specifiedRules, specifiedSDLRules } from './specifiedRules'; import { type SDLValidationRule,