Skip to content

ADR 1: Batch API Operations

Status

proposed

Context

UC 15b consumes an array of organization records and submits them to the Boyar API. A batch operation would be more effective than a series of PUTs.

Decision

Upon reflection, I am considering a sub-resource like POST /items/batches. This would map to a command like CreateItemBatch and contains an array of models.

Benefits to this approach:

  • Maps well to command pattern
  • Result could be either:
  • A batch id if an actual batch construct exists
  • An array of result models of the created objects
  • A POST of a batch could imply that the process is asynchronous. The PATCH approach below would not allow for this.

Approaches considered but not used

PATCH of collection

In an effort to stay in the spirit of REST, we will expose a PATCH operation at the collection

PATCH /items
[ { id: 1, name: 'foo' }, { id: 2, name: 'bar' } ]

https://stackoverflow.com/a/32101994/107161

PUT at the resource level

This implies a replacement of the entire resource. https://stackoverflow.com/a/53245225/107161

Shopware does this but in a PATCH-style operation.

Consequences

A pattern for batch updates is available for REST apis.