File tree Expand file tree Collapse file tree 9 files changed +47
-8
lines changed Expand file tree Collapse file tree 9 files changed +47
-8
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ const PersonType = new GraphQLObjectType({
141
141
/* ... */
142
142
friends: {
143
143
type: new GraphQLList(PersonType),
144
- resolve: person => person.friends.map(getPersonByURL ),
144
+ resolve: person => person.friends.map(fetchPersonByURL ),
145
145
},
146
146
}),
147
147
});
@@ -395,7 +395,7 @@ To create a `DataLoader` you supply a method that can resolve a list of objects
395
395
396
396
``` js
397
397
const personLoader = new DataLoader (
398
- urls => Promise .all (urls .map (getPersonByURL ))
398
+ urls => Promise .all (urls .map (fetchPersonByURL ))
399
399
);
400
400
```
401
401
Original file line number Diff line number Diff line change @@ -107,7 +107,9 @@ $ curl -XPOST "http://0:3000" -H'Content-Type: application/json' -d'{
107
107
(executor/execute nil schema resolver-fn "{ hello }")
108
108
\`\`\`
109
109
110
- - [lacinia](https://github.com/walmartlabs/lacinia):一套 GraphQL 规范的完整实现,致力于维护对规范的外部兼容。
110
+ #### [lacinia](https://github.com/walmartlabs/lacinia)
111
+
112
+ 一套 GraphQL 规范的完整实现,致力于维护对规范的外部兼容。
111
113
112
114
### Elixir
113
115
@@ -335,7 +337,7 @@ $resolvers = [
335
337
];
336
338
$schema = Graphql\schema($typeDefs, $resolvers);
337
339
338
- echo "Server running at http://127.0.0.1:8080\\n ";
340
+ echo "Server running at http://127.0.0.1:8080";
339
341
Http\server(Graphql\psr7($schema), function (\Throwable $err) {
340
342
var_dump($err);
341
343
return Diactoros\json([
Original file line number Diff line number Diff line change @@ -72,3 +72,4 @@ GraphQL Conf 是欧洲非营利性的 GraphQL 大会,邀请了来自世界各
72
72
- [ GraphQL Tel Aviv] ( https://www.meetup.com/GraphQL-TLV/ )
73
73
- [ GraphQL Tokyo] ( https://www.meetup.com/GraphQL-Tokyo/ )
74
74
- [ GraphQL Meetup (Bangalore)] ( https://www.meetup.com/GraphQL-Meetup/ )
75
+ - [ GraphQL Meetup (Bangkok)] ( https://www.meetup.com/GraphQL-Bangkok/ )
Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ sublinks: 博客,视频
23
23
24
24
- [ @GraphQL ] ( https://twitter.com/GraphQL )
25
25
- [ @graphqlweekly ] ( https://twitter.com/graphqlweekly )
26
- - [ @graphqlnews ] ( https://twitter.com/graphqlnews )
27
26
- [ @GraphQLStackOverflow ] ( https://twitter.com/GraphQLatSO )
28
27
- [ @apollographql ] ( https://twitter.com/apollographql )
29
28
- [ @graphcool ] ( https://twitter.com/graphcool )
Original file line number Diff line number Diff line change @@ -124,6 +124,33 @@ fragment comparisonFields on Character {
124
124
125
125
你可以看到上面的查询如何漂亮地重复了字段。片段的概念经常用于将复杂的应用数据需求分割成小块,特别是你要将大量不同片段的 UI 组件组合成一个初始数据获取的时候。
126
126
127
+ ### 在片段内使用变量
128
+
129
+ 片段可以访问查询或变更中声明的变量。详见 [ 变量] ( learn/queries/#variables ) 。
130
+
131
+ ``` graphql
132
+ # { "graphiql": true }
133
+ query HeroComparison ($first : Int = 3 ) {
134
+ leftComparison : hero (episode : EMPIRE ) {
135
+ ... comparisonFields
136
+ }
137
+ rightComparison : hero (episode : JEDI ) {
138
+ ... comparisonFields
139
+ }
140
+ }
141
+
142
+ fragment comparisonFields on Character {
143
+ name
144
+ friendsConnection (first : $first ) {
145
+ totalCount
146
+ edges {
147
+ node {
148
+ name
149
+ }
150
+ }
151
+ }
152
+ }
153
+ ```
127
154
128
155
## 操作名称(Operation name)
129
156
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ GraphQL 服务可以用任何语言编写,因为我们并不依赖于任何特
42
42
``` graphql
43
43
type Character {
44
44
name : String !
45
- appearsIn : [Episode ]!
45
+ appearsIn : [Episode ! ]!
46
46
}
47
47
```
48
48
@@ -52,7 +52,7 @@ type Character {
52
52
- `name` 和 `appearsIn` 是 `Character` 类型上的**字段**。这意味着在一个操作 `Character` 类型的 GraphQL 查询中的任何部分,都只能出现 `name` 和 `appearsIn` 字段。
53
53
- `String` 是内置的**标量**类型之一 —— 标量类型是解析到单个标量对象的类型,无法在查询中对它进行次级选择。后面我们将细述标量类型。
54
54
- `String!` 表示这个字段是**非空的**,GraphQL 服务保证当你查询这个字段后总会给你返回一个值。在类型语言里面,我们用一个感叹号来表示这个特性。
55
- - `[Episode]!` 表示一个 `Episode` **数组**。因为它也是**非空的**,所以当你查询 `appearsIn` 字段的时候,你也总能得到一个数组(零个或者多个元素)。
55
+ - `[Episode! ]!` 表示一个 `Episode` **数组**。因为它也是**非空的**,所以当你查询 `appearsIn` 字段的时候,你也总能得到一个数组(零个或者多个元素)。且由于 `Episode!` 也是**非空的**,你总是可以预期到数组中的每个项目都是一个 `Episode` 对象 。
56
56
57
57
现在你知道一个 GraphQL 对象类型看上去是怎样,也知道如何阅读基础的 GraphQL 类型语言了。
58
58
Original file line number Diff line number Diff line change @@ -655,7 +655,17 @@ var logos = [
655
655
name : 'UC Trends' ,
656
656
img : 'uctrends.png' ,
657
657
link : 'https://trends.ucweb.com'
658
- }
658
+ } ,
659
+ {
660
+ name : 'Expert360' ,
661
+ img : 'expert360.png' ,
662
+ link : 'https://expert360.com'
663
+ } ,
664
+ {
665
+ name : 'Cloverleaf' ,
666
+ img : 'cloverleaf.png' ,
667
+ link : 'https://cloverleaf.me/'
668
+ } ,
659
669
// Adding your logo?
660
670
// Add it to the /users/logos/ directory and then append an entry above this comment.
661
671
//
You can’t perform that action at this time.
0 commit comments