WebAPI-DBIC icon indicating copy to clipboard operation
WebAPI-DBIC copied to clipboard

Simplify the separate evolution of the API and the Schema

Open timbunce opened this issue 10 years ago • 0 comments

WebAPI::DBIC defaults to the pragmatic approach of being a thin layer over your existing DBIx::Class schema. This is indeed very pragmatic and gives you an 'Instant RESTful API'.

However, time rolls on and your schema might evolve in ways that would break the existing API clients, like change the name or type or semantics of a field. Or you might want to create a new API that abstracts/hides some details of the implementation in order to then be able to change those details without affecting clients.

One (very minor) step would be to make it easy for a resource to specify a list of field name and whether each of those fields is included in a response by default, or can be requested via the fields parameter. (If a field isn't on the list at all then it could not be included in responses and would trigger an error if included in PUT/POST requests.)

At a deeper level, WAPID is very much about being an interface to the services and semantics of DBIx::Class schema, especially the handling of relationships. So arguably the right place to handle evolution is 'behind' the DBIx::Class API. In other words, document and encourage use of advanced DBIx::Class features like subclassing ResultSource classes (and/or use of DBIx::Class::ResultSourceProxy::Table and DBIx::Class::ResultSource::View).

We should develop a list of evolution use-cases and corresponding recommended approaches.

timbunce avatar Dec 04 '14 14:12 timbunce