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

feat: allow symbols as GraphQLSchema extension fields #3511

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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