I am using @graphql-codegen/typescript-react-query to generate typescript from my graphql schema.
these are my @graphql-codegen dependencies
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-operations": "^4.0.1",
"@graphql-codegen/typescript-react-query": "^6.0.0",
"@graphql-eslint/eslt-plugin": "^3.19.1",
my generation configuration is:
"schema.ts": {
plugins: [
"typescript",
"typescript-operations",
"typescript-react-query"
],
config: {
enumValues: enumValues,
exposeDocument: true,
exposeQueryKeys: true,
exposeMutationKeys: true,
exposeFetcher: true,
addInfiniteQuery: true
}
}
when I build the typescript from graphql the useMyQuery functions are created with property format
return useQuery<MyQuery, TError, TData>(
variables === undefined ? ['myQuery'] : ['myQuery', variables],
fetcher<myQuery, myQueryVariables>(dataSource.endpoint, dataSource.fetchParams || {}, myQueryDocument, variables),
options
)};
and not object format (as documented https://tanstack.com/query/v5/docs/react/guides/migrating-to-v5)
return useQuery<MyQuery, TError, TData>({
variables === undefined ? ['myQuery'] : ['myQuery', variables],
fetcher<myQuery, myQueryVariables>(dataSource.endpoint, dataSource.fetchParams || {}, myQueryDocument, variables),
...options}
)};
is there a configuration item I'm missing (obviously, this code is scrubbed of identifying variable names).
thanks...
I've tried different packages and configurations
You need to add
reactQueryVersion: 5
to your generation configuration.Source PR