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

ts: switch to use ObjMap utility type #3005

Merged
merged 1 commit into from Mar 30, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/execution/execute.d.ts
@@ -1,4 +1,5 @@
import { Maybe } from '../jsutils/Maybe';
import { ObjMap } from '../jsutils/ObjMap';

import { PromiseOrValue } from '../jsutils/PromiseOrValue';
import { Path } from '../jsutils/Path';
Expand Down Expand Up @@ -50,9 +51,9 @@ import {
*/
export interface ExecutionContext {
schema: GraphQLSchema;
fragments: { [key: string]: FragmentDefinitionNode };
rootValue: unknown;
contextValue: unknown;
fragments: ObjMap<FragmentDefinitionNode>;
operation: OperationDefinitionNode;
variableValues: { [key: string]: unknown };
fieldResolver: GraphQLFieldResolver<any, any>;
Expand Down Expand Up @@ -162,9 +163,9 @@ export function collectFields(
exeContext: ExecutionContext,
runtimeType: GraphQLObjectType,
selectionSet: SelectionSetNode,
fields: { [key: string]: Array<FieldNode> },
visitedFragmentNames: { [key: string]: boolean },
): { [key: string]: Array<FieldNode> };
fields: ObjMap<Array<FieldNode>>,
visitedFragmentNames: ObjMap<boolean>,
): ObjMap<Array<FieldNode>>;

/**
* @internal
Expand Down
5 changes: 3 additions & 2 deletions src/execution/values.d.ts
@@ -1,4 +1,5 @@
import { Maybe } from '../jsutils/Maybe';
import { ObjMap } from '../jsutils/ObjMap';

import { GraphQLError } from '../error/GraphQLError';
import {
Expand Down Expand Up @@ -42,7 +43,7 @@ export function getVariableValues(
export function getArgumentValues(
def: GraphQLField<unknown, unknown> | GraphQLDirective,
node: FieldNode | DirectiveNode,
variableValues?: Maybe<{ [key: string]: unknown }>,
variableValues?: Maybe<ObjMap<unknown>>,
): { [key: string]: unknown };

/**
Expand All @@ -61,5 +62,5 @@ export function getDirectiveValues(
node: {
readonly directives?: ReadonlyArray<DirectiveNode>;
},
variableValues?: Maybe<{ [key: string]: unknown }>,
variableValues?: Maybe<ObjMap<unknown>>,
): undefined | { [key: string]: unknown };
34 changes: 13 additions & 21 deletions src/type/definition.d.ts
Expand Up @@ -336,7 +336,7 @@ export type GraphQLScalarValueParser<TInternal> = (
) => Maybe<TInternal>;
export type GraphQLScalarLiteralParser<TInternal> = (
valueNode: ValueNode,
variables: Maybe<{ [key: string]: unknown }>,
variables: Maybe<ObjMap<unknown>>,
) => Maybe<TInternal>;

export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
Expand Down Expand Up @@ -479,7 +479,7 @@ export interface GraphQLResolveInfo {
readonly parentType: GraphQLObjectType;
readonly path: Path;
readonly schema: GraphQLSchema;
readonly fragments: { [key: string]: FragmentDefinitionNode };
readonly fragments: ObjMap<FragmentDefinitionNode>;
readonly rootValue: unknown;
readonly operation: OperationDefinitionNode;
readonly variableValues: { [variableName: string]: unknown };
Expand Down Expand Up @@ -522,9 +522,7 @@ export interface GraphQLFieldConfig<
astNode?: Maybe<FieldDefinitionNode>;
}

export interface GraphQLFieldConfigArgumentMap {
[key: string]: GraphQLArgumentConfig;
}
export type GraphQLFieldConfigArgumentMap = ObjMap<GraphQLArgumentConfig>;

/**
* Custom extensions
Expand All @@ -548,9 +546,9 @@ export interface GraphQLArgumentConfig {
astNode?: Maybe<InputValueDefinitionNode>;
}

export interface GraphQLFieldConfigMap<TSource, TContext> {
[key: string]: GraphQLFieldConfig<TSource, TContext>;
}
export type GraphQLFieldConfigMap<TSource, TContext> = ObjMap<
GraphQLFieldConfig<TSource, TContext>
>;

export interface GraphQLField<
TSource,
Expand Down Expand Up @@ -580,9 +578,9 @@ export interface GraphQLArgument {

export function isRequiredArgument(arg: GraphQLArgument): boolean;

export interface GraphQLFieldMap<TSource, TContext> {
[key: string]: GraphQLField<TSource, TContext>;
}
export type GraphQLFieldMap<TSource, TContext> = ObjMap<
GraphQLField<TSource, TContext>
>;

/**
* Custom extensions
Expand Down Expand Up @@ -778,7 +776,7 @@ export class GraphQLEnumType {
parseValue(value: unknown): Maybe<any>;
parseLiteral(
valueNode: ValueNode,
_variables: Maybe<{ [key: string]: unknown }>,
_variables: Maybe<ObjMap<unknown>>,
): Maybe<any>;

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

export interface GraphQLEnumValueConfigMap {
[key: string]: GraphQLEnumValueConfig;
}
export type GraphQLEnumValueConfigMap = ObjMap<GraphQLEnumValueConfig>;

/**
* Custom extensions
Expand Down Expand Up @@ -921,9 +917,7 @@ export interface GraphQLInputFieldConfig {
astNode?: Maybe<InputValueDefinitionNode>;
}

export interface GraphQLInputFieldConfigMap {
[key: string]: GraphQLInputFieldConfig;
}
export type GraphQLInputFieldConfigMap = ObjMap<GraphQLInputFieldConfig>;

export interface GraphQLInputField {
name: string;
Expand All @@ -937,6 +931,4 @@ export interface GraphQLInputField {

export function isRequiredInputField(field: GraphQLInputField): boolean;

export interface GraphQLInputFieldMap {
[key: string]: GraphQLInputField;
}
export type GraphQLInputFieldMap = ObjMap<GraphQLInputField>;
5 changes: 2 additions & 3 deletions src/type/schema.d.ts
Expand Up @@ -2,6 +2,7 @@
/* eslint-disable import/no-cycle */

import { Maybe } from '../jsutils/Maybe';
import { ObjMap } from '../jsutils/ObjMap';

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

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

interface TypeMap {
[key: string]: GraphQLNamedType;
}
type TypeMap = ObjMap<GraphQLNamedType>;

interface InterfaceImplementations {
objects: ReadonlyArray<GraphQLObjectType>;
Expand Down
3 changes: 2 additions & 1 deletion src/utilities/separateOperations.d.ts
@@ -1,3 +1,4 @@
import { ObjMap } from '../jsutils/ObjMap';
import { DocumentNode } from '../language/ast';

/**
Expand All @@ -8,4 +9,4 @@ import { DocumentNode } from '../language/ast';
*/
export function separateOperations(
documentAST: DocumentNode,
): { [key: string]: DocumentNode };
): ObjMap<DocumentNode>;
3 changes: 2 additions & 1 deletion src/utilities/valueFromAST.d.ts
@@ -1,4 +1,5 @@
import { Maybe } from '../jsutils/Maybe';
import { ObjMap } from '../jsutils/ObjMap';

import { ValueNode } from '../language/ast';
import { GraphQLInputType } from '../type/definition';
Expand Down Expand Up @@ -26,5 +27,5 @@ import { GraphQLInputType } from '../type/definition';
export function valueFromAST(
valueNode: Maybe<ValueNode>,
type: GraphQLInputType,
variables?: Maybe<{ [key: string]: unknown }>,
variables?: Maybe<ObjMap<unknown>>,
): unknown;
3 changes: 2 additions & 1 deletion src/utilities/valueFromASTUntyped.d.ts
@@ -1,4 +1,5 @@
import { Maybe } from '../jsutils/Maybe';
import { ObjMap } from '../jsutils/ObjMap';

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

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