How to extend meta with DjangoObjectType #1183
Replies: 2 comments
-
What about an interface? That should let you extend meta for a DjangoObjectType. It works the same way for DjangoObjectType as for graphene.ObjectType. |
Beta Was this translation helpful? Give feedback.
-
One solution we figured out is simply be inheriting from At the end make sure to call Some might ask, why not deriving from ObjectType instead? The reason for this is that DjangoObjectType is hardcoded in the registry so we can't use any DjangoConnection without the DjangoObjectType as base class. This is how it should generally look like:
|
Beta Was this translation helpful? Give feedback.
-
I would like to extend DjangoObjectType to add some custom Meta attributes. Before 2.0 I did this through a custom DjangoObjectTypeMeta, which was ugly but effective. After 2.0 it looks like this is done with "__init_subclass_with_meta__". However DjangoObjectTypeOptions is hard-coded in "DjangoObjectType.__init_subclass_with_meta__" as "_meta = DjangoObjectTypeOptions(cls)"
Is there a clean way to extend the Meta? Could we add a options_class kwarg that defaults to DjangoObjectTypeOptions but could be overridden if needed?
Beta Was this translation helpful? Give feedback.
All reactions