@@ -33,16 +33,46 @@ GraphQL 已有多种编程语言支持。下表包含一些流行的服务端框
33
33
- [Groovy](#groovy)
34
34
- [Java](#java)
35
35
- [JavaScript](#javascript)
36
+ - [Kotlin](#kotlin)
36
37
- [PHP](#php)
37
38
- [Python](#python)
38
- - [Scala](#scala)
39
39
- [Ruby](#ruby)
40
+ - [Rust](#rust)
41
+ - [Scala](#scala)]
42
+ - [Swift](#swift)
40
43
41
44
### C# / .NET
42
45
43
- - [graphql-dotnet](https://github.com/graphql-dotnet/graphql-dotnet):.NET 的 GraphQL 实现
46
+ #### [graphql-dotnet](https://github.com/graphql-dotnet/graphql-dotnet):.NET 的 GraphQL 实现
47
+
48
+ \`\`\`csharp
49
+ using System;
50
+ using GraphQL;
51
+ using GraphQL.Types;
52
+
53
+ public class Program
54
+ {
55
+ public static void Main(string[] args)
56
+ {
57
+ var schema = Schema.For(@"
58
+ type Query {
59
+ hello: String
60
+ }
61
+ ");
62
+ var json = schema.Execute(_ =>
63
+ {
64
+ _.Query = "{ hello }";
65
+ _.Root = new { Hello = "Hello World!" };
66
+ });
67
+ Console.WriteLine(json);
68
+ }
69
+ }
70
+ \`\`\`
71
+
44
72
- [graphql-net](https://github.com/ckimes89/graphql-net):转换 GraphQL 到 IQueryable
45
- - [Hot Chocolate](https://github.com/ChilliCream/hotchocolate):针对 .net core 和 .net classic 的 GraphQL 服务器
73
+ - [Entity GraphQL](https://github.com/lukemurray/EntityGraphQL):针对 .NET Core 的 GraphQL 库。编译为 IQueryable 以轻松地从现有的数据模型(例如从 Entity Framework 数据模型)中暴露出 schema
74
+ - [DotNetGraphQLQueryGen](https://github.com/lukemurray/DotNetGraphQLQueryGen):从 GraphQL schema 生成类,以在 dotnet 中进行类型安全的查询的 .NET Core 库
75
+ - [Hot Chocolate](https://github.com/ChilliCream/hotchocolate):针对 .NET core 和 .NET classic 的 GraphQL 服务器
46
76
47
77
### Clojure
48
78
@@ -128,6 +158,8 @@ $ curl -XPOST "http://0:3000" -H'Content-Type: application/json' -d'{
128
158
- [graphql-relay-go](https://github.com/graphql-go/relay):一个用于帮助构建 graphql-go 服务器的 Go/Golang 库,支持 react-relay 。
129
159
- [machinebox/graphql](https://github.com/machinebox/graphql):用于 GraphQL 的一个优雅的底层 HTTP 客户端。
130
160
- [samsarahq/thunder](https://github.com/samsarahq/thunder):可轻松进行 schema 构建、实时查询和批处理的 GraphQL 实现。
161
+ - [99designs/gqlgen](https://github.com/99designs/gqlgen):一个 schema 优先的 GraphQL 服务器生成。
162
+ - [appointy/jaal](https://github.com/appointy/jaal):在 Go 中开发符合规范的 GraphQL 服务器。
131
163
132
164
### Groovy
133
165
@@ -145,7 +177,7 @@ $ curl -XPOST "http://0:3000" -H'Content-Type: application/json' -d'{
145
177
146
178
更多信息请查看 [文档](https://grails.github.io/gorm-graphql/latest/guide/index.html)。
147
179
148
- #### [GQL](https://grooviter.github.io/gql/)
180
+ #### [GQL](https://grooviter.github.io/gql/)
149
181
150
182
GQL 是一个在 Groovy 中使用 GraphQL 的库。
151
183
@@ -177,7 +209,7 @@ public class HelloWorld {
177
209
SchemaParser schemaParser = new SchemaParser();
178
210
TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(schema);
179
211
180
- RuntimeWiring runtimeWiring = newRuntimeWiring ()
212
+ RuntimeWiring runtimeWiring = new RuntimeWiring ()
181
213
.type("Query", builder -> builder.dataFetcher("hello", new StaticDataFetcher("world")))
182
214
.build();
183
215
@@ -266,47 +298,83 @@ app.listen(4000, () => console.log('Now browse to localhost:4000/graphql'));
266
298
如果要运行 \`apollo-server-express\` 的 hello world 服务器:
267
299
268
300
\`\`\`bash
269
- npm install apollo-server-express body-parser express graphql graphql-tools
301
+ npm install apollo-server-express express
270
302
\`\`\`
271
303
272
304
然后使用 \`node server.js\` 以运行 \`server.js\` 中的代码:
273
305
274
306
\`\`\`js
275
- var express = require('express');
276
- var bodyParser = require('body-parser');
277
- var { graphqlExpress, graphiqlExpress } = require('apollo-server-express');
278
- var { makeExecutableSchema } = require('graphql-tools');
279
-
280
- var typeDefs = [\`
281
- type Query {
282
- hello: String
283
- }
284
-
285
- schema {
286
- query: Query
287
- }\`];
288
-
289
- var resolvers = {
290
- Query: {
291
- hello(root) {
292
- return 'world';
293
- }
307
+ const express = require('express');
308
+ const { ApolloServer, gql } = require('apollo-server-express');
309
+ const typeDefs = gql\`
310
+ type Query {
311
+ hello: String
294
312
}
313
+ \`;
314
+ const resolvers = {
315
+ Query: {
316
+ hello: () => 'Hello world!',
317
+ },
295
318
};
296
-
297
- var schema = makeExecutableSchema({typeDefs, resolvers} );
298
- var app = express( );
299
- app.use('/graphql', bodyParser.json(), graphqlExpress({schema}));
300
- app.use('/graphiql', graphiqlExpress({endpointURL: '/graphql'}));
301
- app.listen(4000, () => console.log('Now browse to localhost:4000/graphiql') );
319
+ const server = new ApolloServer({ typeDefs, resolvers });
320
+ const app = express( );
321
+ server.applyMiddleware({ app } );
322
+ app.listen({ port: 4000 }, () =>
323
+ console.log('Now browse to http://localhost:4000' + server.graphqlPath)
324
+ );
302
325
\`\`\`
303
326
304
327
Apollo Server 也支持所有的 Node.js HTTP 服务器框架:Express、Connect、HAPI 和 Koa。
305
328
329
+ ### Kotlin
330
+
331
+ - [graphql-kotlin](https://github.com/ExpediaGroup/graphql-kotlin/):一组用于在 Kotlin 中运行 GraphQL 服务器的库。
332
+
333
+
306
334
### PHP
307
335
308
336
- [graphql-php](https://github.com/webonyx/graphql-php):GraphQL 参考实现的 PHP 移植版本。
309
337
- [graphql-relay-php](https://github.com/ivome/graphql-relay-php):一个用于辅助构建 graphql-php 服务器的库,支持 react-relay。
338
+ - [Lighthouse](https://github.com/nuwave/lighthouse):一个用于 Laravel 的 GraphQL 服务器
339
+ - [GraphQLBundle](https://github.com/overblog/GraphQLBundle):一个用于 Symfony 的 GraphQL 服务器
340
+
341
+ #### [API Platform](https://api-platform.com) ([github](https://github.com/api-platform/api-platform))
342
+
343
+ API Platform 是一个基于 Symfony 构建的功能齐全、灵活且可扩展的 API 框架。
344
+ 以下的类足以创建与 Relay 兼容的 GraphQL 服务器和支持现代 REST 格式(JSON-LD、JSONAPI...)的超媒体 API:
345
+
346
+ \`\`\`php
347
+ <?php
348
+
349
+ namespace App\Entity;
350
+
351
+ use ApiPlatform\Core\Annotation\ApiResource;
352
+ use Doctrine\ORM\Mapping as ORM;
353
+
354
+ /**
355
+ * Greet someone!
356
+ *
357
+ * @ApiResource
358
+ * @ORM\Entity
359
+ */
360
+ class Greeting
361
+ {
362
+ /**
363
+ * @ORM\Id
364
+ * @ORM\Column(type="guid")
365
+ */
366
+ public $id;
367
+
368
+ /**
369
+ * @var string Your nice message
370
+ *
371
+ * @ORM\Column
372
+ */
373
+ public $hello;
374
+ }
375
+ \`\`\`
376
+
377
+ API Platform 的其他功能还包括数据验证、身份验证、授权、弃用、缓存和 GraphiQL 集成。
310
378
311
379
#### [Siler](https://siler.leocavalcante.com/graphql/) ([github](https://github.com/leocavalcante/siler))
312
380
@@ -349,6 +417,10 @@ Http\server(Graphql\psr7($schema), function (\Throwable $err) {
349
417
350
418
它还根据 Apollo 的工作原理提供了构建 WebSocket 订阅服务器的功能。
351
419
420
+ ### Swift
421
+
422
+ - [Graphiti](https://github.com/GraphQLSwift/Graphiti):一个 Swift 库,可快速、安全且轻松地构建 GraphQL schema/类型。
423
+
352
424
### Python
353
425
354
426
#### [Graphene](http://graphene-python.org/) ([github](https://github.com/graphql-python/graphene))
@@ -396,15 +468,15 @@ gem install graphql
396
468
\`\`\`ruby
397
469
require 'graphql'
398
470
399
- QueryType = GraphQL::ObjectType.define do
400
- name 'Query'
471
+ class QueryType < GraphQL::Schema::Object
472
+ graphql_name 'Query'
401
473
field :hello do
402
474
type types.String
403
475
resolve -> (obj, args, ctx) { 'Hello world!' }
404
476
end
405
477
end
406
478
407
- Schema = GraphQL::Schema.define do
479
+ class Schema < GraphQL::Schema
408
480
query QueryType
409
481
end
410
482
@@ -413,6 +485,10 @@ puts Schema.execute('{ hello }').to_json
413
485
414
486
其也有对于 Relay 和 Rails 的良好绑定。
415
487
488
+ ### Rust
489
+
490
+ - [graphql-rust/juniper](https://github.com/graphql-rust/juniper):用于 Rust 的 GraphQL 服务端库
491
+
416
492
### Scala
417
493
418
494
#### [Sangria](http://sangria-graphql.org/) ([github](https://github.com/sangria-graphql/sangria)):支持 [Relay](https://facebook.github.io/relay/) 的一个 Scala GraphQL 库。
@@ -439,6 +515,7 @@ Executor.execute(schema, query) map println
439
515
440
516
- [C# / .NET](#c-net-1)
441
517
- [Clojurescript](#clojurescript-1)
518
+ - [Flutter](#flutter)
442
519
- [Go](#go-1)
443
520
- [Java / Android](#java-android)
444
521
- [JavaScript](#javascript-1)
@@ -455,6 +532,10 @@ Executor.execute(schema, query) map println
455
532
456
533
- [re-graph](https://github.com/oliyh/re-graph/):一个在 Clojurescript 中实现的 GraphQL 客户端,支持 websockets。
457
534
535
+ ### Flutter
536
+
537
+ - [graphql](https://github.com/zino-app/graphql-flutter#readme):一个 Flutter 中的 GraphQL 客户端实现。
538
+
458
539
### Go
459
540
460
541
- [graphql](https://github.com/shurcooL/graphql#readme):一个使用 Go 编写的 GraphQL 客户端实现。
@@ -468,12 +549,13 @@ Executor.execute(schema, query) map println
468
549
469
550
- [Relay](https://facebook.github.io/relay/) ([github](https://github.com/facebook/relay)) ([npm](https://www.npmjs.com/package/react-relay)):Facebook 的框架,用于构建与 GraphQL 后端交流的 React 应用。
470
551
- [Apollo Client](http://apollographql.com/client/) ([github](https://github.com/apollographql/apollo-client)):一个强大的 JavaScript GraphQL 客户端,设计用于与 React、React Native、Angular 2 或者原生 JavaScript 一同工作。
471
- - [graphql-request](https://github.com/graphcool /graphql-request):一个简单的弹性的 JavaScript GraphQL 客户端,可以运行于所有的 JavaScript 环境(浏览器,Node.js 和 React Native)—— 基本上是 \`fetch\` 的轻度封装。
552
+ - [graphql-request](https://github.com/prisma /graphql-request):一个简单灵活的 JavaScript GraphQL 客户端,可以运行于所有的 JavaScript 环境(浏览器,Node.js 和 React Native)—— 基本上是 \`fetch\` 的轻度封装。
472
553
- [Lokka](https://github.com/kadirahq/lokka):一个简单的 JavaScript GraphQL 客户端,可以运行于所有的 JavaScript 环境 —— 浏览器,Node.js 和 React Native。
473
554
- [nanogql](https://github.com/yoshuawuyts/nanogql):一个使用模板字符串的小型 GraphQL 客户端库。
474
555
- [gq-loader](https://github.com/Houfeng/gq-loader):一个简单的 JavaScript GraphQL 客户端,通过 webpack 加载器让 *.gql 文件作为模块使用。
475
556
- [AWS Amplify](https://aws.github.io/aws-amplify):使用云服务进行应用开发的 JavaScript 库,支持 GraphQL 后端和用于处理 GraphQL 数据的 React 组件。
476
557
- [Grafoo](https://github.com/grafoojs/grafoo):一个通用的 GraphQL 客户端,具有仅 1.6kb 的多框架的视图层集成。
558
+ - [urql](https://formidable.com/open-source/urql/) ([github](https://github.com/FormidableLabs/urql)):一个用于 React 的高度可定制且用途广泛的 GraphQL 客户端。
477
559
478
560
### Swift / Objective-C iOS
479
561
@@ -483,7 +565,7 @@ Executor.execute(schema, query) map println
483
565
### Python
484
566
485
567
- [GQL](https://github.com/graphql-python/gql):一个 Python 中的 GraphQL 客户端。
486
- - [python-graphql-client](https://github.com/graphcool /python-graphql-client):适用于 Python 2.7+ 的简单 GraphQL 客户端。
568
+ - [python-graphql-client](https://github.com/prisma /python-graphql-client):适用于 Python 2.7+ 的简单 GraphQL 客户端。
487
569
- [sgqlc](https://github.com/profusion/sgqlc):一个简单的 Python GraphQL 客户端。支持为 GraphQL schema 中定义的类型生成代码。
488
570
489
571
## 工具
@@ -495,14 +577,15 @@ Executor.execute(schema, query) map println
495
577
496
578
## 服务
497
579
498
- - [Apollo Engine ](http://www .apollographql.com/engine/ ):一个用于监视 GraphQL 后端的性能和使用的服务 。
580
+ - [Apollo Graph Manage ](http://engine .apollographql.com):一个用于监视 GraphQL 后端的性能和使用的云服务 。
499
581
- [GraphCMS](https://graphcms.com/):一个 BaaS(后端即服务),它为你配置了一个作为内容编辑工具来处理存储数据的 GraphQL 后端。
500
- - [Graphcool ](https://www.graph.cool ) ([github](https://github.com/graphcool )):一个 BaaS(后端即服务),它为你的应用程序提供了一个 GraphQL 后端,且具有用于管理数据库和存储数据的强大的 web ui。
582
+ - [Prisma ](https://www.prisma.io ) ([github](https://github.com/prisma )):一个 BaaS(后端即服务),它为你的应用程序提供了一个 GraphQL 后端,且具有用于管理数据库和存储数据的强大的 web ui。
501
583
- [Reindex](https://www.reindex.io/baas/) ([github](https://github.com/reindexio/reindex-js)):一个 BaaS(后端即服务),它针对使用 React 和 Relay 的应用程序配置了 GraphQL 后端。
502
584
- [Scaphold](https://scaphold.io) ([github](https://github.com/scaphold-io)):一个 BaaS(后端即服务),为你的应用程序配置了一个拥有多种不同集成的 GraphQL 后端。
503
585
- [Tipe](https://tipe.io) ([github](https://github.com/tipeio)):一个 SaaS(软件即服务)内容管理系统,允许你使用强大的编辑工具创建你的内容,并通过 GraphQL 或 REST API 从任何地方访问它。
504
586
- [AWS AppSync](https://aws.amazon.com/appsync/):完全托管的 GraphQL 服务,包含实时订阅、离线编程和同步、企业级安全特性以及细粒度的授权控制。
505
587
- [Hasura](https://hasura.io):一个 BaaS(后端即服务),允许你在 Postgres 上创建数据表、定义权限并使用 GraphQL 接口查询和操作。
588
+ - [FaunaDB](https://docs.fauna.com/fauna/current/graphql):通过导入 gql schema 创建即时 GraphQL 后端。数据库将为你创建关系和索引,因此你无需编写任何数据库代码即可在几秒钟内查询。Serverless 定价可免费开始使用。
506
589
507
590
## 更多内容
508
591
0 commit comments