Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learn-Execution.md #55

Merged
merged 15 commits into from Aug 17, 2017
Merged

Learn-Execution.md #55

merged 15 commits into from Aug 17, 2017

Conversation

whisperfairy
Copy link

@whisperfairy whisperfairy commented Aug 1, 2017

close #8

@linhe0x0 linhe0x0 mentioned this pull request Aug 1, 2017
@linhe0x0 linhe0x0 changed the title 翻译完成请校对 Learn-Execution.md Aug 1, 2017
@@ -6,11 +6,11 @@ permalink: /learn/execution/
next: /learn/introspection/
---

After being validated, a GraphQL query is executed by a GraphQL server which returns a result that mirrors the shape of the requested query, typically as JSON.
在验证环节之后,GraphQL服务端在处理数据之后,会根据GraphQL query的请求内容生成对应结构的结果,一般情况下会以JSON形式返回。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请参照 翻译术语表翻译规范指南 先对文章做一遍自查吧

@linhe0x0
Copy link
Member

linhe0x0 commented Aug 9, 2017

@whisperfairy 文中有很多问题,辛苦你参照 翻译术语表翻译规范指南 调整一下哈。

@whisperfairy
Copy link
Author

修改了一遍,抱歉耽误了大家的时间

修改超链接的间距
@@ -68,71 +69,67 @@ Query: {
}
```

This example is written in JavaScript, however GraphQL servers can be built in [many different languages](/code/). A resolver function receives three arguments:
这个例子使用了 JavaScript 语言,但 GraphQL 服务端应用可以被 [多种语言实现](https://github.com/whisperfairy/graphql-china.github.io/blob/zh-cn/code) .无论哪种语言,解析器函数都接受3个参数
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『多种语言实现』后面的标点请用全角。

@@ -68,71 +69,67 @@ Query: {
}
```

This example is written in JavaScript, however GraphQL servers can be built in [many different languages](/code/). A resolver function receives three arguments:
这个例子使用了 JavaScript 语言,但 GraphQL 服务端应用可以被 [多种语言实现](https://github.com/whisperfairy/graphql-china.github.io/blob/zh-cn/code) .无论哪种语言,解析器函数都接受3个参数
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

数字前后需要加一个空格。

- `context` A value which is provided to every resolver and holds important contextual information like the currently logged in user, or access to a database.
- `obj` 上一级对象,如果字段属于根节点查询类型通常不会被使用。
- `args` 可以提供在 GraphQL 查询中传入的参数
- `context` 会被提供了所有解析器,并且持有重要的上下文信息比如当前登入的用户或者数据库访问对象
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

75, 76 这两行没有结束标点。


Resolving the name in this case is very straight-forward. The name resolver function is called and the `obj` argument is the `new Human` object returned from the previous field. In this case, we expect that Human object to have a `name` property which we can read and return directly.
在这个例子中,对 name 字段的处理非常的清晰, name 字段对应的解析器函数调用了在上层回调函数生成的 `new Human` 对象在这个案例中,我们设计Human对象会拥有一个 `name` 属性可以让我们从 obj 对象中直接读取。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『Human』前后缺少空格。


## Scalar coercion
当 `name` 字段被处理后,`appearsIn` 和 `starships` 字段可以被同步执行, `appearsIn` 字段
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appearsIn 字段』怎么了?之后呢?


This is an example of scalar coercion. The type system knows what to expect and will convert the values returned by a resolver function into something that upholds the API contract. In this case, there may be an Enum defined on our server which uses numbers like `4`, `5`, and `6` internally, but represents them as Enum values in the GraphQL type system.
这是标量强制的一个例子。类型系统知道预期的内容,并将将解析器函数返回的值转换为维护 API 合同的内容。在这种情况下,可能在我们的服务器上定义了一个枚举类型,但解析器在内部使用 4,5 和 6 的整数类型,但在 GraphQL 类型系统中将它们表示为枚举值,如果类型不匹配将返回 null,并提示错误。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『4,5』=>『4、5』


GraphQL will wait for all of these Promises concurrently before continuing, and when left with a list of objects, it will concurrently continue yet again to load the `name` field on each of these items.
GraphQL 将在同步执行这些 Promise,当返回一个对象列表,它将继续同步加载每个这些对象的 `name` 字段。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一句话不太通顺,建议调整一下。@ydfzgyj 你觉得呢?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GraphQL 将 在同步“并发” 执行 这些“所有的” Promise,当返回一个对象列表“之后”,它将继续同步“并发”加载每个这些对象的 name 字段
觉得可以吗?

@whisperfairy
Copy link
Author

收到,马上修改

linhe0x0
linhe0x0 previously approved these changes Aug 15, 2017
Copy link
Collaborator

@ydfzgyj ydfzgyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

翻译不是自己的博客,还是要遵循原文的,这篇有些地方的译文感觉跟原文已经没有关系了,自我发挥的成分太大
然后还有几句明显看得出机翻的痕迹,整体风格明显不统一,希望不要因为时间不够就机翻赶进度
问题比较多,请好好再过一遍


```graphql
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

graphql 不能去掉,否则网站不能解析,下同

@@ -6,11 +6,11 @@ permalink: /learn/execution/
next: /learn/introspection/
---

After being validated, a GraphQL query is executed by a GraphQL server which returns a result that mirrors the shape of the requested query, typically as JSON.
在验证环节之后,GraphQL 服务端在处理数据之后,会根据 GraphQL 查询的请求内容生成对应结构的结果,一般情况下会以JSON形式返回。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

两个“之后”重复


GraphQL cannot execute a query without a type system, let's use an example type system to illustrate executing a query. This is a part of the same type system used throughout the examples in these articles:
GraphQL 不能脱离类型系统处理查询,让我们用一个类型系统的例子来说明一个查询的执行过程,在这一系列的文章中我们重复使用了这些类型,下文是其中的一部分
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最后缺冒号

@@ -32,9 +32,9 @@ type Starship {
}
```

In order to describe what happens when a query is executed, let's use an example to walk through.
现在让我们用一个例子来描述当一个查询请求被执行的全过程
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最后缺句号

@@ -47,18 +47,19 @@ In order to describe what happens when a query is executed, let's use an example
}
```

You can think of each field in a GraphQL query as a function or method of the previous type which returns the next type. In fact, this is exactly how GraphQL works. Each field on each type is backed by a function called the *resolver* which is provided by the GraphQL server developer. When a field is executed, the corresponding *resolver* is called to produce the next value.
您可以将 GraphQL 查询中的每个字段视为返回下一个类型的上一个类型的函数或方法。事实上,这正是 GraphQL 的工作原理。每个类型的每个字段都由称为解析器的函数支持,该函数由 GraphQL 服务器开发人员提供。当一个字段被执行时,相应的解析器被调用以产生下一个值。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原文的 resolver 是函数名,请保留不翻译


This is an example of scalar coercion. The type system knows what to expect and will convert the values returned by a resolver function into something that upholds the API contract. In this case, there may be an Enum defined on our server which uses numbers like `4`, `5`, and `6` internally, but represents them as Enum values in the GraphQL type system.
这是标量强制的一个例子。类型系统知道预期的内容,并将将解析器函数返回的值转换为维护 API 合同的内容。在这种情况下,可能在我们的服务器上定义了一个枚举类型,但解析器在内部使用 4,5 和 6 的整数类型,但在 GraphQL 类型系统中将它们表示为枚举值,如果类型不匹配将返回 null,并提示错误。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

机翻,有些单词的意思明显不对,请重新润色下

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里因为当时没看懂自己实际实现试了下,加了一点内容,这样可以吗
这是一个强制标量的例子。因为类型系统已经被设定,所以解析器函数的返回值必须符合与类型系统对应的API规则的约束。在这种情况下,我们在的服务器的类定义了一个应该返回枚举值解析器在内部返回了 4,5 和 6 的整数类型,由于 GraphQL 类型系统中将它们表示为枚举值,类型不匹配。因此实际的返回不是[4,5,6]而是[null,null,null],并提示错误。


## List resolvers
我们已经看到一个字段返回上面的`appearsIn`字段的事物列表时会发生什么。它返回了枚举值的列表,因为这是系统期望的类型,列表中的每个项目被强制为适当的枚举值。让我们看下`startships`被解析的时候会发生什么?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 原文斜体的地方,翻译成中文后加粗
  2. 英文前后加空格

@@ -144,18 +141,16 @@ Human: {
}
```

The resolver for this field is not just returning a Promise, it's returning a *list* of Promises. The `Human` object had a list of ids of the `Starships` they piloted, but we need to go load all of those ids to get real Starship objects.
解析器函数在这个字段中返回了一个 Promise 对象,它返回一个 Promises 列表。 `Human` 对象具有他们正在驾驶的 `Starships` ids 列表,但是我们需要通过这些 id 来获得真正的 Starship 对象。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. “解析器函数在这个字段中返回了一个 Promise 对象”=>“这个字段的解析器不仅仅是返回一个 Promise 对象”
  2. “列表”加粗


GraphQL will wait for all of these Promises concurrently before continuing, and when left with a list of objects, it will concurrently continue yet again to load the `name` field on each of these items.
GraphQL 将在同步执行这些 Promise,当返回一个对象列表,它将继续同步加载每个这些对象的 `name` 字段。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GraphQL 将 在同步“并发” 执行 这些“所有的” Promise,当返回一个对象列表“之后”,它将继续同步“并发”加载每个这些对象的 name 字段
觉得可以吗?


## Producing the result
当每个字段被解析时,结果值被放置到键值映射中,字段名称(或别名)作为键,并且解析器的值作为值,这继续从查询的底部叶字段返回直到根据“查询”类型的原始字段。总而言之,这些结构反映了原始查询,然后可以将其发送(通常为 JSON)到请求的客户端。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

机翻,root Query type 明显不对

内容校对回复,尚有疑问
格式修复
格式修复
@@ -6,11 +6,11 @@ permalink: /learn/execution/
next: /learn/introspection/
---

在验证环节之后,GraphQL 服务端在处理数据之后,会根据 GraphQL 查询的请求内容生成对应结构的结果,一般情况下会以 JSON 形式返回。
在验证环节之后,GraphQL 服务端在处理数据,会根据 GraphQL 查询的请求内容生成对应结构的结果,一般情况下会以 JSON 形式返回。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除第二个“之后”,也要重新调整一下语句,现在不甚通畅

您可以将 GraphQL 查询中的每个字段视为返回下一个类型的上一个类型的函数或方法。事实上,这正是 GraphQL 的工作原理。每个类型的每个字段都由称为解析器的函数支持,该函数由 GraphQL 服务器开发人员提供。当一个字段被执行时,相应的解析器被调用以产生下一个值。

如果字段产生标量值,例如字符串或数字,则执行完成。但是,如果一个字段产生一个实体对象,则该查询将继续执行对应字段的解析器函数,直到生成标量值。GraphQL 查询始终以标量值结尾。
您可以将 GraphQL 查询中的每个字段视为返回下一个类型的上一个类型的函数或方法。事实上,这正是 GraphQL 的工作原理。每个类型的每个字段都由称为 *resolver* 的函数支持,该函数由 GraphQL 服务器开发人员提供。当一个字段被执行时,相应的解析器被调用以产生下一个值。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还有一个 resolver


## 根字段&解析器函数
每一个 GraphQL 服务端应用的顶层,必有一个类型代表着所有进入 GraphQL API 可能的入口点,我们将他称之为*Root* 类型或 *Query* 类型。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Root 前面缺空格
  2. “他”=>“它”,其他文章内的他和它也请统一

@@ -69,67 +67,67 @@ Query: {
}
```

这个例子使用了 JavaScript 语言,但 GraphQL 服务端应用可以被 [多种语言实现](https://github.com/whisperfairy/graphql-china.github.io/blob/zh-cn/code) 。无论哪种语言,解析器函数都接受 3 个参数
这个例子使用了 JavaScript 语言,但 GraphQL 服务端应用可以被 [多种语言实现](/code/) 。解析器函数接受 3 个参数
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. “接受”=>“接收”
  2. 句号前边无需加空格


这里要注意的是,只有解析器函数能感知到 Promise,GraphQL 查询只关注 `human` 字段是否返回,在执行期间如果异步操作没有完成,则 GraphQL 会一直等待下去,因此在这个环节需要关注异步处理上的优化。
这里要注意的是,只有解析器能感知到 Promise 的进度,GraphQL 查询只关注一个包含着`name`属性的 `human` 字段是否返回,在执行期间如果异步操作没有完成,则 GraphQL 会一直等待下去,因此在这个环节需要关注异步处理上的优化。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name 前后加空格

Human: {
appearsIn(obj) {
return obj.appearsIn // returns [ 4, 5, 6 ]
}
}
```

请注意,我们的类型系统声明 `appearsIn` 字段将返回具有已知值的枚举值,但是此函数返回数字!实际上,如果我们查看结果,我们将看到正在返回适当的枚举值。这是怎么回事?
请注意,我们的类型系统声明 `appearsIn` 字段将返回具有已知值的枚举值,但是此函数返回数字实际上,如果我们查看结果,我们将看到正在返回适当的枚举值。这是怎么回事?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么这里把叹号删掉?


## 列表解析器

我们已经看到一个字段返回上面的 `appearsIn` 字段的事物列表时会发生什么。它返回了枚举值的列表,因为这是系统期望的类型,列表中的每个项目被强制为适当的枚举值。让我们看下`startships`被解析的时候会发生什么?
我们已经看到一个字段返回上面的 `appearsIn` 字段的事物列表时会发生什么。它返回了枚举值的*列表*,因为这是系统期望的类型,列表中的每个项目被强制为适当的枚举值。让我们看下`startships`被解析的时候会发生什么?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原文斜体的地方,翻译成中文后加粗,下同


这是标量强制的一个例子。类型系统知道预期的内容,并将将解析器函数返回的值转换为维护 API 合同的内容。在这种情况下,可能在我们的服务器上定义了一个枚举类型,但解析器在内部使用 4、5 和 6 的整数类型,但在 GraphQL 类型系统中将它们表示为枚举值。如果发生类型不匹配的情况,类型不匹配的部分将返回 null,并提示错误。
这是一个强制标量的例子。因为类型系统已经被设定,所以解析器函数的返回值必须符合与类型系统对应的API规则的约束。在这种情况下,我们在的服务器的类定义了一个应该返回枚举值解析器在内部返回了 4,5 和 6 的整数类型,由于 GraphQL 类型系统中将它们表示为枚举值,类型不匹配。因此实际的返回不是`[4,5,6]`而是`[null,null,null]`,并提示错误。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. API 前后加空格
  2. “我们在的服务器的类定义了一个应该返回枚举值解析器在内部返回了 4、5 和 6 的整数类型” 整句完全不通
  3. “由于 GraphQL 类型系统中将它们表示为枚举值,类型不匹配。因此实际的返回不是[4,5,6]而是[null,null,null],并提示错误。” 这句的原文在哪里???


GraphQL 将在同步执行这些 Promise,当执行结束返回一个对象列表后,它将继续同步加载列表中每个对象的 `name` 字段。
GraphQL 将在并发执行这些 Promise,当执行结束返回一个对象列表后,它将继续并发加载列表中每个对象的 `name` 字段。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第一个“在”字去掉


## 产生结果

当每个字段被解析时,结果值被放置到键值映射中,字段名称(或别名)作为键,并且解析器的值作为值,这继续从查询的底部叶字段返回直到根据“查询”类型的原始字段。总而言之,这些结构反映了原始查询,然后可以将其发送(通常为 JSON)到请求的客户端。
当每个字段被解析时,结果被放置到键值映射中,字段名称(或别名)作为键值映射的键,解析器的值作为键值映射的值,这个过程从查询字段的底部叶子节点开始返回,直到根查询类型的根字段。总而言之,这些结构反映了根查询类型,然后可以将其发送(通常为 JSON 格式)到请求的客户端。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. original 和 root 不是一回事
  2. root Query type 的 Query 不翻译
  3. “总而言之,这些结构反映了根查询类型”=>“最后合并成为能够镜像到原始查询结构的结果”

@@ -6,9 +6,9 @@ permalink: /learn/execution/
next: /learn/introspection/
---

After being validated, a GraphQL query is executed by a GraphQL server which returns a result that mirrors the shape of the requested query, typically as JSON.
在验证环节之后,GraphQL 服务端在处理数据,会根据 GraphQL 查询的请求内容生成对应结构的结果,一般情况下会以 JSON 形式返回。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在验证环节之后,GraphQL 服务端在处理数据,
->
在验证环节之后,GraphQL 服务端处理数据时,

感觉这样顺口些

其实整句而言,我的翻译是

一个 GraphQL 查询在被验证后,GraphQL 服务器会将之执行,并返回与请求的结构相对应的结果,通常会是 JSON
 的格式。

仅作参考啦~~

有些地方之前没看明白,所以自己实现了一下,看了结果,加进去当备注所以多了很多不用的东西,抱歉

如果字段产生标量值,例如字符串或数字,则执行完成。但是,如果一个字段产生一个对象,则该查询将继续执行该对象对应字段的解析器,直到生成标量值。GraphQL 查询始终以标量值结束。

## 根字段 & 解析器

每一个 GraphQL 服务端应用的顶层,必有一个类型代表着所有进入 GraphQL API 可能的入口点,我们将他称之为*Root* 类型或 *Query* 类型。
每一个 GraphQL 服务端应用的顶层,必有一个类型代表着所有进入 GraphQL API 可能的入口点,我们将它称之为 **Root** 类型或 **Query** 类型。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

英文可以保留斜体,翻译成中文的才要改成加粗


事实上在返回的字段可以直接从对象中获得的时候,大部分 GraphQL 库可以让我们省略定义的步骤,当然这是当我们请求的字段可以直接从上层返回对象中取得并返回的情况
事实上在返回的字段可以直接从对象中获得的时候,大部分 GraphQL 库可以让我们省略定义的步骤,当然这只适用于我们请求的字段可以直接从上层返回对象中取得并返回的情况
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一句还是没有改好
第一句“返回的字段可以直接从对象中获得”和第三句“我们请求的字段可以直接从上层返回对象中取得并返回”是一样的话,重复说了两遍,是多余的
而原文的“if a resolver isn't provided for a field”又根本没有译,“没有提供解析器”所以才只能从“上层对象中读取”,这是因果关系,不可以省去的


## 产生结果

当每个字段被解析时,结果被放置到键值映射中,字段名称(或别名)作为键值映射的键,解析器的值作为键值映射的值,这个过程从查询字段的底部叶子节点开始返回,直到根查询类型的根字段。总而言之,这些结构反映了根查询类型,然后可以将其发送(通常为 JSON 格式)到请求的客户端。
当每个字段被解析时,结果被放置到键值映射中,字段名称(或别名)作为键值映射的键,解析器的值作为键值映射的值,这个过程从查询字段的底部叶子节点开始返回,直到根 Query 类型的起始节点。总而言之,这些结构反映了根 Query 类型,然后可以将其发送(通常为 JSON 格式)到请求的客户端。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. original 和 root 不是一回事
  2. “总而言之,这些结构反映了根查询类型”=>“最后合并成为能够镜像到原始查询结构的结果”


这是一个强制标量的例子。因为类型系统已经被设定,所以解析器函数的返回值必须符合与类型系统对应的API规则的约束。在这种情况下,我们在的服务器的类定义了一个应该返回枚举值解析器在内部返回了 4、5 和 6 的整数类型,由于 GraphQL 类型系统中将它们表示为枚举值,类型不匹配。因此实际的返回不是 `[4,5,6]` 而是 `[null,null,null]`,并提示错误
这是一个强制标量的例子。因为类型系统已经被设定,所以解析器函数的返回值必须符合与类型系统对应的API规则的约束。在这种情况下,我们在的服务器的类定义了一个应该返回枚举值解析器在内部返回了 4、5 和 6 的整数类型,但是 GraphQL 类型系统中将它们表示为枚举值。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. API 前后加空格
  2. “我们在的服务器的类定义了一个应该返回枚举值解析器在内部返回了 4、5 和 6 的整数类型” 整句不通,可以改成
    “在这个案例中, 我们可能在服务器上定义了一个枚举类型,它在内部使用像是 4、5 和 6 这样的数字,但在 GraphQL 类型系统中将它们表示为枚举值。”

@jonirrings
Copy link
Collaborator

😂 看来这块儿骨头比较硬啊

1.修改斜体:我们将它称之为 *Root* 类型或 *Query* 类型。
2.修改斜体:通常称作 *Futures*、*Tasks* 或者 *Defferred*。
3.修改内容 API 加空格:"事实上在返回的字段可以直接从对象中获得的时候,大部分 GraphQL 库可以让我们省略定义的步骤,当然这只适用于我们请求的字段可以直接从上层返回对象中取得并返回的情况。"=>"这是一个强制标量的例子。因为类型系统已经被设定,所以解析器函数的返回值必须符合与类型系统对应的 API 规则的约束。在这个案例中, 我们可能在服务器上定义了一个枚举类型,它在内部使用像是 4、5 和 6 这样的数字,但在 GraphQL 类型系统中将它们表示为枚举值。"
4.修改内容"总而言之,这些结构反映了根 Query 类型"=>"总而言之,最后合并成为能够镜像到原始查询结构的结果"
Copy link
Collaborator

@ydfzgyj ydfzgyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还差一点点

@@ -121,7 +122,7 @@ Human: {

请注意,我们的类型系统声明 `appearsIn` 字段将返回具有已知值的枚举值,但是此函数返回数字!实际上,如果我们查看结果,我们将看到正在返回适当的枚举值。这是怎么回事?

这是一个强制标量的例子。因为类型系统已经被设定,所以解析器函数的返回值必须符合与类型系统对应的API规则的约束。在这种情况下,我们在的服务器的类定义了一个应该返回枚举值解析器在内部返回了 4、5 和 6 的整数类型,但是 GraphQL 类型系统中将它们表示为枚举值。
这是一个强制标量的例子。因为类型系统已经被设定,所以解析器函数的返回值必须符合与类型系统对应的 API 规则的约束。在这个案例中, 我们可能在服务器上定义了一个枚举类型,它在内部使用像是 4、5 和 6 这样的数字,但在 GraphQL 类型系统中将它们表示为枚举值。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“我们可能……”前边的空格去掉

@@ -145,19 +146,6 @@ GraphQL 将并发执行这些 Promise,当执行结束返回一个对象列表

## 产生结果

当每个字段被解析时,结果被放置到键值映射中,字段名称(或别名)作为键值映射的键,解析器的值作为键值映射的值,这个过程从查询字段的底部叶子节点开始返回,直到根 Query 类型的起始节点。总而言之,这些结构反映了根 Query 类型,然后可以将其发送(通常为 JSON 格式)到请求的客户端。
当每个字段被解析时,结果被放置到键值映射中,字段名称(或别名)作为键值映射的键,解析器的值作为键值映射的值,这个过程从查询字段的底部叶子节点开始返回,直到根 Query 类型的起始节点。总而言之,最后合并成为能够镜像到原始查询结构的结果,然后可以将其发送(通常为 JSON 格式)到请求的客户端。

让我们最后一眼看看原来的查询,看看这些解析函数如何产生一个结果:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最后的一段代码怎么删掉了

@@ -4,6 +4,7 @@ layout: ../_core/DocsLayout
category: Learn
permalink: /learn/execution/
next: /learn/introspection/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个多余的空行去掉

@@ -145,19 +146,6 @@ GraphQL 将并发执行这些 Promise,当执行结束返回一个对象列表

## 产生结果

当每个字段被解析时,结果被放置到键值映射中,字段名称(或别名)作为键值映射的键,解析器的值作为键值映射的值,这个过程从查询字段的底部叶子节点开始返回,直到根 Query 类型的起始节点。总而言之,这些结构反映了根 Query 类型,然后可以将其发送(通常为 JSON 格式)到请求的客户端。
当每个字段被解析时,结果被放置到键值映射中,字段名称(或别名)作为键值映射的键,解析器的值作为键值映射的值,这个过程从查询字段的底部叶子节点开始返回,直到根 Query 类型的起始节点。总而言之,最后合并成为能够镜像到原始查询结构的结果,然后可以将其发送(通常为 JSON 格式)到请求的客户端。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“总而言之,”去掉

@@ -105,7 +106,7 @@ GraphQL 服务端应用的业务取决于类型系统的结构。在 `human` 对

在这个例子中,对 name 字段的处理非常的清晰,name 字段对应的解析器被调用的时候,解析器回调函数的 obj 参数是由上层回调函数生成的 `new Human` 对象。在这个案例中,我们希望 Human 对象会拥有一个 `name` 属性可以让我们直接读取。

事实上在返回的字段可以直接从对象中获得的时候,大部分 GraphQL 库可以让我们省略定义的步骤,当然这只适用于我们请求的字段可以直接从上层返回对象中取得并返回的情况
事实上在返回的字段可以直接从对象中获得并且没有额外定义解析器的时候,大部分 GraphQL 库可以让我们省略定义的步骤。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

意思还是有偏差……没有体现出“没有定义解析器再去读取对象”的先后关系
可译为:“事实上,许多 GraphQL 库可以让你省略这些简单的解析器,假定一个字段没有提供解析器时,那么应​​该从上层返回对象中读取和返回和这个字段同名的属性。”

1. 去掉多余行
2. 但是,如果一个字段产生一个对象,去掉了但是,
3.“事实上在返回的字段可以直接从对象中获得的时候,大部分 GraphQL 库可以让我们省略定义的步骤,当然这只适用于我们请求的字段可以直接从上层返回对象中取得并返回的情况。”=>“事实上,许多 GraphQL 库可以让你省略这些简单的解析器,假定一个字段没有提供解析器时,那么应​​该从上层返回对象中读取和返回和这个字段同名的属性。”
4.去掉多余空格124行
5.去掉总而言之,
@ydfzgyj
Copy link
Collaborator

ydfzgyj commented Aug 17, 2017

终于完成啦,撒花~🎉🎉🎉

@whisperfairy
Copy link
Author

不好意思耽误您这么长时间。

@whisperfairy
Copy link
Author

谢谢您的指导

@ydfzgyj ydfzgyj merged commit ecdb81b into xitu:zh-Hans Aug 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Learn-Execution.md
4 participants