-
We have a specific GraphQL query accepting a specific nullable Question: Is there a way to hook early into the code and allow/convert the invalid input values for this specific query, avoiding generating the error Using GraphQL middleware didn't work (types already validated before middleware are run) and I'm trying to avoid HTTP middleware to not impose overhead to the entire app because of this single issue. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I remember also being impacted by the strict input coercion. The previous way felt more "PHP style" to me, but that ship has sailed anyway. I'm sorry I don't have anymore recommendations, adding a Laravel HTTP middleware would be my solution. I know you evaluating that option and I cannot know your stack, but have you already benchmarked such a solution? In my experience the GraphQL type system overhead (building the schema, parsing the request, validating all the fields in the response) brings more latency to a request than a middleware manipulating some data structure slightly. |
Beta Was this translation helpful? Give feedback.
I remember also being impacted by the strict input coercion. The previous way felt more "PHP style" to me, but that ship has sailed anyway.
I'm sorry I don't have anymore recommendations, adding a Laravel HTTP middleware would be my solution.
I know you evaluating that option and I cannot know your stack, but have you already benchmarked such a solution? In my experience the GraphQL type system overhead (building the schema, parsing the request, validating all the fields in the response) brings more latency to a request than a middleware manipulating some data structure slightly.