@@ -58,7 +58,10 @@ const hasOwn = Object.prototype.hasOwnProperty;
58
58
// parameter types, and more details about the properties exposed by instances
59
59
// of the SchemaDirectiveVisitor class.
60
60
61
- export class SchemaDirectiveVisitor extends SchemaVisitor {
61
+ export class SchemaDirectiveVisitor <
62
+ TArgs = { [ name : string ] : any } ,
63
+ TContext = { [ key : string ] : any }
64
+ > extends SchemaVisitor {
62
65
// The name of the directive this visitor is allowed to visit (that is, the
63
66
// identifier that appears after the @ character in the schema). Note that
64
67
// this property is per-instance rather than static because subclasses of
@@ -71,15 +74,15 @@ export class SchemaDirectiveVisitor extends SchemaVisitor {
71
74
// A map from parameter names to argument values, as obtained from a
72
75
// specific occurrence of a @directive (arg1: value1, arg2: value2, ...) in
73
76
// the schema. Visitor methods may refer to this object via this.args.
74
- public args : { [ name : string ] : any } ;
77
+ public args : TArgs ;
75
78
76
79
// A reference to the type object that this visitor was created to visit.
77
80
public visitedType : VisitableSchemaType ;
78
81
79
82
// A shared object that will be available to all visitor instances via
80
83
// this.context. Callers of visitSchemaDirectives can provide their own
81
84
// object, or just use the default empty object.
82
- public context : { [ key : string ] : any } ;
85
+ public context : TContext ;
83
86
84
87
// Override this method to return a custom GraphQLDirective (or modify one
85
88
// already present in the schema) to enforce argument types, provide default
@@ -275,10 +278,10 @@ export class SchemaDirectiveVisitor extends SchemaVisitor {
275
278
// subclasses (not instances) to visitSchemaDirectives.
276
279
protected constructor ( config : {
277
280
name : string ;
278
- args : { [ name : string ] : any } ;
281
+ args : TArgs ;
279
282
visitedType : VisitableSchemaType ;
280
283
schema : GraphQLSchema ;
281
- context : { [ key : string ] : any } ;
284
+ context : TContext ;
282
285
} ) {
283
286
super ( ) ;
284
287
this . name = config . name ;
0 commit comments