Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Code of Conduct
- I agree to follow this project's Code of Conduct
Code Sandbox link
No response
Bug report
This is probably me and might not be a bug.
I created the `runQuery` as so:
export const runQuery = makeSafeQueryRunner((query, params: Record<string, unknown> = {}) =>
client.fetch(query, params),
);
But when I use it as typed:
const pageData = (await runQuery(pageQuery, { parameters: { slug } }))[0]
I get the following error:
`[ Server ] Error: param $slug referenced, but not provided`
Here is the query I have written:
const pageQuery = q
.parameters<{ slug: string }>()
.star.filterByType('page')
.filterBy('seo.slug.current == $slug')
.project(page => ({
body: page.field('body[]').project(componentGeneratorFragment),
})),
However if I were to change the `runQuery` like so:
const pageData = (await runQuery(pageQuery, { slug }))[0];
It retrieves the data fine but I am getting the type error
Argument of type '{ slug: string; }' is not assignable to parameter of type '{ parameters: { slug: string; }; } & Record<string, unknown>'.
Property 'parameters' is missing in type '{ slug: string; }' but required in type '{ parameters: { slug: string; }; }'
It seems that the typing of `makeSafeQueryRunner` might not actually line up with the function? Or maybe I set something up wrong.