Skip to content

Commit 10ba0fa

Browse files
committed
feat: allow symbols as extension fields
1 parent da57238 commit 10ba0fa

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/jsutils/ObjMap.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
export interface ObjMap<T> {
2-
[key: string]: T;
2+
[key: string | symbol]: T;
33
}
44

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

77
export interface ReadOnlyObjMap<T> {
8-
readonly [key: string]: T;
8+
readonly [key: string | symbol]: T;
99
}
1010

1111
export type ReadOnlyObjMapLike<T> =
1212
| ReadOnlyObjMap<T>
13-
| { readonly [key: string]: T };
13+
| { readonly [key: string | symbol]: T };

src/type/definition.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ export function resolveObjMapThunk<T>(thunk: ThunkObjMap<T>): ObjMap<T> {
552552
* an object which can contain all the values you need.
553553
*/
554554
export interface GraphQLScalarTypeExtensions {
555-
[attributeName: string]: unknown;
555+
[attributeName: string | symbol]: unknown;
556556
}
557557

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

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

10931093
/**
@@ -1211,7 +1211,7 @@ export interface GraphQLInterfaceTypeNormalizedConfig
12111211
* an object which can contain all the values you need.
12121212
*/
12131213
export interface GraphQLUnionTypeExtensions {
1214-
[attributeName: string]: unknown;
1214+
[attributeName: string | symbol]: unknown;
12151215
}
12161216

12171217
/**
@@ -1339,7 +1339,7 @@ interface GraphQLUnionTypeNormalizedConfig
13391339
* an object which can contain all the values you need.
13401340
*/
13411341
export interface GraphQLEnumTypeExtensions {
1342-
[attributeName: string]: unknown;
1342+
[attributeName: string | symbol]: unknown;
13431343
}
13441344

13451345
/**
@@ -1551,7 +1551,7 @@ export type GraphQLEnumValueConfigMap /* <T> */ =
15511551
* an object which can contain all the values you need.
15521552
*/
15531553
export interface GraphQLEnumValueExtensions {
1554-
[attributeName: string]: unknown;
1554+
[attributeName: string | symbol]: unknown;
15551555
}
15561556

15571557
export interface GraphQLEnumValueConfig {
@@ -1581,7 +1581,7 @@ export interface GraphQLEnumValue {
15811581
* an object which can contain all the values you need.
15821582
*/
15831583
export interface GraphQLInputObjectTypeExtensions {
1584-
[attributeName: string]: unknown;
1584+
[attributeName: string | symbol]: unknown;
15851585
}
15861586

15871587
/**
@@ -1716,7 +1716,7 @@ interface GraphQLInputObjectTypeNormalizedConfig
17161716
* an object which can contain all the values you need.
17171717
*/
17181718
export interface GraphQLInputFieldExtensions {
1719-
[attributeName: string]: unknown;
1719+
[attributeName: string | symbol]: unknown;
17201720
}
17211721

17221722
export interface GraphQLInputFieldConfig {

src/type/directives.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function assertDirective(directive: unknown): GraphQLDirective {
4646
* an object which can contain all the values you need.
4747
*/
4848
export interface GraphQLDirectiveExtensions {
49-
[attributeName: string]: unknown;
49+
[attributeName: string | symbol]: unknown;
5050
}
5151

5252
/**

src/type/schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ export function assertSchema(schema: unknown): GraphQLSchema {
5454
* your library or project. Do not use a shortened identifier as this increases
5555
* the risk of conflicts. We recommend you add at most one extension field,
5656
* an object which can contain all the values you need.
57+
* Conflicts can be avoided by using a symbol instead of a string key.
5758
*/
5859
export interface GraphQLSchemaExtensions {
59-
[attributeName: string]: unknown;
60+
[attributeName: string | symbol]: unknown;
6061
}
6162

6263
/**

0 commit comments

Comments
 (0)