a query with DateTime argument variable, it will be time.Time in go
query SiteDetail($from: DateTime!) {
data(from: $from){
from
}
}
a query with DateTime argument in string, it will be string in go
query {
data(from: "2017-10-06T03:40:00.000Z"){
from
}
}
from := params.Args["from"]
switch from.(type) {
case string:
fmt.Println("String")
case time.Time:
fmt.Println("Time")
}
if a query with DateTime argument variables in string, it should be converted to time.Time
I've just come across this exact issue. To clarify, the value from params.Args is a time.Time when the argument is given through a variable. It is a string when given directly. Consequently, the resolver needs to handle both cases. I'm unsure if this is intended or a bug, but it is definitely not expected behaviour as a developer interfacing with this package.
I'm pretty confident this was unintentional and just a bug. I've put in a PR to fix it (see above).
Most helpful comment
I'm pretty confident this was unintentional and just a bug. I've put in a PR to fix it (see above).