https://www.apollographql.com/docs/apollo-server/schema/dire...
Have you actually used GraphQL in production or for a wide-scale project? A lot of these criticisms for GraphQL comes from people who have played with it for an hour and determined it's not good. Give it a real chance and you'll see why big companies are using it and understand why the ecosystem is growing so fast.
If you're so brave and confident find a good pen tester and let them have a go at your api. It's a humbling experience.
You generally don't want to use HTTP error codes with field level errors in GQL.
And bo one is stopping you from returning a response that contains error details.
For example, the Pothos library implements this pattern automatically:
type Error {
message: String!
}
type Query {
hello(name: String!): QueryHelloResult
}
union QueryHelloResult = Error | QueryHelloSuccess
type QueryHelloSuccess {
data: String!
}
This field can be queried using fragments like: query {
hello(name: "World") {
__typename
... on Error {
message
}
... on QueryHelloSuccess {
data
}
}
}
https://pothos-graphql.dev/docs/plugins/errorsIf someone has solved the asshole corporate middle box problem using GQL, that’s really good news.
I'm surprised how so many HN posts about graphql just slander it. If you go to the website and look at the use case of why it was made, it makes it pretty clear when it could be a good to use. My experience with it has been very straight forward and a joy