graphql-code-generator
graphql-code-generator copied to clipboard
Auto select ids for relay
Description
Relay automatically selects the id
field on a type if one is available, event when the engineer did not explicitly select it in their query / fragment / whatever. At Gallery, we use graphql-codegen to generate type safe mocks for our tests. This leads to a divergence between the two technologies. The types generated by graphql-codegen do not have the id
field in the types. This leads to Relay freaking out when the id
field is not present.
This PR simply automatically selects the field if one is present.
Type of change
Please delete options that are not relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
How Has This Been Tested?
I added a new test block to ts-document-spec
with some good coverage related to this code.
Test Environment:
- OS: MacOS
-
@graphql-codegen/...
: ? - NodeJS: 16.12.0
Checklist:
- [ ] 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
- [ ] Any dependent changes have been merged and published in downstream modules
⚠️ No Changeset found
Latest commit: dd4599c55bb8bb90fbfffd4461bce32786f54977
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
Someone is attempting to deploy a commit to the The Guild Team on Vercel.
A member of the Team first needs to authorize it.
@charlypoly I'm a bit confused on how I can help move this PR forward. Should we be discussing in the other thread? https://github.com/dotansimha/graphql-code-generator/issues/7888
@charlypoly can we get this merged?
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Updated |
---|---|---|---|
graphql-code-generator | ✅ Ready (Inspect) | Visit Preview | Aug 19, 2022 at 10:16AM (UTC) |
@n1ru4l definitely. i've since fixed a few small bugs. will get this PR updated asap.
@n1ru4l Alright, we should be good for a review
Hey @tbezman, starting with https://github.com/dotansimha/graphql-code-generator/releases/tag/release-1676995873 it is now possible to provide custom document transforms.
This allows implementing this in user-land, therefore this PR might no longer be needed.
What do you think?
Hey @tbezman any update regarding https://github.com/dotansimha/graphql-code-generator/pull/7881#issuecomment-1443393864?
Closing this. Please use document transforms for implementing this. https://github.com/dotansimha/graphql-code-generator/releases/tag/release-1676995873