How can I build a custom node resolver for Global Object Identification with an XYZ unique identifier?
Consider that I defined the type(s) as below.
@strawberry_django.type(models.User)
class User(relay.Node):
username: auto
first_name: auto
last_name: auto
email: auto
@strawberry.type
class UserQuery:
"""
User query class for GraphQL
"""
users: strawberry.relay.ListConnection[User] = strawberry_django.connection(
resolver=resolve_users
)
By default, I can query a specific User
node using its Global ID
like this -
query{
node(id:"VXNlcjox"){
... on User{
username
firstName
email
}
}
}
But, how can I customize the behavior in a way that the node(...)
should be able to accept other than the Global ID
(like pk
or any arbitrary field on all models in Django)
Example: (See customUniqueID
parameter)
query{
node(customUniqueID:"user_1234asdzxc"){
... on User{
username
firstName
email
}
}
}
or (see anythingGoesHere(...)
query along with customUniqueID
)
query{
anythingGoesHere(customUniqueID:"user_1234asdzxc"){
... on User{
username
firstName
email
}
}
}
Is this doable?
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