You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like the date fields coming from the server to be stored as dates in redux. Better yet I'd like them to be types of our date library (dayjs). Redux doesn't love objects in its store but we've had no issues with it up until now. This could be implemented manually outside of schema generation but per #1441, enhanceEndpoints can't change the types. Would it be possible to automatically interpret strings in date-time format as Date? Query requests would convert from string to Date and mutator requests would convert back to string.
My preferred crazy idea though would be to add parseResponse and serializeRequest config options. Not sure if it's possible to do this while accommodating typescript but it would somehow map schema property types to a TS type. Strings are extra tricky because their type is a "string" but they have a format with them. This would allow us to customize any OpenAPI type however we wanted. Example:
From the above, the code generator would infer the new type based on the return type of the custom callback.
Lastly in case someone has some insight, I was looking at the openapi-generator and it looks like someone implemented a redux-query client. Has there been any discussion around building out rtk-query? I may take a whack at that if the 2 ideas above are no good.
The text was updated successfully, but these errors were encountered:
Unfortunately no, I was not able to find a good query solution that integrates with redux. I've been toying with useSWR though. It solves the "get data from the server and put it somewhere" problem but I still need redux to manage the client side state.
I would like the date fields coming from the server to be stored as dates in redux. Better yet I'd like them to be types of our date library (dayjs). Redux doesn't love objects in its store but we've had no issues with it up until now. This could be implemented manually outside of schema generation but per #1441, enhanceEndpoints can't change the types. Would it be possible to automatically interpret strings in
date-time
format as Date? Query requests would convert from string to Date and mutator requests would convert back to string.My preferred crazy idea though would be to add
parseResponse
andserializeRequest
config options. Not sure if it's possible to do this while accommodating typescript but it would somehow map schema property types to a TS type. Strings are extra tricky because their type is a "string" but they have a format with them. This would allow us to customize any OpenAPI type however we wanted. Example:From the above, the code generator would infer the new type based on the return type of the custom callback.
Lastly in case someone has some insight, I was looking at the openapi-generator and it looks like someone implemented a redux-query client. Has there been any discussion around building out rtk-query? I may take a whack at that if the 2 ideas above are no good.
The text was updated successfully, but these errors were encountered: