Skip to content

Commit a9bc1c1

Browse files
committed
merge from master
2 parents b764e23 + 62c7f3b commit a9bc1c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+41865
-17715
lines changed

.eslintrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ rules:
253253
operator-assignment: [error, always]
254254
padding-line-between-statements: off
255255
prefer-object-spread: error
256-
quotes: [error, single, { avoidEscape: true, allowTemplateLiterals: true }]
256+
quotes: [error, single, { avoidEscape: true, allowTemplateLiterals: false }]
257257
sort-keys: off
258258
sort-vars: off
259259
spaced-comment: [error, always]

.npmignore

+2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ package-lock.json
1212
.babelrc
1313
.nycrc
1414
.nyc_output
15+
codecov.yml
1516
CONTRIBUTING.md
1617
node_modules
1718
coverage
1819
resources
1920
src
21+
docs
2022
dist
2123
__tests__
2224
npm

.travis.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ node_js:
1111
- '8'
1212
- '6'
1313

14-
script: npm run testonly
14+
script: |
15+
if [[ "$(node -pe process.version)" == v10.* ]]; then # Is latest LTS?
16+
npm run test:ci &&
17+
bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json
18+
else
19+
npm run testonly
20+
fi
1521
1622
jobs:
1723
include:
18-
- node_js: 'lts/*'
19-
script: npm run test:ci && bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json
2024
- stage: deploy
2125
if: branch = master OR tag IS present
2226
script: echo "Deploying..."

docs/APIReference-Errors.md

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
title: graphql/error
3+
layout: ../_core/GraphQLJSLayout
4+
category: API Reference
5+
permalink: /graphql-js/error/
6+
sublinks: formatError,GraphQLError,locatedError,syntaxError
7+
next: /graphql-js/execution/
8+
---
9+
10+
The `graphql/error` module is responsible for creating and formatting
11+
GraphQL errors. You can import either from the `graphql/error` module, or from the root `graphql` module. For example:
12+
13+
```js
14+
import { GraphQLError } from 'graphql'; // ES6
15+
var { GraphQLError } = require('graphql'); // CommonJS
16+
```
17+
18+
## Overview
19+
20+
<ul class="apiIndex">
21+
<li>
22+
<a href="#graphqlerror">
23+
<pre>class GraphQLError</pre>
24+
A representation of an error that occurred within GraphQL.
25+
</a>
26+
</li>
27+
<li>
28+
<a href="#syntaxerror">
29+
<pre>function syntaxError</pre>
30+
Produces a GraphQLError representing a syntax error.
31+
</a>
32+
</li>
33+
<li>
34+
<a href="#locatedError">
35+
<pre>function locatedError</pre>
36+
Produces a new GraphQLError aware of the location responsible for the error.
37+
</a>
38+
</li>
39+
<li>
40+
<a href="#formaterror">
41+
<pre>function formatError</pre>
42+
Format an error according to the rules described by the Response Format.
43+
</a>
44+
</li>
45+
</ul>
46+
47+
## Errors
48+
49+
### GraphQLError
50+
51+
```js
52+
class GraphQLError extends Error {
53+
constructor(
54+
message: string,
55+
nodes?: Array<any>,
56+
stack?: ?string,
57+
source?: Source,
58+
positions?: Array<number>,
59+
originalError?: ?Error,
60+
extensions?: ?{ [key: string]: mixed }
61+
)
62+
}
63+
```
64+
65+
A representation of an error that occurred within GraphQL. Contains
66+
information about where in the query the error occurred for debugging. Most
67+
commonly constructed with `locatedError` below.
68+
69+
### syntaxError
70+
71+
```js
72+
function syntaxError(
73+
source: Source,
74+
position: number,
75+
description: string
76+
): GraphQLError;
77+
```
78+
79+
Produces a GraphQLError representing a syntax error, containing useful
80+
descriptive information about the syntax error's position in the source.
81+
82+
### locatedError
83+
84+
```js
85+
function locatedError(error: ?Error, nodes: Array<any>): GraphQLError {
86+
```
87+
88+
Given an arbitrary Error, presumably thrown while attempting to execute a
89+
GraphQL operation, produce a new GraphQLError aware of the location in the
90+
document responsible for the original Error.
91+
92+
### formatError
93+
94+
```js
95+
function formatError(error: GraphQLError): GraphQLFormattedError
96+
97+
type GraphQLFormattedError = {
98+
message: string,
99+
locations: ?Array<GraphQLErrorLocation>
100+
};
101+
102+
type GraphQLErrorLocation = {
103+
line: number,
104+
column: number
105+
};
106+
```
107+
108+
Given a GraphQLError, format it according to the rules described by the
109+
Response Format, Errors section of the GraphQL Specification.

docs/APIReference-Execution.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: graphql/execution
3+
layout: ../_core/GraphQLJSLayout
4+
category: API Reference
5+
permalink: /graphql-js/execution/
6+
sublinks: execute
7+
next: /graphql-js/language/
8+
---
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:
12+
13+
```js
14+
import { execute } from 'graphql'; // ES6
15+
var { execute } = require('graphql'); // CommonJS
16+
```
17+
18+
## Overview
19+
20+
<ul class="apiIndex">
21+
<li>
22+
<a href="#execute">
23+
<pre>function execute</pre>
24+
Executes a GraphQL request on the provided schema.
25+
</a>
26+
</li>
27+
</ul>
28+
29+
## Execution
30+
31+
### execute
32+
33+
```js
34+
export function execute(
35+
schema: GraphQLSchema,
36+
documentAST: Document,
37+
rootValue?: mixed,
38+
contextValue?: mixed,
39+
variableValues?: ?{[key: string]: mixed},
40+
operationName?: ?string
41+
): MaybePromise<ExecutionResult>
42+
43+
type MaybePromise<T> = Promise<T> | T;
44+
45+
type ExecutionResult = {
46+
data: ?Object;
47+
errors?: Array<GraphQLError>;
48+
}
49+
```
50+
51+
Implements the "Evaluating requests" section of the GraphQL specification.
52+
53+
Returns a Promise that will eventually be resolved and never rejected.
54+
55+
If the arguments to this function do not result in a legal execution context,
56+
a GraphQLError will be thrown immediately explaining the invalid input.
57+
58+
`ExecutionResult` represents the result of execution. `data` is the result of
59+
executing the query, `errors` is null if no errors occurred, and is a
60+
non-empty array if an error occurred.

docs/APIReference-ExpressGraphQL.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: express-graphql
3+
layout: ../_core/GraphQLJSLayout
4+
category: API Reference
5+
permalink: /graphql-js/express-graphql/
6+
sublinks: graphqlHTTP
7+
next: /graphql-js/graphql/
8+
---
9+
10+
The `express-graphql` module provides a simple way to create an [Express](https://expressjs.com/) server that runs a GraphQL API.
11+
12+
```js
13+
import graphqlHTTP from 'express-graphql'; // ES6
14+
var graphqlHTTP = require('express-graphql'); // CommonJS
15+
```
16+
17+
### graphqlHTTP
18+
19+
```js
20+
graphqlHTTP({
21+
schema: GraphQLSchema,
22+
graphiql?: ?boolean,
23+
rootValue?: ?any,
24+
context?: ?any,
25+
pretty?: ?boolean,
26+
formatError?: ?Function,
27+
validationRules?: ?Array<any>,
28+
}): Middleware
29+
```
30+
31+
Constructs an Express application based on a GraphQL schema.
32+
33+
See the [express-graphql tutorial](/graphql-js/running-an-express-graphql-server/) for sample usage.
34+
35+
See the [GitHub README](https://github.com/graphql/express-graphql) for more extensive documentation of the details of this method.

0 commit comments

Comments
 (0)