Hi there! I’m quite new with GraphQL and DGraph and to this point I’ve encountered a couple problems when playing with a basic graph.
What I want to do
The objective is to create a graph of Users connected to Phones, where each user node can be connected to multiple phones and viceversa. I’m also adding a facet into the edges to track the registration time of the user-phone link. Pretty simple overall.
What I did
First of all, I’m using Dgraph’s standalone image in Docker. docker run -p 8000:8000 -p 9000:9000 -p 8080:8080 -p 9080:9080 -p 5080:5080 -it --name dgraph-learn -v ~/dgraph-learn/dgraph:/dgraph dgraph/standalone:latest
To this point, everything works smoothly, and simple queries work. However, if I try to get all the Users connected to phone “222222222”, the Docker container stops with an error (exited 255). This is the query I am using:
Glad to hear it worked for you without crashing, it reaffirms me that the problem is somewhere else.
(Docker M1 has stability issues)
Aahh, that must be it! I am indeed using Docker for a M1-chip Mac, so the crashes are almost surely related to this.
Regarding the changes on the schema, 2 quick questions:
The definition of the edge as [uid] (between brackets) is mandatory? I just created the edge through Ratel and the brackets were not there, but next time I’ll make sure to change it in Bulk edit just in case
I assume edges need to be always defined under a dgraph node type, right? So, since I left the link_user_phone outside User or Phone, this could lead to problems
Thanks again for your detailed answer, I’ll try tomorrow with these changes and let you know about the outcome
Regarding the changes on the schema, 2 quick questions:
The definition of the edge as [uid] (between brackets) is not mandatory if it’s only a one to one relation. If it’s m to n relation then it’ll need to be an array of uid => [uid]
It’s a good practice to name your predicate as objectName.predicate, so that way even if two predicates (of different objects) have the same name they will actually point to two distinct predicates (instead of overlapping on one another).