Skip to content

Commit e4cedca

Browse files
committed
Merge branch 'master' of https://github.com/nveenjain/graphql-js into feature/addCommentInAST
Signed-off-by: Naveen Jain <[email protected]>
2 parents 5a5825c + 688f93c commit e4cedca

18 files changed

+369
-369
lines changed

.eslintrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ overrides:
433433
flowtype/require-valid-file-annotation: off
434434

435435
##########################################################################
436-
# `@typescript-eslint/eslint-plugin` rule list based on `v2.17.x`
436+
# `@typescript-eslint/eslint-plugin` rule list based on `v2.21.x`
437437
##########################################################################
438438

439439
# Supported Rules

.flowconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)?)\\)
4040
suppress_comment=\\(.\\|\n\\)*\\$DisableFlowOnNegativeTest
4141

4242
[version]
43-
^0.118.0
43+
^0.119.0

package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@
4444
},
4545
"dependencies": {},
4646
"devDependencies": {
47-
"@babel/core": "7.8.4",
47+
"@babel/core": "7.8.6",
4848
"@babel/plugin-transform-flow-strip-types": "7.8.3",
49-
"@babel/preset-env": "7.8.4",
50-
"@babel/register": "7.8.3",
51-
"@typescript-eslint/eslint-plugin": "2.19.2",
52-
"@typescript-eslint/parser": "2.19.2",
53-
"babel-eslint": "10.0.3",
49+
"@babel/preset-env": "7.8.6",
50+
"@babel/register": "7.8.6",
51+
"@typescript-eslint/eslint-plugin": "2.21.0",
52+
"@typescript-eslint/parser": "2.21.0",
53+
"babel-eslint": "10.1.0",
5454
"chai": "4.2.0",
55-
"cspell": "4.0.46",
56-
"dtslint": "2.0.6",
55+
"cspell": "4.0.55",
56+
"dtslint": "3.2.0",
5757
"eslint": "6.8.0",
5858
"eslint-plugin-flowtype": "4.6.0",
5959
"eslint-plugin-import": "2.20.1",
60-
"flow-bin": "0.118.0",
61-
"mocha": "7.0.1",
60+
"flow-bin": "0.119.1",
61+
"mocha": "7.1.0",
6262
"nyc": "15.0.0",
6363
"prettier": "1.19.1",
64-
"typescript": "^3.7.5"
64+
"typescript": "^3.8.3"
6565
}
6666
}

src/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Each sub directory within is a sub-module of graphql-js:
1717
fulfilling a GraphQL result.
1818
- [`graphql/execution`](execution/README.md): The Execution phase of fulfilling
1919
a GraphQL request.
20-
- [`graphql/error`](error/README.md): Creating and formating GraphQL errors.
20+
- [`graphql/error`](error/README.md): Creating and formatting GraphQL errors.
2121
- [`graphql/utilities`](utilities/README.md): Common useful computations upon
2222
the GraphQL language and type objects.
2323
- [`graphql/subscription`](subscription/README.md): Subscribe to data updates.

src/__tests__/graphql-test.js

-18
This file was deleted.

src/execution/__tests__/sync-test.js

+11
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ describe('Execute: synchronously when possible', () => {
9393
});
9494

9595
describe('graphqlSync', () => {
96+
it('report errors raised during schema validation', () => {
97+
const badSchema = new GraphQLSchema({});
98+
const result = graphqlSync({
99+
schema: badSchema,
100+
source: '{ __typename }',
101+
});
102+
expect(result).to.deep.equal({
103+
errors: [{ message: 'Query root type must be provided.' }],
104+
});
105+
});
106+
96107
it('does not return a Promise for syntax errors', () => {
97108
const doc = 'fragment Example on Query { { { syncField }';
98109
const result = graphqlSync({

src/language/__tests__/parser-test.js

+34-16
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,28 @@ describe('Parser', () => {
153153
type alpha{ field(arg: string):string }
154154
`);
155155

156-
expect(ast).to.have.nested.property(
157-
'comments[0].value',
158-
'This comment has a \u0A0A multi-byte character.',
159-
);
160-
expect(ast.comments).to.have.length(1);
156+
expect(toJSONDeep(ast.comments)).to.deep.equal([
157+
{
158+
kind: 'Comment',
159+
loc: { start: 7, end: 50 },
160+
value: 'This comment has a ਊ multi-byte character.',
161+
},
162+
]);
163+
});
164+
165+
it('Add empty comments from in AST', () => {
166+
const ast = parse(`
167+
#
168+
type alpha{ field(arg: string):string }
169+
`);
170+
171+
expect(toJSONDeep(ast.comments)).to.deep.equal([
172+
{
173+
kind: 'Comment',
174+
loc: { start: 7, end: 8 },
175+
value: '',
176+
},
177+
]);
161178
});
162179

163180
it('Add multiple comments in AST', () => {
@@ -169,15 +186,18 @@ describe('Parser', () => {
169186
}
170187
`);
171188

172-
expect(ast).to.have.nested.property(
173-
'comments[0].value',
174-
'This comment is demo comment.',
175-
);
176-
expect(ast).to.have.nested.property(
177-
'comments[1].value',
178-
'This is another demo comment having # inside',
179-
);
180-
expect(ast.comments).to.have.length(2);
189+
expect(toJSONDeep(ast.comments)).to.deep.equal([
190+
{
191+
kind: 'Comment',
192+
loc: { start: 27, end: 57 },
193+
value: 'This comment is demo comment.',
194+
},
195+
{
196+
kind: 'Comment',
197+
loc: { start: 101, end: 146 },
198+
value: 'This is another demo comment having # inside',
199+
},
200+
]);
181201
});
182202

183203
it('parses kitchen sink', () => {
@@ -264,7 +284,6 @@ describe('Parser', () => {
264284

265285
expect(toJSONDeep(result)).to.deep.equal({
266286
kind: Kind.DOCUMENT,
267-
comments: [],
268287
loc: { start: 0, end: 41 },
269288
definitions: [
270289
{
@@ -355,7 +374,6 @@ describe('Parser', () => {
355374

356375
expect(toJSONDeep(result)).to.deep.equal({
357376
kind: Kind.DOCUMENT,
358-
comments: [],
359377
loc: { start: 0, end: 30 },
360378
definitions: [
361379
{

0 commit comments

Comments
 (0)