Skip to content

Conversation

@ydfzgyj
Copy link
Contributor

@ydfzgyj ydfzgyj commented Jul 11, 2018

close #318
Hope somebody will review my translation

@Akryum
Copy link
Member

Akryum commented Aug 30, 2018

@ydfzgyj Thanks for your contribution! 👍
I think you need to check if the translation is up-to-date with the recent docs changes.

@ydfzgyj
Copy link
Contributor Author

ydfzgyj commented Aug 31, 2018

@Akryum Already updated~ 😄

@Akryum
Copy link
Member

Akryum commented Aug 31, 2018

Awesome! @sodatea would you review the translation?

@haoqunjiang
Copy link
Member

😄My pleasure

- title: 自动更新
details: 无需考虑更新 UI 或重新获取查询的问题!
- title: 模板内组件
details: 通过真正声明 Apollo 组件的方式使用 Apollo
Copy link
Member

Choose a reason for hiding this comment

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

这句话有点不通顺。"in a declarative way" 应当是「声明式地使用」


## Apollo Boost

Apollo Boost 是一种零配置开始使用 Apollo Client 的方式。它包含一些合理的默认值,例如我们推荐的 `InMemoryCache` 和 `HttpLink`,它非常适合用于快速启动开发:
Copy link
Member

Choose a reason for hiding this comment

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

sensible 在这里的意思可能更接近于「实用的」


## 查询(Queries)

为每个你需要通过 Apollo 查询提供数据的属性,在 `apollo` 对象中添加一个特性。
Copy link
Member

Choose a reason for hiding this comment

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

这里 property 和 attribute 应该不需要区分,都翻译成「属性」比较好(考虑到后面代码里的注释也都是这么翻译的)。如果实在需要区分,个人觉得「字段」比「特性」更常用。
「Apollo 查询」漏翻了 result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里 property 和 attribute 应该不需要区分,都翻译成「属性」比较好(考虑到后面代码里的注释也都是这么翻译的)。如果实在需要区分,个人觉得「字段」比「特性」更常用。

“为属性添加属性”这种写法看起来太奇怪了……我是参考了 Vue 文档的翻译,把 attribute 改成“特性”了

Copy link
Member

Choose a reason for hiding this comment

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

但是其他地方 attribute 都是翻译成属性……感觉有点不一致。而且 Vue 里面的特性更多指的是模板中的特性,这个概念跟 HTML 特性一致,但不适合形容对象属性。
可以试着加个定语?为 Vue 属性在 apollo 对象里添加对应属性?如果还是觉得不通顺的话这里不改也不要紧。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的,加一个定语应该更好理解

@@ -0,0 +1,401 @@
# 查询

为每个你需要通过 Apollo 查询提供数据的属性,在 `apollo` 对象中添加一个特性。每一个特性都将创建一个智能查询。
Copy link
Member

Choose a reason for hiding this comment

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

同 docs/zh-cn/guide/apollo/README.md 中的评论。

const apolloProvider = new VueApollo({
defaultClient: apolloClient,
defaultOptions: {
// apollo 选项将应用于组件中的所有查询
Copy link
Member

Choose a reason for hiding this comment

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

「将应用于组件中的所有查询的 apollo 选项」

想要了解更多信息,请访问 [apollo 文档](https://www.apollographql.com/docs/react/api/apollo-client.html#ApolloClient.mutate)。有一个以变更为重点的 [示例应用](https://github.com/Akryum/vue-apollo-todos),你可以看看。

::: warning
你不应当在变量中发送 `__typename` 字段,因此不建议直接发送 Apollo 结果对象。
Copy link
Member

Choose a reason for hiding this comment

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

不应当发送变量中的 __typename 字段

Copy link
Contributor Author

Choose a reason for hiding this comment

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

不应当发送变量中的 __typename 字段

这里是指在使用 this.$apollo.mutate 时,其中传递给 variables 这个属性的值不能包含 __typename,如果改成“变量中的 __typename 字段”意思就不对了
如果有歧义的话,我把“变量”改成“变量属性”如何?

Copy link
Member

Choose a reason for hiding this comment

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

这里是说 the variables 而不是 variables,应该说的是变量里不应该带 __typename 属性,也就是说,其他 apollo 查询拿到的结果(因为结果里会带 __typename)不能直接拿来当做参数。

当然按你的理解也不影响使用,但这样的话 variables 就应该保留原文了。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我还是倾向于这里的 variables 和下边是对应的,那么我改成原文吧

expect(wrapper.element).toMatchSnapshot();
});
```
对于简单的变更测试,你需要检查组件中是否调用了 `$apollo` 的方法 `mutate`。接下来的示例在 `addHero` 方法中调用了变更:
Copy link
Member

Choose a reason for hiding this comment

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

$apollomutate 方法

expect(wrapper.element).toMatchSnapshot();
});
```
在这个用例中,所有字符串字段将等于 `Hello World` 且所有数值都将为负数。如果你想要获得更多实际的响应,则应当为某些查询指定解析器:
Copy link
Member

@haoqunjiang haoqunjiang Sep 5, 2018

Choose a reason for hiding this comment

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

「更多实际的响应」->「更贴近实际的响应」

@haoqunjiang
Copy link
Member

抱歉之前时间有限没有 review 完整。
刚指出来的这几点修改完之后应该就没什么问题了~

@Akryum Akryum merged commit 906975e into vuejs:master Sep 8, 2018
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.

Chinese translation of documentation

3 participants