Home > Enterprise >  NestJs @ResolveField alternative in REST
NestJs @ResolveField alternative in REST

Time:10-27

In NestJs when we use it in combination with GraphQl, we can call @ResolveField decorator, do we have some alternatives when we use REST?

I have worked once with GraphQl and used that decorator, and now im working with rest, and want to know do we have something simillar in NestJs without Graph.

CodePudding user response:

REST does not have the idea of being able to optionally add extra fields to the response just by adding a sub field to the response. It's not a query language like GraphQL is. You would need to either add in a query parameter that allows the client to say "fetch extra data" or just return the extra data by default and let the client ignore it if it is not wanted

  • Related