GraphQLエンジン比較:Hasura vs PostGraphile vs WunderGraph でGraphQL APIを構築する
オープンソースラボ編集部 ・ 2026年6月14日
GraphQLエンジン比較:Hasura vs PostGraphile vs WunderGraph でGraphQL APIを構築する
⚡ データベースから自動でGraphQL APIを生成するエンジンは開発速度を劇的に向上させます。Hasura・PostGraphile・WunderGraphの特徴を比較します。
GraphQLエンジンとは
データベースのスキーマを元に、GraphQL APIを自動生成するツールです。手動でリゾルバを書く必要がなく、RESTful APIより柔軟なクエリが可能になります。
主要ツール比較表
| 項目 | Hasura | PostGraphile | WunderGraph |
|---|---|---|---|
| ライセンス | Apache 2.0(CE) | MIT | Apache 2.0 |
| DB対応 | PG/MySQL/Mongo等 | PostgreSQLのみ | 複数ソース統合 |
| リアルタイム | ◎ Subscriptions | ◎ Live Queries | ◎ |
| 認証 | JWT/Webhook | Row-level security | 統合済み |
| REST同時提供 | ○ | × | ◎ |
| Managed SaaS | Hasura Cloud | × | WunderGraph Cloud |
| セットアップ | ◎ 超簡単 | ○ | ○ |
| カスタムロジック | Actions/Events | Plugins | TypeScript hooks |
各ツールの特徴
Hasura
PostgreSQLをはじめ複数のDBからGraphQL APIを瞬時に生成。Dockerイメージを1つ起動するだけで動き始めるシンプルさが人気の理由です。
主な特徴:
- テーブルをUIで選ぶだけでCRUDのGraphQL APIが完成
- リアルタイムサブスクリプションをWebSocketで提供
- Role-based access control(RBAC)をYAMLで設定
- Actions(REST API呼び出し)・Event Triggers・Scheduled Triggersで拡張
# docker-compose.yml
version: '3.6'
services:
postgres:
image: postgres:15
environment:
POSTGRES_PASSWORD: postgrespassword
volumes:
- db_data:/var/lib/postgresql/data
graphql-engine:
image: hasura/graphql-engine:v2.38.0
ports:
- "8080:8080"
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
depends_on:
- postgres
volumes:
db_data:
向いているケース: 高速プロトタイピング・複数DB統合
PostGraphile
PostgreSQLのRow Level Security(RLS)と完全連携するGraphQLエンジン。Postgresの機能を最大限活用したい場合に最適です。
主な特徴:
- PostgreSQLのRLSをそのまま権限管理に使用
- Postgresの関数・ビュー・トリガーをGraphQL APIとして公開
- Live Queries(リアルタイム)サポート
- プラグインシステムで高度なカスタマイズ
// PostGraphile をExpress/Node.jsで起動
const express = require('express');
const { postgraphile } = require('postgraphile');
const app = express();
app.use(
postgraphile(
'postgres://user:password@localhost:5432/mydb',
'public',
{
watchPg: true,
graphiql: true,
enhanceGraphiql: true,
enableQueryBatching: true,
dynamicJson: true,
pgDefaultRole: 'anonymous',
jwtSecret: process.env.JWT_SECRET,
jwtPgTypeIdentifier: 'public.jwt_token',
}
)
);
app.listen(5000);
向いているケース: PostgreSQLのRLSを活用したセキュリティ重視の設計
WunderGraph
複数のAPIソース(REST/GraphQL/gRPC/DB)を統合するAPIゲートウェイ。Type-safeなTypeScriptクライアントを自動生成する点が独特です。
主な特徴:
- 複数のデータソースをSchema Stitchingで統合
- TypeScriptによるカスタムフックとオペレーション
- 自動生成されたType-safeクライアントSDK
- GraphQL・REST・gRPCを統一APIとして提供
// wundergraph.config.ts
import { configureWunderGraphApplication, cors, EnvironmentVariable, introspect } from '@wundergraph/sdk';
const db = introspect.postgresql({
apiNamespace: 'db',
databaseURL: new EnvironmentVariable('DATABASE_URL'),
});
const stripeAPI = introspect.openApi({
apiNamespace: 'stripe',
source: { kind: 'file', filePath: './stripe.yaml' },
requestTimeoutSeconds: 10,
});
configureWunderGraphApplication({
apis: [db, stripeAPI],
server: { hooks: { queries: {}, mutations: {} } },
operations: { defaultConfig: { authentication: { required: false } } },
});
向いているケース: マイクロサービス統合・複数APIの一元管理
選択ガイド
| 要件 | 推奨 |
|---|---|
| 高速プロトタイピング・複数DB | Hasura |
| PostgreSQL + RLSを活用 | PostGraphile |
| 複数REST/GraphQL/gRPCを統合 | WunderGraph |
内部リンク
外部リソース
FAQ
Q. HasuraはPostgreSQL以外のDBも使えますか?
Hasura v2以降はMySQL・MongoDB・BigQuery・Microsoft SQL Serverなど多数のデータソースをサポートしています。
Q. GraphQLのN+1問題はどう解決されていますか?
HasuraとPostGraphileはDataloaderパターンで自動的にN+1を解消するクエリを生成します。
Q. 既存のREST APIと並行して使えますか?
HasuraはREST APIとGraphQL APIを同時に提供できます。WunderGraphは既存REST APIを統合するのが得意です。
Q. HasuraのOSSとCloud版の違いは何ですか?
OSS版は機能的に十分使えます。Cloud版ではObservability・より高度なRBAC・SLAが追加されます。