- Is there a way to add a schema directive by overriding one of the methods of SchemaDirectiveVisitor for all the queries and mutations? For example to check the authentication token in a directive. Would be nice to add it just once not for every query/mutation defined.
If yes, which one of the following methods should be overwritten and how? I wasn't able to find an example on how to override each of them.
visitSchema(schema: GraphQLSchema)
visitScalar(scalar: GraphQLScalarType)
visitObject(object: GraphQLObjectType)
visitFieldDefinition(field: GraphQLField<any, any>)
visitArgumentDefinition(argument: GraphQLArgument)
visitInterface(iface: GraphQLInterfaceType)
visitUnion(union: GraphQLUnionType)
visitEnum(type: GraphQLEnumType)
visitEnumValue(value: GraphQLEnumValue)
visitInputObject(object: GraphQLInputObjectType)
visitInputFieldDefinition(field: GraphQLInputField)
My intuition would say that visitObject(object: GraphQLObjectType)
since type Query
is a GraphQLObjectType
.
- What will be the DirectiveLocation in the end? OBJECT or QUERY/MUTATION?