-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add factory for creating the fake data of Operation/Fragment #83
Comments
// src/libs/get-feature-one-data.mock.ts
import { defineUserFactory } from '../../__generated__/fabbrica.ts';
export const FeatureOneUserFactory = defineUserFactory({
defaultFields: {
name: 'Admin',
isAdmin: true,
},
}); // src/libs/get-feature-two-data.mock.ts
import { defineUserFactory } from '../../__generated__/fabbrica.ts';
export const FeatureTwoUserFactory = defineUserFactory({
defaultFields: {
name: 'User',
isAdmin: false,
},
}); |
@mizdra let me explain a bit more. Let's assume we have schema:type Book {
id: ID!
title: String!
}
type Node {
id: ID!
someField: String!
book: Book!
}
type Query {
node: Node!
} Folder structure
content of `fragment-one.ts`:fragment MyNodeFragment on Node {
id
someField
}
query MyQuery {
node {
...MyNodeFragment
}
} Based on that I'd expect to have generated mocks for To summarize I don't know how to specify paths for my documents - in this example -> |
Do you want graphql-codegen-typescript-fabricca to generate a factory file (e.g. What will the generated |
Correct, example:
I was thinking of having such exports:
Basically exports for every DocumentNode (query, mutation, fragment). |
Thank you. I understand what you want to do. First, graphql-codegen-typescript-fabbrica cannot create fake data for fragments. It can only create fake data of object types (defined by I think it is worth adding that feature. However, it would be a big step as it would require parsing all *.ts files and extracting fragments. Pull requests are welcome! |
Hello.
First of all thanks for the plugin! It has many great features.
My question is related to operation/fragment mocks.
Did you consider such a feature to support creating mocks for operation/fragments next to the file that contains the type? For example:
The plugin would generate
get-feature-one-data.mock.ts
file next to the operation/fragment. Such a feature is in this plugin https://stackblitz.com/github/zhouzi/graphql-codegen-factories/tree/main/examples/usage-with-near-operation-file-preset but it's not maintained anymore.The text was updated successfully, but these errors were encountered: