Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. GraphQL
  3. graphql-bookshelf

graphql-bookshelf

JavaScriptv1.0.1

A helper library for defining GraphQL schemas around BookshelfJS models with automatic relationship mapping.

GitHubGitHub
184 stars12 forks0 contributors

What is graphql-bookshelf?

GraphQL Bookshelf is a helper library that bridges BookshelfJS models with GraphQL schemas. It automates the mapping of model attributes and relationships to GraphQL fields, reducing the need for repetitive resolve functions. The library provides utilities like `model.attr()`, `model.belongsTo()`, and `model.hasMany()` to streamline schema definition and optimize database queries.

Target Audience

Node.js developers using BookshelfJS as their ORM who want to expose their data models through a GraphQL API with minimal boilerplate.

Value Proposition

It eliminates repetitive code by automatically handling relationship resolution and attribute mapping, while still offering flexibility through direct query builder access. Unlike full schema generators, it keeps control in the developer's hands for complex use cases.

Overview

Some help defining GraphQL schema around BookshelfJS models

Use Cases

Best For

  • Rapidly building GraphQL APIs on top of existing BookshelfJS models
  • Reducing boilerplate code when defining GraphQL schemas with relational data
  • Optimizing GraphQL query performance by leveraging KnexJS query builders
  • Integrating GraphQL Relay connections with BookshelfJS associations
  • Maintaining control over schema definition while automating common patterns
  • Mapping complex one-to-many and belongs-to relationships in GraphQL

Not Ideal For

  • Projects using a different ORM like Sequelize or Prisma, as it's tightly coupled to BookshelfJS
  • Teams preferring fully automated schema generation from database models, since it avoids over-automation
  • Applications requiring real-time GraphQL features like subscriptions, which are not mentioned in the library
  • Large-scale production systems where stability is critical, due to its early version status

Pros & Cons

Pros

Automatic Attribute Mapping

Uses model.attr() to eliminate manual resolve functions for simple fields, as shown in the example where id is mapped without a resolve function.

Seamless Relationship Integration

Provides model.belongsTo() and model.hasMany() to automatically resolve one-to-one and one-to-many associations, reducing boilerplate for relationships like subject and students.

Query Builder Optimization

Offers direct access to KnexJS query builder in resolve functions, enabling custom sorting and filtering, such as ordering homeworks by created_at in the example.

GraphQL Relay Compatibility

Supports graphql-relay-js for defining connection types and arguments, easing integration with Relay as demonstrated in the homeworks field.

Cons

Early Development Stage

The README labels it as an 'early version', indicating potential instability, limited features, and fewer updates or community contributions.

BookshelfJS Lock-in

Heavily dependent on BookshelfJS, making migration or use with other ORMs difficult and restricting it to specific database setups like Postgres mentioned in the description.

Limited Advanced Features

Focuses on basic CRUD and relationships; lacks built-in support for mutations, subscriptions, or complex query optimizations beyond the provided hooks.

Frequently Asked Questions

Quick Stats

Stars184
Forks12
Contributors0
Open Issues8
Last commit3 years ago
CreatedSince 2015

Tags

#orm-integration#graphql#schema-definition#nodejs#api-development#database-abstraction#postgresql#knexjs

Built With

S
SQLite
P
PostgreSQL
G
GraphQL
N
Node.js

Included in

GraphQL15.0k
Auto-fetched 1 day ago

Related Projects

apollo-serverapollo-server

🌍  Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.

Stars13,952
Forks2,001
Last commit2 days ago
graphql-yogagraphql-yoga

🧘 Rewrite of a fully-featured GraphQL Server with focus on easy setup, performance & great developer experience. The core of Yoga implements WHATWG Fetch API and can run/deploy on any JS environment.

Stars8,531
Forks598
Last commit3 days ago
join-monsterjoin-monster

A GraphQL to SQL query execution layer for query planning and batch data fetching.

Stars2,697
Forks227
Last commit1 year ago
mercuriusmercurius

Implement GraphQL servers and gateways with Fastify

Stars2,493
Forks257
Last commit4 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub