Open akikoskinen opened 3 years ago
Yeah Graphene's metaclass system is a mess, I don't understand why they had to rely on such a complex abstraction (although I'm sure there are reasons). I'll try to take a look in the weekend. Thanks!
Not directly related to this, but it could work as a solution. I have come to the conclusion that the @validated
class decorator can't be used in every use case. With the class decorator solution validation is always run before mutate
is entered. But there are use cases where the Mutation
's mutate
method is entered, something is first done (for example related to authorisation), and only after that validation should be run.
My current idea is to provide a validation function from graphene-validator
. Basically the current _do_validation
can almost work as is. That function can then be called from inside the mutate
method at any point that is fit for the purpose.
This solution could also be used to circumvent the MRO problem mentioned in this issue, if the meta class magic proves too problematic to be solved otherwise.
My current idea is to provide a validation function from
graphene-validator
.
@chpmrc PR #11 now contains this kind of validation function. Can you check it out?
Relay mutations are those inherited from
graphene.relay.ClientIDMutation
. To reproduce, add this code totests.py
and try to run tests:An error is produced already in the import phase. Output could look something like this:
Graphene's Relay code does some meta class magic and dynamically produces various classes and at some point it manages to create a cyclic dependency chain between classes and thus Python can't create an MRO.
I have no idea how to solve this. The meta class magic in Graphene looks too complex to me.