Dgraph Undefined Variables Error in GraphQL

example schema that should reproduce (If you need full schema let me know)

type Contact {
  id: ID!
  name: String
  hasTasks: [Task] # tasks that need to be done to this contact
  hasToDos: [Task] # tasks that this contact needs to do
}

type Task {
  id: ID!
  name: String!
  occurrances: [TaskOccurance] @hasInverse(field: task)
  forContact: Contact @hasInverse(field: hasTasks)
  designated: Contact @hasInverse(field: hasToDos)
}

type TaskOccurance { # broken out of Tasks that way a single task can be recurring
  id: ID!
  task: Task @hasInverse(field: occurrances)
  due: DateTime
  comp: DateTime
}

Now my query, I want to get contacts and the tasks that need to be done for them, and the tasks that they have to do.

query {
  queryContact {
    id
    name
    hasTasks {
      id
      name
      occurrances {
        due
        comp
      }
    }
    hasToDos {
      id
      name
      occurrances {
        due
        comp
      }
    }
  }
}

which resulted in the following error:

Dgraph query failed because Dgraph execution failed because Some variables are used but not defined\nDefined:[]\nUsed:[TaskOccurance1 TaskOccurance2]

This is all valid schema and should be an acceptable query even without any data present.

Again using version: v2.0.0-rc1-448-gd5892dc0c

Hi @amaster507,

I created this schema on an empty dgraph instance and then ran your query. It didn’t fail for me but of course there was no data in results because I hadn’t added any.

If you have added some data post which this is happening, please share the data mutation query as well. I will try to replicate.

1 Like

I was able to execute the above query without getting error. Can you share the JWT claim that you are passing? The error might be related to it.

@arijit, I am getting this error on a consistent basis now with multiple different queries. Happens more often with deeply nested queries. Any results back yet on a resolution? Were you able to duplicate it with the JWT I sent you in a PM?

Hi @amaster507, I couldn’t find the JWT in PM. Can you reshare it? I will take a look at this today and get back to you with my findings.

1 Like

Thanks for sharing the JWT. I was able to reproduce the issue locally. I am working on the fix now.

2 Likes

This issue has been fixed and merged to master.

2 Likes

@gja,

Can this get pulled into Slash. I am having this error repeatedly. Or, if this has already been pulled into Slash, can you let me know so that I can raise new similar issue.

This is preventing some of my @auth directive rules from being ran until this gets fixed, so an urgency would be appreciated.

@amaster507 Just confirmed with the slash team. They will pull the changes by tomorrow.

2 Likes