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

Make object types exact by default #277

Merged
merged 1 commit into from
Jul 8, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ unsafe-getters-setters=error
unnecessary-optional-chain=error
unnecessary-invariant=error
signature-verification-failure=error
implicit-inexact-object=error
ambiguous-object-type=error
implicit-inexact-object=off
ambiguous-object-type=off
uninitialized-instance-property=error
unsafe-addition=error

Expand All @@ -39,6 +39,7 @@ include_warnings=true
module.use_strict=true
babel_loose_array_spread=true
esproposal.optional_chaining=enable
exact_by_default=true

[version]
^0.127.0
4 changes: 2 additions & 2 deletions src/connection/arrayconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import type {
ConnectionCursor,
} from './connectiontypes';

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

/**
* A simple function that accepts an array and connection arguments, and returns
Expand Down
8 changes: 4 additions & 4 deletions src/connection/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ export const connectionArgs: GraphQLFieldConfigArgumentMap = {
...backwardConnectionArgs,
};

type ConnectionConfig = {|
type ConnectionConfig = {
name?: ?string,
nodeType: GraphQLObjectType,
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
12 changes: 6 additions & 6 deletions src/connection/connectiontypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ export type ConnectionCursor = string;
/**
* A flow type designed to be exposed as `PageInfo` over GraphQL.
*/
export type PageInfo = {|
export type PageInfo = {
startCursor: ?ConnectionCursor,
endCursor: ?ConnectionCursor,
hasPreviousPage: ?boolean,
hasNextPage: ?boolean,
|};
};

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

/**
* A flow type describing the arguments a connection field receives in GraphQL.
Expand Down
4 changes: 2 additions & 2 deletions src/mutation/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ 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,
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 @@ -15,11 +15,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 @@ -77,10 +77,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 @@ -9,7 +9,7 @@ import type {
GraphQLResolveInfo,
} from 'graphql';

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

export function pluralIdentifyingRootField(
config: PluralIdentifyingRootFieldConfig,
Expand Down