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

fix: reuse foreign key field in @belongsTo transformer #8557

Merged
merged 3 commits into from
Oct 26, 2021

Conversation

edwardfoyle
Copy link
Contributor

Description of changes

Modifies the @belongsTo transformer to reuse the foreign key field created by the corresponding @hasMany directive when generating the belongsTo resolvers and types. It also reuses the same field name when the corresponding relation is @hasOne. While this is not strictly necessary, it creates a more consistent naming experience. It also means that a @hasOne relation can be changed to a @hasMany relation and existing relationships will be maintained.

Also created an E2E test utility that wraps a bunch of common logic for spinning up test APIs. Hopefully this can be used across many tests in the future

Issue #, if available

Description of how you validated changes

Manually tested and added an E2E test

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@edwardfoyle edwardfoyle requested a review from a team as a code owner October 26, 2021 17:04
@edwardfoyle edwardfoyle changed the title Belongs to field fix fix: reuse foreign key field in @belongsTo transformer Oct 26, 2021
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@ammarkarachi ammarkarachi merged commit 39fbe6f into aws-amplify:master Oct 26, 2021
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.

3 participants