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鈥檒l 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

Conversation

@agnes512
Copy link
Contributor

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 Oct 2, 2019
@agnes512 agnes512 marked this pull request as ready for review Oct 2, 2019
@agnes512 agnes512 requested review from bajtos and raymondfeng as code owners Oct 2, 2019
@agnes512 agnes512 force-pushed the inclusion-cli branch from 49968eb to 4b7a0bf Oct 2, 2019
docs/site/Relation-generator.md Outdated Show resolved Hide resolved
const relationPropertyName = this._getRepositoryRelationPropertyName();
if (options.isInclusionResolverRegistered) {
const statement =
"this.registerInclusionResolver('" +

This comment has been minimized.

Copy link
@dhmlau

dhmlau Oct 2, 2019

Contributor

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.

This comment has been minimized.

Copy link
@raymondfeng

raymondfeng Oct 7, 2019

Member

Agree. Template string makes the code easier to read.

packages/cli/generators/relation/index.js Outdated Show resolved Hide resolved
@agnes512 agnes512 force-pushed the inclusion-cli branch from 7d80293 to 911fb07 Oct 3, 2019
Copy link
Member

bajtos left a comment

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/,

This comment has been minimized.

Copy link
@bajtos

bajtos Oct 3, 2019

Member

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.
@agnes512 agnes512 force-pushed the inclusion-cli branch from 911fb07 to 8ec8625 Oct 7, 2019
@agnes512 agnes512 force-pushed the inclusion-cli branch from 1a5e4e8 to a77b297 Oct 8, 2019
@bajtos
bajtos approved these changes Oct 8, 2019
Copy link
Member

bajtos left a comment

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

@agnes512 agnes512 force-pushed the inclusion-cli branch from a77b297 to 14a6131 Oct 8, 2019
@agnes512 agnes512 merged commit 199e1bc into master Oct 8, 2019
4 checks passed
4 checks passed
Travis CI - Pull Request Build Passed
Details
clahub All contributors have signed the Contributor License Agreement.
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
coverage/coveralls Coverage increased (+0.01%) to 91.841%
Details
@agnes512 agnes512 deleted the inclusion-cli branch Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can鈥檛 perform that action at this time.