Closed scottrippey closed 5 months ago
Implemented q.fragment method for defining reusable fragments.
q.fragment
const productFragment = q.fragment<SanitySchema.Product>().project(qProduct => ({ name: true, price: true, imageUrls: qProduct.field('images[]').deref().field('url'), })); type ProductFragment = InferFragmentType<typeof productFragment>; // Evaluates to: { name: string, price: number, imageUrls: Array<string> }
You can pass to project:
project
q.star.filterByType('product').project(productFragment);
You can spread inside a project:
q.star.filterByType('product').project({ ...productFragment, description: true, category: true, });
You can compose multiple fragments by spreading.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Implemented
q.fragment
method for defining reusable fragments.Examples
Defining a fragment:
Consuming a fragment
You can pass to
project
:You can spread inside a
project
:You can compose multiple fragments by spreading.
TODO