The easiest way to start from scratch is to use the application
Alternatively, download and point to the template locally:
git diff to see the changes to a blank Rails app.
This process is straightforward; you can add Graphiti to an existing
Rails app alongside JBuilder or ActiveModelSerializers.
Start with gems:
You’ll be up-and-running at this point. Verify with a simple standalone
Now we just need to integrate with Rails endpoints (to give us things
And wire-up our error-handling:
That’s it for the basics. You may have issues with generators
conflicting with your existing application structure - but you can
always write files manually or submit an issue.
Graphiti supports JSONAPI, simple JSON, and XML. You can do this
manually when inheriting from
But we can inherit from
ActionController::API while avoiding this
boilerplate with with the Responders gem:
To get this functionality:
Note: Persistence operations only support JSONAPI format, so you’ll
render jsonapi: and
render jsonapi_errors: for those.
To add our Integration Tests:
Bootstrap RSpec if you haven’t already:
Add some RSpec configuration:
By default, we use Kaminari for
ActiveRecord pagination. If you prefer [will_paginate] (or anything
You can use Graphiti in any plain
.rb file. To see this in action,
check out the Plain Ruby Sample App.