Skip to content

Commit

Permalink
feat: allow symbols as extension fields
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l committed Mar 15, 2022
1 parent da57238 commit 10ba0fa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/jsutils/ObjMap.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export interface ObjMap<T> {
[key: string]: T;
[key: string | symbol]: T;
}

export type ObjMapLike<T> = ObjMap<T> | { [key: string]: T };
export type ObjMapLike<T> = ObjMap<T> | { [key: string | symbol]: T };

export interface ReadOnlyObjMap<T> {
readonly [key: string]: T;
readonly [key: string | symbol]: T;
}

export type ReadOnlyObjMapLike<T> =
| ReadOnlyObjMap<T>
| { readonly [key: string]: T };
| { readonly [key: string | symbol]: T };
16 changes: 8 additions & 8 deletions src/type/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ export function resolveObjMapThunk<T>(thunk: ThunkObjMap<T>): ObjMap<T> {
* an object which can contain all the values you need.
*/
export interface GraphQLScalarTypeExtensions {
[attributeName: string]: unknown;
[attributeName: string | symbol]: unknown;
}

/**
Expand Down Expand Up @@ -1031,7 +1031,7 @@ export type GraphQLFieldConfigArgumentMap = ObjMap<GraphQLArgumentConfig>;
* an object which can contain all the values you need.
*/
export interface GraphQLArgumentExtensions {
[attributeName: string]: unknown;
[attributeName: string | symbol]: unknown;
}

export interface GraphQLArgumentConfig {
Expand Down Expand Up @@ -1087,7 +1087,7 @@ export type GraphQLFieldMap<TSource, TContext> = ObjMap<
* an object which can contain all the values you need.
*/
export interface GraphQLInterfaceTypeExtensions {
[attributeName: string]: unknown;
[attributeName: string | symbol]: unknown;
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -1551,7 +1551,7 @@ export type GraphQLEnumValueConfigMap /* <T> */ =
* an object which can contain all the values you need.
*/
export interface GraphQLEnumValueExtensions {
[attributeName: string]: unknown;
[attributeName: string | symbol]: unknown;
}

export interface GraphQLEnumValueConfig {
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/type/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/type/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 10ba0fa

Please sign in to comment.