Skip to content

Commit 3cd8303

Browse files
linpu.lilinhe0x0
authored andcommitted
APIReference-GraphQL.md (xitu#59)
1 parent 3ab8862 commit 3cd8303

File tree

1 file changed

+32
-41
lines changed

1 file changed

+32
-41
lines changed

site/graphql-js/APIReference-GraphQL.md

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,139 +6,137 @@ permalink: /graphql-js/graphql/
66
sublinks: graphql
77
next: /graphql-js/error/
88
---
9-
10-
The `graphql` module exports a core subset of GraphQL functionality for creation
11-
of GraphQL type systems and servers.
9+
`graphql` 模块导出了 GraphQL 的一个核心子集,其主要功能是创建 GraphQL 的类型系统和服务。
1210

1311
```js
1412
import { graphql } from 'graphql'; // ES6
1513
var { graphql } = require('graphql'); // CommonJS
1614
```
1715

18-
## Overview
16+
## 概述
1917

20-
*Entry Point*
18+
**入口点**
2119

2220
<ul class="apiIndex">
2321
<li>
2422
<a href="#graphql">
2523
<pre>function graphql</pre>
26-
Lexes, parses, validates, and executes a GraphQL request on a schema.
24+
根据 schema 对一个 GraphQL 请求进行词法分析、解析、验证及执行。
2725
</a>
2826
</li>
2927
</ul>
3028

31-
*Schema*
29+
**Schema**
3230

3331
<ul class="apiIndex">
3432
<li>
3533
<a href="../type/#graphqlschema">
3634
<pre>class GraphQLSchema</pre>
37-
A representation of the capabilities of a GraphQL Server.
35+
一个 GraphQL 服务的功能配置描述
3836
</a>
3937
</li>
4038
</ul>
4139

42-
*Type Definitions*
40+
**类型定义**
4341

4442
<ul class="apiIndex">
4543
<li>
4644
<a href="../type/#graphqlscalartype">
4745
<pre>class GraphQLScalarType</pre>
48-
A scalar type within GraphQL.
46+
GraphQL 里的标量类型。
4947
</a>
5048
</li>
5149
<li>
5250
<a href="../type/#graphqlobjecttype">
5351
<pre>class GraphQLObjectType</pre>
54-
An object type within GraphQL that contains fields.
52+
GraphQL 里的自定义对象类型,包含一个 fields 字段。
5553
</a>
5654
</li>
5755
<li>
5856
<a href="../type/#graphqlinterfacetype">
5957
<pre>class GraphQLInterfaceType</pre>
60-
An interface type within GraphQL that defines fields implementations will contain.
58+
GraphQL 里的接口类型,定义多个类型中通用的字段。
6159
</a>
6260
</li>
6361
<li>
6462
<a href="../type/#graphqluniontype">
6563
<pre>class GraphQLUnionType</pre>
66-
A union type within GraphQL that defines a list of implementations.
64+
GraphQL 里的联合类型,定义了(某个字段能支持的所有返回类型的)一个实现列表。
6765
</a>
6866
</li>
6967
<li>
7068
<a href="../type/#graphqlenumtype">
7169
<pre>class GraphQLEnumType</pre>
72-
An enum type within GraphQL that defines a list of valid values.
70+
GraphQL 里的枚举类型,定义了一个有效(可枚举)数据类型的列表。
7371
</a>
7472
</li>
7573
<li>
7674
<a href="../type/#graphqlinputobjecttype">
7775
<pre>class GraphQLInputObjectType</pre>
78-
An input object type within GraphQL that represents structured inputs.
76+
GraphQL 里的输入对象类型,表示一些结构化的输入。
7977
</a>
8078
</li>
8179
<li>
8280
<a href="../type/#graphqllist">
8381
<pre>class GraphQLList</pre>
84-
A type wrapper around other types that represents a list of those types.
82+
这是对其他类型进行封装的类型,表示一个包含那些类型的列表。
8583
</a>
8684
</li>
8785
<li>
8886
<a href="../type/#graphqlnonnull">
8987
<pre>class GraphQLNonNull</pre>
90-
A type wrapper around other types that represents a non-null version of those types.
88+
这也是对其他类型进行封装的类型,并强制要求类型值不能为空。
9189
</a>
9290
</li>
9391
</ul>
9492

95-
*Scalars*
93+
**标量类型**
9694

9795
<ul class="apiIndex">
9896
<li>
9997
<a href="../type/#graphqlint">
10098
<pre>var GraphQLInt</pre>
101-
A scalar type representing integers.
99+
表示整数的标量类型。
102100
</a>
103101
</li>
104102
<li>
105103
<a href="../type/#graphqlfloat">
106104
<pre>var GraphQLFloat</pre>
107-
A scalar type representing floats.
105+
表示浮点数的标量类型。
108106
</a>
109107
</li>
110108
<li>
111109
<a href="../type/#graphqlstring">
112110
<pre>var GraphQLString</pre>
113-
A scalar type representing strings.
111+
表示字符串的标量类型。
114112
</a>
115113
</li>
116114
<li>
117115
<a href="../type/#graphqlboolean">
118116
<pre>var GraphQLBoolean</pre>
119-
A scalar type representing booleans.
117+
表示布尔值的标量类型。
120118
</a>
121119
</li>
122120
<li>
123121
<a href="../type/#graphqlid">
124122
<pre>var GraphQLID</pre>
125-
A scalar type representing IDs.
123+
表示 ID 值的标量类型。
126124
</a>
127125
</li>
128126
</ul>
129127

130-
*Errors*
128+
**错误信息**
131129

132130
<ul class="apiIndex">
133131
<li>
134132
<a href="../error/#formaterror">
135133
<pre>function formatError</pre>
136-
Format an error according to the rules described by the Response Format.
134+
根据返回格式描述的规则格式化一个错误。
137135
</a>
138136
</li>
139137
</ul>
140138

141-
## Entry Point
139+
## 入口点
142140

143141
### graphql
144142

@@ -153,27 +151,20 @@ graphql(
153151
): Promise<GraphQLResult>
154152
```
155153
156-
The `graphql` function lexes, parses, validates and executes a GraphQL request.
157-
It requires a `schema` and a `requestString`. Optional arguments include a
158-
`rootValue`, which will get passed as the root value to the executor, a `contextValue`,
159-
which will get passed to all resolve functions,
160-
`variableValues`, which will get passed to the executor to provide values for
161-
any variables in `requestString`, and `operationName`, which allows the caller
162-
to specify which operation in `requestString` will be run, in cases where
163-
`requestString` contains multiple top-level operations.
154+
`graphql` 方法可以对一个 GraphQL 请求进行词法分析、解析、验证和执行。必要的参数是 `schema``requestString`,可选的参数则包括 `rootValue`(将作为根值传入执行器方法)、`contextValue`(将传入所有的解析函数)、`variableValues`(将传入执行器方法,为 `requestString` 中的任意类型变量赋值)以及 `operationName`(在 `requestString` 包含多个顶级操作的情况下,这个参数允许调用函数指定 `requestString` 运行哪个操作)。
164155
165156
## Schema
166157
167-
See the [Type System API Reference](../type#schema).
158+
详细介绍请看 [类型系统 API 参考](../type#schema)
168159
169-
## Type Definitions
160+
## 类型定义
170161
171-
See the [Type System API Reference](../type#definitions).
162+
详细介绍请看 [类型系统 API 参考](../type#definitions)
172163
173-
## Scalars
164+
## 标量类型
174165
175-
See the [Type System API Reference](../type#scalars).
166+
详细介绍请看 [类型系统 API 参考](../type#scalars)
176167
177-
## Errors
168+
## 错误信息
178169
179-
See the [Errors API Reference](../error)
170+
详细介绍请看 [错误信息 API 参考](../error)

0 commit comments

Comments
 (0)