Skip to content

Commit 3204d97

Browse files
committed
Flow: Remove some of the 'existential type' usages
See: https://flow.org/en/docs/types/utilities/#toc-existential-type
1 parent a5a9aa3 commit 3204d97

File tree

9 files changed

+30
-28
lines changed

9 files changed

+30
-28
lines changed

src/execution/execute.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ export function buildExecutionContext(
293293
contextValue: mixed,
294294
rawVariableValues: ?{ +[variable: string]: mixed, ... },
295295
operationName: ?string,
296-
fieldResolver: ?GraphQLFieldResolver<any, any>,
297-
typeResolver?: ?GraphQLTypeResolver<any, any>,
296+
fieldResolver: ?GraphQLFieldResolver<mixed, mixed>,
297+
typeResolver?: ?GraphQLTypeResolver<mixed, mixed>,
298298
): $ReadOnlyArray<GraphQLError> | ExecutionContext {
299299
const errors: Array<GraphQLError> = [];
300300
let operation: OperationDefinitionNode | void;
@@ -682,7 +682,7 @@ function resolveField(
682682

683683
export function buildResolveInfo(
684684
exeContext: ExecutionContext,
685-
fieldDef: GraphQLField<*, *>,
685+
fieldDef: GraphQLField<mixed, mixed>,
686686
fieldNodes: $ReadOnlyArray<FieldNode>,
687687
parentType: GraphQLObjectType,
688688
path: ResponsePath,
@@ -705,12 +705,12 @@ export function buildResolveInfo(
705705

706706
// Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
707707
// function. Returns the result of resolveFn or the abrupt-return Error object.
708-
export function resolveFieldValueOrError<TSource>(
708+
export function resolveFieldValueOrError(
709709
exeContext: ExecutionContext,
710-
fieldDef: GraphQLField<TSource, *>,
710+
fieldDef: GraphQLField<mixed, mixed>,
711711
fieldNodes: $ReadOnlyArray<FieldNode>,
712-
resolveFn: GraphQLFieldResolver<TSource, *>,
713-
source: TSource,
712+
resolveFn: GraphQLFieldResolver<mixed, mixed>,
713+
source: mixed,
714714
info: GraphQLResolveInfo,
715715
): Error | mixed {
716716
try {
@@ -1165,7 +1165,7 @@ function _collectSubfields(
11651165
* Otherwise, test each possible type for the abstract type by calling
11661166
* isTypeOf for the object being coerced, returning the first type that matches.
11671167
*/
1168-
export const defaultTypeResolver: GraphQLTypeResolver<any, *> = function(
1168+
export const defaultTypeResolver: GraphQLTypeResolver<mixed, mixed> = function(
11691169
value,
11701170
contextValue,
11711171
info,
@@ -1211,12 +1211,10 @@ export const defaultTypeResolver: GraphQLTypeResolver<any, *> = function(
12111211
* and returns it as the result, or if it's a function, returns the result
12121212
* of calling that function while passing along args and context value.
12131213
*/
1214-
export const defaultFieldResolver: GraphQLFieldResolver<any, *> = function(
1215-
source,
1216-
args,
1217-
contextValue,
1218-
info,
1219-
) {
1214+
export const defaultFieldResolver: GraphQLFieldResolver<
1215+
mixed,
1216+
mixed,
1217+
> = function(source: any, args, contextValue, info) {
12201218
// ensure source is a value for which property access is acceptable.
12211219
if (isObjectLike(source) || typeof source === 'function') {
12221220
const property = source[info.fieldName];
@@ -1240,7 +1238,7 @@ export function getFieldDef(
12401238
schema: GraphQLSchema,
12411239
parentType: GraphQLObjectType,
12421240
fieldName: string,
1243-
): ?GraphQLField<*, *> {
1241+
): ?GraphQLField<mixed, mixed> {
12441242
if (
12451243
fieldName === SchemaMetaFieldDef.name &&
12461244
schema.getQueryType() === parentType

src/execution/values.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export function getVariableValues(
119119
* Object prototype.
120120
*/
121121
export function getArgumentValues(
122-
def: GraphQLField<*, *> | GraphQLDirective,
122+
def: GraphQLField<mixed, mixed> | GraphQLDirective,
123123
node: FieldNode | DirectiveNode,
124124
variableValues?: ?ObjMap<mixed>,
125125
): { [argument: string]: mixed, ... } {

src/jsutils/defineToStringTag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* typically one of your own creation through the class keyword; `class A {}`,
1414
* for example.
1515
*/
16-
export default function defineToStringTag(classObject: Class<any>): void {
16+
export default function defineToStringTag(classObject: Class<mixed>): void {
1717
if (typeof Symbol === 'function' && Symbol.toStringTag) {
1818
Object.defineProperty(classObject.prototype, Symbol.toStringTag, {
1919
get() {

src/language/lexer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function printCharCode(code) {
172172
* punctuators immediately or calls the appropriate helper function for more
173173
* complicated tokens.
174174
*/
175-
function readToken(lexer: Lexer<*>, prev: Token): Token {
175+
function readToken(lexer: Lexer<mixed>, prev: Token): Token {
176176
const source = lexer.source;
177177
const body = source.body;
178178
const bodyLength = body.length;
@@ -339,7 +339,7 @@ function unexpectedCharacterMessage(code) {
339339
function positionAfterWhitespace(
340340
body: string,
341341
startPosition: number,
342-
lexer: Lexer<*>,
342+
lexer: Lexer<mixed>,
343343
): number {
344344
const bodyLength = body.length;
345345
let position = startPosition;

src/type/definition.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ defineToStringTag(GraphQLObjectType);
727727
defineToJSON(GraphQLObjectType);
728728

729729
function defineInterfaces(
730-
config: GraphQLObjectTypeConfig<*, *>,
730+
config: GraphQLObjectTypeConfig<mixed, mixed>,
731731
): Array<GraphQLInterfaceType> {
732732
const interfaces = resolveThunk(config.interfaces) || [];
733733
invariant(
@@ -1096,7 +1096,7 @@ defineToStringTag(GraphQLUnionType);
10961096
defineToJSON(GraphQLUnionType);
10971097

10981098
function defineTypes(
1099-
config: GraphQLUnionTypeConfig<*, *>,
1099+
config: GraphQLUnionTypeConfig<mixed, mixed>,
11001100
): Array<GraphQLObjectType> {
11011101
const types = resolveThunk(config.types) || [];
11021102
invariant(

src/utilities/TypeInfo.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class TypeInfo {
4242
_typeStack: Array<?GraphQLOutputType>;
4343
_parentTypeStack: Array<?GraphQLCompositeType>;
4444
_inputTypeStack: Array<?GraphQLInputType>;
45-
_fieldDefStack: Array<?GraphQLField<*, *>>;
45+
_fieldDefStack: Array<?GraphQLField<mixed, mixed>>;
4646
_defaultValueStack: Array<?mixed>;
4747
_directive: ?GraphQLDirective;
4848
_argument: ?GraphQLArgument;
@@ -106,7 +106,7 @@ export class TypeInfo {
106106
}
107107
}
108108

109-
getFieldDef(): ?GraphQLField<*, *> {
109+
getFieldDef(): ?GraphQLField<mixed, mixed> {
110110
if (this._fieldDefStack.length > 0) {
111111
return this._fieldDefStack[this._fieldDefStack.length - 1];
112112
}
@@ -293,7 +293,7 @@ function getFieldDef(
293293
schema: GraphQLSchema,
294294
parentType: GraphQLType,
295295
fieldNode: FieldNode,
296-
): ?GraphQLField<*, *> {
296+
): ?GraphQLField<mixed, mixed> {
297297
const name = fieldNode.name.value;
298298
if (
299299
name === SchemaMetaFieldDef.name &&

src/utilities/findBreakingChanges.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ function findFieldChanges(
359359

360360
function findArgChanges(
361361
oldType: GraphQLObjectType | GraphQLInterfaceType,
362-
oldField: GraphQLField<*, *>,
363-
newField: GraphQLField<*, *>,
362+
oldField: GraphQLField<mixed, mixed>,
363+
newField: GraphQLField<mixed, mixed>,
364364
): Array<BreakingChange | DangerousChange> {
365365
const schemaChanges = [];
366366
const argsDiff = diff(oldField.args, newField.args);

src/validation/ValidationContext.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export class ValidationContext extends ASTValidationContext {
227227
return this._typeInfo.getParentInputType();
228228
}
229229

230-
getFieldDef(): ?GraphQLField<*, *> {
230+
getFieldDef(): ?GraphQLField<mixed, mixed> {
231231
return this._typeInfo.getFieldDef();
232232
}
233233

src/validation/rules/OverlappingFieldsCanBeMerged.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ type ConflictReason = [string, ConflictReasonMessage];
100100
// Reason is a string, or a nested list of conflicts.
101101
type ConflictReasonMessage = string | Array<ConflictReason>;
102102
// Tuple defining a field node in a context.
103-
type NodeAndDef = [GraphQLCompositeType, FieldNode, ?GraphQLField<*, *>];
103+
type NodeAndDef = [
104+
GraphQLCompositeType,
105+
FieldNode,
106+
?GraphQLField<mixed, mixed>,
107+
];
104108
// Map of array of those.
105109
type NodeAndDefCollection = ObjMap<Array<NodeAndDef>>;
106110

0 commit comments

Comments
 (0)