Skip to content
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

Initial implementation to support bulk extension #218

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bjornharrtell
Copy link
Contributor

This is an initial spike to implement #215.

@bjornharrtell
Copy link
Contributor Author

@joukevandermaas do you think something like this could be a reasonable approach to support the bulk extension?

@joukevandermaas
Copy link
Owner

@bjornharrtell looks like a good approach.

It's not very clear from the examples on the page you linked, but it seems that you should be able to post/patch/delete resources of different types in a single request?

That doesn't seem feasible with this solution, because the enumerable has a fixed type in the action method's parameter. Perhaps we could create a type like this:

class JsonApiType
{
    string Type { get; }
    T ConvertTo<T>();
}

Then force action methods with BulkExtRouteAttributeAttribute to take IEnumerable<JsonApiType>? Or perhaps we don't force it, but document that if you want to support multiple types, you'd do it this way?

@bjornharrtell
Copy link
Contributor Author

I don't think it makes sense to support different types, as the bulk extension works explicitly on a specific resource collection?

Unrelated, I note that there is a requirement for extension negotiation described at http://springbot.github.io/json-api/extensions/#extension-negotiation.

@bjornharrtell
Copy link
Contributor Author

Seems I jumped the gun here and that heterogeneous resource collections are indeed supported by JSON-API (although that's a bit of a surprise to me..), at least that's my interpretation of the discussion at json-api/json-api#278. However if Saule currently assumes homogenous resource collections (which I think it does?) I think it's reasonable to have the same limitation here.

@bjornharrtell
Copy link
Contributor Author

And yet another realization is that this and other extensions have been deprecated (https://jsonapi.org/extensions/#prior-extensions). However, it still does seem quite useful anyway and it doesn't look like the upcoming JSON API 1.1 will include what seemed to be the intended replacement (Operations, json-api/json-api#1254).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants