Skip to content

Commit

Permalink
Remove extraneous UnwrappedObject type
Browse files Browse the repository at this point in the history
  • Loading branch information
eddeee888 committed Dec 16, 2024
1 parent 70a8f36 commit f3cad5e
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 132 deletions.
7 changes: 0 additions & 7 deletions packages/plugins/typescript/resolvers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,6 @@ export type ResolverWithResolve<TResult, TParent, TContext, TArgs> = {
const stitchingResolverUsage = `StitchingResolver<TResult, TParent, TContext, TArgs>`;

if (visitor.hasFederation()) {
if (visitor.config.wrapFieldDefinitions) {
defsToInclude.push(`export type UnwrappedObject<T> = {
[P in keyof T]: T[P] extends infer R | Promise<infer R> | (() => infer R2 | Promise<infer R2>)
? R & R2 : T[P]
};`);
}

defsToInclude.push(
`export type ReferenceResolver<TResult, TReference, TContext> = (
reference: TReference,
Expand Down
16 changes: 1 addition & 15 deletions packages/plugins/typescript/resolvers/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@ import {
ParsedResolversConfig,
} from '@graphql-codegen/visitor-plugin-common';
import autoBind from 'auto-bind';
import {
EnumTypeDefinitionNode,
FieldDefinitionNode,
GraphQLSchema,
ListTypeNode,
NamedTypeNode,
NonNullTypeNode,
} from 'graphql';
import { EnumTypeDefinitionNode, GraphQLSchema, ListTypeNode, NamedTypeNode, NonNullTypeNode } from 'graphql';
import { TypeScriptResolversPluginConfig } from './config.js';

export const ENUM_RESOLVERS_SIGNATURE =
Expand Down Expand Up @@ -96,13 +89,6 @@ export class TypeScriptResolversVisitor extends BaseResolversVisitor<
return `${this.config.immutableTypes ? 'ReadonlyArray' : 'Array'}<${str}>`;
}

protected getParentTypeForSignature(node: FieldDefinitionNode) {
if (this._federation.isResolveReferenceField(node) && this.config.wrapFieldDefinitions) {
return 'UnwrappedObject<ParentType>';
}
return 'ParentType';
}

NamedType(node: NamedTypeNode): string {
return `Maybe<${super.NamedType(node)}>`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
info: GraphQLResolveInfo
) => TResult | Promise<TResult>;


/** Mapping of union types */
export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = ResolversObject<{
ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( MyOtherType );
Expand Down Expand Up @@ -425,6 +426,7 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
info: GraphQLResolveInfo
) => TResult | Promise<TResult>;


/** Mapping of union types */
export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = ResolversObject<{
ChildUnion: ( Omit<Types.Child, 'parent'> & { parent?: Types.Maybe<_RefType['MyType']> } ) | ( Types.MyOtherType );
Expand Down Expand Up @@ -770,6 +772,7 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
info?: GraphQLResolveInfo
) => TResult | Promise<TResult>;


/** Mapping of union types */
export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = ResolversObject<{
ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( MyOtherType );
Expand Down
Loading

0 comments on commit f3cad5e

Please sign in to comment.