pg_graphql 支持使用GraphQL查询现有的PostgreSQL数据库,提供了SQL模式->GraphQL模式反射引擎和关联的GraphQL查询->SQL查询转译器,任何可以连接到PostgreSQL的编程语言都可以通过GraphQL查询数据库,而无需额外的服务器、进程或库。
SQL架构
createtableaccout(idserialprimarykey,emailvarchar(255)otull,ecrypted_passwordvarchar(255)otull,created_attimestampotull,updated_attimestampotull);createtableblog(idserialprimarykey,ower_iditegerotullreferecesaccout(id),amevarchar(255)otull,descriptiovarchar(255),created_attimestampotull,updated_attimestampotull);createtypeblog_post_statusaseum('PENDING','RELEASED');createtableblog_post(iduuidotulldefaultuuid_geerate_v4()primarykey,blog_iditegerotullreferecesblog(id),titlevarchar(255)otull,bodyvarchar(10000),statusblog_post_statusotull,created_attimestampotull,updated_attimestampotull);转换为GraphQL模式,将每个表公开为一个可分页的集合,其关系由外键定义。
评论