[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
type Cat {
...
food(brand: String): [Food]
}
export class Cat {
...
abstract food(brand?: string): Food[] | Promise<Food[]>;
}
Error must not be thrown on server start after _src/graphql.schema.ts_ update
https://github.com/biryukvy/nest-gql-abstract-method-issue
(Changes, that have been added to reproduce the issue can be found in the commit: 87053d)
It is needed to pass parameters to subqueries
Nest version: 5.5.0
For Tooling issues:
- Node version: 8.14.1
- Platform: Linux Ubuntu 18.04
Others:
What would be the desired output, I wonder? Would it be the following?
export class Cat {
food(brand?: string): Food[] | Promise<Food[]> {
throw new NotImplementedError();
}
}
I have the same problem
Given the following graphql type:
type Image {
url(options: ImageOptions): String!
}
Te result of the code generation process is:
export class Image {
abstract url(options?: ImageOptions): string | Promise<string>;
}
An abstrat method cannot be defined in a concrete class so, the class should be generated in the following way:
export abstract class Image {
abstract url(options?: ImageOptions): string | Promise<string>;
}
What would be the desired output, I wonder? Would it be the following?
export class Cat { food(brand?: string): Food[] | Promise<Food[]> { throw new NotImplementedError(); } }
Well, the desired output would be:
export abstract class Cat {
abstract food(brand?: string): Food[] | Promise<Food[]>;
}
It actually should be fixed in 5.5.0+
@kamilmysliwiec, For me, it is still reproducible, though I am using "@nestjs/graphql": "^5.5.1". Could you check the minimal reproducible example, that I've provided in the issue description?
As far as I see, all methods are abstract (+ class is marked as abstract too) https://github.com/biryukvy/nest-gql-abstract-method-issue/blob/master/src/graphql.schema.ts
@kamilmysliwiec, that is right - the repository contains the graphql schema of the app state, that was before I added the subquery. If you build the application, the non-abstract class "Cat" will obtain the abstract method "food". At this point, the server should be successfully started. But, after this, you will not be able to restart (rebuild) the application because of that abstract method.
@kamilmysliwiec, the problem is not fixed, could you reopen the issue?
@kamilmysliwiec, I have tried with nestjs v.5.5.0 and 5.6.0 - the issue is still present
Any workaround for this at the moment? Experiencing the same issue.
I'm fixing it manually everytime by the moment.
@Simonpedro how are you doing that? My manual changes in graphql.schema.ts are overwritten every time I restart the server bc it is autogenerated.
I think one way to work around this may be to change outputAs from class to interface. However, you would not be able to do any validation inside your DTO's.
@triedal I just leave auto generation deactivated and turn it on after a change is made on queries or schema, an then fix the types manually. I'd be annoying to do this when the schema/queries are not stable but well 🤷
@Simonpedro thanks for the reply. My schema is changing pretty rapidly so I elected to switch everything over to interfaces which resolved the issue.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@kamilmysliwiec, the problem is not fixed, could you reopen the issue?