Possible to return an empty array for missing predicates

Hi there,

Is it possible to return an empty array in case the predicate is missing?

The query looks as the following:

{
      objectives(func: uid(XXXX))
          uid
          objective_lead {
              uid
              fullName
    }
}

And the query result looks currently like this:

  "data": {
    "objectives": [{
        "uid": "XXXXX"
    }]
},

But what I want is this:

  "data": {
    "objectives": [{
         "uid": "XXXXX",
        "objective_lead": []
    }]
  },

Thanks!

2 Likes

I think we could do this though it might be a nuisance for clients which already depend on the current behaviour. I would also like to check what does GraphQL spec say about this? Could you create a Github issue for this and we can look into this?

Thanks for the reply.

I opened an issue: https://github.com/dgraph-io/dgraph/issues/2337

So, let’s move the discussion there…

1 Like