Comments (1)
After internal discussions, we'll propose a new API regarding hook directives. This will result into significant break changes.
Here is the diff regarding existing hook:
@Directive("myDirective")
class MyDirective:
@staticmethod
- async def on_argument_execution(
+ async def on_post_argument_coercion(
directive_args,
next_directive,
parent_node,
argument_definition_node,
- argument_node,
value,
ctx,
):
pass
@staticmethod
async def on_post_input_coercion(
directive_args,
next_directive,
parent_node,
+ input_definition_node,
value,
ctx,
):
pass
The on_argument_execution
has been renamed into on_post_argument_coercion
to gain clarity and consistency with hooks of the same order. Its method prototype has changed too, we'll drop the argument_node
parameter which isn't really useful.
Also, the on_post_input_coercion
method prototype has been changed too, we'll add the input_definition_node
parameter which will contains the input definition node of the coerced value (Union[InputObjectTypeDefinitionNode, InputValueDefinitionNode, ScalarTypeDefinitionNode, EnumValueDefinitionNode]
).
In addition to those changes, we'll provide new hooks for each kind of node. This way, it will be possible to be more granular in the implementation of directives depending to the type of node.
Here are the new hooks which will be available:
@Directive("myDirective")
class MyDirective:
+ @staticmethod
+ async def on_post_input_object_coercion(
+ directive_args,
+ next_directive,
+ parent_node,
+ input_object_type_definition: InputObjectTypeDefinitionNode,
+ value,
+ ctx,
+ ):
+ pass
+ @staticmethod
+ async def on_post_input_field_coercion(
+ directive_args,
+ next_directive,
+ parent_node,
+ input_field_definition: InputValueDefinitionNode,
+ value,
+ ctx,
+ ):
+ pass
+ @staticmethod
+ async def on_post_scalar_input_coercion(
+ directive_args,
+ next_directive,
+ parent_node,
+ scalar_definition: ScalarTypeDefinitionNode,
+ value,
+ ctx,
+ ):
+ pass
+ @staticmethod
+ async def on_post_enum_type_input_coercion(
+ directive_args,
+ next_directive,
+ parent_node,
+ enum_type_definition: EnumTypeDefinitionNode,
+ value,
+ ctx,
+ ):
+ pass
+ @staticmethod
+ async def on_post_enum_value_input_coercion(
+ directive_args,
+ next_directive,
+ parent_node,
+ enum_value_definition: EnumValueDefinitionNode,
+ value,
+ ctx,
+ ):
+ pass
With those new hooks we should cover every case of post input coercions, meaning that the on_post_input_coercion
hook could have no utility anymore but that's not the case. The on_post_input_coercion
hook will be use as fallback/generic hook for each type. It means that, if you have a common use-case for each type you can implement the on_post_input_coercion
hook instead of implementing each hooks. Also, you can implement the on_post_input_coercion
hook and some other specific type hook if you want a specific behavior for those types. This way, we'll allow both flexibility and granurality regarding post input coercion hooks 👍
In addition to the post input coercion hooks, we'll think to do the same on the pre_output_coercion
one.
from tartiflette.
Related Issues (20)
- Redis HOT 3
- Types generation HOT 5
- ERROR: Failed building wheel for tartiflette HOT 2
- Cross-resolver parameters HOT 1
- [v2] Allow usage of @Resolver on interface fields
- Tartiflette fails to build libgraphqlparser on install HOT 1
- Middlewares? HOT 12
- Exceptions in directives are not handled HOT 1
- Improve performance for I/O bound list resolvers by using parallel execution HOT 15
- forcefully unregister all resolvers for debug purposes HOT 6
- OSError: cannot load library '/var/task/tartiflette/language/parsers/libgraphqlparser/cffi/libgraphqlparser.dylib': /var/task/tartiflette/language/parsers/libgraphqlparser/cffi/libgraphqlparser.dylib: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called HOT 12
- tartiflette.io slack invite link broken HOT 1
- 1.3.3 wheels on pypi are broken HOT 3
- cmake issue while installing on win10 HOT 1
- Setup/teardown is failing when doing automated tests
- Subscription result always `null` - what's the right format to yield? HOT 1
- Error coercers should not wrap custom exceptions inside Tartiflette errors HOT 2
- "poetry add tartiflette" not working
- Incremental delivery support
- ERROR: Failed building wheel for tartiflette
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tartiflette.