Graffy is an open source library to serve and consume your app’s data over deliciously fast and intuitive APIs. It runs on any JavaScript-based client or server environment, and supports:

Live queries Clients can say “give me this data now, and then let me know of changes as they happen.”

Multiple data sources Supports PostgreSQL out of the box; custom providers are super easy to write.

Client-side state management Use a single library to seamlessly manage both client-side state and server-side data.

Resource expansion Fetch everything in one round trip, even if related objects are in different databases.

Optimistic writes Update the UI immediately on writes, without waiting for a server response.

Efficient pagination Uses scalable and efficient cursor-based pagination to deal with long lists of things.

All these things are composable and work seamlessly together.

Graffy is still under heavy development; some of this stuff may not work yet.

Overview

You use Graffy to build and access stores — an abstraction over some underlying storage mechanism, such as a database, a web server, event stream or just some objects in memory.

const store = new Graffy();
const app = express();
app.use(graffyServer(store));

Graffy stores can be deployed to a server for clients to access over HTTP or WebSockets. They also have an elegant JavaScript API for use within client or server code.

On the client, Graffy provides caching (with optional persistence and optimistic updates), manages real-time data streams from the server and provides a unified API for local and remote data.

store.use(graffyClient('/api'));
store.read(query);

Graffy also has an idiomatic API for React and React Native users.

const { data, loading, error } = useQuery(query);

Powered by Fruition