Expected 1-2 arguments, but got 3. react tanstack query options

Expected 1-2 arguments, but got 3. react tanstack query options


0

Using graphql codegen.yml file:

`# 1. Schema (graphql schema location)

schema: "src/graphql/schema.graphql"

documents: "src/graphql/*.graphql"

generates: 
  src/graphql/generated.ts:
    plugins:
      - typescript
      - typescript-operations
      - typescript-react-query
      - fragment-matcher

    config:
      dedupeFragments: true
      fetcher:
        # Function to run
        func: "./auth-fetcher#fetchData"
        isReactHook: false`

My auth-fetcher file using react query fetcher from https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-react-query

`export const fetchData = <TData, TVariables>(
  query: string,
  variables?: TVariables,
  options?: RequestInit['headers']
): (() => Promise<TData>) => {
  return async () => {
    const res = await fetch('https://api.url', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        ...options
      },
      body: JSON.stringify({
        query,
        variables
      })
    })
 
    const json = await res.json()
 
    if (json.errors) {
      const { message } = json.errors[0] || {}
      throw new Error(message || 'Error…')
    }
 
    return json.data
  }
}`

my generated.ts file with one issue in this snippet:

`export const useExplorePublicationsQuery = <
      TData = ExplorePublicationsQuery,
      TError = unknown
    >(
      variables: ExplorePublicationsQueryVariables,
      options?: UseQueryOptions<ExplorePublicationsQuery, TError, TData>
    ) => {
    
    return useQuery<ExplorePublicationsQuery, TError, TData>(
      ['ExplorePublications', variables],
      fetchData<ExplorePublicationsQuery, ExplorePublicationsQueryVariables>(ExplorePublicationsDocument, variables),
      options
    )};`

…where the very last line of code options has error Expected 1-2 arguments, but got 3.ts(2554)

Any idea what I could be doing wrong?

I have tried re-running yarn codegen to re-generate the file and insured the correct items are imported

import { useQuery, UseQueryOptions } from '@tanstack/react-query';
import { fetchData } from './auth-fetcher';

New contributor

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

1

  • fixed by downgrading from v5 to v4.35.3

    – 0xHyroglyph

    1 hour ago


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

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