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
Hi, in patch update 6.1.7, support for aliases was added to query projections (#676).
This seems like an innocent change, since the _alias parameter has default value (null), however it will cause problems when the projection is used in user code without explicitly named arguments. That's caused by the fact that the _alias parameter was added to the beginning of the parameter list, not to the end. Example:
Before 6.1.7:
Generated projection(foo: String), called in user code as projection("bar") - compiles
After 6.1.7.:
Generated projection(_alias: String = null, foo: String), called in code as projection("bar") - won't compile, because bar will be passed as _alias, leaving the required parameter foo undefined.
The fix on the user side is simple, we just need to use named argument like this: projection(foo = "bar") and everything works again. But for larger projects it can be quite annoying, especially since this isn't something that can be mass replaced and you need to fix it case by case.
Therefore I propose to revert this update and either add the _alias parameter to the end of the parameter list, or to release it as major version change, not patch.
The text was updated successfully, but these errors were encountered:
Thanks for flagging this @njuro. @mbossenbroek - what do you think? I can revert or if you are ok with moving the _alias to the end, we can go with that so it's not a breaking change.
Hi, in patch update 6.1.7, support for aliases was added to query projections (#676).
This seems like an innocent change, since the
_alias
parameter has default value (null
), however it will cause problems when the projection is used in user code without explicitly named arguments. That's caused by the fact that the_alias
parameter was added to the beginning of the parameter list, not to the end. Example:Before 6.1.7:
Generated
projection(foo: String)
, called in user code asprojection("bar")
- compilesAfter 6.1.7.:
Generated
projection(_alias: String = null, foo: String)
, called in code asprojection("bar")
- won't compile, becausebar
will be passed as_alias
, leaving the required parameterfoo
undefined.The fix on the user side is simple, we just need to use named argument like this:
projection(foo = "bar")
and everything works again. But for larger projects it can be quite annoying, especially since this isn't something that can be mass replaced and you need to fix it case by case.Therefore I propose to revert this update and either add the
_alias
parameter to the end of the parameter list, or to release it as major version change, not patch.The text was updated successfully, but these errors were encountered: