I want to query using custom DQL in GraphQL and return a scalar type:
schema
type URL {
url: String!
}
type Query {
co(tp: String!): Int @custom(dql: """
query q($tp: string) {
co(func: type($tp)) {
count(uid)
}
}
""")
}
query:
query MyQuery {
co(tp: "URL")
}
response:
{
"errors": [
{
"message": "A scalar type was returned, but GraphQL was expecting an object. This indicates an internal error - probably a mismatch between the GraphQL and Dgraph/remote schemas. The value was resolved as null (which may trigger GraphQL error propagation) and as much other data as possible returned.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"co"
]
}
],
"data": {
"co": null
},
...
...
Why is GraphQL expecting an object? Does GraphQL support returning scalar types from custom DQL? If so, how?
Thx