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-ExpressGraphQL.md #48

Merged
merged 4 commits into from
Aug 5, 2017
Merged

Tutorial-ExpressGraphQL.md #48

merged 4 commits into from
Aug 5, 2017

Conversation

hikerpig
Copy link

@hikerpig hikerpig commented Jul 27, 2017

求校对

close #24

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.

一些标点上的小问题


```bash
npm install express express-graphql graphql --save
```

Let's modify our “hello world” example so that it's an API server rather than a script that runs a single query. We can use the 'express' module to run a webserver, and instead of executing a query directly with the `graphql` function, we can use the `express-graphql` library to mount a GraphQL API server on the “/graphqlHTTP endpoint:
现在我们来改进 “hello world” 示例,把它从一个只能使用一个查询的简单的脚本变成一个 API 服务器。使用 `express` 模块来运行一个服务器,然后不再直接调用 `graphql` 函数进行查询,而是使用 `express-graphql` 库来构建 GraphQL API 服务器,响应以 '/graphql' 开头的 HTTP 请求。

```javascript
var express = require('express');
Copy link
Collaborator

Choose a reason for hiding this comment

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

有一句注释最好也翻译一下~

@@ -7,13 +7,13 @@ permalink: /graphql-js/running-an-express-graphql-server/
next: /graphql-js/graphql-clients/
---

The simplest way to run an GraphQL API server is to use [Express](https://expressjs.com), a popular web application framework for Node.js. You will need to install two additional dependencies:
运行 GraphQL 最简单的方法是使用 [Express](https://expressjs.com)(一个 Node.js 上流行的 web 应用框架)。你需要安装两个依赖库:
Copy link
Collaborator

Choose a reason for hiding this comment

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

最后一个冒号是英文标点

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

You can run this GraphQL server with:
用以下命令启动该 GraphQL 服务器:
Copy link
Collaborator

Choose a reason for hiding this comment

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

同冒号的问题


```bash
node server.js
```

Since we configured `graphqlHTTP` with `graphiql: true`, you can use the GraphiQL tool to manually issue GraphQL queries. If you navigate in a web browser to `http://localhost:4000/graphql`, you should see an interface that lets you enter queries. It should look like:
由于我们对 `graphqlHTTP` 设置 `graphiql: true`, 你可以使用 GraphiQL 工具来手动执行 GraphQL 查询。若使用浏览器浏览 `http://localhost:4000/graphql`,你会看到一个界面能让你输入查询语句。它看起来是这样的:
Copy link
Collaborator

Choose a reason for hiding this comment

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

第一个逗号是英文标点


```bash
npm install express express-graphql graphql --save
```

Let's modify our “hello world” example so that it's an API server rather than a script that runs a single query. We can use the 'express' module to run a webserver, and instead of executing a query directly with the `graphql` function, we can use the `express-graphql` library to mount a GraphQL API server on the “/graphqlHTTP endpoint:
现在我们来改进 “hello world” 示例,把它从一个只能使用一个查询的简单的脚本变成一个 API 服务器。使用 `express` 模块来运行一个服务器,然后不再直接调用 `graphql` 函数进行查询,而是使用 `express-graphql` 库来构建 GraphQL API 服务器,响应以 '/graphql' 开头的 HTTP 请求。
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' 开头”不准确,只是针对“/graphql”这一个 endpoint,不包含以它开头的其它入口
  2. endpoint 目前商议是统一翻译成“入口端点”

@hikerpig
Copy link
Author

hikerpig commented Aug 2, 2017

更改完毕,等下一轮校对


```javascript
var express = require('express');
var graphqlHTTP = require('express-graphql');
var { buildSchema } = require('graphql');

// Construct a schema, using GraphQL schema language
// 使用 GraphQL 模式语言创建一个 schema
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里还有一个 schema language


```bash
node server.js
```

Since we configured `graphqlHTTP` with `graphiql: true`, you can use the GraphiQL tool to manually issue GraphQL queries. If you navigate in a web browser to `http://localhost:4000/graphql`, you should see an interface that lets you enter queries. It should look like:
由于我们对 `graphqlHTTP` 设置 `graphiql: true`, 你可以使用 GraphiQL 工具来手动执行 GraphQL 查询。若使用浏览器浏览 `http://localhost:4000/graphql`,你会看到一个界面能让你输入查询语句。它看起来是这样的:
Copy link
Collaborator

Choose a reason for hiding this comment

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

逗号后边多了一个空格


```bash
npm install express express-graphql graphql --save
```

Let's modify our “hello world” example so that it's an API server rather than a script that runs a single query. We can use the 'express' module to run a webserver, and instead of executing a query directly with the `graphql` function, we can use the `express-graphql` library to mount a GraphQL API server on the “/graphqlHTTP endpoint:
现在我们来改进 “hello world” 示例,把它从一个只能使用一个查询的简单的脚本变成一个 API 服务器。使用 `express` 模块来运行一个服务器,然后不再直接调用 `graphql` 函数进行查询,而是使用 `express-graphql` 库来构建 GraphQL API 服务器,响应入口端点为 '/graphql' 的 HTTP 请求。
Copy link
Collaborator

Choose a reason for hiding this comment

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

最后的 '/graphql' 两边的引号与前边 “hello world” 保持统一为好

@@ -7,27 +7,27 @@ permalink: /graphql-js/running-an-express-graphql-server/
next: /graphql-js/graphql-clients/
---

The simplest way to run an GraphQL API server is to use [Express](https://expressjs.com), a popular web application framework for Node.js. You will need to install two additional dependencies:
运行 GraphQL 最简单的方法是使用 [Express](https://expressjs.com)(一个 Node.js 上流行的 web 应用框架)。你需要安装两个依赖库:
Copy link
Collaborator

Choose a reason for hiding this comment

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

title,sidebarTitle和category也麻烦翻一下

Copy link
Author

Choose a reason for hiding this comment

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

噢漏漏翻,补上了

@jonirrings jonirrings changed the title 完成 'Tutorial-ExpressGraphQL.md' 翻译 Tutorial-ExpressGraphQL.md Aug 4, 2017
@jonirrings
Copy link
Collaborator

那木有问题了

Copy link
Collaborator

@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.

done

@jonirrings jonirrings merged commit 34e33a6 into xitu:zh-Hans Aug 5, 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-ExpressGraphQL.md
4 participants