Closed JosimarCamargo closed 4 years ago
Glad you like it. It's nice to get feedback everyone in a while, thanks.
I think you will laugh when I tell you... just raise an exception. 😄
Hahaha, you are right, I laughed. Thanks for the quick response, it worked I'm curious, I'm getting something like this
{ "errors" => [{
"message" => "Unauthorized: Unauthorized",
"code" => "eval error",
"timestamp"=>"2020-08-11T19:29:37.788091347Z"
}]}
is this"code" => "eval error"
expected?
I'll have to check on where the code is being set. I'll do that in an hour or two. Breaking for dinner.
Slight delay on dinner. When the evaluation of a query fails it causes a error in the GraphQL evaluator which becomes "eval error". That string is in err.c. The code is supposed to be a string hence the string version of the code.
Thanks again, you are doing an awesome work here
@ohler55 or @JosimarCamargo ,
I have created an exception with code and message
class Unauthorized < StandardError
attr_reader :code
def initialize
@code = 401
super('Unauthorized')
end
end
And raised the exception inside a query
raise Unauthorized.new
But it keeps returning 400 code on the response and the "eval error" on the code attribute besides the expected 401 for both cases.
< HTTP/1.1 400 Bad Request
{
"errors": [
{
"message": "GraphQL::Queries::Unauthorized: Unauthorized",
"code": "eval error",
"timestamp": "2022-06-15T01:52:08.083186200Z"
}
]
}
Could you please show me how to change the status code?
Hello, first of all, thanks for this cool blazing fast gem, I currently creating a microservice using the GraphQL, and didn't find how to fill the errors in the response, like:
{ "data": { ... }, "errors": [ ... ] }
https://graphql.org/learn/serving-over-http/#responsethere is any example that you may provide ?