M
M
MOTORIST2016-11-17 21:33:49
go
MOTORIST, 2016-11-17 21:33:49

Error format in GraphQL?

Hello!
I decided to play around with GraphQL, I write in Go using https://github.com/graphql-go/graphql.
There was a philosophical question with return of errors. The rest api returns statuses, messages, codes, an error in development mode, a link to the documentation. I threw a 401 error, the client knows that the user should log in, sent him for authorization, validation errors, access errors, etc.
How is this in GraphQL?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Yarosh, 2017-11-14
@MOTORIST

GraphQL doesn't bind to REST... so specific headers and response statuses are not used.
Server error codes are handled as part of the GraphQL schema. GraphQL itself was developed for any transports, not only HTTP1&2, so that it could be driven, for example, under WebSockets or in general under some rtmfp thread or any other custom protocol.
It's like a REST joke:
"When was the last time you saw a HEAD request with range headers and a response status of 206 (Partial Content) ?"
"This determines the degree of knowledge and responsibility of modern hipsters in software development"
I do not recommend using a native golang lib - it does not meet the latest specifications and does not work well with either relay or apollo.
ps rest no one really knows;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question