Skip to content

Export QueryKey type from generated tanstack query client #1705

Open
@lsdch

Description

Description

Would be nice to have for passing query options around. I'm using tanstack vue query client (and it's awesome), made a generic component that takes a query option as prop, but I had to copy-paste QueryKey type from the client to make the compiler happy:

interface DatasetQueryData {
  headers?: {
    Authorization: string
  }
  path: {
    slug: string
  }
}

type QueryKey<TOptions extends Options> = [
  Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
    _id: string
    _infinite?: boolean
  }
]

const { slug, query } = defineProps<{
  slug: string
  query: (options: OptionsLegacyParser<DatasetQueryData>) => UndefinedInitialQueryOptions<
    DatasetType,
    ErrorModel,
    DatasetType,
    QueryKey<DatasetQueryData>
  > & {
    queryKey: QueryKey<DatasetQueryData>
  }
}>()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions