# Using GraphQL after setting data through DQL returns no results

**URL:** <https://discuss.dgraph.io/t/using-graphql-after-setting-data-through-dql-returns-no-results/15033>\
**Category:** GraphQL\
**Tags:** kind:bug\
**Created:** [July 22, 2021, 8:02am UTC](https://discuss.dgraph.io/t/using-graphql-after-setting-data-through-dql-returns-no-results/15033 "2021-07-22T08:02:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Assem\_Marwan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/assem_marwan/32/8619_2.png) [@Assem\_Marwan](https://discuss.dgraph.io/u/Assem_Marwan)\
**Post date:** [July 22, 2021, 8:02am UTC](https://discuss.dgraph.io/t/using-graphql-after-setting-data-through-dql-returns-no-results/15033/1 "2021-07-22T08:02:41Z")

</div>

* * *

## Report a GraphQL Bug

### What edition and version of Dgraph are you using?

Edition:

- SlashGraphQL
- Dgraph (community edition/Dgraph Cloud)

If you are using the community edition or enterprise edition of Dgraph, please list the version:

> **Dgraph Version**
>
> ```auto
> $ dgraph version
>  
> v21.03.1
> 
> ```

### Have you tried reproducing the issue with the latest release?

Yes

### Steps to reproduce the issue (paste the query/schema if possible)

- I have a local setup of Dgraph using the standalone version docker image and another container running RatelUI.
- Added predicates through RatelUI using the `set` mutation and all data was added successfully. The predicates were typed, so for email for instance, the predicate is `User.email`.
- Created a GraphQL Schema to match the predicate structure used in the first step. Schema created successfully along with the queries/mutations.

### Expected behaviour and actual result.

#### Expected Behavior

- When using `queryUser`, I should get all users added through GraphQL mutation `addUser` and users added through DQL in RatelUI.
- At the same time, I should get all users using DQL

```dql
{
   users(func: has()){
       uid
       name: User.email
   }

}

```

#### Actual Results

- Using the GraphQL query, `queryUser`, I only get users that were added using `addUser` mutation (expectation not met)
- Using DQL, I actually get all the results whether added in RatelUI (DQL) or GraphQL (Expectation met reality)

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [July 22, 2021, 11:51am UTC](https://discuss.dgraph.io/t/using-graphql-after-setting-data-through-dql-returns-no-results/15033/2 "2021-07-22T11:51:56Z")

</div>

So you have a sample of your DQL set mutation? This should work and there is not enough info here to see the problem or to duplicate.

---

<div class="post-metadata">

**Author:** ![Assem\_Marwan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/assem_marwan/32/8619_2.png) [@Assem\_Marwan](https://discuss.dgraph.io/u/Assem_Marwan)\
**Post date:** [July 23, 2021, 9:11am UTC](https://discuss.dgraph.io/t/using-graphql-after-setting-data-through-dql-returns-no-results/15033/3 "2021-07-23T09:11:05Z")

</div>

My bad, here are more details. These are not exactly the emails I have in place, so I have modified them to look anonymous

### DQL set mutation:

```json
[
  {
    "User.email": "user1@hotmail.com",
  },
  {
    "User.email": "user2@gmail.com",
  },
  {
    "User.email": "user3@gmail.com",
  }
]

```

### DQL Query and Result

#### Query

```dql
{
	receipts(func: has(User.email)){
  	  uid
 	  email: User.email

	}
}

```

#### Result

```json
{
  "data": {
    "receipts": [
     {
        "uid": "0x6b4c",
        "email": "user1@hotmail.com"
      },
      {
        "uid": "0x6b4d",
        "email": "user3@gmail.com"
      },
      {
        "uid": "0x6b50",
        "email": "user2@gmail.com"
      },
    ]
  },
}

```

### Schema (User)

This schema was set using the /admin API

```graphql
type User {
    id: ID!
    email: String
}

```

### GraphQL Query and its result:

#### Query

```graphql

query {
  queryUser {
    id
    email
  }
}

```

#### Result

```json
{
  "data": {
    "queryUser": []
  }
}

```

Please let me know if more info is required 😃

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [July 23, 2021, 12:17pm UTC](https://discuss.dgraph.io/t/using-graphql-after-setting-data-through-dql-returns-no-results/15033/4 "2021-07-23T12:17:49Z")

</div>

You need to add in the dgraph.type predicate

[https://dgraph.io/docs/query-language/type-system/#setting-the-type-of-a-node](https://dgraph.io/docs/query-language/type-system/#setting-the-type-of-a-node)

> [@Assem\_Marwan](#):
>
> The predicates were typed

But your data is not typed…

> [@Assem\_Marwan](#):
>
> ```auto
> [
> {
> "User.email": "user1@hotmail.com",
> },
> {
> "User.email": "user2@gmail.com",
> },
> {
> "User.email": "user3@gmail.com",
> }
> ]
> 
> ```

Should be:

```auto
[
  {
    "dgraph.type": "User",
    "User.email": "user1@hotmail.com",
  },
  {
    "dgraph.type": "User",
    "User.email": "user2@gmail.com",
  },
  {
    "dgraph.type": "User",
    "User.email": "user3@gmail.com",
  }
]

```

You could alternatively run an upsert mutation that adds the dgraph.type for all nodes that have the User.email predicate already.

---

<div class="post-metadata">

**Author:** ![Assem\_Marwan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/assem_marwan/32/8619_2.png) [@Assem\_Marwan](https://discuss.dgraph.io/u/Assem_Marwan)\
**Post date:** [July 23, 2021, 9:01pm UTC](https://discuss.dgraph.io/t/using-graphql-after-setting-data-through-dql-returns-no-results/15033/5 "2021-07-23T21:01:33Z")

</div>

@amaster507 Thanks very much 😃 , that did the trick
