Ideas on how to handle supporting multiple versions of the API (0.18.x, 0.19.x) #12
Replies: 2 comments 5 replies
-
how difficult would it be to create multiple classes to support different API versions? If it's just a matter of copy and paste, and a few changes, then it might be worth doing that, at least until 0.18.x. Drops to a low threshold of instances (say 2% for example) and then remove the 0.18.x classes in favor of the 0.19.x classes. This may only be a few months depending on instance administration. |
Beta Was this translation helpful? Give feedback.
-
Our approach thus far has been to try to make the API changes transparent to the calling code. While a caller might check compatibility for a particular new call using But the problem really comes down to the response type and how to handle multiple potential types in the code that uses it. My inclination would be to see if we can map any of the old types to the new type. For example, it seems like the Lemmy devs determined that putting the whole post in |
Beta Was this translation helpful? Give feedback.
-
There's been some more changes to the API since the last major refactor (see #10). The changes are listed here: LemmyNet/lemmy-js-client@0.19.0-rc.14...0.19.0-alpha.16.
While most of the changes are fairly minor, there is one change that I'd like to have a discussion on. This is with regards to changes to the output of the API responses for specific endpoints. I wanted to start a discussion here to see if anyone has any ideas on how best we can support the changes to the API responses.
I do want to clarify that most of the changes resulting in different API responses are endpoints that we don't currently use (with the exception of a few). Depending on the result of this discussion, we might end up only partially supporting 0.18.x (and dropping 0.18.x support for endpoints whose API responses have changed that we don't currently use).
For example:
has changed to
This means that
MarkPostAsRead
no longer returns backPostResponse
but instead returnsSuccessResponse
in the latest 0.19.x API.Currently, the class that handles this API call looks like this:
There's a couple of options I can think of at the moment. Feel free to suggest any other ideas you may have!
MarkPostAsRead
classes, each one targeting a specific version of the API. We would then call the respective class within Thunder depending on the instance version. If we want to fully support 0.18.x, then we would have to do this for each API call whose response has changedCC: @micahmo
Beta Was this translation helpful? Give feedback.
All reactions