GraphQL Field Collection does not work with Dgraph

I’m not sure weather this is a bug or not but I have experienced an issue that the Field Collection as stated in the GraphQL specs is not working in Dgraph.

Types

type User {
  id: ID!
  userName: String
  role: Role
}

type Role {
  id: ID!
  roleName: String
}

Query

query UserQuery {
  queryUser(filter: { id: "0x123" }) {
    id
    role {
     id
   }
   ...UserFragment
  }
}

fragment UserFragment on User {
  userName
  role {
    roleName
  }
}

Expected Output

{
  "data": {
    "queryUser": [
      {
        "id": "0x123"
        "userName": "My User"
        "role": {
          "id": "0x321"
          "roleName": "My Role"
        }
      }
    ]
  }
}

Output Instead

{
  "data": {
    "queryUser": [
      {
        "id": "0x123"
        "role": {
          "id": "0x321"
        }
      }
    ]
  }
}

Also, if I move the fragment in the query all the way to the top

query UserQuery {
  queryUser(filter: { id: "0x123" }) {
    ...UserFragment
    id
    role {
     id
   }
  }
}

the result changes to that of the fragment only

{
  "data": {
    "queryUser": [
      {
        "userName": "My User"
        "role": {
          "roleName": "My Role"
        }
      }
    ]
  }
}

According to the specs this should not be the case, right? Does this happen to someone else too? Did I understand this right?

Thanks!

2 Likes