-
Notifications
You must be signed in to change notification settings - Fork 1
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
How do I use these custom directives? #3
Comments
I have the same question... how the heck do you use these, and how do I write my own?! |
According to the tests:
Now the middleware runs on every resolver, looping through the registered and initialised and installed directives graphene-custom-directives/graphene_custom_directives/middleware.py Lines 23 to 25 in 56d0cd7
The predefined directives in this package seem to register themselves due to their inheritance of the
graphene-custom-directives/graphene_custom_directives/middleware.py Lines 48 to 49 in 56d0cd7
... which itself relies on CustomDirectiveMeta which auto-registers itself to the middleware:graphene-custom-directives/graphene_custom_directives/middleware.py Lines 30 to 41 in 56d0cd7
All the registered directives are pulled into the schema via that graphene-custom-directives/graphene_custom_directives/middleware.py Lines 43 to 45 in 56d0cd7
Writing directives themselves seems pretty simple: they are wrapper functions for resolvers which, as we saw from the above code examples, relies on a static
|
I've also had to change the |
Do I need to add them to the Schema creation under directives or add them as middleware to GraphQL?
I'm really interested in writing my own directives to inject some code to remove/add to my query (as is suggested here) and your repo seems like a good framework to achieve this with Graphene (which is lacking any documentation on implementing custom directives).
Right now, I'm getting this error:
Do you have any advice for getting these to work? (I know this repo is 2 years old)
The text was updated successfully, but these errors were encountered: