Skip to content

client-nuxt: composable should be optional (default to $fetch) #2595

@brolnickij

Description

@brolnickij

Description

Generated ...Mutation() / ...Query() (with @pinia/colada plugin) require passing composable key when used together with @hey-api/client-nuxt

This transport detail (composable: '$fetch' | 'useAsyncData' / ...) is noise and should default internally

Config

plugins: [
  '@hey-api/client-nuxt',
  {
    name: '@pinia/colada',
    queryOptions: true,
    mutationOptions: true
  }
]

Example (current)

const { mutate: updateCounteragent } = useMutation({
  ...updateCounteragentMutation()
})

updateCounteragent({ 
  // it is required key
  composable: '$fetch'
})

Expected behavior

  • composable is optional (defaults to $fetch)
const { mutate: updateCounteragent } = useMutation({
  ...updateCounteragentMutation()
})

updateCounteragent()

Reproducible example or configuration

Argument of type '{ body: { edoOperator: "SBIS"; }; path: { organization_id: string; }; onResponse: (data: FetchContext<unknown, ResponseType> & { response: FetchResponse<unknown>; }) => void; }' is not assignable to parameter of type 'Options<TComposable, UpdateCounteragentData, unknown, DefaultT>'.
  Property 'composable' is missing in type '{ body: { edoOperator: "SBIS"; }; path: { organization_id: string; }; onResponse: (data: FetchContext<unknown, ResponseType> & { response: FetchResponse<unknown>; }) => void; }' but required in type 'OmitKeys<RequestOptions<TComposable, unknown, DefaultT, string>, "body" | "path" | "query" | "url">'.

https://stackblitz.com/edit/nuxt-starter-yw7ncxpb?file=app.vue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Something isn't workingclientClient package relatedfeature 🚀New feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions