diff --git a/.changeset/slow-penguins-deliver.md b/.changeset/slow-penguins-deliver.md new file mode 100644 index 00000000000..83e8caab38f --- /dev/null +++ b/.changeset/slow-penguins-deliver.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/typescript-resolvers': patch +--- + +Use `globalThis` for `Record` in case of conflict diff --git a/dev-test/modules/types.ts b/dev-test/modules/types.ts index 893f0c452f1..fcc39cfa74a 100644 --- a/dev-test/modules/types.ts +++ b/dev-test/modules/types.ts @@ -165,7 +165,7 @@ export type DirectiveResolverFn TResult | Promise; /** Mapping of union types */ -export type ResolversUnionTypes> = { +export type ResolversUnionTypes> = { PaymentOption: CreditCard | Paypal; }; diff --git a/packages/plugins/other/visitor-plugin-common/CHANGELOG.md b/packages/plugins/other/visitor-plugin-common/CHANGELOG.md index 7e53d4c440a..de36008b8ca 100644 --- a/packages/plugins/other/visitor-plugin-common/CHANGELOG.md +++ b/packages/plugins/other/visitor-plugin-common/CHANGELOG.md @@ -274,7 +274,7 @@ The generated types will look like this: ```ts - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { CharacterNode: Fighter | Wizard; }; @@ -318,7 +318,7 @@ Then, the generated type looks like this: ```ts - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { CharacterNode: (Fighter & { __typename: 'Fighter' }) | (Wizard & { __typename: 'Wizard' }); }; diff --git a/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts b/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts index 123f9e6b3b6..3446cd94018 100644 --- a/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts +++ b/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts @@ -1137,7 +1137,7 @@ export class BaseResolversVisitor< return new DeclarationBlock(this._declarationBlockConfig) .export() .asKind(declarationKind) - .withName(this.convertName('ResolversUnionTypes'), `>`) + .withName(this.convertName('ResolversUnionTypes'), `>`) .withComment('Mapping of union types') .withBlock( Object.entries(this._resolversUnionTypes) @@ -1155,7 +1155,7 @@ export class BaseResolversVisitor< return new DeclarationBlock(this._declarationBlockConfig) .export() .asKind(declarationKind) - .withName(this.convertName('ResolversInterfaceTypes'), `>`) + .withName(this.convertName('ResolversInterfaceTypes'), `>`) .withComment('Mapping of interface types') .withBlock( Object.entries(this._resolversInterfaceTypes) diff --git a/packages/plugins/typescript/resolvers/CHANGELOG.md b/packages/plugins/typescript/resolvers/CHANGELOG.md index e59d6277552..e73a272d44c 100644 --- a/packages/plugins/typescript/resolvers/CHANGELOG.md +++ b/packages/plugins/typescript/resolvers/CHANGELOG.md @@ -278,7 +278,7 @@ The generated types will look like this: ```ts - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { CharacterNode: Fighter | Wizard; }; @@ -322,7 +322,7 @@ Then, the generated type looks like this: ```ts - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { CharacterNode: (Fighter & { __typename: 'Fighter' }) | (Wizard & { __typename: 'Wizard' }); }; diff --git a/packages/plugins/typescript/resolvers/tests/__snapshots__/ts-resolvers.spec.ts.snap b/packages/plugins/typescript/resolvers/tests/__snapshots__/ts-resolvers.spec.ts.snap index f2ab6d709f2..183f6a050d9 100644 --- a/packages/plugins/typescript/resolvers/tests/__snapshots__/ts-resolvers.spec.ts.snap +++ b/packages/plugins/typescript/resolvers/tests/__snapshots__/ts-resolvers.spec.ts.snap @@ -98,7 +98,7 @@ export type AnotherNodeWithAll = AnotherNode & WithChild & WithChildren & { }; export type MyUnion = MyType | MyOtherType; -export type WithIndex = TObject & Record; +export type WithIndex = TObject & globalThis.Record; export type ResolversObject = WithIndex; export type ResolverTypeWrapper = Promise | T; @@ -167,13 +167,13 @@ export type DirectiveResolverFn TResult | Promise; /** Mapping of union types */ -export type ResolversUnionTypes> = ResolversObject<{ +export type ResolversUnionTypes> = ResolversObject<{ ChildUnion: ( Child ) | ( MyOtherType ); MyUnion: ( Omit & { unionChild?: Maybe } ) | ( MyOtherType ); }>; /** Mapping of interface types */ -export type ResolversInterfaceTypes> = ResolversObject<{ +export type ResolversInterfaceTypes> = ResolversObject<{ Node: ( SomeNode ); AnotherNode: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); @@ -357,7 +357,7 @@ exports[`TypeScript Resolvers Plugin Config namespacedImportName - should work c "import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql'; export type Omit = Pick>; export type RequireFields = Omit & { [P in K]-?: NonNullable }; -export type WithIndex = TObject & Record; +export type WithIndex = TObject & globalThis.Record; export type ResolversObject = WithIndex; export type ResolverTypeWrapper = Promise | T; @@ -426,13 +426,13 @@ export type DirectiveResolverFn TResult | Promise; /** Mapping of union types */ -export type ResolversUnionTypes> = ResolversObject<{ +export type ResolversUnionTypes> = ResolversObject<{ ChildUnion: ( Types.Child ) | ( Types.MyOtherType ); MyUnion: ( Omit & { unionChild?: Types.Maybe } ) | ( Types.MyOtherType ); }>; /** Mapping of interface types */ -export type ResolversInterfaceTypes> = ResolversObject<{ +export type ResolversInterfaceTypes> = ResolversObject<{ Node: ( Types.SomeNode ); AnotherNode: ( Omit & { unionChild?: Types.Maybe } ) | ( Omit & { unionChild?: Types.Maybe, unionChildren: Array } ); WithChild: ( Omit & { unionChild?: Types.Maybe } ) | ( Omit & { unionChild?: Types.Maybe, unionChildren: Array } ); @@ -702,7 +702,7 @@ export type AnotherNodeWithAll = AnotherNode & WithChild & WithChildren & { }; export type MyUnion = MyType | MyOtherType; -export type WithIndex = TObject & Record; +export type WithIndex = TObject & globalThis.Record; export type ResolversObject = WithIndex; export type ResolverTypeWrapper = Promise | T; @@ -771,13 +771,13 @@ export type DirectiveResolverFn TResult | Promise; /** Mapping of union types */ -export type ResolversUnionTypes> = ResolversObject<{ +export type ResolversUnionTypes> = ResolversObject<{ ChildUnion: ( Child ) | ( MyOtherType ); MyUnion: ( Omit & { unionChild?: Maybe } ) | ( MyOtherType ); }>; /** Mapping of interface types */ -export type ResolversInterfaceTypes> = ResolversObject<{ +export type ResolversInterfaceTypes> = ResolversObject<{ Node: ( SomeNode ); AnotherNode: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); diff --git a/packages/plugins/typescript/resolvers/tests/mapping.spec.ts b/packages/plugins/typescript/resolvers/tests/mapping.spec.ts index ec9d5ba7bbf..8adc69d903f 100644 --- a/packages/plugins/typescript/resolvers/tests/mapping.spec.ts +++ b/packages/plugins/typescript/resolvers/tests/mapping.spec.ts @@ -8,13 +8,13 @@ describe('ResolversTypes', () => { const result = await plugin(resolversTestingSchema, [], {}, { outputFile: '' }); expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Child ) | ( MyOtherType ); MyUnion: ( Omit & { unionChild?: Maybe } ) | ( MyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); @@ -84,13 +84,13 @@ describe('ResolversTypes', () => { )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Omit & { bar: RefType['String'], parent?: Maybe } ) | ( Omit & { bar: RefType['String'] } ); MyUnion: ( MyTypeDb ) | ( Omit & { bar: RefType['String'] } ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( AnotherNodeWithChildMapper ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( AnotherNodeWithChildMapper ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); @@ -178,7 +178,7 @@ describe('ResolversTypes', () => { const content = mergeOutputs([result]); expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { MovieLike: ( MovieEntity ) | ( Book ); }; `); @@ -248,7 +248,7 @@ describe('ResolversTypes', () => { const content = mergeOutputs([result]); expect(content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { MovieLike: ( MovieEntity ) | ( Book ); }; `); @@ -391,13 +391,13 @@ describe('ResolversTypes', () => { )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Partial ) | ( Partial ); MyUnion: ( Partial & { unionChild?: Maybe }> ) | ( Partial ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( Partial ); AnotherNode: ( Partial & { unionChild?: Maybe }> ) | ( Partial & { unionChild?: Maybe, unionChildren: Array }> ); WithChild: ( Partial & { unionChild?: Maybe }> ) | ( Partial & { unionChild?: Maybe, unionChildren: Array }> ); @@ -464,13 +464,13 @@ describe('ResolversTypes', () => { expect(result.prepend).toContain(`import { CustomPartial } from './my-wrapper';`); expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( CustomPartial ) | ( CustomPartial ); MyUnion: ( CustomPartial & { unionChild?: Maybe }> ) | ( CustomPartial ); } `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( CustomPartial ); AnotherNode: ( CustomPartial & { unionChild?: Maybe }> ) | ( CustomPartial & { unionChild?: Maybe, unionChildren: Array }> ); WithChild: ( CustomPartial & { unionChild?: Maybe }> ) | ( CustomPartial & { unionChild?: Maybe, unionChildren: Array }> ); @@ -540,13 +540,13 @@ describe('ResolversTypes', () => { expect(result.prepend).toContain(`import { CustomPartial } from './my-wrapper';`); expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Omit & { parent?: Maybe } ) | ( MyOtherType ); MyUnion: ( CustomPartial & { unionChild?: Maybe }> ) | ( MyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( CustomPartial & { unionChild?: Maybe }> ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( CustomPartial & { unionChild?: Maybe }> ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); @@ -692,13 +692,13 @@ describe('ResolversTypes', () => { `import { AnotherNodeWithChild as AnotherNodeWithChildMapper } from './my-interface';` ); expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Omit & { parent?: Maybe } ) | ( MyOtherType ); MyUnion: ( DatabaseMyType ) | ( MyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( AnotherNodeWithChildMapper ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( AnotherNodeWithChildMapper ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); @@ -770,13 +770,13 @@ describe('ResolversTypes', () => { expect(result.prepend).toContain(`import DatabaseMyOtherType, { MyType as DatabaseMyType } from './my-type';`); expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Omit & { parent?: Maybe } ) | ( DatabaseMyOtherType ); MyUnion: ( DatabaseMyType ) | ( DatabaseMyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); WithChild: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); @@ -854,13 +854,13 @@ describe('ResolversTypes', () => { `import type { default as AnotherNodeWithChildMapper, AnotherNodeWithAll as AnotherNodeWithAllMapper } from './my-interface';` ); expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Omit & { parent?: Maybe } ) | ( DatabaseMyOtherType ); MyUnion: ( DatabaseMyType ) | ( DatabaseMyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); WithChild: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); @@ -994,13 +994,13 @@ describe('ResolversTypes', () => { )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Omit & { parent?: Maybe } ) | ( CustomMyOtherType ); MyUnion: ( MyTypeDb ) | ( CustomMyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); WithChild: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); @@ -1069,13 +1069,13 @@ describe('ResolversTypes', () => { )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Omit & { parent?: Maybe } ) | ( MyOtherType ); MyUnion: ( Partial & { unionChild?: Maybe }> ) | ( MyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( ExtraPartial & { unionChild?: Maybe }> ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( ExtraPartial & { unionChild?: Maybe }> ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); @@ -1608,13 +1608,13 @@ describe('ResolversTypes', () => { )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Omit & { parent?: Maybe } ) | ( MyOtherTypeCustom ); MyUnion: ( Omit & { otherType?: Maybe, unionChild?: Maybe } ) | ( MyOtherTypeCustom ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); @@ -1684,13 +1684,13 @@ describe('ResolversTypes', () => { )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Omit & { parent?: Maybe } ) | ( MyOtherTypeCustom ); MyUnion: ( MyTypeCustom ) | ( MyOtherTypeCustom ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); @@ -1762,13 +1762,13 @@ describe('ResolversTypes', () => { expect(result.prepend).toContain(`import { MyNamespace } from './my-file';`); expect(result.prepend).toContain(`import { InterfaceNamespace } from './my-interface';`); expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Omit & { parent?: Maybe } ) | ( MyNamespace.MyCustomOtherType ); MyUnion: ( Omit & { otherType?: Maybe, unionChild?: Maybe } ) | ( MyNamespace.MyCustomOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( InterfaceNamespace.AnotherNodeWithChildMapper ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( InterfaceNamespace.AnotherNodeWithChildMapper ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); @@ -1918,13 +1918,13 @@ describe('ResolversTypes', () => { expect(result.prepend).toContain(`import { MyNamespace } from './my-file';`); expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( Child ) | ( MyOtherType ); MyUnion: ( Omit & { unionChild?: Maybe } ) | ( MyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); @@ -1996,13 +1996,13 @@ describe('ResolversTypes', () => { expect(result.prepend).toContain(`import { MyNamespace } from './my-file';`); expect(result.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { ChildUnion: ( MyNamespace.MyDefaultMapper & { parent?: Maybe }> ) | ( MyNamespace.MyDefaultMapper ); MyUnion: ( MyNamespace.MyType & { unionChild?: Maybe }> ) | ( MyNamespace.MyDefaultMapper ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( MyNamespace.MyDefaultMapper ); AnotherNode: ( InterfaceNamespace.MyInterface & { unionChild?: Maybe }> ) | ( MyNamespace.MyDefaultMapper & { unionChild?: Maybe, unionChildren: Array }> ); WithChild: ( InterfaceNamespace.MyInterface & { unionChild?: Maybe }> ) | ( MyNamespace.MyDefaultMapper & { unionChild?: Maybe, unionChildren: Array }> ); diff --git a/packages/plugins/typescript/resolvers/tests/ts-resolvers.spec.ts b/packages/plugins/typescript/resolvers/tests/ts-resolvers.spec.ts index ca86237229a..7321d930e6f 100644 --- a/packages/plugins/typescript/resolvers/tests/ts-resolvers.spec.ts +++ b/packages/plugins/typescript/resolvers/tests/ts-resolvers.spec.ts @@ -234,13 +234,13 @@ export type MyTypeResolvers> = { + export type ResolversUnionTypes> = { ChildUnion: ( Child & { __typename: 'Child' } ) | ( MyOtherType & { __typename: 'MyOtherType' } ); MyUnion: ( Omit & { unionChild?: Maybe } & { __typename: 'MyType' } ) | ( MyOtherType & { __typename: 'MyOtherType' } ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode & { __typename: 'SomeNode' } ); AnotherNode: ( Omit & { unionChild?: Maybe } & { __typename: 'AnotherNodeWithChild' } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } & { __typename: 'AnotherNodeWithAll' } ); WithChild: ( Omit & { unionChild?: Maybe } & { __typename: 'AnotherNodeWithChild' } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } & { __typename: 'AnotherNodeWithAll' } ); @@ -258,7 +258,7 @@ export type MyTypeResolvers> = { + export type ResolversUnionTypes> = { ChildUnion: ( Child & { __typename: 'Child' } ) | ( MyOtherType & { __typename: 'MyOtherType' } ); MyUnion: ( Omit & { unionChild?: Maybe } & { __typename: 'MyType' } ) | ( MyOtherType & { __typename: 'MyOtherType' } ); }; @@ -277,7 +277,7 @@ export type MyTypeResolvers> = { + export type ResolversUnionTypes> = { ChildUnion: ( ChildMapper & { __typename: 'Child' } ) | ( MyOtherType & { __typename: 'MyOtherType' } ); MyUnion: ( MyTypeMapper & { __typename: 'MyType' } ) | ( MyOtherType & { __typename: 'MyOtherType' } ); }; @@ -296,7 +296,7 @@ export type MyTypeResolvers> = { + export type ResolversUnionTypes> = { ChildUnion: ( Wrapper & { parent?: Maybe }> & { __typename: 'Child' } ) | ( MyOtherType & { __typename: 'MyOtherType' } ); MyUnion: ( MyWrapper & { unionChild?: Maybe }> & { __typename: 'MyType' } ) | ( MyOtherType & { __typename: 'MyOtherType' } ); }; @@ -315,7 +315,7 @@ export type MyTypeResolvers> = { + export type ResolversUnionTypes> = { ChildUnion: ( Partial & { __typename: 'Child' } ) | ( Partial & { __typename: 'MyOtherType' } ); MyUnion: ( Partial & { unionChild?: Maybe }> & { __typename: 'MyType' } ) | ( Partial & { __typename: 'MyOtherType' } ); }; @@ -346,7 +346,7 @@ export type MyTypeResolvers> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode & { __typename: 'SomeNode' } ); AnotherNode: ( Omit & { unionChild?: Maybe } & { __typename: 'AnotherNodeWithChild' } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } & { __typename: 'AnotherNodeWithAll' } ); WithChild: ( Omit & { unionChild?: Maybe } & { __typename: 'AnotherNodeWithChild' } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } & { __typename: 'AnotherNodeWithAll' } ); @@ -367,7 +367,7 @@ export type MyTypeResolvers> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode & { __typename: 'SomeNode' } ); AnotherNode: ( AnotherNodeWithChildMapper & { __typename: 'AnotherNodeWithChild' } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } & { __typename: 'AnotherNodeWithAll' } ); WithChild: ( AnotherNodeWithChildMapper & { __typename: 'AnotherNodeWithChild' } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } & { __typename: 'AnotherNodeWithAll' } ); @@ -388,7 +388,7 @@ export type MyTypeResolvers> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode & { __typename: 'SomeNode' } ); AnotherNode: ( Wrapper & { unionChild?: Maybe }> & { __typename: 'AnotherNodeWithChild' } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } & { __typename: 'AnotherNodeWithAll' } ); WithChild: ( Wrapper & { unionChild?: Maybe }> & { __typename: 'AnotherNodeWithChild' } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } & { __typename: 'AnotherNodeWithAll' } ); @@ -409,7 +409,7 @@ export type MyTypeResolvers> = { + export type ResolversInterfaceTypes> = { Node: ( Partial & { __typename: 'SomeNode' } ); AnotherNode: ( Partial & { unionChild?: Maybe }> & { __typename: 'AnotherNodeWithChild' } ) | ( Partial & { unionChild?: Maybe, unionChildren: Array }> & { __typename: 'AnotherNodeWithAll' } ); WithChild: ( Partial & { unionChild?: Maybe }> & { __typename: 'AnotherNodeWithChild' } ) | ( Partial & { unionChild?: Maybe, unionChildren: Array }> & { __typename: 'AnotherNodeWithAll' } ); @@ -447,14 +447,14 @@ export type MyTypeResolvers> = { + export type ResolversUnionTypes> = { ChildUnion: ( Child ) | ( MyOtherType ); MyUnion: ( Omit & { unionChild?: Maybe } & { __typename: 'MyType' } ) | ( MyOtherType & { __typename: 'MyOtherType' } ); }; `); expect(result.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( Omit & { unionChild?: Maybe } & { __typename: 'AnotherNodeWithChild' } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } & { __typename: 'AnotherNodeWithAll' } ); @@ -1681,7 +1681,7 @@ export type ResolverFn = ( `); expect(content.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { CCCUnion: ( CccFoo ) | ( CccBar ); }; `); @@ -2032,7 +2032,7 @@ export type ResolverFn = ( const content = await plugin(testSchema, [], {}, { outputFile: 'graphql.ts' }); expect(content.content).toBeSimilarStringTo(` - export type ResolversUnionTypes> = { + export type ResolversUnionTypes> = { UserPayload: ( UserResult ) | ( StandardError ); PostsPayload: ( PostsResult ) | ( StandardError ); }; @@ -2092,7 +2092,7 @@ export type ResolverFn = ( const content = await plugin(resolversTestingSchema, [], {}, { outputFile: 'graphql.ts' }); expect(content.content).toBeSimilarStringTo(` - export type ResolversInterfaceTypes> = { + export type ResolversInterfaceTypes> = { Node: ( SomeNode ); AnotherNode: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); @@ -2158,7 +2158,7 @@ export type ResolverFn = ( ); expect(content.content).toBeSimilarStringTo(` - export type I_ResolversInterfaceTypes_Types> = { + export type I_ResolversInterfaceTypes_Types> = { Node: ( I_SomeNode_Types ); AnotherNode: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } ); WithChild: ( Omit & { unionChild?: Maybe } ) | ( Omit & { unionChild?: Maybe, unionChildren: Array } );