Sometimes one doesn't want to use pk
as the lookup field for a single object, but something else. In my case, we have a public_id
which is a string type for example, but others may use UUIDs, or relay type ids as the lookup id.
I propose an interface such as the following:
@strawberry.django.type(MyModel, lookup_key="public_id", lookup_key_type=str)
class MyModelType:
public_id: str
# other fields here...
@strawberry.type
class Query:
model: MyModelType = strawberry.django.field()
This would then allow for graphql queries of the form model(publicId: "model_id"){...}
rather than forcing the use of pk
as it does now. I've created some working code in a fork of this project to test this idea out. The change is backwards compatible by defaulting to the same field/type (though it does make the argument required as per #107 ).
I'd be happy to make a PR if my proposal seems reasonable and compatible with other plans for the project?
Tangentially related to: #121.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too