Open anthonyn60 opened 7 months ago
I am also having this same problem. Any update on this or did you find a solution @anthonyn60 ?
I have not @gjdame
I saw someone else ran into it here, also without a solution: https://github.com/dotansimha/graphql-code-generator-community/pull/434#issuecomment-1909138484
Which packages are impacted by your issue?
@graphql-codegen/typescript-react-query
Describe the bug
The generated hook code for infinite queries applies the spread operator on
metaData.pageParam
, which is of typeunknown
. Typescript complains about this.Your Example Website or App
/
Steps to Reproduce the Bug or Issue
My query has an
after
variable with a custom fetcher that has this signature:My query looks like:
Expected behavior
The generated code is free of errors from Typescript. If the spread operator needs to be applied here (to pass the page variables into the query), perhaps the generated code could cast
metadata.pageParam
into an object?Screenshots or Videos
Platform
graphql
version: 16.8.1@graphql-codegen/*
version(s): 5 for CLI, deps:Codegen Config File
import type { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = { overwrite: true, schema: "graphql/schema.graphql", documents: "*/.graphql", generates: { "graphql/generated.ts": { plugins: [ "typescript", "typescript-operations", "typescript-react-query" ], config: { exposeFetcher: true, exposeMutationKeys: true, exposeQueryKeys: true, enumsAsConst: true, addInfiniteQuery: true, reactQueryVersion: 5, fetcher: { func: "./graphql-fetch#graphQLFetch", isReactHook: false } } }, "graphql/graphql.schema.json": { plugins: ["introspection"] } } };
export default config;
Additional context
No response