diff --git a/src/jsutils/ObjMap.ts b/src/jsutils/ObjMap.ts index 2c20282187..fb70be09ed 100644 --- a/src/jsutils/ObjMap.ts +++ b/src/jsutils/ObjMap.ts @@ -1,13 +1,13 @@ export interface ObjMap { - [key: string]: T; + [key: string | symbol]: T; } -export type ObjMapLike = ObjMap | { [key: string]: T }; +export type ObjMapLike = ObjMap | { [key: string | symbol]: T }; export interface ReadOnlyObjMap { - readonly [key: string]: T; + readonly [key: string | symbol]: T; } export type ReadOnlyObjMapLike = | ReadOnlyObjMap - | { readonly [key: string]: T }; + | { readonly [key: string | symbol]: T }; diff --git a/src/type/definition.ts b/src/type/definition.ts index 5e0c6d0472..e69be9882b 100644 --- a/src/type/definition.ts +++ b/src/type/definition.ts @@ -552,7 +552,7 @@ export function resolveObjMapThunk(thunk: ThunkObjMap): ObjMap { * an object which can contain all the values you need. */ export interface GraphQLScalarTypeExtensions { - [attributeName: string]: unknown; + [attributeName: string | symbol]: unknown; } /** @@ -1031,7 +1031,7 @@ export type GraphQLFieldConfigArgumentMap = ObjMap; * an object which can contain all the values you need. */ export interface GraphQLArgumentExtensions { - [attributeName: string]: unknown; + [attributeName: string | symbol]: unknown; } export interface GraphQLArgumentConfig { @@ -1087,7 +1087,7 @@ export type GraphQLFieldMap = ObjMap< * an object which can contain all the values you need. */ export interface GraphQLInterfaceTypeExtensions { - [attributeName: string]: unknown; + [attributeName: string | symbol]: unknown; } /** @@ -1211,7 +1211,7 @@ export interface GraphQLInterfaceTypeNormalizedConfig * an object which can contain all the values you need. */ export interface GraphQLUnionTypeExtensions { - [attributeName: string]: unknown; + [attributeName: string | symbol]: unknown; } /** @@ -1339,7 +1339,7 @@ interface GraphQLUnionTypeNormalizedConfig * an object which can contain all the values you need. */ export interface GraphQLEnumTypeExtensions { - [attributeName: string]: unknown; + [attributeName: string | symbol]: unknown; } /** @@ -1551,7 +1551,7 @@ export type GraphQLEnumValueConfigMap /* */ = * an object which can contain all the values you need. */ export interface GraphQLEnumValueExtensions { - [attributeName: string]: unknown; + [attributeName: string | symbol]: unknown; } export interface GraphQLEnumValueConfig { @@ -1581,7 +1581,7 @@ export interface GraphQLEnumValue { * an object which can contain all the values you need. */ export interface GraphQLInputObjectTypeExtensions { - [attributeName: string]: unknown; + [attributeName: string | symbol]: unknown; } /** @@ -1716,7 +1716,7 @@ interface GraphQLInputObjectTypeNormalizedConfig * an object which can contain all the values you need. */ export interface GraphQLInputFieldExtensions { - [attributeName: string]: unknown; + [attributeName: string | symbol]: unknown; } export interface GraphQLInputFieldConfig { diff --git a/src/type/directives.ts b/src/type/directives.ts index bb3e441a43..eab15272fe 100644 --- a/src/type/directives.ts +++ b/src/type/directives.ts @@ -46,7 +46,7 @@ export function assertDirective(directive: unknown): GraphQLDirective { * an object which can contain all the values you need. */ export interface GraphQLDirectiveExtensions { - [attributeName: string]: unknown; + [attributeName: string | symbol]: unknown; } /** diff --git a/src/type/schema.ts b/src/type/schema.ts index 97c2782145..af968f4ea7 100644 --- a/src/type/schema.ts +++ b/src/type/schema.ts @@ -54,9 +54,10 @@ export function assertSchema(schema: unknown): GraphQLSchema { * your library or project. Do not use a shortened identifier as this increases * the risk of conflicts. We recommend you add at most one extension field, * an object which can contain all the values you need. + * Conflicts can be avoided by using a symbol instead of a string key. */ export interface GraphQLSchemaExtensions { - [attributeName: string]: unknown; + [attributeName: string | symbol]: unknown; } /**