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-Queries.md #37

Merged
merged 6 commits into from
Aug 5, 2017
Merged

Learn-Queries.md #37

merged 6 commits into from
Aug 5, 2017

Conversation

jonirrings
Copy link
Collaborator

@jonirrings jonirrings commented Jul 25, 2017

Signed-off-by: Jonir Rings peterpuyi@live.cn

close #10

Signed-off-by: Jonir Rings <peterpuyi@live.cn>
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.

内容之前已校对过,格式上

  1. 需要保留关键词的地方统一按照 中文翻译(英文关键词)的格式。
  2. 链接之间增加空格
    两处还需要再按新的格式规范修正一下

@jonirrings
Copy link
Collaborator Author

已修改,有劳复查

permalink: /learn/queries/
next: /learn/schema/
sublinks: Fields,Arguments,Aliases,Fragments,Variables,Operation Name,Directives,Mutations,Inline Fragments
sublinks: 字段(Fields),参数(Arguments),别名(Aliases),片段(Fragments),变量(Variables),操作名称(Operation Name),指令(Directives),变更(Mutations),内联片段(Inline Fragments)
Copy link
Collaborator

Choose a reason for hiding this comment

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

后边的括号全是英文的


```graphql
# { "graphiql": true }
{
hero {
name
# Queries can have comments!
# 查询可以有备注!
Copy link
Collaborator

Choose a reason for hiding this comment

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

感叹号是英文的


> Oh, one more thing - the query above is *interactive*. That means you can change it as you like and see the new result. Try adding an `appearsIn` field to the `hero` object in the query, and see the new result.
> 对了,还有一点 — 上述查询是*可交互的*。也就是你可以按你喜欢来改变查询,然后看看新的结果。尝试给查询中的 `hero` 对象添加一个` appearsIn` 字段,看看新的结果吧。
Copy link
Collaborator

Choose a reason for hiding this comment

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

也是斜体改成粗体,这篇里的都是用的 * 啊……另一篇都是 _ 的

@@ -72,15 +72,14 @@ In a system like REST, you can only pass a single set of arguments - the query p
}
```

Arguments can be of many different types. In the above example, we have used an Enumeration type, which represents one of a finite set of options (in this case, units of length, either `METER` or `FOOT`). GraphQL comes with a default set of types, but a GraphQL server can also declare its own custom types, as long as they can be serialized into your transport format.
参数可以是多种不同的类型。上面例子中,我们使用了一个枚举类型,其代表了一个有限选项集合(本例中为长度单位,即是 `METER` 或者 `FOOT` )。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.

FOOT 和括号之间不加空格,第二个 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.

我是按照原文换的啊……他用的md模版没细看,不知道有没区分_和单*。是翻译规范里面加了_和*转换规则么?

Copy link
Collaborator

Choose a reason for hiding this comment

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

没加这个规则,只是吐槽原文也是乱用


In REST, any request might end up causing some side-effects on the server, but by convention it's suggested that one doesn't use `GET` requests to modify data. GraphQL is similar - technically any query could be implemented to cause a data write. However, it's useful to establish a convention that any operations that cause writes should be sent explicitly via a mutation.
REST 中,任何请求都可能最后导致一些服务端副作用,但是约定上建议不要使用 `GET` 请求来修改数据。GraphQL 也是类似 — 技术上而言,任何查询都可以被实现为导致数据写入。然而,建一个约定来规范任何导致写入的操作都应该显示通过 变更(mutation)来发送。
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.

这个空格是漏网之鱼……



## Inline Fragments
## 内联片段(Inline Fragments
Copy link
Collaborator

Choose a reason for hiding this comment

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

左括号是英文



### Meta fields
### 元字段(Meta fields)
Copy link
Collaborator

Choose a reason for hiding this comment

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

两个括号都是英文

@jonirrings
Copy link
Collaborator Author

已修正,有劳再次审校。

@@ -4,7 +4,7 @@ layout: ../_core/DocsLayout
category: 学习
permalink: /learn/queries/
next: /learn/schema/
sublinks: 字段(Fields),参数(Arguments),别名(Aliases),片段(Fragments),变量(Variables),操作名称(Operation Name),指令(Directives),变更(Mutations),内联片段(Inline Fragments)
sublinks: 字段(Fields),参数Arguments),别名Aliases,片段Fragments,变量Variables,操作名称Operation Name,指令Directives,变更Mutations,内联片段Inline Fragments
Copy link
Collaborator

Choose a reason for hiding this comment

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

参数后边掉了一个括号


```graphql
# { "graphiql": true }
{
human(id: "1000") {
name
height(unit: FOOT)
heightunit: FOOT)
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 允许你在查询的任何位置请求 `__typename`,一个元字段,以获得那个位置的对象类型名称。

```graphql
# { "graphiql": true}
{
search(text: "an") {
searchtext: "an") {
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
Copy link
Collaborator Author

已修正,有劳再次审校。喷血了:joy:,typo好多

permalink: /learn/queries/
next: /learn/schema/
sublinks: Fields,Arguments,Aliases,Fragments,Variables,Operation Name,Directives,Mutations,Inline Fragments
sublinks: 字段(Fields),参数Arguments),别名(Aliases),片段(Fragments),变量(Variables),操作名称(Operation Name),指令(Directives),变更(Mutations),内联片段(Inline Fragments
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

@jonirrings jonirrings Aug 5, 2017

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
Copy link
Collaborator Author

@sqrthree 老大,这边有劳approve一下


In the previous example, we just asked for the name of our hero which returned a String, but fields can also refer to Objects. In that case, you can make a *sub-selection* of fields for that object. GraphQL queries can traverse related objects and their fields, letting clients fetch lots of related data in one request, instead of making several roundtrips as one would need in a classic REST architecture.
在前一例子中,我们请求了我们主角的名字,返回了一个字符串类型(String),但是字段也能指代对象类型(Object)。这个时候,你可以对这个对象的字段进行 **次级选择(sub-selection)**。GraphQL 查询能够遍历相关对象及其字段,使得客户端可以一次请求查询大量相关数据,而不像传统 REST 架构中那样需要多次往返查询。
Copy link
Member

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.

好的,在IDE上有自动换行,没注意到。:joy:

Signed-off-by: Jonir Rings <peterpuyi@live.cn>
@linhe0x0 linhe0x0 merged commit 666e268 into xitu:zh-Hans Aug 5, 2017
@jonirrings jonirrings deleted the Learn-Queries branch May 23, 2021 12:26
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-Queries.md
3 participants