Wener Site

GraphQL

约 3 分钟阅读
标签:资源精选
  • 主要让 consumer/client 方使用便捷
  • 核心特性/卖点 - 推荐开启
    • GlobalID - ID 包含类型消息,能实现 ID -> __typename
    • Graph Cache - 以 __typename + id 来缓存 - 类似一个内存的 KV 数据库,可以直接查询
      • 配合自定义 resolver 将查询指向缓存 能大量减少查询
      • 需要暴露 __typename, 但是一般影响不大
    • Batch
    • Subscription - EventSource, WebSocket
    • 代码生成
  • 推荐特性
    • partial query - 只返回需要的字段
    • Document Cache - 以查询维度来缓存
    • persisted query - 通过 hash 来缓存查询, 避免暴露整个查询内容
    • schema aware - 直接告诉查询引擎 schema 内容能让查询引擎更加智能
      • 例如 判断 nullable 可以先返回缓存数据再发起查询
    • federation - 多个 schema 合并
    • schema stitching - 多个 schema 合并
bash
# 获取 Schema
npm install -g graphqurl
gq https://my-graphql-engine.com/v1/graphql --introspect > schema.graphql
gq https://my-graphql-engine.com/v1/graphql -H 'X-Hasura-Admin-Secret: adminsecretkey' --introspect > schema.graphql
gq https://my-graphql-engine.com/v1/graphql --introspect --format json > schema.json

# https://github.com/apollographql/apollo-tooling
# schema.json
npm install -g apollo
apollo schema:download --endpoint https://my-graphql-engine.com/v1/graphql
apollo schema:download --endpoint https://my-graphql-engine.com/v1/graphql --header 'X-Hasura-Admin-Secret: adminsecretkey'
Packagesgraphqurlnpm PackagegraphqurlNPMapollonpm PackageapolloNPM

Apollo

FAQ

N + 1

DateTime

vs REST

TBD

graphql.org/code

skevy/graphiql-appGitHubskevy/graphiql-app Light, Electron-based Wrapper around GraphiQL

apollographql/apollo-serverGitHubapollographql/apollo-server

graphcool/graphql-playgroundGitHubgraphcool/graphql-playground GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)

docker run -p 5000

postgraphql/postgraphql --connection postgres://POSTGRES_USER
@POSTGRES_HOST
/POSTGRES_SCHEMA

chentsulin/awesome-graphqlGitHubchentsulin/awesome-graphql Awesome list of GraphQL & Relay

www.graphql.com graphql.org/learn/best-practices GraphQL Best Practices

www.apollographql.com Apollo provides a universal GraphQL API on top of your existing services, so you can build new application features fast without waiting on backend changes.

facebook/dataloaderGitHubfacebook/dataloader DataLoader is a generic utility to be used as part of your application's data fetching layer to provide a consistent API over various backends and reduce requests to those backends via batching and caching.

blog.datank.ai/graphql-grpc-part-1-54d92a109619 GraphQL & gRPC

relay

global id

关联信息

反向链接和本文引用的外部资料。

References

GitHub

22 条

另有 14 个未显示 references。

Wikipedia

1 条

Hacker News

2 条

其他外链

37 条

另有 29 个未显示 references。

另有 43 个 references 未显示。

最近更新commit e4a5270Edit

On this page