graphql-code-generator
graphql-code-generator copied to clipboard
Issue #7615: allow interfaces to implement other interfaces
Description
This change allows users to define interfaces that implement other interfaces in their GraphQL schema, and for graphql-code-generator to properly reflect this inheritance structure in its generated code. Some minor bugs were also fixed ("abstract class" was largely ignored and did not properly "implement" the same way "class" did) and bits of code were cleaned up (where it made sense, some snippets were converted into protected methods that can be reused or adjusted by child visitors). This fix brings graphql-code-generator in-line with the most recent GraphQL spec and graphql-js as of v15.0.0 which allows for interfaces implementing other interfaces.
Related #7615
Type of change
Please delete options that are not relevant.
- [X] Bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
Screenshots/Sandbox (if appropriate/relevant):
I don't believe this is relevant, but let me know if you'd prefer something.
How Has This Been Tested?
A test already existed that set the faulty behavior as expected. The snpashot that test used (typescript.spec.ts.snap) has been changed to reflect the correct expected behavior. The specific test that called that snapshot (should use implementing types as node type - issue #5126) has been annotated to include #7615.
Test Environment:
- OS: macOS Monterey v12.2.1
@graphql-codegen/typescript: 2.4.5- NodeJS: 17.2.0
Checklist:
- [X] I have followed the CONTRIBUTING doc and the style guidelines of this project
- [X] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [X] My changes generate no new warnings
- [X] I have added tests that prove my fix is effective or that my feature works
- [X] New and existing unit tests pass locally with my changes
- [X] Any dependent changes have been merged and published in downstream modules
Further comments
This fix is relatively simple. I didn't really observe many comments in the area of the code I edited, but let me know if you think the changes warrant comments and I will make them. For the most part, I find the changes and code to be fairly straightforward and self-explanatory. I haven't made any changes to the documentation as I don't believe this is something that users need to know is explicitly possible. Users should expect this behavior out-of-the-box as it is a part of the GraphQL spec and has been a part of graphql-js for a bit now. There was no explicint warning in the documentation (that I could find) that this isn't possible, and so I didn't make any doc changes.
I read the portion of the contributing doc that said something about changeset. I'm not sure what I'm supposed to do in that regard, let me know if you need more actions on my end.
⚠️ No Changeset found
Latest commit: 5cc0a0f902100eb16d6c8efa54d35623ead08921
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/theguild/graphql-code-generator/FLdw76rdWdm4CV2qHmXzjrMAQBXS
✅ Preview: https://graphql-code-generator-git-fork-benhchoi-interface-fix-theguild.vercel.app