Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

entgql: improve var name collision avoidance in toCursor #572

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

henrywoody
Copy link
Contributor

Improves variable name collision avoidance in the toCursor method of the pager types in the gql_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.

Improves variable name collision avoidance in the `toCursor` method of
the pager types in the `gql_pagination` template by suffixing all
hard-coded variables names with an underscore.
@a8m
Copy link
Member

a8m commented Apr 11, 2024

Thanks for the contribution, @henrywoody 🫶

@a8m a8m merged commit 4ec1976 into ent:master Apr 11, 2024
4 checks passed
@henrywoody
Copy link
Contributor Author

Thanks for the quick turnaround @a8m!

skeletal pushed a commit to netfira/fork-entgo.io-contrib that referenced this pull request May 9, 2024
Improves variable name collision avoidance in the `toCursor` method of
the pager types in the `gql_pagination` template by suffixing all
hard-coded variables names with an underscore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants