-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
RFC - Refactor (Part 1) to get all the adapters using the same API #1843
Comments
I didn't know that existed, thanks! |
yup, basically
caching should be its own layer. This is a bug. See my incomplete starts to fix this 9477fb2^...bf4:remove_caching 9477fb2^...bf4:remove_caching_only_knuckles 155033e^...bf4:collection_caching |
We'll also want to discuss other concerns, not totally related, but on my mind:
|
@bf4, updated with the RFC template. |
So that it's recorded, I'm going to start with some PRs of refactoring some of the smaller things, such as include, and fields, and see where that takes me |
@NullVoxPopuli can you turn this into a PR? |
I think so. Should I wait on your caching removal PR / any other PRs? |
@NullVoxPopuli no, and the caching removal pr is really mean to refactor caching. I'll push the tests to it to make that more clear |
Spent some time looking at the JSON API adapter yesterday and here is an issue I see. Attributes adapter has a serializer-calls-serializers pattern. One serializer serializes itself and its relationships, turtles all the way down. JSON API adapter recurses over each relationship instead. The parent serializer doesn't serialize his children, the adapter contains this logic. This is confusing code, but actually makes a kind of sense. The Attributes adapter returns relations as a nested payload - so each serializer can just keep nesting. But JSON API sideloads everything in Currently that memo is on the adapter. The alternative would be sticking it on the parent serializer, but then you could make the case A) adapter (formatter) logic is leaking into the serializers, B) JSONAPI-specific logic is leaking into areas not specific to JSONAPI. You could also follow the JSONAPI adapter's pattern in every adapter, it just means the additional complexity that comes with that pattern. You'd more or less be taking something simple, converting it to something more complex, then formatting it back as something simple again. |
I kind of consider this a bug in the divergence of how serializers are used. However, to be fair-ish to history, it was my work that pushed most of the 'Attributes' code back into the serializer. |
Summary
The goal here is to redesign the serializer <-> adapter interaction such that there is minimum effort in formatting the output. Adapters would then only really be responisble for formatting, and it may be more appropriate to name them
Formatters
Motivation
There is inconsistency with what adapters implement what features. I feel like this is confusing for people.
Current Issues with adapters:
JSON
andAttributes
are missing features thatJSON API
offersDetailed design
in-progress, needs discussion.
Adapters should have an API modeled after JSON API
data
included
meta
links
errors
A lot of these are already accessible to the serializer, but we've been relying on the adapter to traverse all of it.
An adapter would be responsible for converting each of these structures into whatever format it wishes.
Drawbacks
a lot of work, would invalidate / cause major conflicts for nearly all outstanding PRs.
Alternatives
deal with things as they are.
Unresolved questions
The text was updated successfully, but these errors were encountered: