Closed sdobbelaere closed 9 months ago
Hi @sdobbelaere ,
Hrm, that is a corner case of the fields='__all__'
you are using.
I'll try to take a look at that soon
Interesting @bellini666, what should I be seeing?
The following stripped down type, with manually declared fields yields the same query response:
@strawberry.django.type(Company)
class CompanyType(relay.Node):
id: auto
name: auto
related_companies: List['CompanyType']
@strawberry.type(name="Query")
class ContactsQuery:
companies: ListConnectionWithTotalCount[CompanyType] = strawberry_django.connection(extensions=[IsAuthenticated()])
{
companies(first:1) {
edges {
node {
name
id
}
}
}
}
{
"data": {
"companies": {
"edges": [
{
"node": {
"name": "Some name",
"id": "1"
}
}
]
}
}
}
Oh I see, it's the declaring of field id
that causes the original id to be shown instead of the hash.
As a workaround, it seems that excluding the id from the fields returns the right data.
@strawberry_django.type(Company, filters=CompanyFilter, order=CompanyOrder, pagination=True, exclude=['id'])
class CompanyType(relay.Node, TypeMultiTenantFilterMixin):
name: auto
related_companies: List['CompanyType']
{
companies(first:1) {
edges {
node {
name
id
}
}
}
}
{
"data": {
"companies": {
"edges": [
{
"node": {
"name": "Some Name",
"id": "Q29tcGFueVR5cGU6MQ=="
}
}
]
}
}
}
@bellini666 I added a pull-request to exclude the id from the model-fields. This seemed to be the lowest hanging fruit to handle the inclusions. Looking forward to your thoughts.
Pull request: #373
I've setup Strawberry django for a Company model, and created types, input types, queries via relay and mutations. Also, I've setup the
MAP_AUTO_ID_AS_GLOBAL_ID: True
setting.When I look at the query result, I can see that the object ID is mapped as a GlobalID.
However, when I want to try and remove that object, the mutation is complaining that my ID is of the wrong type and should be a base64 string.
If the mutation is correct, shouldn't the query supply me with an actual converted GlobalID instead of a stringified id? Or perhaps I'm missing something in my setup?
Some more detail on the models, types, inputtypes and queries below:
Upvote & Fund