You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there an existing issue that is already proposing this?
I have searched the existing issues
Potential Commit/PR that introduced the regression
No response
Versions
9.1.1 -> 10.2.0
Describe the regression
After Upgrading the nestjs packages in our repo, we had a bunch of failing tests. Upon further inspection, we found that all of our E2E tests, which are spawning a test nest application to run some gql-queries against it, were failing, if the related resolver was created by inheritance of another abstract resolver.
We are using the following additional packages:
jasmine
apollo
Minimum reproduction code
import{gql}from"@apollo/client/core";import{ApolloDriver,ApolloDriverConfig}from"@nestjs/apollo";import{INestApplication,Module}from"@nestjs/common";import{Args,Field,GraphQLModule,InputType,Int,Mutation,Query,Resolver}from"@nestjs/graphql";import{Test,TestingModule}from"@nestjs/testing";import{ApolloServerBase}from"apollo-server-core";interfaceCurrentThisContext{module: TestingModule;app: INestApplication;apolloServer: ApolloServerBase;}
@InputType()classMyArgs{
@Field()publicmyInput: number;}
@Resolver({isAbstract: true})abstractclassMyBaseResolver{
@Query(returns=>Int)publicmyQuery(): number{return10;}
@Mutation(returns=>Int)publicmyMutation(@Args({type: ()=>MyArgs,name: "input"})args: MyArgs): number{returnargs.myInput;}}
@Resolver()classMyResolverextendsMyBaseResolver{}
@Module({imports: [GraphQLModule.forRoot<ApolloDriverConfig>({driver: ApolloDriver,autoSchemaFile: true,}),],providers: [MyResolver],})classMyModule{}describe("MyIssue",function(){beforeEach(asyncfunction(this: CurrentThisContext){constmoduleRef=awaitTest.createTestingModule({imports: [MyModule]});this.module=awaitmoduleRef.compile();this.app=this.module.createNestApplication();awaitthis.app.init();// Currently our "way" to run some gql-queries in the specs. There may be a better one, but this should be sufficient for the issueconstgraphqlModule: GraphQLModule=this.module.get<GraphQLModule<ApolloDriver>>(GraphQLModule);this.apolloServer=graphqlModule.graphQlAdapter["_apolloServer"];});afterEach(asyncfunction(this: CurrentThisContext){awaitthis.app.close();});functioncreateMyTest(){it("myTest",asyncfunction(this: CurrentThisContext){constmutation=gql` mutation MyTest { myMutation(input: { myInput: 5 }) } `;constresult=awaitthis.apolloServer.executeOperation({query: mutation});expect(result?.data?.myMutation).toEqual(5);});}// The first test that gets executed is successful, the second one fails with message 'Unknown argument "input" on field "Mutation.myMutation".'createMyTest();createMyTest();});
After some deep digging it seems that the type-metadata.storage removes the methodArgs for the second run when compiling the schema. Example:
Mutation metadata in the first run
Did you read the migration guide?
Is there an existing issue that is already proposing this?
Potential Commit/PR that introduced the regression
No response
Versions
9.1.1 -> 10.2.0
Describe the regression
After Upgrading the nestjs packages in our repo, we had a bunch of failing tests. Upon further inspection, we found that all of our E2E tests, which are spawning a test nest application to run some gql-queries against it, were failing, if the related resolver was created by inheritance of another abstract resolver.
We are using the following additional packages:
Minimum reproduction code
After some deep digging it seems that the
type-metadata.storage
removes the methodArgs for the second run when compiling the schema. Example:Mutation metadata in the first run
Mutation metadata in the second run:
Expected behavior
We expected this to work just like before.
Other
No response
The text was updated successfully, but these errors were encountered: