-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Description
Right now , the generated -components
file exports a flat list of types, query functions, and query hooks.
While this is simple and works fine for small schemas, it becomes difficult to work with when:
- The schema is large and includes many endpoints
- Multiple schemas are used across the project
In these cases, it’s hard to discover or autocomplete the correct function or hook by name.
Proposal
In addition to the current flat exports, introduce grouped object exports:
Fetches
– an object that groups all fetch functionsQueries
– an object that groups all query/mutation hooksQueryOptions
- an object that groups all queryOptions objects used by query hooks
Example:
export const getPets = ...
export const useGetPets = ...
export const getPetsQueryOptions = ...
export const createPet = ...
export const useCreatePet = ...
export const createPetMutationOptions = ...
// Grouped exports
export const Fetches = { getPets, createPet };
export const Queries = { useGetPets, useCreatePet };
export const QueryOptions = {
getPets: getPetsQueryOptions,
createPet: createPetMutationOptions,
};
Usage
With the proposed grouped exports, it’s easy to build a single client entry point that aggregates all schemas:
// apiClient.ts
import * as Petstore from './api/petstoreComponents';
import * as Payments from '.api/paymentsComponents';
import * as Admin from './api/adminComponents';
export const API = { Petstore, Payments, Admin };
Then throughout your application, you can access everything in a clear and organized way:
API.Petstore.Queries.useGetPets();
API.Payments.Fetches.getPaymentDetails();
API.Admin.QueryOptions.getAdminUsers();
I believe this makes working with large or multi-schema APIs intuitive and reduces the cognitive load of searching for auto-generated names or digging through individual files.
Metadata
Metadata
Assignees
Labels
No labels