Hi,
I’m trying to use the latest dgraph/dgraph:v20.07.0-beta.Jun22 to map an existing Dgraph schema to graphql schema and expose my database via graphql.
It didn’t work for me so I created this minimal example, which doesn’t work either.
In the ratel console I set these two nodes from the tutorial:
{
"set": [
{
"name": "Karthic",
"age": 28,
"follows": {
"name": "Jessica",
"age": 31
}
}
]
}
I can query them in ratel:
{
people(func: has(name)) {
name
age
}
}
The result:
{
"data": {
"people": [
{
"name": "Karthic",
"age": 28
},
{
"name": "Jessica",
"age": 31
}
]
},
"extensions": {
...
}
}
Now I want to expose it via graphql so following the documentation at https://graphql.dgraph.io/dgraph/ I tried this:
curl localhost:8080/admin/schema -d '
type Person {
name: String @search(by: [hash]) @dgraph(pred: "name")
age: Int @dgraph(pred: "age")
follows: Person @dgraph(pred: "follows")
}
'
I expected this to map to the implicit Dgraph schema generated after adding Karthic and Jessica to Dgraph previously. However, when I query via graphql I don’t get back these nodes:
curl 'http://localhost:8080/graphql' \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
--data-binary '{"query":"query {\n queryPerson {\n name\n age\n }\n}","variables":null}'
Result:
{"data":{"queryPerson":[]},"extensions":{}}
Could you please help me what am I doing wrong here?
Thanks!