Skip to content

feat: Support end-to-end relation discoveries in lb4 discover - #10874

Draft
aaqilniz wants to merge 1 commit into
loopbackio:masterfrom
aaqilniz:feat/relation-in-discovery
Draft

aaqilniz wants to merge 1 commit into
loopbackio:masterfrom
aaqilniz:feat/relation-in-discovery

Conversation

@aaqilniz

@aaqilniz aaqilniz commented Apr 7, 2025 •

Copy link
Copy Markdown
Contributor

Description

Building upon PR#8461, which introduced model-level relation generation when discovering models with relations: true, this pull request extends functionality to complete end-to-end relation discovery.

While PR#8461 successfully decorates the model classes, introspected relations currently fail at runtime because repositories lack the required accessors and controllers lack the REST routing endpoints. This PR implements the complete synchronization required across all three tiers (belongsTo model decorators, repository factories/inclusion resolvers, and REST controller routes).

Support for inverse relations (hasOne, hasMany) will be introduced in a subsequent pull request once exported foreign key introspection is expanded.

Change

  • Model Property Transformation: Safely merges existing column properties into unified relation decorators without duplicating properties.

  • Repository Integration: Automatically generates repositories and injects Getter parameters, registers repository factories (createBelongsToAccessorFor), and adds inclusion resolvers to source repositories.

  • Controller Generation: Scaffolds relation-specific REST controller files with proper OpenAPI schema definitions (getModelSchemaRef) and routing paths.

Checklist

  • DCO (Developer Certificate of Origin) signed in all commits
  • 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 👈

@aaqilniz
aaqilniz force-pushed the feat/relation-in-discovery branch 3 times, most recently from 3747874 to d1bf2a5 Compare October 4, 2025 14:24
@aaqilniz aaqilniz changed the title feat: create controller and repo while discovering when relations: true feat: create controller and repo while discovering when relations: true Oct 4, 2025
@aaqilniz
aaqilniz marked this pull request as ready for review October 4, 2025 14:32
@aaqilniz
aaqilniz force-pushed the feat/relation-in-discovery branch from d1bf2a5 to b36f8e8 Compare October 25, 2025 03:31
@coveralls

coveralls commented Oct 25, 2025 •

Copy link
Copy Markdown

Coverage Report for CI Build 44127368436

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.2%) to 55.067%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 441 coverage regressions across 32 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

441 previously-covered lines in 32 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
packages/repository/src/relations/has-many/has-many-through.repository.ts 73 0.33%
packages/rest/src/rest.server.ts 62 59.41%
packages/repository/src/relations/has-many/has-many-through.inclusion-resolver.ts 48 4.61%
packages/repository/src/repositories/repository.ts 36 1.32%
packages/filter/src/query.ts 28 15.28%
packages/context/src/binding.ts 27 64.79%
packages/repository/src/relations/has-one/has-one.repository.ts 22 24.43%
packages/http-server/src/http-server.ts 19 60.36%
packages/express/src/middleware-interceptor.ts 17 62.5%
packages/repository/src/repositories/legacy-juggler-bridge.ts 16 79.03%

Coverage Stats

Coverage Status
Relevant Lines: 11972
Covered Lines: 9086
Line Coverage: 75.89%
Relevant Branches: 10784
Covered Branches: 3445
Branch Coverage: 31.95%
Branches in Coverage %: Yes
Coverage Strength: 1362.46 hits per line

💛 - Coveralls

@aaqilniz
aaqilniz marked this pull request as draft November 14, 2026 13:43
@aaqilniz aaqilniz changed the title feat: create controller and repo while discovering when relations: true feat: Support relation discoveries in lb4 discover Nov 17, 2026
@aaqilniz aaqilniz changed the title feat: Support relation discoveries in lb4 discover feat: Support end-to-end relation discoveries in lb4 discover Nov 17, 2026
@aaqilniz
aaqilniz marked this pull request as ready for review November 17, 2026 17:31
Signed-off-by: Muhammad Aaqil <aaqilcs102@gmail.com>
@aaqilniz
aaqilniz force-pushed the feat/relation-in-discovery branch from 07e7dbc to f68d346 Compare November 19, 2026 16:16
@aaqilniz
aaqilniz marked this pull request as draft November 19, 2026 16:18

This branch has not been deployed

No deployments
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.

2 participants