Skip to content

Expose queryClient in QueryFunctionContext #3151

Closed
@GLabat

Description

@GLabat

however, composing query functions from other queries of the same client seems useful. for example, you can currently do this via:

const queryClient = useQueryClient()
useQuery(key, () => queryClient.getQueryData(something) ?? axios.get(...))

if the query function is not inlined, passing the client is necessary, so I agree that having the client injected might be useful in some cases. I'll definitely think about it :)

Originally posted by @TkDodo in #2764 (comment)

This issue is a follow-up of the discussion above.
The idea is to have access to the queryClient in the queryFn, using QueryFunctionContext to simplify usage when the queryFn is defined outside of a useQuery/fetchQuery call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions