moleculerjs / moleculer-web

:earth_africa: Official API Gateway service for Moleculer framework
http://moleculer.services/docs/moleculer-web.html
MIT License
292 stars 118 forks source link

Route-level `mergeParams` doesn't exist for auto aliases #333

Open ggondim opened 10 months ago

ggondim commented 10 months ago

The mergeParams feature exists at the route-level when declared directly in the API Gateway. However, Auto-alias does not have this feature at the route-level.

At present, auto-alias only supports fullPath, basePath, path and method.

Aliases should have consistent features, whether they are declared in the gateway service or as auto-aliases.

This inconsistency directly affects the ecosystem of modules and plugins, both official and third-party. They are hindered in their ability to set route-level options in services.

For instance, moleculer-db (an official module) has already indicated its lack of support for a global mergeParams: false setting in the API Gateway (Issue #83). Should developers really be mandated to use mergeParams: true when working with moleculer-db?

To cite another case, I'm developing a third-party module named moleculer-mongobubble. It's a mixin that generates actions with auto-aliases, similar to moleculer-db. Due to this issue, it cannot determine if developers have set the mergeParams flag to true or false. This forces me to add extra conditionals to discern how parameters were passed to each action.

icebob commented 10 months ago

so an action level mergeParams could solve this problem, right? I will check whether it can be implemented or not.