Interface for DjangoFilterConnectionField
I have two classes
class RegisteredUser(graphene.ObjectType):
class Meta:
interfaces = (BaseClient, )
name = graphene.String()
group = graphene.String()
policy = graphene.Int()
event = graphene_django.filter.DjangoFilterConnectionField(AuthEvent, max_limit=15)
Then I also have another class for users that have not signed up
class NonRegisteredUser(graphene.ObjectType):
class Meta:
interfaces = (BaseClient, )
name = graphene.String()
source = graphene.Int()
event = graphene_django.filter.DjangoFilterConnectionField(NonRegisteredEvent, max_limit=15)
And finally we have BaseClient class which is the common interface for both of the above classes
class BaseClient(graphene.Interface):
name = graphene.String()
events = graphene_django.filter.DjangoFilterConnectionField('NotSureWhatToAdd', max_limit=15)
@classmethod
def resolve_type(cls, instance, info):
if instance.type == 'RegisteredUser':
return RegisteredUser
return NonRegisteredUser
Now everything works fine if I query "name" field but not sure how do I make 'events' field work since both have different DjangoFilterConnectionField.
Hey im not certain about this because I haven't faced this myself. But since there are no answers here Im just gonna throw this out there. I dont think that you need things that are different in the base interface. And i dont think you need things that are in common in the sub object types.
So, what this means is that you can probably delete
events = graphene_django.filter.DjangoFilterConnectionField('NotSureWhatToAdd', max_limit=15)
in the BaseClient
and you can also probably delete name = graphene.String() from the two subclasses.
Also Im not sure if this is intentional but you seem to be using plural events in the base and singular event in the objectType classes