Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to alternative format for type imports #2668

Merged
merged 1 commit into from Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.yml
Expand Up @@ -57,7 +57,7 @@ rules:
flowtype/sort-keys: off
flowtype/spread-exact-type: off
flowtype/type-id-match: [error, '^[A-Z]']
flowtype/type-import-style: [error, identifier, { ignoreTypeDefault: true }]
flowtype/type-import-style: [error, declaration]
flowtype/use-flow-type: error

# Bellow rules are disabled because coflicts with Prettier, see:
Expand Down Expand Up @@ -402,7 +402,7 @@ rules:
no-class-assign: error
no-const-assign: error
no-dupe-class-members: error
no-duplicate-imports: error
no-duplicate-imports: off # Superseded by `import/no-duplicates`
no-new-symbol: error
no-restricted-exports: off
no-restricted-imports: off
Expand Down
7 changes: 4 additions & 3 deletions src/error/GraphQLError.js
Expand Up @@ -6,9 +6,10 @@
import isObjectLike from '../jsutils/isObjectLike';
import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols';

import { type ASTNode } from '../language/ast';
import { type Source } from '../language/source';
import { type SourceLocation, getLocation } from '../language/location';
import type { ASTNode } from '../language/ast';
import type { Source } from '../language/source';
import type { SourceLocation } from '../language/location';
import { getLocation } from '../language/location';
import { printLocation, printSourceLocation } from '../language/printLocation';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/error/formatError.js
Expand Up @@ -2,9 +2,9 @@

import devAssert from '../jsutils/devAssert';

import { type SourceLocation } from '../language/location';
import type { SourceLocation } from '../language/location';

import { type GraphQLError } from './GraphQLError';
import type { GraphQLError } from './GraphQLError';

/**
* Given a GraphQLError, format it according to the rules described by the
Expand Down
2 changes: 1 addition & 1 deletion src/error/locatedError.js
@@ -1,6 +1,6 @@
// @flow strict

import { type ASTNode } from '../language/ast';
import type { ASTNode } from '../language/ast';

import { GraphQLError } from './GraphQLError';

Expand Down
2 changes: 1 addition & 1 deletion src/error/syntaxError.js
@@ -1,6 +1,6 @@
// @flow strict

import { type Source } from '../language/source';
import type { Source } from '../language/source';

import { GraphQLError } from './GraphQLError';

Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/lists-test.js
Expand Up @@ -5,13 +5,13 @@ import { describe, it } from 'mocha';

import { parse } from '../../language/parser';

import type { GraphQLOutputType } from '../../type/definition';
import { GraphQLSchema } from '../../type/schema';
import { GraphQLString, GraphQLInt } from '../../type/scalars';
import {
GraphQLList,
GraphQLNonNull,
GraphQLObjectType,
type GraphQLOutputType,
} from '../../type/definition';

import { execute } from '../execute';
Expand Down
3 changes: 2 additions & 1 deletion src/execution/__tests__/nonnull-test.js
Expand Up @@ -13,7 +13,8 @@ import { GraphQLNonNull, GraphQLObjectType } from '../../type/definition';

import { buildSchema } from '../../utilities/buildASTSchema';

import { execute, type ExecutionResult } from '../execute';
import type { ExecutionResult } from '../execute';
import { execute } from '../execute';

const syncError = new Error('sync');
const syncNonNullError = new Error('syncNonNull');
Expand Down
6 changes: 2 additions & 4 deletions src/execution/__tests__/resolve-test.js
Expand Up @@ -3,12 +3,10 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import type { GraphQLFieldConfig } from '../../type/definition';
import { GraphQLSchema } from '../../type/schema';
import { GraphQLInt, GraphQLString } from '../../type/scalars';
import {
GraphQLObjectType,
type GraphQLFieldConfig,
} from '../../type/definition';
import { GraphQLObjectType } from '../../type/definition';

import { graphqlSync } from '../../graphql';

Expand Down
47 changes: 25 additions & 22 deletions src/execution/execute.js
Expand Up @@ -2,35 +2,47 @@

import arrayFrom from '../polyfills/arrayFrom';

import type { Path } from '../jsutils/Path';
import type { ObjMap } from '../jsutils/ObjMap';
import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
import inspect from '../jsutils/inspect';
import memoize3 from '../jsutils/memoize3';
import invariant from '../jsutils/invariant';
import devAssert from '../jsutils/devAssert';
import isPromise from '../jsutils/isPromise';
import { type ObjMap } from '../jsutils/ObjMap';
import isObjectLike from '../jsutils/isObjectLike';
import isCollection from '../jsutils/isCollection';
import promiseReduce from '../jsutils/promiseReduce';
import promiseForObject from '../jsutils/promiseForObject';
import { type PromiseOrValue } from '../jsutils/PromiseOrValue';
import { type Path, addPath, pathToArray } from '../jsutils/Path';
import { addPath, pathToArray } from '../jsutils/Path';

import { GraphQLError } from '../error/GraphQLError';
import { locatedError } from '../error/locatedError';

import { Kind } from '../language/kinds';
import {
type DocumentNode,
type OperationDefinitionNode,
type SelectionSetNode,
type FieldNode,
type FragmentSpreadNode,
type InlineFragmentNode,
type FragmentDefinitionNode,
import type {
DocumentNode,
OperationDefinitionNode,
SelectionSetNode,
FieldNode,
FragmentSpreadNode,
InlineFragmentNode,
FragmentDefinitionNode,
} from '../language/ast';
import { Kind } from '../language/kinds';

import type { GraphQLSchema } from '../type/schema';
import type {
GraphQLObjectType,
GraphQLOutputType,
GraphQLLeafType,
GraphQLAbstractType,
GraphQLField,
GraphQLFieldResolver,
GraphQLResolveInfo,
GraphQLTypeResolver,
GraphQLList,
} from '../type/definition';
import { assertValidSchema } from '../type/validate';
import { type GraphQLSchema } from '../type/schema';
import {
SchemaMetaFieldDef,
TypeMetaFieldDef,
Expand All @@ -41,15 +53,6 @@ import {
GraphQLSkipDirective,
} from '../type/directives';
import {
type GraphQLObjectType,
type GraphQLOutputType,
type GraphQLLeafType,
type GraphQLAbstractType,
type GraphQLField,
type GraphQLFieldResolver,
type GraphQLResolveInfo,
type GraphQLTypeResolver,
type GraphQLList,
isObjectType,
isAbstractType,
isLeafType,
Expand Down
23 changes: 10 additions & 13 deletions src/execution/values.js
Expand Up @@ -2,28 +2,25 @@

import find from '../polyfills/find';

import type { ObjMap } from '../jsutils/ObjMap';
import keyMap from '../jsutils/keyMap';
import inspect from '../jsutils/inspect';
import { type ObjMap } from '../jsutils/ObjMap';
import printPathArray from '../jsutils/printPathArray';

import { GraphQLError } from '../error/GraphQLError';

import type {
FieldNode,
DirectiveNode,
VariableDefinitionNode,
} from '../language/ast';
import { Kind } from '../language/kinds';
import { print } from '../language/printer';
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 type { GraphQLSchema } from '../type/schema';
import type { GraphQLField } from '../type/definition';
import type { GraphQLDirective } from '../type/directives';
import { isInputType, isNonNullType } from '../type/definition';

import { typeFromAST } from '../utilities/typeFromAST';
import { valueFromAST } from '../utilities/valueFromAST';
Expand Down
17 changes: 9 additions & 8 deletions src/graphql.js
@@ -1,21 +1,22 @@
// @flow strict

import type { PromiseOrValue } from './jsutils/PromiseOrValue';
import isPromise from './jsutils/isPromise';
import { type PromiseOrValue } from './jsutils/PromiseOrValue';

import type { Source } from './language/source';
import { parse } from './language/parser';
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,
import type {
GraphQLFieldResolver,
GraphQLTypeResolver,
} from './type/definition';
import type { GraphQLSchema } from './type/schema';
import { validateSchema } from './type/validate';

import { type ExecutionResult, execute } from './execution/execute';
import type { ExecutionResult } from './execution/execute';
import { execute } from './execution/execute';

/**
* This is the primary entry point function for fulfilling GraphQL operations
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/__tests__/toObjMap-test.js
Expand Up @@ -3,8 +3,8 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import type { ObjMapLike } from '../ObjMap';
import toObjMap from '../toObjMap';
import { type ObjMapLike } from '../ObjMap';

// Workaround to make both ESLint and Flow happy
const __proto__: string = '__proto__';
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/keyMap.js
@@ -1,6 +1,6 @@
// @flow strict

import { type ObjMap } from './ObjMap';
import type { ObjMap } from './ObjMap';

/**
* Creates a keyed JS object from an array, given a function to produce the keys
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/keyValMap.js
@@ -1,6 +1,6 @@
// @flow strict

import { type ObjMap } from './ObjMap';
import type { ObjMap } from './ObjMap';

/**
* Creates a keyed JS object from an array, given a function to produce the keys
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/mapValue.js
Expand Up @@ -2,7 +2,7 @@

import objectEntries from '../polyfills/objectEntries';

import { type ObjMap } from './ObjMap';
import type { ObjMap } from './ObjMap';

/**
* Creates an object map with the same keys as `map` and values generated by
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/promiseForObject.js
@@ -1,6 +1,6 @@
// @flow strict

import { type ObjMap } from './ObjMap';
import type { ObjMap } from './ObjMap';

/**
* This function transforms a JS object `ObjMap<Promise<T>>` into
Expand Down
3 changes: 2 additions & 1 deletion src/jsutils/promiseReduce.js
@@ -1,7 +1,8 @@
// @flow strict

import type { PromiseOrValue } from './PromiseOrValue';

import isPromise from './isPromise';
import { type PromiseOrValue } from './PromiseOrValue';

/**
* Similar to Array.prototype.reduce(), however the reducing callback may return
Expand Down
10 changes: 5 additions & 5 deletions src/jsutils/toObjMap.js
Expand Up @@ -2,11 +2,11 @@

import objectEntries from '../polyfills/objectEntries';

import {
type ObjMap,
type ObjMapLike,
type ReadOnlyObjMap,
type ReadOnlyObjMapLike,
import type {
ObjMap,
ObjMapLike,
ReadOnlyObjMap,
ReadOnlyObjMapLike,
} from './ObjMap';

/* eslint-disable no-redeclare */
Expand Down
2 changes: 1 addition & 1 deletion src/language/__tests__/predicates-test.js
Expand Up @@ -3,8 +3,8 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import type { ASTNode } from '../ast';
import { Kind } from '../kinds';
import { type ASTNode } from '../ast';
import {
isDefinitionNode,
isExecutableDefinitionNode,
Expand Down
4 changes: 2 additions & 2 deletions src/language/ast.js
Expand Up @@ -2,8 +2,8 @@

import defineInspect from '../jsutils/defineInspect';

import { type Source } from './source';
import { type TokenKindEnum } from './tokenKind';
import type { Source } from './source';
import type { TokenKindEnum } from './tokenKind';

/**
* Contains a range of UTF-8 character offsets and token references that
Expand Down
5 changes: 3 additions & 2 deletions src/language/lexer.js
Expand Up @@ -2,10 +2,11 @@

import { syntaxError } from '../error/syntaxError';

import type { Source } from './source';
import type { TokenKindEnum } from './tokenKind';
import { Token } from './ast';
import { type Source } from './source';
import { TokenKind } from './tokenKind';
import { dedentBlockStringValue } from './blockString';
import { type TokenKindEnum, TokenKind } from './tokenKind';

/**
* Given a Source object, creates a Lexer for that source.
Expand Down
2 changes: 1 addition & 1 deletion src/language/location.js
@@ -1,6 +1,6 @@
// @flow strict

import { type Source } from './source';
import type { Source } from './source';

/**
* Represents a location in a Source.
Expand Down