Skip to content

Commit 47e6bd1

Browse files
authored
ts: switch to use ObjMap utility type (#3005)
1 parent b800c57 commit 47e6bd1

File tree

7 files changed

+29
-33
lines changed

7 files changed

+29
-33
lines changed

src/execution/execute.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Maybe } from '../jsutils/Maybe';
2+
import { ObjMap } from '../jsutils/ObjMap';
23

34
import { PromiseOrValue } from '../jsutils/PromiseOrValue';
45
import { Path } from '../jsutils/Path';
@@ -50,9 +51,9 @@ import {
5051
*/
5152
export interface ExecutionContext {
5253
schema: GraphQLSchema;
53-
fragments: { [key: string]: FragmentDefinitionNode };
5454
rootValue: unknown;
5555
contextValue: unknown;
56+
fragments: ObjMap<FragmentDefinitionNode>;
5657
operation: OperationDefinitionNode;
5758
variableValues: { [key: string]: unknown };
5859
fieldResolver: GraphQLFieldResolver<any, any>;
@@ -162,9 +163,9 @@ export function collectFields(
162163
exeContext: ExecutionContext,
163164
runtimeType: GraphQLObjectType,
164165
selectionSet: SelectionSetNode,
165-
fields: { [key: string]: Array<FieldNode> },
166-
visitedFragmentNames: { [key: string]: boolean },
167-
): { [key: string]: Array<FieldNode> };
166+
fields: ObjMap<Array<FieldNode>>,
167+
visitedFragmentNames: ObjMap<boolean>,
168+
): ObjMap<Array<FieldNode>>;
168169

169170
/**
170171
* @internal

src/execution/values.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Maybe } from '../jsutils/Maybe';
2+
import { ObjMap } from '../jsutils/ObjMap';
23

34
import { GraphQLError } from '../error/GraphQLError';
45
import {
@@ -42,7 +43,7 @@ export function getVariableValues(
4243
export function getArgumentValues(
4344
def: GraphQLField<unknown, unknown> | GraphQLDirective,
4445
node: FieldNode | DirectiveNode,
45-
variableValues?: Maybe<{ [key: string]: unknown }>,
46+
variableValues?: Maybe<ObjMap<unknown>>,
4647
): { [key: string]: unknown };
4748

4849
/**
@@ -61,5 +62,5 @@ export function getDirectiveValues(
6162
node: {
6263
readonly directives?: ReadonlyArray<DirectiveNode>;
6364
},
64-
variableValues?: Maybe<{ [key: string]: unknown }>,
65+
variableValues?: Maybe<ObjMap<unknown>>,
6566
): undefined | { [key: string]: unknown };

src/type/definition.d.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ export type GraphQLScalarValueParser<TInternal> = (
336336
) => Maybe<TInternal>;
337337
export type GraphQLScalarLiteralParser<TInternal> = (
338338
valueNode: ValueNode,
339-
variables: Maybe<{ [key: string]: unknown }>,
339+
variables: Maybe<ObjMap<unknown>>,
340340
) => Maybe<TInternal>;
341341

342342
export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
@@ -479,7 +479,7 @@ export interface GraphQLResolveInfo {
479479
readonly parentType: GraphQLObjectType;
480480
readonly path: Path;
481481
readonly schema: GraphQLSchema;
482-
readonly fragments: { [key: string]: FragmentDefinitionNode };
482+
readonly fragments: ObjMap<FragmentDefinitionNode>;
483483
readonly rootValue: unknown;
484484
readonly operation: OperationDefinitionNode;
485485
readonly variableValues: { [variableName: string]: unknown };
@@ -522,9 +522,7 @@ export interface GraphQLFieldConfig<
522522
astNode?: Maybe<FieldDefinitionNode>;
523523
}
524524

525-
export interface GraphQLFieldConfigArgumentMap {
526-
[key: string]: GraphQLArgumentConfig;
527-
}
525+
export type GraphQLFieldConfigArgumentMap = ObjMap<GraphQLArgumentConfig>;
528526

529527
/**
530528
* Custom extensions
@@ -548,9 +546,9 @@ export interface GraphQLArgumentConfig {
548546
astNode?: Maybe<InputValueDefinitionNode>;
549547
}
550548

551-
export interface GraphQLFieldConfigMap<TSource, TContext> {
552-
[key: string]: GraphQLFieldConfig<TSource, TContext>;
553-
}
549+
export type GraphQLFieldConfigMap<TSource, TContext> = ObjMap<
550+
GraphQLFieldConfig<TSource, TContext>
551+
>;
554552

555553
export interface GraphQLField<
556554
TSource,
@@ -580,9 +578,9 @@ export interface GraphQLArgument {
580578

581579
export function isRequiredArgument(arg: GraphQLArgument): boolean;
582580

583-
export interface GraphQLFieldMap<TSource, TContext> {
584-
[key: string]: GraphQLField<TSource, TContext>;
585-
}
581+
export type GraphQLFieldMap<TSource, TContext> = ObjMap<
582+
GraphQLField<TSource, TContext>
583+
>;
586584

587585
/**
588586
* Custom extensions
@@ -778,7 +776,7 @@ export class GraphQLEnumType {
778776
parseValue(value: unknown): Maybe<any>;
779777
parseLiteral(
780778
valueNode: ValueNode,
781-
_variables: Maybe<{ [key: string]: unknown }>,
779+
_variables: Maybe<ObjMap<unknown>>,
782780
): Maybe<any>;
783781

784782
toConfig(): GraphQLEnumTypeConfig & {
@@ -801,9 +799,7 @@ export interface GraphQLEnumTypeConfig {
801799
extensionASTNodes?: Maybe<ReadonlyArray<EnumTypeExtensionNode>>;
802800
}
803801

804-
export interface GraphQLEnumValueConfigMap {
805-
[key: string]: GraphQLEnumValueConfig;
806-
}
802+
export type GraphQLEnumValueConfigMap = ObjMap<GraphQLEnumValueConfig>;
807803

808804
/**
809805
* Custom extensions
@@ -921,9 +917,7 @@ export interface GraphQLInputFieldConfig {
921917
astNode?: Maybe<InputValueDefinitionNode>;
922918
}
923919

924-
export interface GraphQLInputFieldConfigMap {
925-
[key: string]: GraphQLInputFieldConfig;
926-
}
920+
export type GraphQLInputFieldConfigMap = ObjMap<GraphQLInputFieldConfig>;
927921

928922
export interface GraphQLInputField {
929923
name: string;
@@ -937,6 +931,4 @@ export interface GraphQLInputField {
937931

938932
export function isRequiredInputField(field: GraphQLInputField): boolean;
939933

940-
export interface GraphQLInputFieldMap {
941-
[key: string]: GraphQLInputField;
942-
}
934+
export type GraphQLInputFieldMap = ObjMap<GraphQLInputField>;

src/type/schema.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* eslint-disable import/no-cycle */
33

44
import { Maybe } from '../jsutils/Maybe';
5+
import { ObjMap } from '../jsutils/ObjMap';
56

67
import { SchemaDefinitionNode, SchemaExtensionNode } from '../language/ast';
78

@@ -97,9 +98,7 @@ export class GraphQLSchema {
9798
get [Symbol.toStringTag](): string;
9899
}
99100

100-
interface TypeMap {
101-
[key: string]: GraphQLNamedType;
102-
}
101+
type TypeMap = ObjMap<GraphQLNamedType>;
103102

104103
interface InterfaceImplementations {
105104
objects: ReadonlyArray<GraphQLObjectType>;

src/utilities/separateOperations.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ObjMap } from '../jsutils/ObjMap';
12
import { DocumentNode } from '../language/ast';
23

34
/**
@@ -8,4 +9,4 @@ import { DocumentNode } from '../language/ast';
89
*/
910
export function separateOperations(
1011
documentAST: DocumentNode,
11-
): { [key: string]: DocumentNode };
12+
): ObjMap<DocumentNode>;

src/utilities/valueFromAST.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Maybe } from '../jsutils/Maybe';
2+
import { ObjMap } from '../jsutils/ObjMap';
23

34
import { ValueNode } from '../language/ast';
45
import { GraphQLInputType } from '../type/definition';
@@ -26,5 +27,5 @@ import { GraphQLInputType } from '../type/definition';
2627
export function valueFromAST(
2728
valueNode: Maybe<ValueNode>,
2829
type: GraphQLInputType,
29-
variables?: Maybe<{ [key: string]: unknown }>,
30+
variables?: Maybe<ObjMap<unknown>>,
3031
): unknown;

src/utilities/valueFromASTUntyped.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Maybe } from '../jsutils/Maybe';
2+
import { ObjMap } from '../jsutils/ObjMap';
23

34
import { ValueNode } from '../language/ast';
45

@@ -20,5 +21,5 @@ import { ValueNode } from '../language/ast';
2021
*/
2122
export function valueFromASTUntyped(
2223
valueNode: ValueNode,
23-
variables?: Maybe<{ [key: string]: unknown }>,
24+
variables?: Maybe<ObjMap<unknown>>,
2425
): unknown;

0 commit comments

Comments
 (0)