Skip to content

support func argument for swr mutate #2259

Open
@prescottprue

Description

@prescottprue

swr-openapi version

5.1.4

Description

Currently the mutate provided by useMutate does not support a filter function argument the same way that swr does. The filter function allows for path matching without filters. For example if you want to invalid /teams with any query params, with swr you can do the following:

const mutate = useMutate()

mutate(
  key => typeof key === 'string' && key.startsWith('/teams?'),
  undefined,
  { revalidate: true }
)

I realize that this will be a bit different with SWR since storage keys are slightly different, but would still be nice to have our own ability to pass this function

Reproduction

Attempt to pass a function to mutate - notice that it does not accept a function the same way that SWR does

Expected result

Calling mutate with custom key settings based on function as you can do with SWR

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingswr-openapiRelevant to swr-openapi library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions