fix: Composition fails when interface implements another interface#2754
fix: Composition fails when interface implements another interface#2754tylerscoville wants to merge 1 commit intowundergraph:mainfrom
Conversation
… return type validation
WalkthroughThis pull request enhances type validation logic to consider interface implementation relationships when validating type compatibility. The Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
composition/src/schema-building/utils.ts (1)
633-633: Minor: Consider line length for readability.This line is quite long (~130 characters). While functional, breaking it for readability would be a small improvement.
♻️ Optional formatting improvement
- return isTypeValidImplementation(originalType.type, implementationType.type, concreteTypeNamesByAbstractTypeName, parentDefinitionDataByTypeName); + return isTypeValidImplementation( + originalType.type, + implementationType.type, + concreteTypeNamesByAbstractTypeName, + parentDefinitionDataByTypeName, + );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@composition/src/schema-building/utils.ts` at line 633, Break the long return statement that calls isTypeValidImplementation for readability: split the arguments onto separate lines or assign intermediate variables for originalType.type, implementationType.type, concreteTypeNamesByAbstractTypeName, and parentDefinitionDataByTypeName before returning; keep the same function call (isTypeValidImplementation) and same argument order so behavior is unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@composition/src/schema-building/utils.ts`:
- Line 633: Break the long return statement that calls isTypeValidImplementation
for readability: split the arguments onto separate lines or assign intermediate
variables for originalType.type, implementationType.type,
concreteTypeNamesByAbstractTypeName, and parentDefinitionDataByTypeName before
returning; keep the same function call (isTypeValidImplementation) and same
argument order so behavior is unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 63592481-ff0e-4b06-a2bc-f78964393ffa
📒 Files selected for processing (4)
composition/src/schema-building/utils.tscomposition/src/v1/federation/federation-factory.tscomposition/src/v1/normalization/normalization-factory.tscomposition/tests/v1/types/interfaces.test.ts
|
Hi @tylerscoville, Does the test that you added in this PR fail without your changes? It doesn't look like it resembles the error message you've provided where there appears to be a mismatch in return types for an implementation of an interface. Perhaps you could add a failing test that resembles the case you're experiencing more closely? Thanks, The WunderGraph Team |
|
Hey @Aenimus Thanks for the quick reply! When i revert the code changes and run the tests i see the following error: |
|
@tylerscoville Apologies—I've just had a closer look. I see the pertinent part of the test here is Regardless, I glanced at the code, and I do believe there is a problem. I'll take a closer look next week. |
|
@Aenimus Happy to make any changes that clarify things. Let me know if there is anything I can help with. |
We are migrating from Apollo and have a situation where we have an interface that implements an interface that is failing composition with an error like:
I believe an interface implementing another interface is valid, and I took a pass at updating the code to support this. The test schema in
subgraphAO, although contrived, mirrors the pattern we have. This is my first time contributing, feel free to let me know if I missed something or if this is not the correct solution/place!Summary by CodeRabbit
New Features
Tests
Checklist
Open Source AI Manifesto
This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.