graphql-python / graphql-python/graphene-django
How to declare custom global ID
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 760
- PR merge metrics
- No merged PRs in 30d
Description
Code
```python
class ShipNode(DjangoObjectType):
class Meta:
model = Ship
filter_fields = ['id', 'size']
interfaces = (relay.Node, )
rowid = graphene.String()
@resolve_only_args
def resolve_rowid(self):
return self.id
class Query(object):
ship = relay.Node.Field(ShipNode)
all_ships = DjangoFilterConnectionField(ShipNode)
```
I have an `id` field in my database which gets override when querying GraphQL server by the custom global ID. Using `resolve_rowid`, I can get the `id` I want, but I am unable to use it in the filters.
```python
query {
ship(id: "124567") {
}
}
```
How can I filter based on my database's primary key instead of the global ID? How can I rename global ID from `id` to `_id`?
Contributor guide
Assessment
This issue has not been assessed yet.