@@ -7,28 +7,27 @@ sublinks: execute
7
7
next : /graphql-js/language/
8
8
---
9
9
10
- The ` graphql/execution ` module is responsible for the execution phase of
11
- fulfilling a GraphQL request. You can import either from the ` graphql/execution ` module, or from the root ` graphql ` module. For example:
10
+ ` graphql/execution ` 模块负责完成一个 GraphQL 请求的执行阶段。你可以直接从 ` graphql/execution ` 模块导入,也可以从 ` graphql ` 这个根模块导入。举例来说就是这样:
12
11
13
12
``` js
14
13
import { execute } from ' graphql' ; // ES6
15
14
var { execute } = require (' graphql' ); // CommonJS
16
15
```
17
16
18
- ## Overview
17
+ ## 概述
19
18
20
19
<ul class =" apiIndex " >
21
20
<li >
22
21
<a href="#execute">
23
22
<pre>function execute</pre>
24
- Executes a GraphQL request on the provided schema.
23
+ 对给定的 schema 执行一个 GraphQL 请求。
25
24
</a>
26
25
</li >
27
26
</ul >
28
27
29
- ## Execution
28
+ ## 执行
30
29
31
- ### execute
30
+ ### 执行
32
31
33
32
``` js
34
33
export function execute (
@@ -46,13 +45,10 @@ type ExecutionResult = {
46
45
}
47
46
` ` `
48
47
49
- Implements the "Evaluating requests" section of the GraphQL specification.
48
+ 上面的代码实现了 GraphQL 规范中“处理请求”的部分。
50
49
51
- Returns a Promise that will eventually be resolved and never rejected.
50
+ 它会返回一个最终一定会被 resolve 而不会被 reject 的 Promise。
52
51
53
- If the arguments to this function do not result in a legal execution context,
54
- a GraphQLError will be thrown immediately explaining the invalid input.
52
+ 如果这个函数的参数造成了一个非法的执行上下文,那么马上就会有一个 GraphQLError 被抛出,这个错误将会解释非法输入的具体信息。
55
53
56
- ` ExecutionResult` represents the result of execution. ` data` is the result of
57
- executing the query, ` errors` is null if no errors occurred, and is a
58
- non-empty array if an error occurred.
54
+ ` ExecutionResult` 代表执行的结果。` data` 是执行查询语句的结果,` errors` 在没有错误发生时为空,在有错误发生时为一个非空的数组。
0 commit comments