I'm interested to know if there is a way (and if it would be beneficial) to abstract some of the resources away into a base resource providing the standard CRUDI functions based on entities and fields rather than the current resource per exported type.

Lets say i create a new content type based on node (call it article, has a tagline, images, and quotes fields) and i want to expose it over services. I would like to call article.retrieve (id) rather than node.retrieve (id, article_type) because the thing calling this service has no idea drupal is being used or what a node is.

In this vein i would also like to be able to modify what data about an article is returned, i don't want to expose vid, nid, and most of the field identifier names that are returned by node_resource.

So an example scenario:
1. Admin creates services as now and selects the article entity type to have CRUD access functions enabled. Article is available as it is just an entity type.
2. Admin edits the Retrieve function and ticks the fields that they want to be returned and maybe specifies an alias that it should be returned as. Eg. nid => ID, field_quotes => 'quotes', field_tagline => 'tagline'.
3. User calls the service to retrieve the article id: 4 returning
{
'ID' : 4,
'quotes' : { 'quote 1', 'quote 2' }
'tagline' : { ' tagline 1' }
}

Given that we know about entity types and their fields - is this possible? field_quotes and field_tagline are returned as an array because the field is allowed to have multiple entries per entity. Granted there is information that may need a specific resource module to retrieve, like a get_related_articles() action, but that is additional to the main functionality and ideally would be handled by services_views.

I guess what this comes down to is being able to providing a leaner interface for clients that are independent from our choice of CMS.

Comments

voxpelli’s picture

I think one of the benefits of #1060362: Remove resources in Services 4.x would be that alternate approaches like this would be able to compete with the current core resources on becoming the standard way of accessing stuff in Drupal.

The "RESTful Web Services" unfortunately decided to duplicate the entire Services module to accomplish what you're describing, which of course isn't necessary. I did an initial port of their project which worked fine - if anyone would like to continue working on it and release it on Drupal.org then please feel free to do so: #1044162: Move to Services, initial port I can only see good things coming out of bridging the gap between Services and "RESTful Web Services".

kylebrowning’s picture

Status: Active » Closed (won't fix)