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

Flow: switched to exact object by default #351

Merged
merged 1 commit into from
Jun 29, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ overrides:
flowtype/no-unused-expressions: off
flowtype/no-weak-types: [error, { any: false }]
flowtype/require-compound-type-alias: off
flowtype/require-exact-type: off
flowtype/require-exact-type: [error, never]
flowtype/require-indexer-name: error
flowtype/require-inexact-type: off # checked by Flow
flowtype/require-parameter-type: off
Expand Down
8 changes: 3 additions & 5 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
<PROJECT_ROOT>/node_modules/graphql

[lints]
sketchy-null-bool=error
sketchy-null-string=error
sketchy-null-number=error
sketchy-null-mixed=error
sketchy-null=error
sketchy-number=error
untyped-type-import=error
nonstrict-import=off
Expand All @@ -25,7 +22,7 @@ unnecessary-optional-chain=error
unnecessary-invariant=error
signature-verification-failure=error
implicit-inexact-object=error
ambiguous-object-type=error
ambiguous-object-type=off
uninitialized-instance-property=error
default-import-access=error
invalid-import-star-use=error
Expand All @@ -37,6 +34,7 @@ export-renamed-default=error
[options]
all=true
module.use_strict=true
exact_by_default=true
babel_loose_array_spread=true
experimental.const_params=true
include_warnings=true
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/starWarsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* JSON objects in a more complex demo.
*/

type Ship = {|
type Ship = {
id: string,
name: string,
|};
};

const allShips: Array<Ship> = [
{ id: '1', name: 'X-Wing' },
Expand All @@ -25,11 +25,11 @@ const allShips: Array<Ship> = [
{ id: '8', name: 'Executor' },
];

type Faction = {|
type Faction = {
id: string,
name: string,
ships: Array<string>,
|};
};

const rebels: Faction = {
id: '1',
Expand Down
4 changes: 2 additions & 2 deletions src/connection/arrayConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type {
ConnectionCursor,
} from './connection';

type ArraySliceMetaInfo = {|
type ArraySliceMetaInfo = {
sliceStart: number,
arrayLength: number,
|};
};

/**
* A simple function that accepts an array and connection arguments, and returns
Expand Down
20 changes: 10 additions & 10 deletions src/connection/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ export type ConnectionArguments = {
...
};

type ConnectionConfig = {|
type ConnectionConfig = {
name?: string,
nodeType: GraphQLNamedType | GraphQLNonNull<GraphQLNamedType>,
resolveNode?: GraphQLFieldResolver<any, any>,
resolveCursor?: GraphQLFieldResolver<any, any>,
edgeFields?: Thunk<GraphQLFieldConfigMap<any, any>>,
connectionFields?: Thunk<GraphQLFieldConfigMap<any, any>>,
|};
};

type GraphQLConnectionDefinitions = {|
type GraphQLConnectionDefinitions = {
edgeType: GraphQLObjectType,
connectionType: GraphQLObjectType,
|};
};

function resolveMaybeThunk<T>(thingOrThunk: Thunk<T>): T {
return typeof thingOrThunk === 'function'
Expand Down Expand Up @@ -143,18 +143,18 @@ export function connectionDefinitions(
/**
* A type designed to be exposed as a `Connection` over GraphQL.
*/
export type Connection<T> = {|
export type Connection<T> = {
edges: Array<Edge<T>>,
pageInfo: PageInfo,
|};
};

/**
* A type designed to be exposed as a `Edge` over GraphQL.
*/
export type Edge<T> = {|
export type Edge<T> = {
node: T,
cursor: ConnectionCursor,
|};
};

/**
* The common page info type used by all connections.
Expand Down Expand Up @@ -185,9 +185,9 @@ const pageInfoType = new GraphQLObjectType({
/**
* A type designed to be exposed as `PageInfo` over GraphQL.
*/
export type PageInfo = {|
export type PageInfo = {
startCursor: ConnectionCursor | null,
endCursor: ConnectionCursor | null,
hasPreviousPage: boolean,
hasNextPage: boolean,
|};
};
4 changes: 2 additions & 2 deletions src/mutation/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ function resolveMaybeThunk<T>(thingOrThunk: Thunk<T>): T {
* input field, and it should return an Object with a key for each
* output field. It may return synchronously, or return a Promise.
*/
type MutationConfig = {|
type MutationConfig = {
name: string,
description?: string,
deprecationReason?: string,
extensions?: { [name: string]: mixed },
inputFields: Thunk<GraphQLInputFieldConfigMap>,
outputFields: Thunk<GraphQLFieldConfigMap<any, any>>,
mutateAndGetPayload: MutationFn,
|};
};

/**
* Returns a GraphQLFieldConfig for the mutation described by the
Expand Down
8 changes: 4 additions & 4 deletions src/node/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import type {

import { base64, unbase64 } from '../utils/base64';

type GraphQLNodeDefinitions<TContext> = {|
type GraphQLNodeDefinitions<TContext> = {
nodeInterface: GraphQLInterfaceType,
nodeField: GraphQLFieldConfig<mixed, TContext>,
nodesField: GraphQLFieldConfig<mixed, TContext>,
|};
};

/**
* Given a function to map from an ID to an underlying object, and a function
Expand Down Expand Up @@ -75,10 +75,10 @@ export function nodeDefinitions<TContext>(
return { nodeInterface, nodeField, nodesField };
}

type ResolvedGlobalId = {|
type ResolvedGlobalId = {
type: string,
id: string,
|};
};

/**
* Takes a type name and an ID specific to that type name, and returns a
Expand Down
4 changes: 2 additions & 2 deletions src/node/plural.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
GraphQLResolveInfo,
} from 'graphql';

type PluralIdentifyingRootFieldConfig = {|
type PluralIdentifyingRootFieldConfig = {
argName: string,
inputType: GraphQLInputType,
outputType: GraphQLOutputType,
Expand All @@ -17,7 +17,7 @@ type PluralIdentifyingRootFieldConfig = {|
info: GraphQLResolveInfo,
) => mixed,
description?: string,
|};
};

export function pluralIdentifyingRootField(
config: PluralIdentifyingRootFieldConfig,
Expand Down