Issue querying data defined/created via graphql with graphql±

Hi Dgraph Team,

I’m attempting to query data defined via SDL and created via vanilla graphql:

schema.graphql:

type Item {
    id: ID!
    name: String!
    attributes: [String]
}

Inserting (via Altair):

mutation {
  addItem(input: [
    {name: "Banana", attributes: ["yellow", "long"] },
    {name: "Apple", attributes:["red", "round"] }
  ]) {
    item {
      id
      name
      attributes
    }
  }
}

Results:

{
  "data": {
    "addItem": {
      "item": [
        {
          "id": "0x2",
          "name": "Banana",
          "attributes": [
            "yellow",
            "long"
          ]
        },
        {
          "id": "0x3",
          "name": "Apple",
          "attributes": [
            "red",
            "round"
          ]
        }
      ]
    }
  }
}

Then, in Ratel:

{
  me(func: has(Item.name)) {
    id
    name@en
    attributes
  }
}

…yields no results:

{
  "data": {
    "me": []
  },
  "extensions": {
    <snip>
    "txn": {
      "start_ts": 83
    },
    "metrics": {
      "num_uids": {
        "Item.name": 0,
        "_total": 6,
        "attributes": 2,
        "id": 2,
        "name": 2
      }
    }
  }
}

You might be thinking, “Dude, just use vanilla graphql to search”. And you have a point, but for some operations using graphql± is a better option so understanding how the two interact would be beneficial.

In case of Graphql you have to add “item.” as a prefix

{
  me(func: has(Item.name)) {
    uid
    Item.name
    Item.attributes
  }
}

1 Like

@MichelDiz Thanks! That worked