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
Global Transient Fields can define special Transient Fields that also affects build methods called on deep stacks.
build
import { defineBookFactory, defineBookShelfFactory, } from '../__generated__/fabbrica'; declare module '@mizdra/graphql-codegen-typescript-fabbrica/helper' { interface GlobalTransientFields { $user: { __typename: 'User', name: string }; } } const BookFactory = defineBookFactory({ defaultFields: { __typename: 'Book', id: dynamic(({ seq }) => `Book:${seq}`), title: 'old-book', author: dynamic(async ({ get }) => await get('$user')!), }, }); const BookShelfFactory = defineBookShelfFactory({ defaultFields: { __typename: 'BookShelf', id: ({ seq }): `BookShelf:${seq}`, name: 'my-bookshelf', owner: dynamic(async ({ get }) => await get('$user')!), books: dynamic(async () => await BookFactory.buildList()), }, }); const bookShelf = BookShelfFactory.build({ $user: { __typename: 'User', name: 'mizdra' }, }); expect(bookShelf).toStrictEqual({ __typename: 'BookShelf', id: 'BookShelf:0', name: 'my-bookshelf', owner: { __typename: 'User', name: 'mizdra' }, books: [ { id: 'Book:0', title: 'old-book', author: { __typename: 'User', name: 'mizdra' }, }, { id: 'Book:1', title: 'old-book', author: { __typename: 'User', name: 'mizdra' }, }, ], });
I think that https://github.com/tc39/proposal-async-context is required to implement this feature.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Global Transient Fields can define special Transient Fields that also affects
build
methods called on deep stacks.I think that https://github.com/tc39/proposal-async-context is required to implement this feature.
The text was updated successfully, but these errors were encountered: