# Dgraph query failed because Dgraph execution failed because Some variables are declared multiple times

**URL:** <https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072>\
**Category:** GraphQL\
**Created:** [December 7, 2022, 3:08pm UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072 "2022-12-07T15:08:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![droslean](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/droslean/32/9583_2.png) [@droslean](https://discuss.dgraph.io/u/droslean)\
**Post date:** [December 7, 2022, 3:08pm UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/1 "2022-12-07T15:08:01Z")

</div>

This error message is useless. Is there any way to figure out why my query is wrong?

---

<div class="post-metadata">

**Author:** ![matthewmcneely](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/matthewmcneely/32/4774_2.png) [@matthewmcneely](https://discuss.dgraph.io/u/matthewmcneely)\
**Post date:** [December 7, 2022, 6:30pm UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/2 "2022-12-07T18:30:48Z")

</div>

Hey @droslean, Can you share the query?

---

<div class="post-metadata">

**Author:** ![droslean](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/droslean/32/9583_2.png) [@droslean](https://discuss.dgraph.io/u/droslean)\
**Post date:** [December 8, 2022, 10:13am UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/3 "2022-12-08T10:13:22Z")

</div>

I could but I don’t see how that will help. The error message is useless. There is no duplicate in my query for sure so I believe that this is more complicated. Perhaps it’s a combination of the schema and what the query is trying to do.

Can you give me some insights on what to look for?

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [December 8, 2022, 3:08pm UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/4 "2022-12-08T15:08:44Z")

</div>

This error never happen in another situation. Just when you really have duplicated variables. Machines don’t lie™.

> [@droslean](#):
>
> Can you give me some insights on what to look for?

Double check your query. This have happened to me too in the past.

---

<div class="post-metadata">

**Author:** ![droslean](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/droslean/32/9583_2.png) [@droslean](https://discuss.dgraph.io/u/droslean)\
**Post date:** [December 8, 2022, 3:36pm UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/5 "2022-12-08T15:36:37Z")

</div>

Thanks @MichelDiz . No duplicates… I rechecked. Also, my query is automatically generated which is quite unlikely that there is a duplicate. Either way, I triple checked it. There is no duplication.

---

<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:** [December 8, 2022, 4:08pm UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/6 "2022-12-08T16:08:18Z")

</div>

Assuming you are using DQL? Post the query to help get past the initial debugging mode for the devs who want to help you.

---

<div class="post-metadata">

**Author:** ![droslean](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/droslean/32/9583_2.png) [@droslean](https://discuss.dgraph.io/u/droslean)\
**Post date:** [December 8, 2022, 4:16pm UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/7 "2022-12-08T16:16:57Z")

</div>

@amaster507 I am not using DQL. My query is a graphql query, and dgraph response with the error in question.

---

<div class="post-metadata">

**Author:** ![droslean](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/droslean/32/9583_2.png) [@droslean](https://discuss.dgraph.io/u/droslean)\
**Post date:** [December 8, 2022, 4:21pm UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/8 "2022-12-08T16:21:27Z")

</div>

[queryBonus.gql](https://discuss.dgraph.io/uploads/short-url/h6OqRRBm2kqR4kS54soe9N5xR4F.gql) (66.4 KB)

There are no duplication in this query.

---

<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:** [December 8, 2022, 4:47pm UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/9 "2022-12-08T16:47:29Z")

</div>

That was the reason for my question. It is a DQL error and not a GraphQL error. So the problem is when the GraphQL gets rewritten into DQL. Do you use any auth directives in your GraphQL schema? Those can get written into DQL vars too.

> [@MichelDiz](#):
>
> Machines don’t lie

They don’t lie, but they can be buggy. This looks to be a GraphQL → DQL rewriting bug that probably involves some `@auth` rules too if I can make an educated guess from prior experiences.

---

<div class="post-metadata">

**Author:** ![matthewmcneely](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/matthewmcneely/32/4774_2.png) [@matthewmcneely](https://discuss.dgraph.io/u/matthewmcneely)\
**Post date:** [December 8, 2022, 6:09pm UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/10 "2022-12-08T18:09:02Z")

</div>

@droslean, It’s hard to replicate without a graph with your schema in place. But as a simple test, could you remove the unused variable parameters in your declaration of `QueryBonus`. I know Dgraph will error if it finds unused variables in a query.

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [December 8, 2022, 7:33pm UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/11 "2022-12-08T19:33:44Z")

</div>

@droslean Well, this is a huge query. Wow.  
We can set up a call to debug this in your end if you are available close to my timezone.

All we will need is docker, create a new cluster with your data in order to debug it.

---

<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:** [December 9, 2022, 12:43am UTC](https://discuss.dgraph.io/t/dgraph-query-failed-because-dgraph-execution-failed-because-some-variables-are-declared-multiple-times/18072/12 "2022-12-09T00:43:19Z")

</div>

If it is just the rewriter bug, then all you will need is the full schema and query. It should create the error without any actual data as this is a pre query error.
