Apollo and graphene

Get real id of item in Django and GraphQL

Hello,

When you use graphql in django using graphen and when you utilize the relay and nodes, the query result of any item while have base64 representation of the id,

You can fix that easily by subclassing from “relay.Node” and then just use the new class in the interface like in the code below:

https://gist.github.com/ahmedalttai/6951af94d056a6b2966eccf7f9b0e6c2

use this code in your schema.py file.

ps: when you want to request an item by its id you gonna need to use its base64 id or use custom resolve to request it by its id.


Posted

in

, ,

by

Comments

اترك تعليقاً

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *