Open NajyFannoun opened 1 year ago
Hi Najy,
It's very helpful if you can provide the mutation example so we can reproduce the issue.
From my experience with Hasura graphql engine, instead of passing the scalar input directly, we can use the top-level object input.
type user_set_input map[string]interface{}
var mutation struct {
UpdateUsers struct {
AffectedRows int `graphql:"affected_rows"`
} `graphql:"update_user(_set: $_set)"`
}
variables := map[string]interface{}{
"_set": user_set_input{
"updated_at": time.Now()
}
}
The library encodes json directly without caring about internal input types.
You also can try type timestamptz string
alias instead of using time.Time
Thanks for the answer
using type timestamptz string
do the trick, and fix the issue.
I was using the provided solution as type timestamptz time.Time
which was throwing the exception
`parsing UTCTime failed, expected String, but encountered Object, Locations: []`
and the solution provided did not work for me, and it throws the following exception:
The reason behind it is the value of
timestamptz(time.Now())
is equivalent totime.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
inConstructMutation
method, to make optional parsing of the arguments manually by the developer(similar toOptionType
..eg..OperationName
implementation by providing the Arguments' names as another Option), rather than only parsing it using only the implemented code.Originally posted by @NajyFannoun in https://github.com/hasura/go-graphql-client/issues/51#issuecomment-1399336163