Closed
Description
Hello, I have two models:
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.
{
"data": {
"departments": {
"edges": [
{
"node": {
"id": "RGVwYXJ0bWVudFR5cGU6MQ==",
"userSet": {
"edges": [
{
"node": {
"id": "VXNlclR5cGU6MQ=="
}
},
{
"node": {
"id": "VXNlclR5cGU6Mg=="
}
},
{
"node": {
"id": "VXNlclR5cGU6Mw=="
}
}
]
}
}
},
{
"node": {
"id": "RGVwYXJ0bWVudFR5cGU6Mg==",
"userSet": {
"edges": [
{
"node": {
"id": "VXNlclR5cGU6MQ=="
}
},
{
"node": {
"id": "VXNlclR5cGU6Mg=="
}
},
{
"node": {
"id": "VXNlclR5cGU6Mw=="
}
}
]
}
}
}
]
}
}
}
I have tried #1111 and #1133, but they all not work.... what should the resolver func return? or is this a bug?