Problem/Motivation

We want to support multiple operations during a single HTTP request. JSON API has no opinion (yet) on how to do that, but the JSON API community is thinking about releasing the Operations Extension

It's also worth noting that this extension will settle the transport format for messages in a future socket/stream based stack. See: https://github.com/json-api/json-api/issues/795#issuecomment-132734761

Proposed resolution

Implement the extension!

Comments

e0ipso created an issue. See original summary.

dawehner’s picture

Interesting to read!

Just from a software point of view we could clearly separate the HTTP level from the other retrieval of things.

e0ipso’s picture

Agreed. I thought a little bit about this, and I would even go further. I believe that there is no reason not to have a non-REST related module that is a generic web service.

That module would have a front controller. That front controller would semantically represent the entire content repository. Maybe /transactions. That controller would only accept POST or PATCH requests with a payload. That payload would contain a set of sequential transactions (we could get in async stuff later) to execute.

Every transaction will have all the information that an individual regular JSON API transaction should have encoded in that payload:

  • The payload for write operations.
  • The headers for that transaction.
  • The path of the operation. Ex: /api/node/article
  • The operation (that maps to an HTTP verb). Ex: read, add, update, replace, delete, explore
  • The query string parameters. Ex: {"filter": {"field_tags": {"value": "6"}}}
  • A list of cookies to pass along from the initial request to the front controller. An option to pass them all.

With that information we can manually create the request object and have the jsonapi module do the processing and process the result.

The response would be an array of JSON API document root responses, each one corresponding to the original transaction.

As you can see there is little that stops us from having a transactions socket instead of a /transactions HTTP endpoint. So this jsonapi_transactions module could not even be constraint by HTTP (although we may want to leave that for the future).

Note that there is no intention to call this proposal REST. It is as RPC as it can be, but that is not a bad.

This proposal is heavily inspired (almost a direct import) of the ideas @dgeb is proposing in the JSON API discussion thread.

e0ipso’s picture

Status: Active » Postponed
wim leers’s picture

Related: #2350401: [PP-1] Collection denormalization. In particular, see comment #2350401-5: [PP-1] Collection denormalization. That points to https://tools.ietf.org/html/rfc6578#section-3.8, which is an enlightening read, and shows many of the problems.

wim leers’s picture

Very very interesting! Both this issue, and https://github.com/json-api/json-api/issues/795. I left a comment there: https://github.com/json-api/json-api/issues/795#issuecomment-246751514.

I also wonder what the impact is of HTTP1 + REST vs HTTP2 + REST (multiplexing, streams).

e0ipso’s picture

Status: Postponed » Closed (won't fix)

If anything this should happen in a separate contrib. Closing.