Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[testing] Add complex Interface test cases for typescript-resolvers #9228

Merged
merged 2 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-queens-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-codegen/testing': patch
---

Add complex test cases for resolvers tests
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,36 @@ export type SomeNode = Node & {
id: Scalars['ID'];
};

export type AnotherNode = {
id: Scalars['ID'];
};

export type WithChild = {
unionChild?: Maybe<ChildUnion>;
node?: Maybe<AnotherNode>;
};

export type WithChildren = {
unionChildren: Array<ChildUnion>;
nodes: Array<AnotherNode>;
};

export type AnotherNodeWithChild = AnotherNode & WithChild & {
__typename?: 'AnotherNodeWithChild';
id: Scalars['ID'];
unionChild?: Maybe<ChildUnion>;
interfaceChild?: Maybe<Node>;
};

export type AnotherNodeWithAll = AnotherNode & WithChild & WithChildren & {
__typename?: 'AnotherNodeWithAll';
id: Scalars['ID'];
unionChild?: Maybe<ChildUnion>;
unionChildren: Array<ChildUnion>;
interfaceChild?: Maybe<Node>;
interfaceChildren: Array<Node>;
};

export type MyUnion = MyType | MyOtherType;
export type WithIndex<TObject> = TObject & Record<string, any>;
export type ResolversObject<TObject> = WithIndex<TObject>;
Expand Down Expand Up @@ -158,6 +188,11 @@ export type ResolversTypes = ResolversObject<{
Node: ResolversTypes['SomeNode'];
ID: ResolverTypeWrapper<Scalars['ID']>;
SomeNode: ResolverTypeWrapper<SomeNode>;
AnotherNode: ResolversTypes['AnotherNodeWithChild'] | ResolversTypes['AnotherNodeWithAll'];
WithChild: ResolversTypes['AnotherNodeWithChild'] | ResolversTypes['AnotherNodeWithAll'];
WithChildren: ResolversTypes['AnotherNodeWithAll'];
AnotherNodeWithChild: ResolverTypeWrapper<Omit<AnotherNodeWithChild, 'unionChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']> }>;
AnotherNodeWithAll: ResolverTypeWrapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']> }>;
MyUnion: ResolverTypeWrapper<ResolversUnionTypes['MyUnion']>;
MyScalar: ResolverTypeWrapper<Scalars['MyScalar']>;
Int: ResolverTypeWrapper<Scalars['Int']>;
Expand All @@ -176,6 +211,11 @@ export type ResolversParentTypes = ResolversObject<{
Node: ResolversParentTypes['SomeNode'];
ID: Scalars['ID'];
SomeNode: SomeNode;
AnotherNode: ResolversParentTypes['AnotherNodeWithChild'] | ResolversParentTypes['AnotherNodeWithAll'];
WithChild: ResolversParentTypes['AnotherNodeWithChild'] | ResolversParentTypes['AnotherNodeWithAll'];
WithChildren: ResolversParentTypes['AnotherNodeWithAll'];
AnotherNodeWithChild: Omit<AnotherNodeWithChild, 'unionChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']> };
AnotherNodeWithAll: Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']> };
MyUnion: ResolversUnionParentTypes['MyUnion'];
MyScalar: Scalars['MyScalar'];
Int: Scalars['Int'];
Expand Down Expand Up @@ -235,6 +275,39 @@ export type SomeNodeResolvers<ContextType = any, ParentType = ResolversParentTyp
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

export type AnotherNodeResolvers<ContextType = any, ParentType = ResolversParentTypes['AnotherNode']> = ResolversObject<{
__resolveType: TypeResolveFn<'AnotherNodeWithChild' | 'AnotherNodeWithAll', ParentType, ContextType>;
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
}>;

export type WithChildResolvers<ContextType = any, ParentType = ResolversParentTypes['WithChild']> = ResolversObject<{
__resolveType: TypeResolveFn<'AnotherNodeWithChild' | 'AnotherNodeWithAll', ParentType, ContextType>;
unionChild?: Resolver<Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
node?: Resolver<Maybe<ResolversTypes['AnotherNode']>, ParentType, ContextType>;
}>;

export type WithChildrenResolvers<ContextType = any, ParentType = ResolversParentTypes['WithChildren']> = ResolversObject<{
__resolveType: TypeResolveFn<'AnotherNodeWithAll', ParentType, ContextType>;
unionChildren?: Resolver<Array<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
nodes?: Resolver<Array<ResolversTypes['AnotherNode']>, ParentType, ContextType>;
}>;

export type AnotherNodeWithChildResolvers<ContextType = any, ParentType = ResolversParentTypes['AnotherNodeWithChild']> = ResolversObject<{
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
unionChild?: Resolver<Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
interfaceChild?: Resolver<Maybe<ResolversTypes['Node']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

export type AnotherNodeWithAllResolvers<ContextType = any, ParentType = ResolversParentTypes['AnotherNodeWithAll']> = ResolversObject<{
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
unionChild?: Resolver<Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
unionChildren?: Resolver<Array<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
interfaceChild?: Resolver<Maybe<ResolversTypes['Node']>, ParentType, ContextType>;
interfaceChildren?: Resolver<Array<ResolversTypes['Node']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

export type MyUnionResolvers<ContextType = any, ParentType = ResolversParentTypes['MyUnion']> = ResolversObject<{
__resolveType: TypeResolveFn<'MyType' | 'MyOtherType', ParentType, ContextType>;
}>;
Expand All @@ -252,6 +325,11 @@ export type Resolvers<ContextType = any> = ResolversObject<{
Subscription?: SubscriptionResolvers<ContextType>;
Node?: NodeResolvers<ContextType>;
SomeNode?: SomeNodeResolvers<ContextType>;
AnotherNode?: AnotherNodeResolvers<ContextType>;
WithChild?: WithChildResolvers<ContextType>;
WithChildren?: WithChildrenResolvers<ContextType>;
AnotherNodeWithChild?: AnotherNodeWithChildResolvers<ContextType>;
AnotherNodeWithAll?: AnotherNodeWithAllResolvers<ContextType>;
MyUnion?: MyUnionResolvers<ContextType>;
MyScalar?: GraphQLScalarType;
}>;
Expand Down Expand Up @@ -367,6 +445,11 @@ export type ResolversTypes = ResolversObject<{
Node: ResolversTypes['SomeNode'];
ID: ResolverTypeWrapper<Types.Scalars['ID']>;
SomeNode: ResolverTypeWrapper<Types.SomeNode>;
AnotherNode: ResolversTypes['AnotherNodeWithChild'] | ResolversTypes['AnotherNodeWithAll'];
WithChild: ResolversTypes['AnotherNodeWithChild'] | ResolversTypes['AnotherNodeWithAll'];
WithChildren: ResolversTypes['AnotherNodeWithAll'];
AnotherNodeWithChild: ResolverTypeWrapper<Omit<Types.AnotherNodeWithChild, 'unionChild'> & { unionChild?: Types.Maybe<ResolversTypes['ChildUnion']> }>;
AnotherNodeWithAll: ResolverTypeWrapper<Omit<Types.AnotherNodeWithAll, 'unionChild' | 'unionChildren'> & { unionChild?: Types.Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']> }>;
MyUnion: ResolverTypeWrapper<ResolversUnionTypes['MyUnion']>;
MyScalar: ResolverTypeWrapper<Types.Scalars['MyScalar']>;
Int: ResolverTypeWrapper<Types.Scalars['Int']>;
Expand All @@ -385,6 +468,11 @@ export type ResolversParentTypes = ResolversObject<{
Node: ResolversParentTypes['SomeNode'];
ID: Types.Scalars['ID'];
SomeNode: Types.SomeNode;
AnotherNode: ResolversParentTypes['AnotherNodeWithChild'] | ResolversParentTypes['AnotherNodeWithAll'];
WithChild: ResolversParentTypes['AnotherNodeWithChild'] | ResolversParentTypes['AnotherNodeWithAll'];
WithChildren: ResolversParentTypes['AnotherNodeWithAll'];
AnotherNodeWithChild: Omit<Types.AnotherNodeWithChild, 'unionChild'> & { unionChild?: Types.Maybe<ResolversParentTypes['ChildUnion']> };
AnotherNodeWithAll: Omit<Types.AnotherNodeWithAll, 'unionChild' | 'unionChildren'> & { unionChild?: Types.Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']> };
MyUnion: ResolversUnionParentTypes['MyUnion'];
MyScalar: Types.Scalars['MyScalar'];
Int: Types.Scalars['Int'];
Expand Down Expand Up @@ -444,6 +532,39 @@ export type SomeNodeResolvers<ContextType = any, ParentType extends ResolversPar
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

export type AnotherNodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['AnotherNode'] = ResolversParentTypes['AnotherNode']> = ResolversObject<{
__resolveType: TypeResolveFn<'AnotherNodeWithChild' | 'AnotherNodeWithAll', ParentType, ContextType>;
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
}>;

export type WithChildResolvers<ContextType = any, ParentType extends ResolversParentTypes['WithChild'] = ResolversParentTypes['WithChild']> = ResolversObject<{
__resolveType: TypeResolveFn<'AnotherNodeWithChild' | 'AnotherNodeWithAll', ParentType, ContextType>;
unionChild?: Resolver<Types.Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
node?: Resolver<Types.Maybe<ResolversTypes['AnotherNode']>, ParentType, ContextType>;
}>;

export type WithChildrenResolvers<ContextType = any, ParentType extends ResolversParentTypes['WithChildren'] = ResolversParentTypes['WithChildren']> = ResolversObject<{
__resolveType: TypeResolveFn<'AnotherNodeWithAll', ParentType, ContextType>;
unionChildren?: Resolver<Array<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
nodes?: Resolver<Array<ResolversTypes['AnotherNode']>, ParentType, ContextType>;
}>;

export type AnotherNodeWithChildResolvers<ContextType = any, ParentType extends ResolversParentTypes['AnotherNodeWithChild'] = ResolversParentTypes['AnotherNodeWithChild']> = ResolversObject<{
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
unionChild?: Resolver<Types.Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
interfaceChild?: Resolver<Types.Maybe<ResolversTypes['Node']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

export type AnotherNodeWithAllResolvers<ContextType = any, ParentType extends ResolversParentTypes['AnotherNodeWithAll'] = ResolversParentTypes['AnotherNodeWithAll']> = ResolversObject<{
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
unionChild?: Resolver<Types.Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
unionChildren?: Resolver<Array<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
interfaceChild?: Resolver<Types.Maybe<ResolversTypes['Node']>, ParentType, ContextType>;
interfaceChildren?: Resolver<Array<ResolversTypes['Node']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

export type MyUnionResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyUnion'] = ResolversParentTypes['MyUnion']> = ResolversObject<{
__resolveType: TypeResolveFn<'MyType' | 'MyOtherType', ParentType, ContextType>;
}>;
Expand All @@ -461,6 +582,11 @@ export type Resolvers<ContextType = any> = ResolversObject<{
Subscription?: SubscriptionResolvers<ContextType>;
Node?: NodeResolvers<ContextType>;
SomeNode?: SomeNodeResolvers<ContextType>;
AnotherNode?: AnotherNodeResolvers<ContextType>;
WithChild?: WithChildResolvers<ContextType>;
WithChildren?: WithChildrenResolvers<ContextType>;
AnotherNodeWithChild?: AnotherNodeWithChildResolvers<ContextType>;
AnotherNodeWithAll?: AnotherNodeWithAllResolvers<ContextType>;
MyUnion?: MyUnionResolvers<ContextType>;
MyScalar?: GraphQLScalarType;
}>;
Expand Down Expand Up @@ -537,6 +663,36 @@ export type SomeNode = Node & {
id: Scalars['ID'];
};

export type AnotherNode = {
id: Scalars['ID'];
};

export type WithChild = {
unionChild?: Maybe<ChildUnion>;
node?: Maybe<AnotherNode>;
};

export type WithChildren = {
unionChildren: Array<ChildUnion>;
nodes: Array<AnotherNode>;
};

export type AnotherNodeWithChild = AnotherNode & WithChild & {
__typename?: 'AnotherNodeWithChild';
id: Scalars['ID'];
unionChild?: Maybe<ChildUnion>;
interfaceChild?: Maybe<Node>;
};

export type AnotherNodeWithAll = AnotherNode & WithChild & WithChildren & {
__typename?: 'AnotherNodeWithAll';
id: Scalars['ID'];
unionChild?: Maybe<ChildUnion>;
unionChildren: Array<ChildUnion>;
interfaceChild?: Maybe<Node>;
interfaceChildren: Array<Node>;
};

export type MyUnion = MyType | MyOtherType;
export type WithIndex<TObject> = TObject & Record<string, any>;
export type ResolversObject<TObject> = WithIndex<TObject>;
Expand Down Expand Up @@ -630,6 +786,11 @@ export type ResolversTypes = ResolversObject<{
Node: ResolversTypes['SomeNode'];
ID: ResolverTypeWrapper<Scalars['ID']>;
SomeNode: ResolverTypeWrapper<SomeNode>;
AnotherNode: ResolversTypes['AnotherNodeWithChild'] | ResolversTypes['AnotherNodeWithAll'];
WithChild: ResolversTypes['AnotherNodeWithChild'] | ResolversTypes['AnotherNodeWithAll'];
WithChildren: ResolversTypes['AnotherNodeWithAll'];
AnotherNodeWithChild: ResolverTypeWrapper<Omit<AnotherNodeWithChild, 'unionChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']> }>;
AnotherNodeWithAll: ResolverTypeWrapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']> }>;
MyUnion: ResolverTypeWrapper<ResolversUnionTypes['MyUnion']>;
MyScalar: ResolverTypeWrapper<Scalars['MyScalar']>;
Int: ResolverTypeWrapper<Scalars['Int']>;
Expand All @@ -648,6 +809,11 @@ export type ResolversParentTypes = ResolversObject<{
Node: ResolversParentTypes['SomeNode'];
ID: Scalars['ID'];
SomeNode: SomeNode;
AnotherNode: ResolversParentTypes['AnotherNodeWithChild'] | ResolversParentTypes['AnotherNodeWithAll'];
WithChild: ResolversParentTypes['AnotherNodeWithChild'] | ResolversParentTypes['AnotherNodeWithAll'];
WithChildren: ResolversParentTypes['AnotherNodeWithAll'];
AnotherNodeWithChild: Omit<AnotherNodeWithChild, 'unionChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']> };
AnotherNodeWithAll: Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']> };
MyUnion: ResolversUnionParentTypes['MyUnion'];
MyScalar: Scalars['MyScalar'];
Int: Scalars['Int'];
Expand Down Expand Up @@ -707,6 +873,39 @@ export type SomeNodeResolvers<ContextType = any, ParentType extends ResolversPar
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

export type AnotherNodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['AnotherNode'] = ResolversParentTypes['AnotherNode']> = ResolversObject<{
__resolveType: TypeResolveFn<'AnotherNodeWithChild' | 'AnotherNodeWithAll', ParentType, ContextType>;
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
}>;

export type WithChildResolvers<ContextType = any, ParentType extends ResolversParentTypes['WithChild'] = ResolversParentTypes['WithChild']> = ResolversObject<{
__resolveType: TypeResolveFn<'AnotherNodeWithChild' | 'AnotherNodeWithAll', ParentType, ContextType>;
unionChild?: Resolver<Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
node?: Resolver<Maybe<ResolversTypes['AnotherNode']>, ParentType, ContextType>;
}>;

export type WithChildrenResolvers<ContextType = any, ParentType extends ResolversParentTypes['WithChildren'] = ResolversParentTypes['WithChildren']> = ResolversObject<{
__resolveType: TypeResolveFn<'AnotherNodeWithAll', ParentType, ContextType>;
unionChildren?: Resolver<Array<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
nodes?: Resolver<Array<ResolversTypes['AnotherNode']>, ParentType, ContextType>;
}>;

export type AnotherNodeWithChildResolvers<ContextType = any, ParentType extends ResolversParentTypes['AnotherNodeWithChild'] = ResolversParentTypes['AnotherNodeWithChild']> = ResolversObject<{
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
unionChild?: Resolver<Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
interfaceChild?: Resolver<Maybe<ResolversTypes['Node']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

export type AnotherNodeWithAllResolvers<ContextType = any, ParentType extends ResolversParentTypes['AnotherNodeWithAll'] = ResolversParentTypes['AnotherNodeWithAll']> = ResolversObject<{
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
unionChild?: Resolver<Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
unionChildren?: Resolver<Array<ResolversTypes['ChildUnion']>, ParentType, ContextType>;
interfaceChild?: Resolver<Maybe<ResolversTypes['Node']>, ParentType, ContextType>;
interfaceChildren?: Resolver<Array<ResolversTypes['Node']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;

export type MyUnionResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyUnion'] = ResolversParentTypes['MyUnion']> = ResolversObject<{
__resolveType: TypeResolveFn<'MyType' | 'MyOtherType', ParentType, ContextType>;
}>;
Expand All @@ -724,6 +923,11 @@ export type Resolvers<ContextType = any> = ResolversObject<{
Subscription?: SubscriptionResolvers<ContextType>;
Node?: NodeResolvers<ContextType>;
SomeNode?: SomeNodeResolvers<ContextType>;
AnotherNode?: AnotherNodeResolvers<ContextType>;
WithChild?: WithChildResolvers<ContextType>;
WithChildren?: WithChildrenResolvers<ContextType>;
AnotherNodeWithChild?: AnotherNodeWithChildResolvers<ContextType>;
AnotherNodeWithAll?: AnotherNodeWithAllResolvers<ContextType>;
MyUnion?: MyUnionResolvers<ContextType>;
MyScalar?: GraphQLScalarType;
}>;
Expand Down
Loading