-
-
Notifications
You must be signed in to change notification settings - Fork 818
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
v5 Roadmap #1306
Comments
How would a functional API look for directives? For example, what would be the arguments to a directive function and what would / could we return from it? |
You can currently (in next branch) use visitSchema to modify an existing schema (vs mapSchema which creates a new schema). visitSchema takes an instantiated SchemaDirectiveVisitor or SchemaVisitor class You can also pass in a visitorSelector function instead of either of those to dynamically change how each object is visited, which is what is done when using schema directives: The function instantiates the class to pass in the directive arguments here: What could easily be done is passing in a special function instead of a SchemaDirectiveVisitor class. This function might take as its arguments the same arguments as the SchemaDirectiveVisitor constructor, but most importantly, the directive arguments, and could return a SchemaVisitorMap. Or, if implementers know which types they are visiting, they could do the extra discrimination and return the correct type visitor. So, it would be a functional approach, the provided function for each named directive would take in all the info for each graphql object including the directive args and return an object containing a set of functions, one of which being the appropriate one, or the exact appropriate one. |
But ideally, thinking more broadly, to allow directives specified on object fields to easily modify the input fields of the resolver arguments (see parallel approach https://github.com/profusion/apollo-validation-directives/blob/master/README.md#value-validation), we can think of a different architecture altogether that is more generic. The schema directive is meant to transform the schema, but perhaps a number of schema directives are meant to work together to modify a schema. A schema directive implementation should really be a function that takes a list of directive names (so users of schema directives can use whatever names they want, to prevent conflicts) and returns a function that takes a schema as an argument and returns a schema. The implementation can rely on visitSchema or mapSchema to assess how the graphql objects are annotated and modify them accordingly. An additional single exported helper would be useful to extract a map of the directives and their arguments from the AST |
Moved several new features to #1337 so we could get v5 out as soon as possible. |
Let's continue discussion on how to easily use combinations of directives to modify schemas at #1234. |
Track and try out the new alpha v5 releases.
New Features
Build
Transformation
Stitching
createRequest
with transforms API #724 via merge graphql-tools-fork into v5 #1307)Utilities
Bug fixes:
The text was updated successfully, but these errors were encountered: