Update: we've released a Mongoose adapter for Graffiti. Here's how to get started with it.

Currently, the consumption of HTTP REST APIs dominate the client-side world and GraphQL aims to change that. The transition can be time-consuming - this is where Graffiti comes into the picture.

Graffiti grabs your existing models, transforms them into a GraphQL schema and exposes it over HTTP.

## Why we made Graffiti for GraphQL

We don't want to rewrite our application - no one wants that. Graffiti provides an express middleware, a hapi plugin and a koa middleware to convert your existing models into a GraphQL schema and exposes it over HTTP.

Use cases of Graffiti

There are a couple of areas where Graffiti is extremely useful:

For existing applications

If you are already running an HTTP REST API and uses an ORM then with adding a couple of lines of code you can expose a GraphQL endpoint.

For new applications

Graffiti comes to the rescue when you just about to start developing a new backend for your endpoint consumers - the only thing you have to define is your models using one of the supported ORMs.

Setup Graffiti

Adding to Graffiti to your project is as easy as:

import express from 'express';
import graffiti from '@risingstack/graffiti';
import {getSchema} from '@risingstack/graffiti-mongoose';
import mongooseSchema from './schema';

const app = express();
app.use(graffiti.express({
  schema: getSchema(mongooseSchema)
}));

For complete, working examples check out our Graffiti examples folder.

You can play with a running Relay application using Graffiti here. Navigate to /graphql to explore the schema with GraphiQL.

You can use a GraphQL schema generated by an adapter or your own GraphQLSchema instance with Graffiti.

GraphQL over Websocket / mqtt

With Graffiti you are not limited to HTTP - with the adapters you can easily expose the GraphQL interface over any transport protocol.

Roadmap

We have a fully functional Graffiti adapter for Mongoose and we have plans to support other ORMs too. Also, please note, that some of the following items depend only on the adapters, and not on the main project itself.

  • Query support (done)
  • Mutation support (done)
  • Yeoman generator (planned)
  • Relay support (done)
  • Adapters
    • for MongoDB: graffiti-mongoose (done)
    • for RethinkDB: graffiti-thinky (in progress)
    • for SQL: graffiti-bookshelf (in progress)

Contributing

If you are interested in contributing, just say hi in the main Graffiti repository.