Skip to content

Support for react query loader func #2024

@jiwanovski87

Description

@jiwanovski87

Introduction

Hi, I am quite new to orval. Is there yet any possibility to generate the loader func for react query too?

As described here, react-query could have some loader func. These will check if a data might already be in the query data and if not it will fetch them.

The example of the link:

export const loader =
  (queryClient) =>
  async ({ params }) => {
    const query = contactDetailQuery(params.contactId)
    // ⬇️ return data or fetch it
    return (
      queryClient.getQueryData(query.queryKey) ??
      (await queryClient.fetchQuery(query))
    )
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requestedtanstack-queryTanStack Query related issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions