Best architecture for large ERP app with 500+ endpoints across many modules #5287
Unanswered
BentolhodaAhmadi
asked this question in
Q&A
Replies: 2 comments
-
|
I would go further than “one For an ERP, a good target is usually:
That gives you one middleware/reducer for a large logical backend, while still letting modules own their endpoint definitions. Example shape: // services/baseApi.ts
export const baseApi = createApi({
reducerPath: 'api',
baseQuery,
tagTypes: ['VoucherList', 'WarehouseItem', 'Account'],
endpoints: () => ({}),
})
// accounting/api.ts
export const accountingApi = baseApi.injectEndpoints({
endpoints: (build) => ({
getVouchers: build.query<..., ...>({
query: ...,
providesTags: ['VoucherList'],
}),
}),
})For your questions:
So I would use “single base API + endpoint injection” by default, then create separate APIs only for genuinely separate backends or incompatible cache/auth behavior. |
Beta Was this translation helpful? Give feedback.
0 replies
This comment was marked as spam.
This comment was marked as spam.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have a large ERP application with many modules:
general, warehouse, treasury, accounting, etc.
Previously I had one
createApiper endpoint (~500 instances) which causedthe stack overflow bug reported in
#5285 #5279
#5283
I also opened a related issue here: #5285
After feedback from phryneas and markerikson on that issue,
I understand the correct approach is fewer
createApiinstances.My current proposed architecture:
One
createApiper module (~20-30 instances),each containing 50-250 endpoints inside.
All modules are combined into one shell store:
My questions:
Is "one
createApiper module" the recommended pattern for large enterprise apps?Or should I go further and use a single
createApifor everything?With ~20-30
createApiinstances, am I still at risk of hittingthe stack overflow issue from Maximum call stack size exceeded with 500+
createApiinstances, but works fine with same number of endpoints under singlecreateApi#5285 RTK Query middleware self-registration can overflow the call stack with manycreateApimiddlewares #5279?Regarding
invalidateTags:If one module api has 100+ tagTypes, when I call
invalidateTags(['VoucherList']),does RTK Query only process queries that provide that specific tag?
Or is there a performance cost to scanning all tags in the same api instance?
Does RTK Query do any work per-endpoint on every action dispatched,
or only for active/subscribed queries?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions