-
-
Notifications
You must be signed in to change notification settings - Fork 677
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
Cooperation with graphql-faker #293
Comments
It's not possible due to #77. All we can do is to create a You can implement it by yourself using middlewares and custom decorators feature. The only problem is that you have to read the type info from |
Response Thank you
It may be possible with Nestjs UsePipes 😂 import { Query, Resolver } from '@nestjs/graphql';
import { UsePipes } from '@nestjs/common';
@Resolver()
class RecipeResolver {
private recipesCollection: Recipe[] = [];
@UsePipes(FakerPipe([Recipe])) // <- ★
@Query(returns => [Recipe])
async recipes() {
return await this.recipesCollection;
}
} |
With TypeGraphQL middlewares too: But the problem is with reading/parsing the |
I missed it. I'm sorry 😹
If you think carefully @ObjectType()
class Recipe {
@Field({
fakerOption: {
fake: {},
examples: {}
}
})
title: string;
} Is it better to use function units? @Resolver()
export class RecipeResolver {
@UseFakerMiddleware([Recipe]) // <- ★
@Query(returns => [Recipe])
async recipes() {
return await this.recipesCollection;
}
} |
We can support different faker modes - global (catch every null/error in resolver and replace with fake data), per type (fake all recipe fields), per query (fake the response object) and per field (fake the title and description fields). |
type-graphql is great
Is your feature request related to a problem? Please describe.
Cooperation with graphql-faker
https://github.com/APIs-guru/graphql-faker
Describe the solution you'd like
I want you to add fakerOption
Describe alternatives you've considered
...
Additional context
↓ generate
The text was updated successfully, but these errors were encountered: