Closed matiasinsaurralde closed 2 years ago
@matiasinsaurralde you can set the alias, or define a custom type with GetGraphQLType
method https://github.com/hasura/go-graphql-client#specify-graphql-type-name
type timestamptz time.Time
type Record struct {
ID string `graphql:"id"`
CreatedAt timestamptz `graphql:"created_at"`
}
type Query struct {
Record []Record `graphql:"record(where:{created_at: {_gte: $gte, _lte: $lte}})"`
}
err := client.Query(context.Background(), &query, map[string]interface{}{
"gte": timestamptz(time.Now()),
"lte": timestamptz(time.Now()),
})
@hgiasac Thanks. Closing this one.
I'm trying to update the updated_at value using the Mutate method. and the solution provided did not work for me, and it throws the following exception:
`parsing UTCTime failed, expected String, but encountered Object, Locations: []`
The reason behind it is the value of timestamptz(time.Now())
is equivalent to time.Time{}
object, and hasura is waiting for String to be parsed. knowing that sending a string will throw the following error:
variable 'time' is declared as 'String!', but used where 'timestamptz' is expected, Locations: []
Building the query inside the buildAndRequest
method do the job, but cannot handle having the 'timestamptz' to be sent as String.
If there are no solution, a possible solution might be by editing the queryArguments
in ConstructMutation
method, to make optional parsing of the arguments manually by the developer(similar to OptionType
..eg.. OperationName
implementation by providing the Arguments' names as another Option), rather than only parsing it using only the implemented code.
Hi, I'm facing an issue when trying to pass
time.Time
values as variables during a query:The following error shows up:
Same error occurs if I pass a string version of the date as
gte
. Wandering what's the appropriate way here.