Weird bug when trying to store an array with repeated values

Try out the following on slash gql β†’

Schema:

type simpleObj{
  name: String! @id
  vals: [Int!]
}

Mutation:

mutation MyMutation($vals: [Int!] ) {
  addsimpleObj(input: {name: "One", vals: $vals}) {
    numUids
  }
}

--- query variable---

{
  "vals": [0,1,0,2,0,3,0,4]
}

Query:

query MyQuery {
  querysimpleObj {
    name
    vals
  }
}

Result:

{
        "name": "One",
        "vals": [
          0,
          4,
          2,
          1,
          3
        ]
}

Expected Result:

{
        "name": "One",
        "vals": [
          0,
          1,
          0,
          2,
          0,
          3,
          0,
          4
        ]
}

Leads to problems if array has repeated values (as those values aren’t returned). Problem occurs for all built-in Object types

1 Like

Hi @kaustubh , Dgraph actually stores list as unordered set where duplicate values are not stored(stored only once). https://dgraph.io/docs/query-language/schema/#list-type

But graphql specs says it should be ordered list graphql specs and list can have duplicate values.
So yeah, currently we are not compliant with graphql specs if we see implementation of list.
Thanks for reporting this bug, we will discuss it with team.