-
Notifications
You must be signed in to change notification settings - Fork 17
fix(schema): use one cache entree for tenant path schemas #1016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| const schemaLoading = schemaIsFetching && schemaData === undefined; | ||
|
|
||
| const keyColumnsIds = schemaData?.PathDescription?.Table?.KeyColumnNames; | ||
| const keyColumnsIds = schemaData?.[path]?.PathDescription?.Table?.KeyColumnNames; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| serializeQueryArgs: ({queryArgs: {path}}) => { | ||
| const parts = path.split('/'); | ||
| return {path: parts[0] || parts[1]}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this serialize works? Data is cached for the tenant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
| do { | ||
| const promise = dispatch( | ||
| schemaApi.endpoints.getSchema.initiate({path}, {forceRefetch: true}), | ||
| ); | ||
| const {data, originalArgs} = await promise; | ||
| promise.unsubscribe(); | ||
| // Check if the result from the current request is received. rtk-query may skip the current request and | ||
| // return data from a parallel request, due to the same cache key. | ||
| if (originalArgs?.path === path) { | ||
| schemaData = data?.[path]; | ||
| break; | ||
| } | ||
| // eslint-disable-next-line no-constant-condition | ||
| } while (true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why to do this in do while cycle? await is not enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As described in the comment, the "promise" may return result from another request (with another params), so we try to repeat the request in this case.

Closes #1014