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

Tutorial-ObjectTypes.md #74

Merged
merged 5 commits into from
Aug 15, 2017
Merged

Tutorial-ObjectTypes.md #74

merged 5 commits into from
Aug 15, 2017

Conversation

dabanlee
Copy link

@dabanlee dabanlee commented Aug 8, 2017

有劳校对 resolve #28

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.

问题稍稍有点多,请继续加油!


In GraphQL schema language, the way you define a new object type is the same way we have been defining the `Query` type in our examples. Each object can have fields that return a particular type, and methods that take arguments. For example, in the [Passing Arguments](/graphql-js/passing-arguments/) documentation, we had a method to roll some random dice:
GraphQL schema 语言中,定义一个新的对象类型就和我们在示例中定义的 `Query` 类型一样。每个对象可以有返回指定类型的的字段,或者带有参数的方法。例如,在 [参数传递](/graphql-js/passing-arguments/) 中,我们有一个掷骰子的方法:
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. “GraphQL schema language”全部保留不翻译
  2. 返回指定类型“的的”字段,多了一个的
  3. “以及”带有参数的方法,不是“或者”
  4. 在参数传递“一节”中

@@ -28,7 +28,7 @@ type Query {
}
```

Instead of a root-level resolver for the `RandomDie` type, we can instead use an ES6 class, where the resolvers are instance methods. This code shows how the `RandomDie` schema above can be implemented:
取而代之的是一个值为 `RandomDie` 类型的根级别解析器,我们可以用 ES6 的 class 语法来替代,这样的话这些解析器就是这个类的实例方法了。下面的代码展示了如何使用 ES6 class 语法来实现上面的 `RandomDie` 对象类型:
Copy link
Collaborator

Choose a reason for hiding this comment

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

前半句的意思是使用 ES6 class 代替 resolver,现在的翻译有些问题

@@ -70,7 +70,7 @@ type Query {
}
```

Putting this all together, here is some sample code that runs a server with this GraphQL API:
最后把这些代码都整到一起,这里是一些运行了用了该 GraphQL API 的示例代码:
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. 后半句 “这里是一些使用该 GraphQL API 运行服务器的示例代码:”

Copy link
Author

Choose a reason for hiding this comment

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

是整理整理😂

@@ -126,7 +126,7 @@ app.listen(4000);
console.log('Running a GraphQL API server at localhost:4000/graphql');
```

When you issue a GraphQL query against an API that returns object types, you can call multiple methods on the object at once by nesting the GraphQL field names. For example, if you wanted to call both `rollOnce` to roll a die once, and `roll` to roll a die three times, you could do it with this query:
当你对一个 API 发出一个 GraphQL 查询时它会返回一个对象类型,你可以通过嵌套 GraphQL 字段名来调用对象上的多个方法。例如,如果你想在调用一次 `rollOnce` 方法的同时也调用 `roll` 方法来掷 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. 第一句 “当你对一个返回对象类型的 API 发出 GraphQL 查询时”
  2. 第二句漏到了 “at once”
  3. 第三句 “如果你想在调用 rollOnce 方法掷一次骰子的同时……”

@@ -137,8 +137,8 @@ When you issue a GraphQL query against an API that returns object types, you can
}
```

If you run this code with `node server.js` and browse to http://localhost:4000/graphql you can try out these APIs with GraphiQL.
如果你用 `node server.js` 命令来运行这些代码并且访问 http://localhost:4000/graphql 的话,你可以用 GraphQL 试一下这些 API。
Copy link
Collaborator

Choose a reason for hiding this comment

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

你可以用 “ GraphiQL”,不是“ GraphQL”


This way of defining object types often provides advantages over a traditional REST API. Instead of doing one API request to get basic information about an object, and then multiple subsequent API requests to find out more information about that object, you can get all of that information in one API request. That saves bandwidth, makes your app run faster, and simplifies your client-side logic.
这种定义对象类型的方式通常会比传统的 REST 风格的 API 会带来更多的好处。取而代之的是只需要请求一次 API 就可以获得一个对象的相关基本信息,或者可以通过多个附带的 API 请求来获取更多关于该对象的信息,当然你也可以通过一次请求来获取该对象的所有信息。这样不仅节省了带宽、让你的应用跑得更快,同时也简化了你客户端应用的逻辑。
Copy link
Collaborator

Choose a reason for hiding this comment

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

第二句,还是 “Instead of”的问题,这个词所引导的句子都是指“被取而代之”,所以这句的意思是“你可以只用一次请求,而不是 一次 API 只能获得一个对象,然后还得再加一堆 API 获取其他对象”

Copy link
Author

Choose a reason for hiding this comment

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

还是想请教一下这句话怎么翻译比较好呢


So far, every API we've looked at is designed for returning data. In order to modify stored data or handle complex input, it helps to [learn about mutations and input types](/graphql-js/mutations-and-input-types/).
到目前为止,我们所看到的每个 API 都是为返回数据而设计的。为了修改存储的数据或处理复杂的输入,它有助于学习 [mutations input types](/graphql-js/mutations-and-input-types/)
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. learn about 是在链接里边的
  2. “为了……,它有助于……”我觉得不通,虽然原文也感觉不通,我觉得不如干脆直接无视原文,改成“为了……,需要继续学习……”

Copy link
Member

@linhe0x0 linhe0x0 left a comment

Choose a reason for hiding this comment

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

代码注释也需要翻译哈。

Copy link
Member

@linhe0x0 linhe0x0 left a comment

Choose a reason for hiding this comment

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

代码注释也需要翻译哈。

@@ -109,7 +110,7 @@ class RandomDie {
}
}

// The root provides the top-level API endpoints
// root 规定了顶层的 API 端点
Copy link
Collaborator

Choose a reason for hiding this comment

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

endpoint 统一译为 “入口端点”

@@ -91,6 +91,7 @@ var schema = buildSchema(`
`);

// This class implements the RandomDie GraphQL type
// 该类继承 RandomDie 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
Author

Choose a reason for hiding this comment

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

Sorry, 漏了删😂


这种定义对象类型的方式通常会比传统的 REST 风格的 API 会带来更多的好处。取而代之的是只需要请求一次 API 就可以获得一个对象的相关基本信息,或者可以通过多个附带的 API 请求来获取更多关于该对象的信息,当然你也可以通过一次请求来获取该对象的所有信息。这样不仅节省了带宽、让你的应用跑得更快,同时也简化了你客户端应用的逻辑。
这种定义对象类型的方式通常会比传统的 REST 风格的 API 会带来更多的好处。你可以只用一次请求,而不是一次 API 只能获得一个对象,然后还得再加一堆 API 获取其他对象,当然你也可以通过一次请求来获取该对象的所有信息。这样不仅节省了带宽、让你的应用跑得更快,同时也简化了你客户端应用的逻辑。
Copy link
Collaborator

Choose a reason for hiding this comment

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

……我只是写了大概意思,不能直接 Copy 过来啊,请重新译一下这段

@@ -126,7 +127,7 @@ app.listen(4000);
console.log('Running a GraphQL API server at localhost:4000/graphql');
```

当你对一个 API 发出一个 GraphQL 查询时它会返回一个对象类型,你可以通过嵌套 GraphQL 字段名来调用对象上的多个方法。例如,如果你想在调用一次 `rollOnce` 方法的同时也调用 `roll` 方法来掷 3 次骰子的话,你可以这么做:
当你对一个返回对象类型的 API 发出 GraphQL 查询时,你可以通过嵌套 GraphQL 字段名来调用对象上的多个方法。例如,如果你想在调用 `rollOnce` 方法掷 1 次骰子的同时也调用 `roll` 方法来掷 3 次骰子的话,你可以这么做:
Copy link
Collaborator

Choose a reason for hiding this comment

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

还是漏了 at once 的翻译

@@ -28,7 +28,7 @@ type Query {
}
```

取而代之的是一个值为 `RandomDie` 类型的根级别解析器,我们可以用 ES6 的 class 语法来替代,这样的话这些解析器就是这个类的实例方法了。下面的代码展示了如何使用 ES6 的 class 语法来实现上面的 `RandomDie` 对象类型:
对于跟级别解析器 `RandomDie` 类型来说,我们可以用 ES6 的 class 语法来替代,这样的话这些解析器就是这个类的实例方法了。下面的代码展示了如何使用 ES6 的 class 语法来实现上面的 `RandomDie` 对象类型:
Copy link
Collaborator

Choose a reason for hiding this comment

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

“对于跟级别解析器 RandomDie 类型来说”=>“对于 RandomDie 类型的根级别解析器来说”

Copy link
Author

Choose a reason for hiding this comment

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

👌

@linhe0x0 linhe0x0 merged commit 137a72b into xitu:zh-Hans Aug 15, 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.

Tutorial-ObjectTypes.md
4 participants