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!

1 Like

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: Add non nullable types to return empty arrays for missing relations · Issue #2337 · dgraph-io/dgraph · GitHub

So, let’s move the discussion there…

1 Like