Generate input types and output enums into target file#10527
Generate input types and output enums into target file#10527eddeee888 merged 22 commits intodotansimha:master-nextfrom
Conversation
🦋 Changeset detectedLatest commit: 9cea149 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
| ); | ||
| this._declarationBlockConfig = { | ||
| ignoreExport: this.config.noExport, | ||
| enumNameValueSeparator: ' =', |
There was a problem hiding this comment.
I experimented with different enumType, this value appears to be required for other enumTypes to work.
There was a problem hiding this comment.
Yes you are right! I've got a similar fix in my follow-up Enum PR here: https://github.com/dotansimha/graphql-code-generator/pull/10525/files#diff-d0b5088bd638fefba8ba49f14b488769f115ef1daff777afbe718a4c5ecdf111R172
| const operationsResult = oldVisit(allAst, { leave: visitor }); | ||
|
|
||
| let operationsContent = operationsResult.definitions.join('\n'); | ||
| const operationsDefinitions = operationsResult.definitions; |
There was a problem hiding this comment.
I rearranged/simplified the code here - please check.
| operationsContent = operationsResult.definitions.concat(exportConsts).join('\n'); | ||
| } | ||
|
|
||
| if (config.globalNamespace) { |
There was a problem hiding this comment.
I moved this block to the end - to include all the generated code.
| `); | ||
| }); | ||
|
|
||
| it('try different ways to generate enums', async () => { |
There was a problem hiding this comment.
Oops sorry! I should have mentioned I'm working on the tests here: #10525
Since similar tests have been moved to standalone.enum.spec.ts, shall we remove the duplicates in this PR?
There was a problem hiding this comment.
Sure! Extra tests removed.
We can probably rearrange tests in a better way - to avoid this file getting cluttered.
|
Sorry! I caused some conflicts in this PR after merging #10525 🙏 |
| private getInputObjectDeclarationBlock(node: InputObjectTypeDefinitionNode): DeclarationBlock { | ||
| return new DeclarationBlock(this._declarationBlockConfig) | ||
| .export() | ||
| .asKind('type') | ||
| .withName(this.convertName(node)) | ||
| .withComment(node.description?.value) | ||
| .withBlock((node.fields || []).join('\n')); | ||
| } | ||
|
|
||
| private getInputObjectOneOfDeclarationBlock(node: InputObjectTypeDefinitionNode): DeclarationBlock { | ||
| const declarationKind = (node.fields?.length || 0) === 1 ? 'type' : 'type'; | ||
| return new DeclarationBlock(this._declarationBlockConfig) | ||
| .export() | ||
| .asKind(declarationKind) | ||
| .withName(this.convertName(node)) | ||
| .withComment(node.description?.value) | ||
| .withContent(`\n` + (node.fields || []).join('\n |')); | ||
| } | ||
|
|
||
| private isValidVisit(ancestors: any): boolean { | ||
| const currentVisitContext = this.getVisitorKindContextFromAncestors(ancestors); | ||
| const isVisitingInputType = currentVisitContext.includes(Kind.INPUT_OBJECT_TYPE_DEFINITION); | ||
| const isVisitingEnumType = currentVisitContext.includes(Kind.ENUM_TYPE_DEFINITION); | ||
|
|
||
| return isVisitingInputType || isVisitingEnumType; | ||
| } |
There was a problem hiding this comment.
With utility functions that can be shared between typescript-operations and base-types-visitor like these, I wonder if we should abstract them into visitor-plugin-common now or in a following PR? 🤔
Having them in visitor-plugin-common helps ensure they'd behave the same all the time. I've done the same for Enum utilities here : https://github.com/dotansimha/graphql-code-generator/pull/10525/files#r2585220345
There was a problem hiding this comment.
Sure, I'll move them to visitor-plugin-common!
Maybe after I fix all the bugs that I discover while running over the yelp codebase?
I am working on a quite tricky bug now with enum not being rendered from a fragment in a separate document.
There was a problem hiding this comment.
Sure! No rush.
I also put a FIXME or TODO on these utility functions in my PRs to refactor later
| const typeInfo = new TypeInfo(schema); | ||
| visit( | ||
| documentNode, | ||
| visitWithTypeInfo(typeInfo, { |
There was a problem hiding this comment.
Huh, this is my first time learning about this. Could you help me with the TLDR; of TypeInfo and how it helps us here?
There was a problem hiding this comment.
I am no expert on this as well. I relied on claude AI for this piece of code.
Having said that, here is what I think this code is doing:
- It looks like an operation’s AST doesn’t include field types - only names.
TypeInfois a stateful helper that tracks typing context while you walk the AST (https://www.graphql-js.org/api-v16/utilities/#typeinfo).visitWithTypeInfowires that context into a visitor. I have not found a working docs link onvisitWithTypeInfo, I guess our best bet is the docs in the source code which is located at the same place asTypeInfo: https://github.com/graphql/graphql-js/blob/next/src/utilities/TypeInfo.ts.
0b36e76 to
eca9224
Compare
83ee745 to
e89b353
Compare
ac4d132 to
e51f65e
Compare
e51f65e to
58a9ac9
Compare
| .withBlock((node.fields || []).join('\n')).string; | ||
| } | ||
|
|
||
| InputValueDefinition( |
There was a problem hiding this comment.
In typescript plugin, the logic to generate a Input Value string is spread across multiple methods:
InputObjectTypeDefinitionNamedTypeListTypeNonNull- And a couple of private methods
That was very confusing to both maintainers and contributors, and results in as any as string in many places.
This version brings all logic into one place method.
I'll see if this could be re-used between both plugins
There was a problem hiding this comment.
Excellent!
I like that you replace all these functions with just one!
However, I am bit concerned about IIFE that you do here. Because this code runs in a hot loop, there is a chance for this code to cause performance issue. The chance is low (it should be optimized by JIT), but still...
Is there a way to write this code without IIFE? In the worst case - we can split it into 3 functions (it is still better than the original version).
There was a problem hiding this comment.
Good call! I've replaced the IIFEs with pure functions in 9cea149
There was a problem hiding this comment.
Great! Yes, this look safer.
Thanks!
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
) * input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
* Add dummy commit to create branch * Ensure CI runs * [typescript-operations] Generate `Exact` into target file (#10504) * Create standalone test * Add Exact and set up test * Remove Exact from typescript plugin * Update tests that switch out Exact * Update dev tests * Add changeset * Update test * Add InputMaybe Scalars tests * Fix schema in test * Fix up examples tests * Add result enum example * [typescript-operations] Remove inputmaybe and scalars (#10509) * [typescript-operations] Remove generation of InputMaybe and Scalars for variables * Adding support for `config.scalars`, fixing intergation tests --------- Co-authored-by: Igor Kusakov <[email protected]> * chore(dependencies): updated changesets for modified dependencies * [typescript-operations] Extract convertSchemaEnumToDeclarationBlockString and getNodeComment to `visitor-plugin-common` (#10520) * Extract convertSchemaEnumToDeclarationBlockString and getNodeComment to visitor-plugin-common to re-use in next major version * Create major breaking changeset for @graphql-codegen/visitor-plugin-common * Fix naming * Replace buildEnumValuesBlock method in base-types-visitor with a utility version * Fix changeset * Fix import path * Fix getNodeComment import issue by moving to utils.ts * [typescript-operations] Generate enums referenced in operation Variables (#10508) * Collect used enums * Use enum converter for Enum * Add changeset * Add doc * Update dev tests * Fix return type issue * [typescript-operations] Add missing enum tests & fix enum generating logic for standalone approach (#10525) * Add tests for enum * Baselin tests * Ensure correctness of enumValues import * Split enum tests * Abstract import printing functions * Add missing enum tests * Format to minimise conflict * Add changeset * Add generatesOperationTypes config option to generate shared types only (#10529) * [typescript-operations] Add importSchemaTypesFrom to import user-defined+used input/enum types externally (#10534) * Draft importSchemaTypesFrom * Minor test fixes * Fix test name * Update dev-tests * Baseline dev-test for importSchemaTypesFrom * Implement relative import paths correctly * Update tests to handle outputDir correctly * Add test for absolute importSchemaTypesFrom * Remove unncessary files * Add test about unused things * Remove comment * Add comments * Add changeset * [typescript-operations][client-preset] Integrate new typescript-operations with client preset (#10540) * Do not use typescript and its config in Client Preset * Fix issue where enumValues are imported even if not used * Split enum tests for client preset * Update unit tests * Update examples * Generate Incremental utilty type * Add changeset * Rebase tests (with errors) * [typescript-operations] No optional Result fields, unless deferred or conditional (#10548) * Fix types issues and put comments * Handle avoidOptionals * Update integration tests * Add FIXME to pass test for now * Add changeset * Generate input types and output enums into target file (#10527) * input types, input/output enums are generated to the target files * cleanup * better code * more tests * cleanup * better code * better tests * bugfixing for inner types and outer enums * bugfixing after merge * cleanup * cleanup * fix snapshots * fix type errors in presets/client * updated tests/examples * Add standalone.input.spec.ts and update standalone tests to TDD * Update operations/visitor.ts to satisfy tests * Revert Client Preset changes * Add oneOf directive for GraphQL 15 * Update changeset * Refactor IIFE --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]> * Remove placeholder and test release 🤞 * Test snapshot release * [typescript-operations] Fix __typename optionality and nullability (#10552) * Fix typename optionality and existence at Result root and types * Update tests * Update tests * Stop allowing skipTypename into Client Preset and typescript-operations, and update tests * Remove dependency on typescript plugin * Add changeset * [typescript-operations] Clean up selection set processor that depends on `typescript` plugin (`preResolveTypes: false`) (#10556) * Remove legacy selection set proccessor that depends on typescript plugin * Remove obsolete tests * Improve tests to be explicit * Adjust config inheritance to reflect usage and type-hint better (#10560) * Refactor utility function to match practice * Fix config option inheritance - addTypename/skipTypename: is only a types-visitor concern. This is moved to types-visitor from base-visitor - nonOptionalTypename: is a documents-visitor and types-visitor concern. Moved from base-visitor there - extractAllFieldsToTypes: is a documents-visitor concern. Moved from base-visitor there - enumPrefix and enumSuffix: need to be in base-visitor as all 3 types of visitors need this to correctly sync the enum type names. This is moved to base visitor - ignoreEnumValuesFromSchema: is a documents-visitor and types-visitor concern. Moved from base-visitor there. - globalNamespace: is a documents-visitor concern. Moved from base-visitor there Other changes: - documents-visitor no longer extends types-visitor _option types_ as they have two distinct usages now. The types now extend base-visitor types. This is now consistent with documents-visitor extending base-visitor - Classes now handle config parsing and types at the same level e.g. if typescript-operations plugin parses configOne, then the types for configOne must be in that class, rather than in base-documents-visitor * Remove references and tests related to skipTypename in operations plugin * Add changeset * chore(dependencies): updated changesets for modified dependencies * Fix issues after rebasing (#10563) * Fix missing dep * chore(dependencies): updated changesets for modified dependencies * Fix dev-tests --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore(dependencies): updated changesets for modified dependencies * Remove unused utility types and functions (#10564) * Remove MakeOptional MakeMaybe MakeEmpty and Incremental utitlity types from typescript plugin because they were used for typescript-operations * Fix unit tests * Remove deprecated functions * Add changeset * Add config extract all fields to types field names only (same as apollo-tooling), v2 (#10568) * add extractAllFieldsToTypesCompact config option * adding changeset * fixing duplication bug * duplication bug fix --------- Co-authored-by: Igor Kusakov <[email protected]> * Only generate `Exact` utility type if documents have operations (#10571) * Remove extraneous test setup * Do not generate Exact utility type of not used * Add default test case to check that Exact is used for Mutation and Subscription variables * Update dev-tests * Add changeset * Remove extraneous config for Exact test * Make `unknown` instead of `any` the default scalar type (#10566) * Make default scalar unknown, instead of any * Set up defaultScalarType tests * Add changeset * Revert unrelated null | undefined changes * Fix test description * Add a test case for custom scalar in dev-test * Decouple `typescript-operations` plugin from `typescript` plugin (#10572) * Decouple TypeScriptOperationVariablesToObject from typescript plugin * Add changeset * Remove typescript plugin dep * chore(dependencies): updated changesets for modified dependencies --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore(dependencies): updated changesets for modified dependencies * Add `inputMaybeValue` to allow changing Variables and Input nullable types (#10573) * Shuffle methods to group things together, cleanup * Wire up _inputMaybeValue and organise config * Wire up inputMaybeValue * Add inputMaybeValue test * Update tests * Add changeset * [typescript-operations] Handle printing "Maybe" types consistently when types are `any` and `unknown` (#10574) * Use printTypeScriptType to handle printing typescript types consistently, especially for any and unknown * Update tests * Add changeset * Make printTypeScriptMaybeType scope smaller * Update tests * [typescript-operations] Fix Input generation when using `importSchemaTypesFrom` (#10575) * Fix importing issue when using importSchemaTypesFrom * Add dev-tests for usage with typescript plugin * Update unit test * Add changeset * Bugfix: enums from external fragments were not generated along with operations (#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 <[email protected]> Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]> * Various test, FIXMEs, config fixes (#10577) * Enable TS test * Add missing test for globalNamespace * Ensure dev-test-apollo-tooling is private * [typescript-operations] Cut down `avoidOptionals` to only support `object`, `inputValue` and `defaultValue` (+ minor drive-by fixes) (#10579) * Trim down avoidOptionals for client use case * Add changeset * Correctly ignore dev-test from changeset * [typescript-operations] Rename `avoidOptionals.object` to `avoidOptionals.variableValue` to better reflect the target (#10582) * Rename avoidOptionals.object -> avoidOptionals.variableValue to better reflect the target. Add tests. * Add default input use cases * [typescript-operations] Fix external custom scalars not getting imported (#10584) * Rename scalar test * Refactor to move position of getEnumsImports to group methods * Implement handling of external scalars * Add (wrong) import scalar tests to work against * Fix importing types wrongly count Scalar as part of types generated into shared type file * Do not generate scalar imports if not needed * Add changeset * Cleanup * Fix granularity of operation-file * Improve comments, remove unused prop (#10589) Co-authored-by: Igor Kusakov <[email protected]> * Remove support for directiveArgumentAndInputFieldMappings (#10596) * [CLI] Set `noSilentErrors: true` by default (#10597) * Set noSilentErrors: true by default * Add changeset * Format tests * Change generatesOperationTypes to generateOperationTypes for consistency (#10602) * [typescript-operations] Set `namespacedImportName` default value when `importSchemaTypesFrom` is used (#10603) * Improve namespacedImportName integration with importSchemaTypesFrom * Update dev-test * Update changeset * [typescript-operations] Change default input ID scalar type (#10604) * Ensure input and variables use the same input scalars default * Add changeset * chore(dependencies): updated changesets for modified dependencies * Fix lint issue * Fix unit tests (#10606) * [client-preset] Update client preset doc and clean up deps (#10608) * Remove typescript plugin from client-preset as no longer used * Update client-preset doc * Add changeset * chore(dependencies): updated changesets for modified dependencies --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore(dependencies): updated changesets for modified dependencies * [client-preset] Fix docs for upcoming major release (#10609) * Fix enumValues doc issue * fix link issues in client preset doc * Move nonOptionalTypename and skipTypeNameForRoot together in the doc for ease of read * chore(dependencies): updated changesets for modified dependencies * Bring in latest near-operation-file preset (#10621) * Master next fix native ast detection (#10637) * Fix isNativeNamedType function * Add changeset * Regen dev-tests * Rename function from collectUsedInputTypes to collectUsedSchemaTypesToGenerate to correctly reflect its functionality (#10640) * [typescript-operations] Add warning for internal utility types (#10643) * Add internal utility type warning * Update snapshots * Add changeset * Improve internal type message * [typescript-operations] Fix `@skip` and `@include` not applying conditional modifiers correctly when used on inline fragment (#10645) * Migrate skip and include directive tests to a new file * Add test for aliased field * Add test for include directive, inline fragment cases * Refactor selection set to object to reflect current usages * Standardise type, parsing, fragment directive handling and fix conditional when inline fragment is used * Add inline fragment skip directive test * Add changeset * [typescript-operations] Fix @Skip and @include not applying conditional modifiers correctly when used on fragment spread (#10646) * Set up TDD * WIP implement conditional fragmentspread * Fix empty object detection logic * Format/cleanup * Add test for include+skip+defer * Add changeset * Fix test * Add test case (#10647) * [Major version release] Drop Node 20 tests for normal runs (#10648) * Drop Node 20 tests for normal runs * Add changeset * Drop Node 20 support for watcher tests * Revert "Drop Node 20 support for watcher tests" This reverts commit cc52a81. * Update package deps (#10650) * Bump ESM packages - detect-indent v7 - auto-bind v5 - chalk v5 - log-symbols v7 - debounce v3 * Bum all package deps to latest * chore(dependencies): updated changesets for modified dependencies * Revert @inquirer/prompts to v7 to be handled later * chore(dependencies): updated changesets for modified dependencies --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore(dependencies): updated changesets for modified dependencies * Bump inquirer and improve related tests (#10651) * Bump inquirer * chore(dependencies): updated changesets for modified dependencies * WIP fix test * Swap bddstd for inquirer/testing * Fix spec tsconfig to fix ts import issue in tests ESM * Fix unnecessary Promise * Update init tests to use @inquirer/testing --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore(dependencies): updated changesets for modified dependencies * Add ESM changeset * [client-preset] Make persisted docs default hashing algorithm sha256, and follow recommended format (#10652) * Update default hash to be sha256 for persisted documents * Add changeset * chore(dependencies): updated changesets for modified dependencies * Update tests * chore(dependencies): updated changesets for modified dependencies --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * [typescript-operations] Add `declarationKind` support (#10654) * typescript-operations: Add support for declarationKind option * Drive-by: add fixme * Add changeset * [typesceript-operations] Refactor operations avoidOptionals and declarationKind config (#10655) * move normalizeAvoidOptionals to visitor-plugin-common * Make normalizeOperationDeclarationKind similar to normalizeOperationAvoidOptionals * Fix issue where extractAllFieldsToTypes always causes console to warn * Fix compilation issues * [typescript-operations] Fix enumValues not considering namingConvention in certain scenarios (#10656) * Set up test * Refactor naming functions to visitor-plugin-common/naming * Parse EnumValues with applying namingConvention on the schema type and use it for imports * Ensure converted enum type is used across imports, exports and Result * Fix enum-values.spec tests * Update implementation to match expected * Update enumValues tests * Ensure correct naming convention being applied to Input, Variables and Result types * Create a section for enumValues * add changeset * [typescript][typescript-resolvers] Fix enumValues not considering namingConvention in certain scenarios (2) (#10657) * Ensure enumValues is consistent in typescript and typescript-resolvers * Add a note to default alias import not doing anything * Add changeset * chore(dependencies): updated changesets for modified dependencies * Cleanup after rebase * feat(cli): use `ESM` by default (#10705) * feat(cli): use `ESM` by default * Update graphql-codegen-esm to use esm/bin.js * Remove master-next CI config --------- Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: Igor Kusakov <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: ikusakov <[email protected]> Co-authored-by: Arda TANRIKULU <[email protected]>
Description
Generates input types into target files.
Generates output enums into target files.
Related # #10496
Type of change
Please delete options that are not relevant.
How Has This Been Tested?