GraphQL (as in the language spec) offers no way to perform authz. Just because there are non-standardized extensions out there for some languages, doesn't mean it is available in whatever language you're using.
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.
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.