Open heggemsnes opened 9 months ago
I am managing to work around this currently by doing this which is not really that good looking :)
import { SectionsType, sectionsFragment } from "./../../lib/queries/sections.query";
import { q } from "@/lib/queries/groq-builder";
import { FragmentInputTypeTag, InferResultType } from "groq-builder";
// @ts-expect-error
export const pageQuery = q.star
.filterByType("page")
.filter("slug.current == $slug")
.slice(0)
.project({
title: true,
sections: q.raw<SectionsType[]>(`sections[]{
${sectionsFragment["[CONDITIONAL] [BY_TYPE]"].query}
}`),
});
export type PageQuery = InferResultType<typeof pageQuery>;
The sample you posted does look correct! You've created a fragment with a conditional projection. This should be supported, here's the unit tests: https://github.com/FormidableLabs/groqd/blob/main/packages/groq-builder/src/commands/fragment.test.ts#L141-L198
Can you give me a little more detail on the errors you're experiencing?
Is there an existing issue for this?
Code of Conduct
Question