We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
defineAuthorFactoryInternal
import { defineAuthorFactoryInternal, dynamic, FieldsResolver, Traits, AuthorFactoryDefineOptions, AuthorFactoryInterface, } from '../__generated__/fabbrica'; import { Author } from '../__generated__/types'; // Prepare custom `defineAuthorFactory` with transient fields type AuthorTransientFields = { bookCount: number; }; function defineAuthorFactoryWithTransientFields< _DefaultFieldsResolver extends FieldsResolver<Author & AuthorTransientFields>, _Traits extends Traits<Author, AuthorTransientFields>, >( options: AuthorFactoryDefineOptions<AuthorTransientFields, _DefaultFieldsResolver, _Traits>, ): AuthorFactoryInterface<AuthorTransientFields, _DefaultFieldsResolver, _Traits> { return defineAuthorFactoryInternal(options); } // Use custom `defineAuthorFactory` const AuthorFactory = defineAuthorFactoryWithTransientFields({ defaultFields: { id: dynamic(({ seq }) => `Author-${seq}`), name: 'Komata Mikami', books: dynamic(async ({ get }) => { const bookCount = (await get('bookCount')) ?? 0; return BookFactory.buildList(bookCount); }), bookCount: 0, }, });
import { dynamic, FieldsResolver, Traits, AuthorFactoryDefineOptions, AuthorFactoryInterface, } from '../__generated__/fabbrica'; import { Author } from '../__generated__/types'; const AuthorFactory = defineAuthorFactory.withTransientFields({ bookCount: 0, })({ defaultFields: { id: dynamic(({ seq }) => `Author-${seq}`), name: 'Komata Mikami', books: dynamic(async ({ get }) => { const bookCount = (await get('bookCount')) ?? 0; return BookFactory.buildList(bookCount); }), }, });
defineXxxFactoryInternal
defineXxxFactory.withTransientFields
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
defineAuthorFactoryInternal
Before
After
Breaking Changes
defineXxxFactoryInternal
is not exported now. UsedefineXxxFactory.withTransientFields
to define Transient Fields.The text was updated successfully, but these errors were encountered: