-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Hypermedia support? #270
Comments
Nobody has worked on this. What does it take? |
I guess making Maybe Roar could be used or looked at, they use Also Designing Hypermedia APIs by @steveklabnik is a good resource. To my understanding the main idea is that the responses should act as a representation of the current state of the application and to provide available transitions for the client to act on. This semantics is described using Hypermedia types. I believe Rails-api and Active Model Serializers is on the path for better Hypermedia support, atleast Steve uses active_model_serializers as an example, so maybe the concepts there could also be derived. |
You've got your head on straight, Mattias. |
I was messing around last night, and started building some simple support for using Roar representers with If there's interest I can see about getting some specs written and package it up into a pull request. Though if there's going to be talk of supporting multiple representation frameworks, a little more design may be required so it doesn't get ugly. |
I think any improvement towards multiple presentation frameworks will be more than welcome! |
Also, it would seem that HAL has been picking up a lot of steam lately, so if you're going to pick a format to emit by default, that should be it. |
I would agree that HAL seems to be the one starting to take favor. I'm not familiar enough with Grape's development to know if that is a design goal. The work that I'm planning would allow for either Grape's entities, or Roar representers. Though if we take it out further then I guess maybe ActiveModel serializers too. I think in any of those cases it's still up to the developer at the end of the chain to implement HAL, or whatever their flavor of output is. If you're just referring to the default output by Grape's entity classes, then ignore this. |
I can comment on Grape's design goals: we want it to be awesome and practical and community developed. So think of what you need and how to make it generic enough for everybody else :) |
Wanted to add my increasing interest in this. I was talking to @macreery last night and this morning my clear head tells me that we've been doing API JSON representations all wrong and that Hypermedia is the way to go. I'll look into #273 today and plan to give Roar a try. |
Awesome @dblock, keep us posted! |
If we want to remove the |
I've made a few changes to the way formatters are defined and declared and made a pull request into grape-rabl to demonstrate this (ruby-grape/grape-rabl#6). You can now do this:
In the same vein it should now be possible to build a clean formatter for Roar, although I am not sure if we even need to given that you serialize a representer with |
I guess the above is my question to @dnd - does this now work out of the box or should we build something more pretty? |
Folks on this thread will be interested in some Russian doll stashing and bashing going on around Hypermedia w/ @dhh. http://37signals.com/svn/posts/3373-getting-hyper-about-hypermedia-apis |
Cheers for the links - watching this thread keenly right now while trying to figure out the best way to do this. |
I hacked together a prototype gem for Roar w/ Grape, confirming that we don't need to do anything special anymore. It just uses If anyone believes we can add useful features for better Roar support, the above can serve as a skeleton. I'm going to close this request, since I don't think we should modify Grape entities to allow hypermedia - gems like Roar do a great job at it. Please speak up if you think I'm wrong. |
Also added this to the README. Hypermedia and other RESTful RepresentationsAlthough Grape ships with its own entity support, it's also possible to use it with other frameworks and renderers. HypermediaUse Roar. Include RablRabl is supported via the grape-rabl gem. |
Can we get an AMS shout out too, if you're covering RABL? Trying to get the On Monday, December 24, 2012, Daniel Doubrovkine (dB.) wrote:
|
Totally, but I didn't get a chance to make it work with Grape yet. Want to do a demo and PR a link? If you need a custom formatter, you can pretty much clone my gem. |
I will submit a PR. Least I can do as its maintainer. :) just wanted to ask On Monday, December 24, 2012, Daniel Doubrovkine (dB.) wrote:
|
Is it possible to get an example or how to get roar and grape working together ? |
There's actually nothing to do for Roar in Grape. I did a formatter in https://github.com/dblock/grape-roar, but that's unnecessary. Once you've setup your representers, you can just do |
Is hypermedia support anything you've been thinking about adding so we can implement HATEOAS apis using grape in a simple way?
The text was updated successfully, but these errors were encountered: