You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have different entities in my project, and want to split up my Query ObjectType into multiple classes.
How should I do that?
There seem to be three ways of doing it:
Just use inheritance as usual:
class UserQueries(graphene.ObjectType):
...
class OtherQueries(graphene.ObjectType):
...
class Queries(UserQueries, OtherQueries):
pass
Using the AbstractType:
class UserQueries(graphene.AbstractType):
...
class OtherQueries(graphene.AbstractType):
...
class Queries(graphene.ObjectType, UserQueries, OtherQueries):
pass
Using the abstract = True attribute:
class UserQueries(graphene.ObjectType):
class Meta:
abstract = True
...
class OtherQueries(graphene.ObjectType):
class Meta:
abstract = True
...
class Queries(UserQueries, OtherQueries):
pass
And this can apparently also be given as a class argument like so:
class UserQueries(graphene.ObjectType, abstract=True):
...
The documentation says to use 2., but in the v2 release notes it says that AbstractType is deprecated. In the same document it uses method 3., but I couldn't find any documentation for that.
I started to just use normal inheritance and it seems to work.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I have different entities in my project, and want to split up my Query ObjectType into multiple classes.
How should I do that?
There seem to be three ways of doing it:
AbstractType
:abstract = True
attribute:And this can apparently also be given as a class argument like so:
The documentation says to use 2., but in the v2 release notes it says that
AbstractType
is deprecated. In the same document it uses method 3., but I couldn't find any documentation for that.I started to just use normal inheritance and it seems to work.
How should it be done?
Probably related to #823
The text was updated successfully, but these errors were encountered: