entgql: improve var name collision avoidance in toCursor #572
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improves variable name collision avoidance in the
toCursor
method of the pager types in thegql_pagination
template by suffixing all hard-coded variables names with an underscore.Address the issue that was the target of #488 and #538. PR #538 fixed the issue for types that start with "O" but broke it for types that start with "Po" (e.g. "Post") or that are two words with the initials "PO" (e.g. "PostOffice"). The issue is also present for types that have the initials "CS" (e.g. "CourseSection"). My fix here puts an underscore as a suffix on all the internal variables so that variable name collision is not possible.
It might be better to opt out of dynamic variables for the argument altogether or updating the variable name generator to accept more context about names to avoid, but this seemed the minimal change to solve the issue. I'll leave it to you guys to decide if a bigger refactor is desired.