Bugfix: enums from external fragments were not generated along with operations#10565
Conversation
🦋 Changeset detectedLatest commit: 180a80a The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…config-extractAllFieldsToTypesCompact
| const documentWithExternalFragments: DocumentNode = { | ||
| ...documentNode, | ||
| definitions: [...documentNode.definitions, ...(config.externalFragments || []).map(f => f.node)], | ||
| }; |
There was a problem hiding this comment.
I wonder if the functionality in the above statement used to create allFragments could be used for our fragments here somehow? 🤔
It seems to do a similar function of collecting fragments, either from documents or from config.
There was a problem hiding this comment.
Good call!
Check the new code - I combined it with allFragments.
dev-test-alpha/.gitignore
Outdated
| @@ -0,0 +1,2 @@ | |||
| **/__generated__/** | |||
There was a problem hiding this comment.
I feel we should unignore the generation 🙂
This could be a good test that can be kept as snapshot test, and an advanced use case of codegen
There was a problem hiding this comment.
OK, generated files added!
| @@ -0,0 +1,106 @@ | |||
| #!/usr/bin/env ts-node | |||
There was a problem hiding this comment.
I created the dev-test-alpha just as a temporary package to demonstrate our company issues.
Do you think it would be worth keeping it?
Then:
- I'll need to add some tests which would get invoked when global tests are running.
- We need to come up with some better name than
dev-test-alpha
There was a problem hiding this comment.
Yes, I think so! I find this test is very valuable, as it can be used to catch unexpected bugs, at least in the initial stage after rolling out.
I feel we might be able to simplify a few things in the setup. And worst case, if its usefulness is overshadowed by maintenance, we can decide to drop it (or further simplify) later 🙂
There was a problem hiding this comment.
OK, I renamed dev-test-alpha to dev-test-apollo-tooling - to give a more descriptive name to what this integration test it about. I also added another (hopefully last) fix - so you can run yarn install && yarn build from the root directory: graphql-code-generator and - it should work.
| // @generated | ||
| // This file was automatically generated and should not be edited. | ||
|
|
||
| import type * as Types from '../../graphql-code-generator/dev-test-alpha/src/__generated__/globalTypes'; |
There was a problem hiding this comment.
I think we already worked on removing this line in typescript-operations plugin.
But it probably comes from near-operation-file preset.
Shall we ignore it until we do the next version of near-operation-file?
There was a problem hiding this comment.
I did a research and - yes, it comes from near-operation-file.
|
|
||
| type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }; | ||
| export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; | ||
| export enum UserManagerRoleType { |
There was a problem hiding this comment.
With the recent fix - it adds the enum in the correct file.
…config-extractAllFieldsToTypesCompact
…config-extractAllFieldsToTypesCompact
There was a problem hiding this comment.
👆 The previous commit had package issues because there were lots of changes (+4k -2k LOC changes) in yarn.lock, which I think caused some package versions to be conflicting.
I've fixed this issue in this commit
git checkout b55828d4ea802db1476fb7eaada41592b9c80985 -- yarn.lock // get working yarn.lock of a stable commit
yarn // re-install packages whilst checking that minimal line changes happened and tests can run
…perations (#10565) * integration test * cleanups * cleanups2 * fixed a bug with external fragments * cleanup * keep generated files, refactored visitorwq * cleanup * changeset * adding missing dependency * delete temporary files * cleanup * cleanups * Adding back the integration tests + fix them * merged + fixes * cleanup * cleanup * patching near-operation-file preset * cleanup * adding duplicates case to integration tests * Fixing bug with duplicates generated when using extractAllFieldsToTypesCompact * cleanup * prevent running prettier on generated code * cleanups * cleanup * adding unit tests * update changeset * cleanups * try resolving graphql 16 error * remove unused deps * remove unused deps * cleanups * Revert and apply minimal yarn.lock changes --------- Co-authored-by: ikusakov <ikusakov@gxnfgqk426.y.yelp> Co-authored-by: Igor Kusakov <igor@kusakov.com> Co-authored-by: Eddy Nguyen <github@eddeee888.me> Co-authored-by: Eddy Nguyen <ch@eddeee888.me>
…perations (#10565) * integration test * cleanups * cleanups2 * fixed a bug with external fragments * cleanup * keep generated files, refactored visitorwq * cleanup * changeset * adding missing dependency * delete temporary files * cleanup * cleanups * Adding back the integration tests + fix them * merged + fixes * cleanup * cleanup * patching near-operation-file preset * cleanup * adding duplicates case to integration tests * Fixing bug with duplicates generated when using extractAllFieldsToTypesCompact * cleanup * prevent running prettier on generated code * cleanups * cleanup * adding unit tests * update changeset * cleanups * try resolving graphql 16 error * remove unused deps * remove unused deps * cleanups * Revert and apply minimal yarn.lock changes --------- Co-authored-by: ikusakov <ikusakov@gxnfgqk426.y.yelp> Co-authored-by: Igor Kusakov <igor@kusakov.com> Co-authored-by: Eddy Nguyen <github@eddeee888.me> Co-authored-by: Eddy Nguyen <ch@eddeee888.me>
…perations (#10565) * integration test * cleanups * cleanups2 * fixed a bug with external fragments * cleanup * keep generated files, refactored visitorwq * cleanup * changeset * adding missing dependency * delete temporary files * cleanup * cleanups * Adding back the integration tests + fix them * merged + fixes * cleanup * cleanup * patching near-operation-file preset * cleanup * adding duplicates case to integration tests * Fixing bug with duplicates generated when using extractAllFieldsToTypesCompact * cleanup * prevent running prettier on generated code * cleanups * cleanup * adding unit tests * update changeset * cleanups * try resolving graphql 16 error * remove unused deps * remove unused deps * cleanups * Revert and apply minimal yarn.lock changes --------- Co-authored-by: ikusakov <ikusakov@gxnfgqk426.y.yelp> Co-authored-by: Igor Kusakov <igor@kusakov.com> Co-authored-by: Eddy Nguyen <github@eddeee888.me> Co-authored-by: Eddy Nguyen <ch@eddeee888.me>
…perations (dotansimha#10565) * integration test * cleanups * cleanups2 * fixed a bug with external fragments * cleanup * keep generated files, refactored visitorwq * cleanup * changeset * adding missing dependency * delete temporary files * cleanup * cleanups * Adding back the integration tests + fix them * merged + fixes * cleanup * cleanup * patching near-operation-file preset * cleanup * adding duplicates case to integration tests * Fixing bug with duplicates generated when using extractAllFieldsToTypesCompact * cleanup * prevent running prettier on generated code * cleanups * cleanup * adding unit tests * update changeset * cleanups * try resolving graphql 16 error * remove unused deps * remove unused deps * cleanups * Revert and apply minimal yarn.lock changes --------- Co-authored-by: ikusakov <ikusakov@gxnfgqk426.y.yelp> Co-authored-by: Igor Kusakov <igor@kusakov.com> Co-authored-by: Eddy Nguyen <github@eddeee888.me> Co-authored-by: Eddy Nguyen <ch@eddeee888.me>
…perations (#10565) * integration test * cleanups * cleanups2 * fixed a bug with external fragments * cleanup * keep generated files, refactored visitorwq * cleanup * changeset * adding missing dependency * delete temporary files * cleanup * cleanups * Adding back the integration tests + fix them * merged + fixes * cleanup * cleanup * patching near-operation-file preset * cleanup * adding duplicates case to integration tests * Fixing bug with duplicates generated when using extractAllFieldsToTypesCompact * cleanup * prevent running prettier on generated code * cleanups * cleanup * adding unit tests * update changeset * cleanups * try resolving graphql 16 error * remove unused deps * remove unused deps * cleanups * Revert and apply minimal yarn.lock changes --------- Co-authored-by: ikusakov <ikusakov@gxnfgqk426.y.yelp> Co-authored-by: Igor Kusakov <igor@kusakov.com> Co-authored-by: Eddy Nguyen <github@eddeee888.me> Co-authored-by: Eddy Nguyen <ch@eddeee888.me>
…perations (#10565) * integration test * cleanups * cleanups2 * fixed a bug with external fragments * cleanup * keep generated files, refactored visitorwq * cleanup * changeset * adding missing dependency * delete temporary files * cleanup * cleanups * Adding back the integration tests + fix them * merged + fixes * cleanup * cleanup * patching near-operation-file preset * cleanup * adding duplicates case to integration tests * Fixing bug with duplicates generated when using extractAllFieldsToTypesCompact * cleanup * prevent running prettier on generated code * cleanups * cleanup * adding unit tests * update changeset * cleanups * try resolving graphql 16 error * remove unused deps * remove unused deps * cleanups * Revert and apply minimal yarn.lock changes --------- Co-authored-by: ikusakov <ikusakov@gxnfgqk426.y.yelp> Co-authored-by: Igor Kusakov <igor@kusakov.com> Co-authored-by: Eddy Nguyen <github@eddeee888.me> Co-authored-by: Eddy Nguyen <ch@eddeee888.me>
…perations (#10565) * integration test * cleanups * cleanups2 * fixed a bug with external fragments * cleanup * keep generated files, refactored visitorwq * cleanup * changeset * adding missing dependency * delete temporary files * cleanup * cleanups * Adding back the integration tests + fix them * merged + fixes * cleanup * cleanup * patching near-operation-file preset * cleanup * adding duplicates case to integration tests * Fixing bug with duplicates generated when using extractAllFieldsToTypesCompact * cleanup * prevent running prettier on generated code * cleanups * cleanup * adding unit tests * update changeset * cleanups * try resolving graphql 16 error * remove unused deps * remove unused deps * cleanups * Revert and apply minimal yarn.lock changes --------- Co-authored-by: ikusakov <ikusakov@gxnfgqk426.y.yelp> Co-authored-by: Igor Kusakov <igor@kusakov.com> Co-authored-by: Eddy Nguyen <github@eddeee888.me> Co-authored-by: Eddy Nguyen <ch@eddeee888.me>
…perations (#10565) * integration test * cleanups * cleanups2 * fixed a bug with external fragments * cleanup * keep generated files, refactored visitorwq * cleanup * changeset * adding missing dependency * delete temporary files * cleanup * cleanups * Adding back the integration tests + fix them * merged + fixes * cleanup * cleanup * patching near-operation-file preset * cleanup * adding duplicates case to integration tests * Fixing bug with duplicates generated when using extractAllFieldsToTypesCompact * cleanup * prevent running prettier on generated code * cleanups * cleanup * adding unit tests * update changeset * cleanups * try resolving graphql 16 error * remove unused deps * remove unused deps * cleanups * Revert and apply minimal yarn.lock changes --------- Co-authored-by: ikusakov <ikusakov@gxnfgqk426.y.yelp> Co-authored-by: Igor Kusakov <igor@kusakov.com> Co-authored-by: Eddy Nguyen <github@eddeee888.me> Co-authored-by: Eddy Nguyen <ch@eddeee888.me>
…perations (#10565) * integration test * cleanups * cleanups2 * fixed a bug with external fragments * cleanup * keep generated files, refactored visitorwq * cleanup * changeset * adding missing dependency * delete temporary files * cleanup * cleanups * Adding back the integration tests + fix them * merged + fixes * cleanup * cleanup * patching near-operation-file preset * cleanup * adding duplicates case to integration tests * Fixing bug with duplicates generated when using extractAllFieldsToTypesCompact * cleanup * prevent running prettier on generated code * cleanups * cleanup * adding unit tests * update changeset * cleanups * try resolving graphql 16 error * remove unused deps * remove unused deps * cleanups * Revert and apply minimal yarn.lock changes --------- Co-authored-by: ikusakov <ikusakov@gxnfgqk426.y.yelp> Co-authored-by: Igor Kusakov <igor@kusakov.com> Co-authored-by: Eddy Nguyen <github@eddeee888.me> Co-authored-by: Eddy Nguyen <ch@eddeee888.me>
Description
This PR includes 2 fixes:
Additionally, an integration test is added that mimics the Apollo-tooling setup:
dev-test-apollo-toolingTesting