@graphql-codegen/typescript-react-query not generating object format for useQuery

@graphql-codegen/typescript-react-query not generating object format for useQuery


-1

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

New contributor

user22997093 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


Load 5 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *