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-Validation.md #56

Merged
merged 4 commits into from
Aug 10, 2017
Merged

Learn-Validation.md #56

merged 4 commits into from
Aug 10, 2017

Conversation

jonirrings
Copy link
Collaborator

@jonirrings jonirrings commented Aug 2, 2017

pr晚了,有劳校对

close #12

Signed-off-by: Jonir Rings <peterpuyi@live.cn>
Signed-off-by: Jonir Rings <peterpuyi@live.cn>
Copy link
Collaborator Author

@jonirrings jonirrings left a comment

Choose a reason for hiding this comment

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

需要校对

@@ -91,8 +73,7 @@ Hero returns a `Character`, and we've been requesting fields like `name` and
}
```

Similarly, if a field is a scalar, it doesn't make sense to query for
additional fields on it, and doing so will make the query invalid:
类似的,如果一个字段是标量,进一步查询它上面的字段也没有意义,这样做也会导致查询无效:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

类似的,类似地。
把握不准,前者是“类似的情况下”的简略写法,后者是状语副词,好像也适合这个场景。有劳校对指教。

Copy link
Collaborator

Choose a reason for hiding this comment

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

原文是副词,这里就用“类似地”就好吧

@linhe0x0 linhe0x0 mentioned this pull request Aug 2, 2017
To start, let's take a complex valid query. This is a nested query, similar to
an example from the previous section, but with the duplicated fields factored
out into a fragment:
对于我们的《星球大战》的案例,[starWarsValidation-test.js](https://github.com/graphql/graphql-js/blob/master/src/__tests__/starWarsValidation-test.js)这个文件包含一些查询,演示了各种无效查询,它也是一个测试文件,用于检测参考实现的验证器。
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. “包含一些查询,演示了各种无效查询” => “包含了若干对于各种无效查询的演示”

given type. So as `hero` returns a `Character`, we have to query for a field
on `Character`. That type does not have a `favoriteSpaceship` field, so this
query is invalid:
查询字段的时候,我们只能查询给定类型上的字段。因此由于 `hero` 返回 `Character`类型,我们只能查询 `Character` 上的字段。因为这个类型上没有 `favoriteSpaceship` 字段,所以这个查询是无效的:
Copy link
Collaborator

Choose a reason for hiding this comment

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

第一个Character后加空格

or an enum, we need to specify what data we want to get back from the field.
Hero returns a `Character`, and we've been requesting fields like `name` and
`appearsIn` on it; if we omit that, the query will not be valid:
当我们查询一个字段时,如果其返回值不是标量或者枚举型,那我们就需要指明想要从这个字段中获取的数据。`hero` 返回 `Character`类型,我们也请求了像是 `name` 和`appearsIn` 的字段;但如果将其省略,这个查询就变无效的了:

```graphql
# { "graphiql": true }
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里也有一句注释,下面还有几处,就不重复了

given type. So as `hero` returns a `Character`, we have to query for a field
on `Character`. That type does not have a `favoriteSpaceship` field, so this
query is invalid:
查询字段的时候,我们只能查询给定类型上的字段。因此由于 `hero` 返回 `Character`类型,我们只能查询 `Character` 上的字段。因为这个类型上没有 `favoriteSpaceship` 字段,所以这个查询是无效的:

```graphql
# { "graphiql": true }
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里有一句注释也翻译一下吧

or an enum, we need to specify what data we want to get back from the field.
Hero returns a `Character`, and we've been requesting fields like `name` and
`appearsIn` on it; if we omit that, the query will not be valid:
当我们查询一个字段时,如果其返回值不是标量或者枚举型,那我们就需要指明想要从这个字段中获取的数据。`hero` 返回 `Character`类型,我们也请求了像是 `name` 和`appearsIn` 的字段;但如果将其省略,这个查询就变无效的了:
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. 第一个Character后加空格
  2. 我们也请求了“其中”像是……
  3. 这个查询就变“成”无效的了

@@ -91,8 +73,7 @@ Hero returns a `Character`, and we've been requesting fields like `name` and
}
```

Similarly, if a field is a scalar, it doesn't make sense to query for
additional fields on it, and doing so will make the query invalid:
类似的,如果一个字段是标量,进一步查询它上面的字段也没有意义,这样做也会导致查询无效:
Copy link
Collaborator

Choose a reason for hiding this comment

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

原文是副词,这里就用“类似地”就好吧

[validation](https://github.com/graphql/graphql-js/blob/master/src/validation)
directory in GraphQL.js contains code implementing a
specification-compliant GraphQL validator.
这只是验正系统的冰山一角;事实上需要一大套验正规则才能保证 GraphQL 查询的语义意义。规范中的“验证”章节有关于本话题更详细的内容,GraphQL.js 的 [validation](https://github.com/graphql/graphql-js/blob/master/src/validation) 目录包含了规范兼容的 GraphQL 验证器实现代码。
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
Collaborator Author

Choose a reason for hiding this comment

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

换了,这可能是脑子没转过去。:joy:

Signed-off-by: Jonir Rings <peterpuyi@live.cn>
@jonirrings
Copy link
Collaborator Author

已修正,有劳再次审核

[validation](https://github.com/graphql/graphql-js/blob/master/src/validation)
directory in GraphQL.js contains code implementing a
specification-compliant GraphQL validator.
这只是验正系统的冰山一角;事实上需要一大套验证规则才能保证 GraphQL 查询的语义意义。规范中的“验证”章节有关于本话题更详细的内容,GraphQL.js 的 [validation](https://github.com/graphql/graphql-js/blob/master/src/validation) 目录包含了规范兼容的 GraphQL 验证器实现代码。
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
Collaborator Author

Choose a reason for hiding this comment

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

😂,又漏了,已修正。

Signed-off-by: Jonir Rings <peterpuyi@live.cn>
@jonirrings jonirrings changed the title learn validation翻译完成 Learn-Validation.md Aug 4, 2017
@linhe0x0 linhe0x0 merged commit aa307e3 into xitu:zh-Hans Aug 10, 2017
@jonirrings jonirrings deleted the Learn-Validation branch May 23, 2021 11:54
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-Validation.md
3 participants