Skip to content

Commit bb58b24

Browse files
ydfzgyjjonirrings
authored andcommitted
Sync 20191130 (graphql#102)
* Sync 191024 * sync 20191111 * sync 20191130
1 parent 936e29c commit bb58b24

12 files changed

+155
-744
lines changed

site/code/index.html.js

Lines changed: 121 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,46 @@ GraphQL 已有多种编程语言支持。下表包含一些流行的服务端框
3333
- [Groovy](#groovy)
3434
- [Java](#java)
3535
- [JavaScript](#javascript)
36+
- [Kotlin](#kotlin)
3637
- [PHP](#php)
3738
- [Python](#python)
38-
- [Scala](#scala)
3939
- [Ruby](#ruby)
40+
- [Rust](#rust)
41+
- [Scala](#scala)]
42+
- [Swift](#swift)
4043
4144
### C# / .NET
4245
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+
4472
- [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 服务器
4676
4777
### Clojure
4878
@@ -128,6 +158,8 @@ $ curl -XPOST "http://0:3000" -H'Content-Type: application/json' -d'{
128158
- [graphql-relay-go](https://github.com/graphql-go/relay):一个用于帮助构建 graphql-go 服务器的 Go/Golang 库,支持 react-relay 。
129159
- [machinebox/graphql](https://github.com/machinebox/graphql):用于 GraphQL 的一个优雅的底层 HTTP 客户端。
130160
- [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 服务器。
131163
132164
### Groovy
133165
@@ -145,7 +177,7 @@ $ curl -XPOST "http://0:3000" -H'Content-Type: application/json' -d'{
145177
146178
更多信息请查看 [文档](https://grails.github.io/gorm-graphql/latest/guide/index.html)。
147179
148-
#### [GQL](https://grooviter.github.io/gql/)
180+
#### [GQL](https://grooviter.github.io/gql/)
149181
150182
GQL 是一个在 Groovy 中使用 GraphQL 的库。
151183
@@ -177,7 +209,7 @@ public class HelloWorld {
177209
SchemaParser schemaParser = new SchemaParser();
178210
TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(schema);
179211
180-
RuntimeWiring runtimeWiring = newRuntimeWiring()
212+
RuntimeWiring runtimeWiring = new RuntimeWiring()
181213
.type("Query", builder -> builder.dataFetcher("hello", new StaticDataFetcher("world")))
182214
.build();
183215
@@ -266,47 +298,83 @@ app.listen(4000, () => console.log('Now browse to localhost:4000/graphql'));
266298
如果要运行 \`apollo-server-express\` 的 hello world 服务器:
267299
268300
\`\`\`bash
269-
npm install apollo-server-express body-parser express graphql graphql-tools
301+
npm install apollo-server-express express
270302
\`\`\`
271303
272304
然后使用 \`node server.js\` 以运行 \`server.js\` 中的代码:
273305
274306
\`\`\`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
294312
}
313+
\`;
314+
const resolvers = {
315+
Query: {
316+
hello: () => 'Hello world!',
317+
},
295318
};
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+
);
302325
\`\`\`
303326
304327
Apollo Server 也支持所有的 Node.js HTTP 服务器框架:Express、Connect、HAPI 和 Koa。
305328
329+
### Kotlin
330+
331+
- [graphql-kotlin](https://github.com/ExpediaGroup/graphql-kotlin/):一组用于在 Kotlin 中运行 GraphQL 服务器的库。
332+
333+
306334
### PHP
307335
308336
- [graphql-php](https://github.com/webonyx/graphql-php):GraphQL 参考实现的 PHP 移植版本。
309337
- [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 集成。
310378
311379
#### [Siler](https://siler.leocavalcante.com/graphql/) ([github](https://github.com/leocavalcante/siler))
312380
@@ -349,6 +417,10 @@ Http\server(Graphql\psr7($schema), function (\Throwable $err) {
349417
350418
它还根据 Apollo 的工作原理提供了构建 WebSocket 订阅服务器的功能。
351419
420+
### Swift
421+
422+
- [Graphiti](https://github.com/GraphQLSwift/Graphiti):一个 Swift 库,可快速、安全且轻松地构建 GraphQL schema/类型。
423+
352424
### Python
353425
354426
#### [Graphene](http://graphene-python.org/) ([github](https://github.com/graphql-python/graphene))
@@ -396,15 +468,15 @@ gem install graphql
396468
\`\`\`ruby
397469
require 'graphql'
398470
399-
QueryType = GraphQL::ObjectType.define do
400-
name 'Query'
471+
class QueryType < GraphQL::Schema::Object
472+
graphql_name 'Query'
401473
field :hello do
402474
type types.String
403475
resolve -> (obj, args, ctx) { 'Hello world!' }
404476
end
405477
end
406478
407-
Schema = GraphQL::Schema.define do
479+
class Schema < GraphQL::Schema
408480
query QueryType
409481
end
410482
@@ -413,6 +485,10 @@ puts Schema.execute('{ hello }').to_json
413485
414486
其也有对于 Relay 和 Rails 的良好绑定。
415487
488+
### Rust
489+
490+
- [graphql-rust/juniper](https://github.com/graphql-rust/juniper):用于 Rust 的 GraphQL 服务端库
491+
416492
### Scala
417493
418494
#### [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
439515
440516
- [C# / .NET](#c-net-1)
441517
- [Clojurescript](#clojurescript-1)
518+
- [Flutter](#flutter)
442519
- [Go](#go-1)
443520
- [Java / Android](#java-android)
444521
- [JavaScript](#javascript-1)
@@ -455,6 +532,10 @@ Executor.execute(schema, query) map println
455532
456533
- [re-graph](https://github.com/oliyh/re-graph/):一个在 Clojurescript 中实现的 GraphQL 客户端,支持 websockets。
457534
535+
### Flutter
536+
537+
- [graphql](https://github.com/zino-app/graphql-flutter#readme):一个 Flutter 中的 GraphQL 客户端实现。
538+
458539
### Go
459540
460541
- [graphql](https://github.com/shurcooL/graphql#readme):一个使用 Go 编写的 GraphQL 客户端实现。
@@ -468,12 +549,13 @@ Executor.execute(schema, query) map println
468549
469550
- [Relay](https://facebook.github.io/relay/) ([github](https://github.com/facebook/relay)) ([npm](https://www.npmjs.com/package/react-relay)):Facebook 的框架,用于构建与 GraphQL 后端交流的 React 应用。
470551
- [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\` 的轻度封装。
472553
- [Lokka](https://github.com/kadirahq/lokka):一个简单的 JavaScript GraphQL 客户端,可以运行于所有的 JavaScript 环境 —— 浏览器,Node.js 和 React Native。
473554
- [nanogql](https://github.com/yoshuawuyts/nanogql):一个使用模板字符串的小型 GraphQL 客户端库。
474555
- [gq-loader](https://github.com/Houfeng/gq-loader):一个简单的 JavaScript GraphQL 客户端,通过 webpack 加载器让 *.gql 文件作为模块使用。
475556
- [AWS Amplify](https://aws.github.io/aws-amplify):使用云服务进行应用开发的 JavaScript 库,支持 GraphQL 后端和用于处理 GraphQL 数据的 React 组件。
476557
- [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 客户端。
477559
478560
### Swift / Objective-C iOS
479561
@@ -483,7 +565,7 @@ Executor.execute(schema, query) map println
483565
### Python
484566
485567
- [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 客户端。
487569
- [sgqlc](https://github.com/profusion/sgqlc):一个简单的 Python GraphQL 客户端。支持为 GraphQL schema 中定义的类型生成代码。
488570
489571
## 工具
@@ -495,14 +577,15 @@ Executor.execute(schema, query) map println
495577
496578
## 服务
497579
498-
- [Apollo Engine](http://www.apollographql.com/engine/):一个用于监视 GraphQL 后端的性能和使用的服务
580+
- [Apollo Graph Manage](http://engine.apollographql.com):一个用于监视 GraphQL 后端的性能和使用的云服务
499581
- [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。
501583
- [Reindex](https://www.reindex.io/baas/) ([github](https://github.com/reindexio/reindex-js)):一个 BaaS(后端即服务),它针对使用 React 和 Relay 的应用程序配置了 GraphQL 后端。
502584
- [Scaphold](https://scaphold.io) ([github](https://github.com/scaphold-io)):一个 BaaS(后端即服务),为你的应用程序配置了一个拥有多种不同集成的 GraphQL 后端。
503585
- [Tipe](https://tipe.io) ([github](https://github.com/tipeio)):一个 SaaS(软件即服务)内容管理系统,允许你使用强大的编辑工具创建你的内容,并通过 GraphQL 或 REST API 从任何地方访问它。
504586
- [AWS AppSync](https://aws.amazon.com/appsync/):完全托管的 GraphQL 服务,包含实时订阅、离线编程和同步、企业级安全特性以及细粒度的授权控制。
505587
- [Hasura](https://hasura.io):一个 BaaS(后端即服务),允许你在 Postgres 上创建数据表、定义权限并使用 GraphQL 接口查询和操作。
588+
- [FaunaDB](https://docs.fauna.com/fauna/current/graphql):通过导入 gql schema 创建即时 GraphQL 后端。数据库将为你创建关系和索引,因此你无需编写任何数据库代码即可在几秒钟内查询。Serverless 定价可免费开始使用。
506589
507590
## 更多内容
508591

site/community/Community-Events.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ sublinks: 即将举行的活动,聚会
88

99
## 即将举行的活动
1010

11-
### GraphQL Conf Berlin
12-
13-
- **日期:** 2019 年 6 月 20 - 21 日
14-
- **地点:** 德国 柏林
15-
- **链接:** https://www.graphqlconf.org/
16-
17-
GraphQL Conf Berlin 是世界上最大的 GraphQL 社区会议。这是一次非盈利性会议,邀请了来自世界各地的演讲嘉宾。了解来自行业专家的 GraphQL 最佳实践,并成为蓬勃发展的 GraphQL 社区的一部分。
18-
1911
### GraphQL 峰会
2012

2113
- **日期:** 2019 年 10 月 29 - 31 日

site/community/Community-Resources.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ layout: ../_core/DocsLayout
44
category: 社区
55
permalink: /community/
66
next: /community/upcoming-events/
7-
sublinks: 博客,视频
7+
sublinks: 博客,视频,图书,更多资源
88
---
99

1010
## Stack Overflow
@@ -25,7 +25,7 @@ sublinks: 博客,视频
2525
- [@graphqlweekly](https://twitter.com/graphqlweekly)
2626
- [@GraphQLStackOverflow](https://twitter.com/GraphQLatSO)
2727
- [@apollographql](https://twitter.com/apollographql)
28-
- [@graphcool](https://twitter.com/graphcool)
28+
- [@prisma](https://twitter.com/prisma)
2929
- [@ScapholdDotIO](https://twitter.com/ScapholdDotIO)
3030

3131
## IRC
@@ -69,6 +69,7 @@ sublinks: 博客,视频
6969
- [GraphQL 服务器基础(第一部分):Schema](https://blog.graph.cool/graphql-server-basics-the-schema-ac5e2950214e) - Nikolas Burk
7070
- [GraphQL 服务器基础(第二部分):网络层](https://blog.graph.cool/graphql-server-basics-the-network-layer-51d97d21861) - Nikolas Burk
7171
- [GraphQL 服务器基础(第三部分):揭秘 GraphQL 解析器中的 `info` 参数](https://blog.graph.cool/graphql-server-basics-demystifying-the-info-argument-in-graphql-resolvers-6f26249f613a) - Nikolas Burk
72+
- [GraphQL 入门指南](https://www.freecodecamp.org/news/a-beginners-guide-to-graphql-86f849ce1bec/) - Leonardo Maldonado
7273

7374
## 视频
7475

@@ -107,11 +108,13 @@ Facebook 内外的开发者在世界各地的会议和聚会上都谈到了 Grap
107108
- [全栈 GraphQL](https://www.graphql.college/fullstack-graphql) - Julian Mayorga
108109
- [在 Elixir 和 Absinthe 中使用 Craft GraphQL API](https://pragprog.com/book/wwgraphql/craft-graphql-apis-in-elixir-with-absinthe) - Bruce Williams and Ben Wilson
109110
- [学习 GraphQL 和 Relay](https://www.packtpub.com/web-development/learning-graphql-and-relay) - Samer Buna
111+
- [GraphQL 之路](https://www.robinwieruch.de/the-road-to-graphql-book/) - Robin Wieruch
110112

111113
## 更多资源
112114

113115
要探索其他有关 GraphQL 的社区开发的资源和内容,请查看以下网站:
114116

117+
- [Exploring GraphQL: A Query Language For APIs](https://www.edx.org/course/exploring-graphql-a-query-language-for-apis):免费的 7 周 edX 课程
115118
- [How to GraphQL](https://www.howtographql.com):GraphQL 的全栈教程
116119
- [Building Apollo](https://dev-blog.apollodata.com/)
117120
- [Learn GraphQL](https://learngraphql.com/basics/introduction)

site/graphql-js/APIReference-TypeSystem.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ class GraphQLList {
508508
var PersonType = new GraphQLObjectType({
509509
name: 'Person',
510510
fields: () => ({
511-
parents: { type: new GraphQLList(Person) },
512-
children: { type: new GraphQLList(Person) },
511+
parents: { type: new GraphQLList(PersonType) },
512+
children: { type: new GraphQLList(PersonType) },
513513
})
514514
});
515515
```

site/graphql-js/Guides-ConstructingTypes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var fakeDatabase = {
4141
};
4242

4343
var root = {
44-
user: function ({id}) {
44+
user: ({id}) => {
4545
return fakeDatabase[id];
4646
}
4747
};
@@ -94,7 +94,7 @@ var queryType = new graphql.GraphQLObjectType({
9494
args: {
9595
id: { type: graphql.GraphQLString }
9696
},
97-
resolve: function (_, {id}) {
97+
resolve: (_, {id}) => {
9898
return fakeDatabase[id];
9999
}
100100
}

site/graphql-js/Tutorial-Authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var schema = buildSchema(`
2424
}
2525
`);
2626

27-
function loggingMiddleware(req, res, next) {
27+
const loggingMiddleware = (req, res, next) => {
2828
console.log('ip:', req.ip);
2929
next();
3030
}

site/graphql-js/Tutorial-ExpressGraphQL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ app.use('/graphql', graphqlHTTP({
4141
graphiql: true,
4242
}));
4343
app.listen(4000);
44-
console.log('Running a GraphQL API server at localhost:4000/graphql');
44+
console.log('Running a GraphQL API server at http://localhost:4000/graphql');
4545
```
4646

4747
用以下命令启动该 GraphQL 服务器:

0 commit comments

Comments
 (0)