Hi,
I am trying to get a custom DQL query to work in a GraphQL setting, but my response is always empty.
I have tried to shrink it down to a minimal example and still no success.
This is my schema:
POST http://localhost:8080/admin/schema
type Person {
id: ID!
firstName: String!
lastName: String!
}
type Query {
queryPersonCustom : [Person] @custom(dql: """
query {
queryPersonCustom(func: uid(0x2)) {
id : uid
firstName : Person.firstName
lastName : Person.lastName
}
}
""")
}
I am adding a person like this:
POST http://localhost:8080/graphql
Content-Type: application/graphql
mutation {
addPerson(input: [{ firstName: "Harry", lastName: "Potter" }]) {
person {
firstName
lastName
}
}
}
and it is assigned the uid 0x2, as I can check with this query:
POST http://localhost:8080/graphql
Content-Type: application/graphql
query {
queryPerson(filter: {id: "0x2"}) {
id
firstName
lastName
}
}
This returns { "id": "0x2", "firstName": "Harry", "lastName": "Potter" }
as expected.
Also, my DQL is working in theory:
POST http://localhost:8080/query
Content-Type: application/dql
query {
q(func: uid(0x2)) {
id : uid
firstName : Person.firstName
lastName : Person.lastName
}
}
This returns { "id": "0x2", "firstName": "Harry", "lastName": "Potter" }
as well.
But calling the custom query via GraphQL always produces an empty result:
POST http://localhost:8080/graphql
Content-Type: application/graphql
query {
queryPersonCustom {
id
firstName
lastName
}
}
Can anyone tell me why? What am I missing?
Also: Is there a way to see what’s going on as dgraph processes my query? Can I somehow find out whether the DQL query’s result is empty or whether something goes wrong while mapping to GraphQL?
Thanks in advance!
Stefan