Search code examples
djangographene-pythongraphene-django

Graphene creates unique ids


Here in relay tutorial they say:

Graphene creates globally unique IDs for all objects.
You may need to copy this value from the results of the first query

Those ids look like this SW5ncmVkaWVudE5vZGU6MQ==. And when querying a list of item in id field one can see that ids.

How can I get normal (int) ids? Or frontend should convert int ids into string ids?


Solution

  • Create a custom relay.Node class and override the from_global_id(...) method

    from graphene import relay
    
    
    class MyCustomNode(relay.Node):
    
        @classmethod
        def from_global_id(cls, global_id):
            return global_id