4 ms·
No. The tool also creates relationships based on foreign key references using Hasura. So to query all the users with the child users, you would make a GraphQL q
by wawhal 8y ago
No. The tool also creates relationships based on foreign key references using Hasura. So to query all the users with the child users, you would make a GraphQL query like:
query {
user {
id
name
childUser: userByUserId {
id
name
}
}
}
The response would be:
{
"data": {
"user": [
{
"id": 123,
"name": "John Doe",
"childUser": {
"id": 123,
"name": "John Doe"
}
},
{
"id": 456,
"name": "Sita K",
"childUser": {
"id": 123,
"name": "John Doe"
}
}
]
}
}
Did I answer your question?
- chrisseaton 8y agoThose child users don't then have their own child users (because it's cyclic) so do you have to choose one option of the two, both with a drawback? I was thinking you could replace or supplement the real user IDs with their indices in the array of returned users.
- general8bitso 8y agoSo, is a hypothetical scenario, an employee that is their own supervisor?
- chrisseaton 8y agoYes, but I'm not sure if you're implying that it's a nonsensical situation with that example. Lots of real-world graphs have genuine cycles.
- stevekemp 8y agoFor a good example of unexpected cycles you can see this classic question on genealogy software: https://stackoverflow.com/questions/6163683/cycles-in-family-tree-software https://stackoverflow.com/questions/6163683/cycles-in-family...
- wawhal 8y agoI am sorry, but if possible, could you elaborate @chrisseaton? (preferably with a bit more punctuation :D)
- chrisseaton 8y agoWith more punctuation? What's that supposed to mean? I've written two short sentences. It's not some wall of text.