-
Notifications
You must be signed in to change notification settings - Fork 493
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
Make directives future-proof #571
Comments
Potentially we could add another method in the type Directive interface {
AllowLocation(l string) bool
ImplementsDirective() string
} In future we might have a general directive on arbitrary locations, which would implement the following interface: // ASTVisitor is a general directive visitor interface that could be invoked on various locations both
// at schema parse time and during requests.
type ASTVisitor interface {
// Visit is invoked for every occurrence of the directive in the SDL schema or in the executable
// definition document (i.e. request). It accepts the parsed schema and the target object it is
// applied to which is a type from the [ast] package.
Visit(ctx context.Context, s *ast.Schema, t interface{})
} |
The above can even be split into two: type ASTSchemaVisitor interface {
Visit(ctx context.Context, s *ast.Schema, t interface{})
} and type ASTVisitor interface {
Visit(ctx context.Context, s *ast.Schema, doc *ast.ExecutableDefinition, t interface{})
} to differentiate between schema and request directives. cc @dackroyd |
It would be awesome for directives applied to objects and input objects to modify the behavior of each field resolver in that object. Now that we have resolver interceptors and the resolver interface, I see this as being quite possible to achieve. |
#609 includes adding |
Currently the library only supports directives on
FIELD_DEFINITION
. When/if we add support for more directive locations, the users who already use the current directive API would face breaking changes. We need to make sure that we can add more directive visitor types and/or directive locations in future without introducing breaking changes.The text was updated successfully, but these errors were encountered: