-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
f37f8b4
to
49968eb
Compare
49968eb
to
4b7a0bf
Compare
const relationPropertyName = this._getRepositoryRelationPropertyName(); | ||
if (options.isInclusionResolverRegistered) { | ||
const statement = | ||
"this.registerInclusionResolver('" + |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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/test/integration/generators/relation.has-many.integration.js
Outdated
Show resolved
Hide resolved
7d80293
to
911fb07
Compare
There was a problem hiding this 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?
/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/, |
There was a problem hiding this comment.
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:
- 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.
- Rebase this PR on top of the first one. Update the snapshots to capture the new version of generated code.
packages/cli/test/integration/generators/relation.belongs-to.integration.js
Outdated
Show resolved
Hide resolved
packages/cli/test/integration/generators/relation.has-many.integration.js
Outdated
Show resolved
Hide resolved
packages/cli/test/integration/generators/relation.has-many.integration.js
Outdated
Show resolved
Hide resolved
911fb07
to
8ec8625
Compare
packages/cli/test/integration/generators/relation.belongs-to.integration.js
Show resolved
Hide resolved
packages/cli/test/integration/generators/relation.has-many.integration.js
Show resolved
Hide resolved
1a5e4e8
to
a77b297
Compare
There was a problem hiding this 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 👍
a77b297
to
14a6131
Compare
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 machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈