DQL's GraphQL Variables (not GraphQL itself) variables does not support datetime

Experience Report for Feature Request

This is in regards to the “GraphQL Variables” in DQL. Not to be very easily confused with variables in GraphQL.

What you wanted to do

Use a datetime graphql variable in DQL:

query getTasksDue($dueBefore:datetime) {
  getTasksDue(func:lt(Task.due,$dueBefore)) {
    id:uid
  }
}

What you actually did

Use type string instead.

query getTasksDue($dueBefore:string) {
  getTasksDue(func:lt(Task.due,$dueBefore)) {
    id:uid
  }
}

Found only int, float, boolean, and string are supported ATM

Why that wasn’t great, with examples

The comparison is expecting a datetime value, but the DQL does not enforce the input to be a valid datetime

Any external references to support your case

Umm, GQL allows more types on “GraphQL” variables.

Do you mean that it throws an error or doesn’t execute the query? If the first, what error it throws?

Cheers.

Here is an HTTP JSON data object with a valid datetime:

{
  "query":"query getTasksDue($dueBefore:string) { getTasksDue(func:lt(Task.due,$dueBefore)) {id:uid } }",
  "variables":{
    "$date":"2019-01-01T00:00:00Z"
  }
}

Here are some with invalid datetime types:

{
  "query":"query getTasksDue($dueBefore:string) { getTasksDue(func:lt(Task.due,$dueBefore)) {id:uid } }",
  "variables":{
    "$date":"2017-13-01T00:00:00Z"
  }
}
{
  "query":"query getTasksDue($dueBefore:string) { getTasksDue(func:lt(Task.due,$dueBefore)) {id:uid } }",
  "variables":{
    "$date":"1483228800"
  }
}

These will return the errors:

: Got error: parsing time "2017-13-01T00:00:00Z": month out of range while running: name:"lt" args:"2017-13-01T00:00:00Z"

: Got error: parsing time "1483228800" as "2006-01-02": cannot parse "228800" as "-" while running: name:"lt" args:"1483228800"

But this bug I guess is a feature in a weird kind of way…

I can search for partial dates, so all of these formats will be valid a YYYY, YYYY-MM, YYYY-MM-dd, YYYY-MM-ddThh:mm:ss``, or YYYY-MM-ddThh:mm:ssZ`.

But, for completeness I cannot use the format S (Epoch seconds),YYYY-MM-ddT, YYYY-MM-ddThh, or YYYY-MM-ddThh:mm

What I was expecting is more along the lines of this error if I try to provide something instead of a string (except null)

Error parsing JSON at line 5, character 1: json: cannot unmarshal [number|bool] into Go struct field .variables of type string\n"

EDIT: Why is this important? I may be wrong, but I believe that the type catches are caught BEFORE query execution and the parsing date is caught DURING queryexecution. If caught before query execution then none of the query blocks will be ran and an immediate error will be triggered. But if there are a dozen query blocks then the error will only be caught on the one with the parsing error and the rest will still be ran utilizing resources not needed because the type was invalid.

I may be wrong in the thought process above because I do not receive any of the extensions to know how many uids were touched if any.