Skip to content
Advertisement

Graphene Python class doesn’t recognize self

I have the following Python module that implements Graphene.

JavaScript

The problem is that resolvers that call other methods of the class raise this error:

JavaScript

The line that rises the error is: if self.validate_path(path):

I don’t know why, if method validate_path() is in the same class that the method that calls it.

Advertisement

Answer

This is because Graphene considering all resolver methods are staticmethods

From the doc,

Sometimes this argument will be named self in Graphene code, but this can be misleading due to Implicit staticmethod while executing queries in Graphene.

So, you must rearrange your code as follows,

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement