-
Notifications
You must be signed in to change notification settings - Fork 123
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
Partial model object with fields
query parameter
#132
Comments
I've run into this as well, and I agree with @sydpy's conclusion. |
I wonder if the additional complexity is even worth it. I feel like that Spotify API feature is mainly useful for dynamically typed languages, where specifying the fields you're working with is a quick low-effort change to reduce load. But in Rust, you'd have to use a different type, and then |
I think there's enough value in this feature for it to not be abandoned. At the time of my previous comment, I had hacked together a proof of concept to test if it actually made a difference for my workflow (fetching the IDs of all tracks in a playlist), and the speed difference was significant. |
That is interesting. Can you share the benchmarking code? |
Unfortunately, it was just a quick hack job to informally test it and was not saved. If I recall correctly, it was pretty much copy-pasting the relevant structs and functions required to make it work, tweaking the struct to only save the ID (I don't recall if I made the other fields Optional or removed them entirely), and passing the |
I've just ran into this issue. Forgive me if I'm missing something here, but why is the |
Some Spotify endpoints, especially the ones returning a paging object, allow to specify the fields that we want to fetch.
For example,
Get a Playlist's Items
has afields
query parameter that allow selection of fields, but we can't use it since it would raise an error when trying to deserialize the fields that are not specify :This behaviour makes the
fields
parameter useless and forces to fetch data even if we don't need it. Solutions to that would be :#[serde(default)]
on existing model object fieldsOption
on existing model object fieldsPartialTrack
, that implement either1.
or2.
and make endpoints that use afields
query parameter return such aPartial
object instead of aFull
orSimplified
one.I think
3.
would be the most reasonable solution, moreover it might be possible to implement it using a macro.The text was updated successfully, but these errors were encountered: