F
F
Fyodor Buzinov2017-10-23 13:56:23
Django
Fyodor Buzinov, 2017-10-23 13:56:23

How to get id from table in graphene?

Hello!
I am making a request like this

{
  all_books(first: 1) {
    edges {
      node {
        id
        title
      }
    }
  }
}

I get this response:
{
  "data": {
    "all_books": {
      "edges": [
        {
          "node": {
            "id": "Qm9va05vZGU6NDc2NDk1",
            "title": "Скромный герой"
          }
        }
      ]
    }
  }
}

How to get the id normally in the form that the book has?
Then I use it to create a link /book/110/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fyodor Buzinov, 2017-10-23
@Feduch

So far, I have found a solution, use from_global_id on the client side

from graphql_relay.node.node import from_global_id
from_global_id(node['id'])[1]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question