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
The behaviour described in the documentation under Field middleware indicates that the middlewares are driven by the @Field() decorator, but I found that they don't work for all types.
In other words, the middlewares only get called on ObectType() but not on @ArgsType() or @InputType().
dragosmc
changed the title
@Field() miidleware not running on @ArgsType() or @InputType()
@Field() midleware not running on @ArgsType() or @InputType()
Oct 13, 2022
This is intentional (GraphQLField supports declaring the resolve method, while GraphQLInputField does not - both classes come from the graphql package). Still, to make this behavior a bit more straightforward, we should probably throw an error (or at least log a warning down to the console) to inform users that middleware functions registered on the input/arg type field level will be ignored.
@kamilmysliwiec - what is the intended solution for running middleware-like transformations on input/arg types? More than happy to do a quick docs PR, but I'm not sure what the message is.
Is there an existing issue for this?
Current behavior
The behaviour described in the documentation under
Field middleware
indicates that the middlewares are driven by the@Field()
decorator, but I found that they don't work for all types.In other words, the middlewares only get called on
ObectType()
but not on@ArgsType()
or@InputType()
.The code snippets are take from the main branch of this repo and the middleware is the one described in the documentation here https://docs.nestjs.com/graphql/field-middleware
Minimum reproduction code
https://gist.github.com/dragosmc/1e59619831f78be9b3420f6e7affd928
Steps to reproduce
No response
Expected behavior
The output to contain the output of all 3 for running the e2e tests that were modified with the middlewares in the gist.
Package version
10.1.3
Graphql version
No response
NestJS version
10.1.3
Node.js version
16.15.1
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: