pg_graphqlPostgreSQL 的 GraphQL 支持
pg_graphql 支持使用 GraphQL 查詢現(xiàn)有的 PostgreSQL 數(shù)據(jù)庫,提供了 SQL 模式 -> GraphQL 模式反射引擎和關(guān)聯(lián)的 GraphQL 查詢 -> SQL 查詢轉(zhuǎn)譯器,任何可以連接到 PostgreSQL 的編程語言都可以通過 GraphQL 查詢數(shù)據(jù)庫,而無需額外的服務(wù)器、進(jìn)程或庫。
SQL 架構(gòu)
create table account( id serial primary key, email varchar(255) not null, encrypted_password varchar(255) not null, created_at timestamp not null, updated_at timestamp not null ); create table blog( id serial primary key, owner_id integer not null references account(id), name varchar(255) not null, description varchar(255), created_at timestamp not null, updated_at timestamp not null ); create type blog_post_status as enum ('PENDING', 'RELEASED'); create table blog_post( id uuid not null default uuid_generate_v4() primary key, blog_id integer not null references blog(id), title varchar(255) not null, body varchar(10000), status blog_post_status not null, created_at timestamp not null, updated_at timestamp not null );
轉(zhuǎn)換為 GraphQL 模式,將每個(gè)表公開為一個(gè)可分頁的集合,其關(guān)系由外鍵定義。
評(píng)論
圖片
表情
