You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When querying a field that does use Laravel Middleware via @middleware, and an Exception is thrown in the Middleware, the Request fails before we are in the GraphQL execution context. The resulting Response is not a proper GraphQL response, it does not conform to the specification.
The problem with this becomes even more apparent when you consider that one might query multiple fields in a single request. A failure in one field would cause the whole query to abort. However, the correct behaviour would be to return an error for one field and resolve the other field as usual.
Describe the solution you'd like
We might use the Context, which is the third resolver argument, to call the Middleware on a per-field basis, while we are already during GraphQL execution.
This would also solve another issue: We are currently forced to load all fields of the root Query and Mutation types to evaluate if they have middleware. Deferring the Middleware execution would allow us to load those fields lazily, just like any other field.
Possible issues
We have to ensure that we always have the request available as part of the Context object
This would change the behaviour of Middleware execution in a possibly breaking way
Is your feature request related to a problem? Please describe.
When querying a field that does use Laravel Middleware via
@middleware
, and an Exception is thrown in the Middleware, the Request fails before we are in the GraphQL execution context. The resulting Response is not a proper GraphQL response, it does not conform to the specification.The problem with this becomes even more apparent when you consider that one might query multiple fields in a single request. A failure in one field would cause the whole query to abort. However, the correct behaviour would be to return an error for one field and resolve the other field as usual.
Describe the solution you'd like
We might use the Context, which is the third resolver argument, to call the Middleware on a per-field basis, while we are already during GraphQL execution.
This would also solve another issue: We are currently forced to load all fields of the root Query and Mutation types to evaluate if they have middleware. Deferring the Middleware execution would allow us to load those fields lazily, just like any other field.
Possible issues
TODOs
The text was updated successfully, but these errors were encountered: