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

graph codegen: handle reserved words #1929

Merged
merged 8 commits into from
Jan 29, 2025
Merged

Conversation

YaroShkvorets
Copy link
Collaborator

@YaroShkvorets YaroShkvorets commented Jan 28, 2025

Fixes #1896

  • Renames fields with reserved name in generated code "yield" -> "yield_"
  • Handles all typescript/assemblyscript reserved words
  • test

Copy link

cloudflare-workers-and-pages bot commented Jan 28, 2025

Deploying graph-tooling with  Cloudflare Pages  Cloudflare Pages

Latest commit: f6ea892
Status: ✅  Deploy successful!
Preview URL: https://3c35e1f8.graph-tooling.pages.dev
Branch Preview URL: https://yaro-codegen-reserved-words.graph-tooling.pages.dev

View logs

Copy link
Contributor

github-actions bot commented Jan 28, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphprotocol/graph-cli 0.96.0-alpha-20250128181754-f6ea8924b365aea798fbd645bad0e8a1e539c94a npm ↗︎ unpkg ↗︎

Copy link

changeset-bot bot commented Jan 28, 2025

🦋 Changeset detected

Latest commit: f6ea892

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphprotocol/graph-cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@YaroShkvorets YaroShkvorets marked this pull request as ready for review January 28, 2025 20:41
@YaroShkvorets YaroShkvorets requested a review from 0237h January 28, 2025 20:43
Copy link
Collaborator

@0237h 0237h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but just curious, why isn't safeName also used in the body of the generated code ?

For example here:

return tsCodegen.method(
`get ${safeName}`,
[],
returnType,
`
let value = this.get('${name}')
${isNullable ? getNullable : getNonNullable}
`,
);
}

@YaroShkvorets
Copy link
Collaborator Author

That would mean renaming these fields in subgraph GraphQL schema, and that's unnecessary and leaks implementation details.

@YaroShkvorets YaroShkvorets merged commit 4311d0e into main Jan 29, 2025
9 checks passed
@YaroShkvorets YaroShkvorets deleted the yaro/codegen-reserved-words branch January 29, 2025 22:25
sins921

This comment was marked as spam.

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.

yield reserved word
3 participants