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
class Department(models.Model):
department = models.CharField(max_length=100)
class User(models.Model):
username = ...
department = ForeignKey(to=Department, on_delete=models.DO_NOTHING,)
And I define two types:
class DepartmentType(DjangoObjectType):
class Meta:
model = Department
def resolve_user_set(root, info, **kwargs):
if info.context.user.is_authorization:
return self.user_set
return None
class UserType(DjangoObjectType):
class Meta:
model = User
class Query(graphene.ObjectType):
departments = DjangoFilterConnectionField(DepartmentType)
Then I use the query without authorization:
query{
departments{
edges{
node{
id
department
userSet{
edges{
node{
id
name
}
}
}
}
}
}
}
but the resolve func run without taking effact(with print func I can see that it return None). The response each have all users.
@RainshawGao hey there! could you please provide more info on what is_authorization actually is?
In case the user is not "authorized", I believe the correct return type should be an empty queryset not None i.e in your case: User.objects.none()
Hello, I have two models:
And I define two types:
Then I use the query without authorization:
but the resolve func run without taking effact(with print func I can see that it return None). The response each have all users.
I have tried #1111 and #1133, but they all not work.... what should the resolver func return? or is this a bug?
The text was updated successfully, but these errors were encountered: