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-GraphQLClients.md #67

Merged
merged 2 commits into from
Aug 9, 2017

Conversation

jonirrings
Copy link
Collaborator

@jonirrings jonirrings commented Aug 7, 2017

有劳审校 resolve #26

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.

一些语句可以再润色一下,多加一些副词修饰一下,感觉有点干

permalink: /graphql-js/graphql-clients/
next: /graphql-js/basic-types/
---

Since a GraphQL API has more underlying structure than a REST API, there are more powerful clients like [Relay](https://facebook.github.io/relay/) which can automatically handle batching, caching, and other features. But you don't need a complex client to call a GraphQL server. With `express-graphql`, you can just send an HTTP POST request to the endpoint you mounted your GraphQL server on, passing the GraphQL query as the `query` field in a JSON payload.
由于 GraphQL API 拥有比 REST API 更多的下层结构,它也有更强大的客户端。辟如 [Relay](https://facebook.github.io/relay/),它能自动操作批处理、缓存等等。但你并不需要一个复杂的客户端才能调用 GraphQL 服务器,在有了 `express-graphql` 的情况下,你可以向 GraphQL 服务器上的入口端点发送一个 HTTP POST 请求,其中将 GraphQL 查询作为 JSON 载荷的 `query` 字段,就能调用 GraphQL 服务器。
Copy link
Collaborator

Choose a reason for hiding this comment

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

“辟如”=>“譬如”


For example, let's say we mounted a GraphQL server on http://localhost:4000/graphql as in the example code for [running an Express GraphQL server](/graphql-js/running-an-express-graphql-server/), and we want to send the GraphQL query `{ hello }`. We can do this from the command line with `curl`. If you paste this into a terminal:
假设我们运行了 [Express GraphQL 服务器](/graphql-js/running-an-express-graphql-server/) 的案例代码,GraphQL 服务运行于 http://localhost:4000/graphql,我们想要发送 GraphQL 请求 `{ hello }`。我们在命令行中运行 `curl`,将下面代码粘贴到终端中去:
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. “query”=>“查询”
  3. “我们可以在命令行中使用 curl 来发送这一请求”


```bash
{"data":{"hello":"Hello world!"}}
```

It's also simple to send GraphQL from the browser. Open up http://localhost:4000, open a developer console, and paste in:
通过浏览器发送 GraphQL 也很简单。打开 http://localhost:4000,开启开发者终端,粘贴:
Copy link
Collaborator

Choose a reason for hiding this comment

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

“console”=>“控制台”

@@ -37,23 +37,23 @@ xhr.onload = function () {
xhr.send(JSON.stringify({query: "{ hello }"}));
```

You should see the data returned, logged in the console:
你会在终端中见到返回的数据:
Copy link
Collaborator

Choose a reason for hiding this comment

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

console +1

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:


For example, let's say you're running the example server from [Passing Arguments](/graphql-js/passing-arguments/) that has a schema of
假设你运行了 [传递参数](/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.

漏了"has a schema of"

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>
@linhe0x0 linhe0x0 merged commit 274f82d into xitu:zh-Hans Aug 9, 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-GraphQLClients.md
3 participants