Graphiti

CI Gem Version Ruby Style Guide semantic-release: angular

discord guides

Graphiti logo

Graphiti sits on top of your models (usually ActiveRecord) and exposes them over a JSON:API-compliant interface. You define Resources instead of controllers and serializers, and get filtering, sorting, pagination, sparse fieldsets, statistics, and nested reads and writes across relationships, all over one endpoint.

It's built on the JSON:API spec, which settles the decisions every API accumulates: response shapes, filtering, sorting, pagination, error formats, and how related data rides along. Your client layer speaks this protocol in return. It isn't complicated, so client logic can be hand-rolled or you can use one of the many available libraries that work with the standard.

A Resource looks like this:

class EmployeeResource < ApplicationResource
  attribute :first_name, :string
  attribute :last_name, :string
  attribute :age, :integer

  has_many :positions
end

That Resource serves ?filter[age][gt]=30, ?sort=-age, ?page[size]=10, ?include=positions and more, without writing any of them. See graphiti.dev for the whole loop, or the example app for a full working API.

Documentation

Docs live at graphiti.dev and are rendered from this repo: the markdown is in /docs, and the Docusaurus site that serves it is in /website. Fixes and improvements are welcome (every page has an "Edit this page" link at the bottom, which makes opening a PR with a change easy).

To preview locally:

cd website
npm install
npm run start

Join the Discord