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

feat(cli): add inclusion resolver to lb4 relation #3856

Merged
merged 1 commit into from
Oct 8, 2019
Merged

Conversation

agnes512
Copy link
Contributor

@agnes512 agnes512 commented Oct 2, 2019

Implements #3451

(updated the cli relation tests with snapshots in #3875)

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@agnes512 agnes512 force-pushed the inclusion-cli branch 2 times, most recently from f37f8b4 to 49968eb Compare October 2, 2019 04:08
@agnes512 agnes512 marked this pull request as ready for review October 2, 2019 12:18
docs/site/Relation-generator.md Outdated Show resolved Hide resolved
const relationPropertyName = this._getRepositoryRelationPropertyName();
if (options.isInclusionResolverRegistered) {
const statement =
"this.registerInclusionResolver('" +
Copy link
Member

Choose a reason for hiding this comment

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

When first looking at this, I wonder if we can use the template string https://developers.google.com/web/updates/2015/01/ES6-Template-Strings instead of concatenating various strings. But it seems to be how we're doing it throughout the file. This might be something to consider but feel free to ignore.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. Template string makes the code easier to read.

packages/cli/generators/relation/index.js Outdated Show resolved Hide resolved
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

The pull request looks good at high level, I'd like you to improve few details.

I noticed that hasOne relation is not covered by your changes because it's not implemented yet. Can you please update the Acceptance Criteria in #2980 to mention that we should implement the "inclusion resolver" prompt too?

packages/cli/generators/relation/index.js Outdated Show resolved Hide resolved
packages/cli/generators/relation/index.js Outdated Show resolved Hide resolved
packages/cli/generators/relation/index.js Outdated Show resolved Hide resolved
/public readonly customer: BelongsToAccessor<Customer, typeof Order\.prototype\.id>;\n/,
/constructor\(@inject\('datasources\.db'\) dataSource: DbDataSource, @repository\.getter\('CustomerRepository'\) protected customerRepositoryGetter: Getter<CustomerRepository>,\) \{\n/,
/super\(Order, dataSource\);\n {4}this\.customer = this\.createBelongsToAccessorFor\('customer', customerRepositoryGetter,\);\n {2}\}\n/,
/super\(Order, dataSource\);\n {4}this\.customer = this\.createBelongsToAccessorFor\('customer', customerRepositoryGetter,\);\n/,
Copy link
Member

Choose a reason for hiding this comment

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

These regexp-based tests are verify difficult to understand and work with. Let's switch to snapshots instead. See #3788.

How to proceed:

  1. Open a new PR that will migrate these tests to snapshots. Don't make any changes in the production code, this way we will know that no regression is accidentally introduced.
  2. Rebase this PR on top of the first one. Update the snapshots to capture the new version of generated code.

@bajtos bajtos added CLI feature Relations Model relations (has many, etc.) labels Oct 3, 2019
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

I quickly scanned through the patch and don't see any obvious problems 👍

@agnes512 agnes512 merged commit 199e1bc into master Oct 8, 2019
@agnes512 agnes512 deleted the inclusion-cli branch October 8, 2019 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI feature Relations Model relations (has many, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants