graphql 15.2.0 → 15.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@ Looking for help? Find resources [from the community](https://graphql.org/commun
13
13
 
14
14
  ## Getting Started
15
15
 
16
- An overview of GraphQL in general is available in the
16
+ A general overview of GraphQL is available in the
17
17
  [README](https://github.com/graphql/graphql-spec/blob/master/README.md) for the
18
18
  [Specification for GraphQL](https://github.com/graphql/graphql-spec). That overview
19
19
  describes a simple set of GraphQL examples that exist as [tests](src/__tests__)
@@ -30,16 +30,16 @@ With npm:
30
30
  npm install --save graphql
31
31
  ```
32
32
 
33
- or alternatively using yarn:
33
+ or using yarn:
34
34
 
35
35
  ```sh
36
36
  yarn add graphql
37
37
  ```
38
38
 
39
- GraphQL.js provides two important capabilities: building a type schema, and
39
+ GraphQL.js provides two important capabilities: building a type schema and
40
40
  serving queries against that type schema.
41
41
 
42
- First, build a GraphQL type schema which maps to your code base.
42
+ First, build a GraphQL type schema which maps to your codebase.
43
43
 
44
44
  ```js
45
45
  import {
@@ -64,10 +64,9 @@ var schema = new GraphQLSchema({
64
64
  });
65
65
  ```
66
66
 
67
- This defines a simple schema with one type and one field, that resolves
67
+ This defines a simple schema, with one type and one field, that resolves
68
68
  to a fixed value. The `resolve` function can return a value, a promise,
69
- or an array of promises. A more complex example is included in the top
70
- level [tests](src/__tests__) directory.
69
+ or an array of promises. A more complex example is included in the top-level [tests](src/__tests__) directory.
71
70
 
72
71
  Then, serve the result of a query against that type schema.
73
72
 
@@ -102,7 +101,7 @@ graphql(schema, query).then((result) => {
102
101
  });
103
102
  ```
104
103
 
105
- **Note**: Please don't forget to set `NODE_ENV=production` if you are running a production server it will disable some checks that can be useful during development but will significantly improve performance.
104
+ **Note**: Please don't forget to set `NODE_ENV=production` if you are running a production server. It will disable some checks that can be useful during development but will significantly improve performance.
106
105
 
107
106
  ### Want to ride the bleeding edge?
108
107
 
@@ -118,7 +117,7 @@ npm install graphql@git://github.com/graphql/graphql-js.git#npm
118
117
 
119
118
  ### Using in a Browser
120
119
 
121
- GraphQL.js is a general purpose library and can be used both in a Node server
120
+ GraphQL.js is a general-purpose library and can be used both in a Node server
122
121
  and in the browser. As an example, the [GraphiQL](https://github.com/graphql/graphiql/)
123
122
  tool is built with GraphQL.js!
124
123
 
@@ -130,7 +129,7 @@ custom build configurations look for `.mjs` files!
130
129
 
131
130
  ### Contributing
132
131
 
133
- We actively welcome pull requests, learn how to [contribute](./.github/CONTRIBUTING.md).
132
+ We actively welcome pull requests. Learn how to [contribute](./.github/CONTRIBUTING.md).
134
133
 
135
134
  ### Changelog
136
135
 
@@ -4,6 +4,7 @@ import { PromiseOrValue } from '../jsutils/PromiseOrValue';
4
4
  import { Path } from '../jsutils/Path';
5
5
 
6
6
  import { GraphQLError } from '../error/GraphQLError';
7
+ import { GraphQLFormattedError } from '../error/formatError';
7
8
 
8
9
  import {
9
10
  DocumentNode,
@@ -55,6 +56,16 @@ export interface ExecutionResult<
55
56
  extensions?: TExtensions;
56
57
  }
57
58
 
59
+ export interface FormattedExecutionResult<
60
+ TData = { [key: string]: any },
61
+ TExtensions = { [key: string]: any }
62
+ > {
63
+ errors?: ReadonlyArray<GraphQLFormattedError>;
64
+ // TS_SPECIFIC: TData. Motivation: https://github.com/graphql/graphql-js/pull/2490#issuecomment-639154229
65
+ data?: TData | null;
66
+ extensions?: TExtensions;
67
+ }
68
+
58
69
  export interface ExecutionArgs {
59
70
  schema: GraphQLSchema;
60
71
  document: DocumentNode;
@@ -840,12 +840,12 @@ var defaultFieldResolver = function defaultFieldResolver(source, args, contextVa
840
840
  };
841
841
  /**
842
842
  * This method looks up the field on the given type definition.
843
- * It has special casing for the two introspection fields, __schema
844
- * and __typename. __typename is special because it can always be
845
- * queried as a field, even in situations where no other fields
846
- * are allowed, like on a Union. __schema could get automatically
847
- * added to the query type, but that would require mutating type
848
- * definitions, which would cause issues.
843
+ * It has special casing for the three introspection fields,
844
+ * __schema, __type and __typename. __typename is special because
845
+ * it can always be queried as a field, even in situations where no
846
+ * other fields are allowed, like on a Union. __schema and __type
847
+ * could get automatically added to the query type, but that would
848
+ * require mutating type definitions, which would cause issues.
849
849
  *
850
850
  * @internal
851
851
  */
@@ -16,6 +16,7 @@ import promiseReduce from '../jsutils/promiseReduce';
16
16
  import promiseForObject from '../jsutils/promiseForObject';
17
17
  import { addPath, pathToArray } from '../jsutils/Path';
18
18
 
19
+ import type { GraphQLFormattedError } from '../error/formatError';
19
20
  import { GraphQLError } from '../error/GraphQLError';
20
21
  import { locatedError } from '../error/locatedError';
21
22
 
@@ -120,6 +121,12 @@ export type ExecutionResult = {|
120
121
  extensions?: ObjMap<mixed>,
121
122
  |};
122
123
 
124
+ export type FormattedExecutionResult = {|
125
+ errors?: $ReadOnlyArray<GraphQLFormattedError>,
126
+ data?: ObjMap<mixed> | null,
127
+ extensions?: ObjMap<mixed>,
128
+ |};
129
+
123
130
  export type ExecutionArgs = {|
124
131
  schema: GraphQLSchema,
125
132
  document: DocumentNode,
@@ -1222,12 +1229,12 @@ export const defaultFieldResolver: GraphQLFieldResolver<
1222
1229
 
1223
1230
  /**
1224
1231
  * This method looks up the field on the given type definition.
1225
- * It has special casing for the two introspection fields, __schema
1226
- * and __typename. __typename is special because it can always be
1227
- * queried as a field, even in situations where no other fields
1228
- * are allowed, like on a Union. __schema could get automatically
1229
- * added to the query type, but that would require mutating type
1230
- * definitions, which would cause issues.
1232
+ * It has special casing for the three introspection fields,
1233
+ * __schema, __type and __typename. __typename is special because
1234
+ * it can always be queried as a field, even in situations where no
1235
+ * other fields are allowed, like on a Union. __schema and __type
1236
+ * could get automatically added to the query type, but that would
1237
+ * require mutating type definitions, which would cause issues.
1231
1238
  *
1232
1239
  * @internal
1233
1240
  */
@@ -820,12 +820,12 @@ export var defaultFieldResolver = function defaultFieldResolver(source, args, co
820
820
  };
821
821
  /**
822
822
  * This method looks up the field on the given type definition.
823
- * It has special casing for the two introspection fields, __schema
824
- * and __typename. __typename is special because it can always be
825
- * queried as a field, even in situations where no other fields
826
- * are allowed, like on a Union. __schema could get automatically
827
- * added to the query type, but that would require mutating type
828
- * definitions, which would cause issues.
823
+ * It has special casing for the three introspection fields,
824
+ * __schema, __type and __typename. __typename is special because
825
+ * it can always be queried as a field, even in situations where no
826
+ * other fields are allowed, like on a Union. __schema and __type
827
+ * could get automatically added to the query type, but that would
828
+ * require mutating type definitions, which would cause issues.
829
829
  *
830
830
  * @internal
831
831
  */
@@ -7,6 +7,7 @@ export {
7
7
  defaultTypeResolver,
8
8
  ExecutionArgs,
9
9
  ExecutionResult,
10
+ FormattedExecutionResult,
10
11
  } from './execute';
11
12
 
12
13
  export { getDirectiveValues } from './values';
@@ -8,6 +8,11 @@ export {
8
8
  defaultFieldResolver,
9
9
  defaultTypeResolver,
10
10
  } from './execute';
11
- export type { ExecutionArgs, ExecutionResult } from './execute';
11
+
12
+ export type {
13
+ ExecutionArgs,
14
+ ExecutionResult,
15
+ FormattedExecutionResult,
16
+ } from './execute';
12
17
 
13
18
  export { getDirectiveValues } from './values';
package/index.d.ts CHANGED
@@ -299,6 +299,7 @@ export {
299
299
  getDirectiveValues,
300
300
  ExecutionArgs,
301
301
  ExecutionResult,
302
+ FormattedExecutionResult,
302
303
  } from './execution/index';
303
304
 
304
305
  export {
package/index.js.flow CHANGED
@@ -288,7 +288,11 @@ export {
288
288
  getDirectiveValues,
289
289
  } from './execution/index';
290
290
 
291
- export type { ExecutionArgs, ExecutionResult } from './execution/index';
291
+ export type {
292
+ ExecutionArgs,
293
+ ExecutionResult,
294
+ FormattedExecutionResult,
295
+ } from './execution/index';
292
296
 
293
297
  export { subscribe, createSourceEventStream } from './subscription/index';
294
298
  export type { SubscriptionArgs } from './subscription/index';
@@ -4,12 +4,11 @@ interface Location {
4
4
  }
5
5
 
6
6
  /**
7
- * A representation of source input to GraphQL.
8
- * `name` and `locationOffset` are optional. They are useful for clients who
9
- * store GraphQL documents in source files; for example, if the GraphQL input
10
- * starts at line 40 in a file named Foo.graphql, it might be useful for name to
11
- * be "Foo.graphql" and location to be `{ line: 40, column: 0 }`.
12
- * line and column in locationOffset are 1-indexed
7
+ * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
8
+ * optional, but they are useful for clients who store GraphQL documents in source files.
9
+ * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
10
+ * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
11
+ * The `line` and `column` properties in `locationOffset` are 1-indexed.
13
12
  */
14
13
  export class Source {
15
14
  body: string;
@@ -16,12 +16,11 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
16
16
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
17
17
 
18
18
  /**
19
- * A representation of source input to GraphQL.
20
- * `name` and `locationOffset` are optional. They are useful for clients who
21
- * store GraphQL documents in source files; for example, if the GraphQL input
22
- * starts at line 40 in a file named Foo.graphql, it might be useful for name to
23
- * be "Foo.graphql" and location to be `{ line: 40, column: 0 }`.
24
- * line and column in locationOffset are 1-indexed
19
+ * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
20
+ * optional, but they are useful for clients who store GraphQL documents in source files.
21
+ * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
22
+ * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
23
+ * The `line` and `column` properties in `locationOffset` are 1-indexed.
25
24
  */
26
25
  var Source = /*#__PURE__*/function () {
27
26
  function Source(body) {
@@ -10,12 +10,11 @@ type Location = {|
10
10
  |};
11
11
 
12
12
  /**
13
- * A representation of source input to GraphQL.
14
- * `name` and `locationOffset` are optional. They are useful for clients who
15
- * store GraphQL documents in source files; for example, if the GraphQL input
16
- * starts at line 40 in a file named Foo.graphql, it might be useful for name to
17
- * be "Foo.graphql" and location to be `{ line: 40, column: 0 }`.
18
- * line and column in locationOffset are 1-indexed
13
+ * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
14
+ * optional, but they are useful for clients who store GraphQL documents in source files.
15
+ * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
16
+ * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
17
+ * The `line` and `column` properties in `locationOffset` are 1-indexed.
19
18
  */
20
19
  export class Source {
21
20
  body: string;
@@ -6,12 +6,11 @@ import { SYMBOL_TO_STRING_TAG } from "../polyfills/symbols.mjs";
6
6
  import devAssert from "../jsutils/devAssert.mjs";
7
7
 
8
8
  /**
9
- * A representation of source input to GraphQL.
10
- * `name` and `locationOffset` are optional. They are useful for clients who
11
- * store GraphQL documents in source files; for example, if the GraphQL input
12
- * starts at line 40 in a file named Foo.graphql, it might be useful for name to
13
- * be "Foo.graphql" and location to be `{ line: 40, column: 0 }`.
14
- * line and column in locationOffset are 1-indexed
9
+ * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
10
+ * optional, but they are useful for clients who store GraphQL documents in source files.
11
+ * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
12
+ * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
13
+ * The `line` and `column` properties in `locationOffset` are 1-indexed.
15
14
  */
16
15
  export var Source = /*#__PURE__*/function () {
17
16
  function Source(body) {
@@ -151,7 +151,7 @@ export const QueryDocumentKeys: {
151
151
  export const BREAK: any;
152
152
 
153
153
  /**
154
- * visit() will walk through an AST using a depth first traversal, calling
154
+ * visit() will walk through an AST using a depth-first traversal, calling
155
155
  * the visitor's enter function at each node in the traversal, and calling the
156
156
  * leave function after visiting that node and all of its child nodes.
157
157
  *
@@ -185,10 +185,10 @@ export const BREAK: any;
185
185
  *
186
186
  * Alternatively to providing enter() and leave() functions, a visitor can
187
187
  * instead provide functions named the same as the kinds of AST nodes, or
188
- * enter/leave visitors at a named key, leading to four permutations of
188
+ * enter/leave visitors at a named key, leading to four permutations of the
189
189
  * visitor API:
190
190
  *
191
- * 1) Named visitors triggered when entering a node a specific kind.
191
+ * 1) Named visitors triggered when entering a node of a specific kind.
192
192
  *
193
193
  * visit(ast, {
194
194
  * Kind(node) {
@@ -64,7 +64,7 @@ var QueryDocumentKeys = {
64
64
  exports.QueryDocumentKeys = QueryDocumentKeys;
65
65
  var BREAK = Object.freeze({});
66
66
  /**
67
- * visit() will walk through an AST using a depth first traversal, calling
67
+ * visit() will walk through an AST using a depth-first traversal, calling
68
68
  * the visitor's enter function at each node in the traversal, and calling the
69
69
  * leave function after visiting that node and all of its child nodes.
70
70
  *
@@ -98,10 +98,10 @@ var BREAK = Object.freeze({});
98
98
  *
99
99
  * Alternatively to providing enter() and leave() functions, a visitor can
100
100
  * instead provide functions named the same as the kinds of AST nodes, or
101
- * enter/leave visitors at a named key, leading to four permutations of
101
+ * enter/leave visitors at a named key, leading to four permutations of the
102
102
  * visitor API:
103
103
  *
104
- * 1) Named visitors triggered when entering a node a specific kind.
104
+ * 1) Named visitors triggered when entering a node of a specific kind.
105
105
  *
106
106
  * visit(ast, {
107
107
  * Kind(node) {
@@ -139,7 +139,7 @@ export const QueryDocumentKeys: VisitorKeyMap<ASTKindToNode> = {
139
139
  export const BREAK: { ... } = Object.freeze({});
140
140
 
141
141
  /**
142
- * visit() will walk through an AST using a depth first traversal, calling
142
+ * visit() will walk through an AST using a depth-first traversal, calling
143
143
  * the visitor's enter function at each node in the traversal, and calling the
144
144
  * leave function after visiting that node and all of its child nodes.
145
145
  *
@@ -173,10 +173,10 @@ export const BREAK: { ... } = Object.freeze({});
173
173
  *
174
174
  * Alternatively to providing enter() and leave() functions, a visitor can
175
175
  * instead provide functions named the same as the kinds of AST nodes, or
176
- * enter/leave visitors at a named key, leading to four permutations of
176
+ * enter/leave visitors at a named key, leading to four permutations of the
177
177
  * visitor API:
178
178
  *
179
- * 1) Named visitors triggered when entering a node a specific kind.
179
+ * 1) Named visitors triggered when entering a node of a specific kind.
180
180
  *
181
181
  * visit(ast, {
182
182
  * Kind(node) {
@@ -54,7 +54,7 @@ export var QueryDocumentKeys = {
54
54
  };
55
55
  export var BREAK = Object.freeze({});
56
56
  /**
57
- * visit() will walk through an AST using a depth first traversal, calling
57
+ * visit() will walk through an AST using a depth-first traversal, calling
58
58
  * the visitor's enter function at each node in the traversal, and calling the
59
59
  * leave function after visiting that node and all of its child nodes.
60
60
  *
@@ -88,10 +88,10 @@ export var BREAK = Object.freeze({});
88
88
  *
89
89
  * Alternatively to providing enter() and leave() functions, a visitor can
90
90
  * instead provide functions named the same as the kinds of AST nodes, or
91
- * enter/leave visitors at a named key, leading to four permutations of
91
+ * enter/leave visitors at a named key, leading to four permutations of the
92
92
  * visitor API:
93
93
  *
94
- * 1) Named visitors triggered when entering a node a specific kind.
94
+ * 1) Named visitors triggered when entering a node of a specific kind.
95
95
  *
96
96
  * visit(ast, {
97
97
  * Kind(node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql",
3
- "version": "15.2.0",
3
+ "version": "15.3.0",
4
4
  "description": "A Query Language and Runtime which can target any service.",
5
5
  "license": "MIT",
6
6
  "main": "index",
@@ -23,4 +23,4 @@
23
23
  "node": ">= 10.x"
24
24
  },
25
25
  "dependencies": {}
26
- }
26
+ }
@@ -241,15 +241,13 @@ export function isNullableType(type: any): type is GraphQLNullableType;
241
241
 
242
242
  export function assertNullableType(type: any): GraphQLNullableType;
243
243
 
244
- // FIXME Disabled because of https://github.com/yaacovCR/graphql-tools-fork/issues/40#issuecomment-586671219
245
- // tslint:disable:unified-signatures
246
244
  export function getNullableType(type: undefined): undefined;
247
245
  export function getNullableType<T extends GraphQLNullableType>(type: T): T;
248
246
  export function getNullableType<T extends GraphQLNullableType>(
247
+ // FIXME Disabled because of https://github.com/yaacovCR/graphql-tools-fork/issues/40#issuecomment-586671219
249
248
  // eslint-disable-next-line @typescript-eslint/unified-signatures
250
249
  type: GraphQLNonNull<T>,
251
250
  ): T;
252
- // tslint:enable:unified-signatures
253
251
 
254
252
  /**
255
253
  * These named types do not include modifiers like List or NonNull.
package/version.js CHANGED
@@ -13,7 +13,7 @@ exports.versionInfo = exports.version = void 0;
13
13
  /**
14
14
  * A string containing the version of the GraphQL.js library
15
15
  */
16
- var version = '15.2.0';
16
+ var version = '15.3.0';
17
17
  /**
18
18
  * An object containing the components of the GraphQL.js version string
19
19
  */
@@ -21,7 +21,7 @@ var version = '15.2.0';
21
21
  exports.version = version;
22
22
  var versionInfo = Object.freeze({
23
23
  major: 15,
24
- minor: 2,
24
+ minor: 3,
25
25
  patch: 0,
26
26
  preReleaseTag: null
27
27
  });
package/version.js.flow CHANGED
@@ -8,14 +8,14 @@
8
8
  /**
9
9
  * A string containing the version of the GraphQL.js library
10
10
  */
11
- export const version = '15.2.0';
11
+ export const version = '15.3.0';
12
12
 
13
13
  /**
14
14
  * An object containing the components of the GraphQL.js version string
15
15
  */
16
16
  export const versionInfo = Object.freeze({
17
17
  major: 15,
18
- minor: 2,
18
+ minor: 3,
19
19
  patch: 0,
20
20
  preReleaseTag: null,
21
21
  });
package/version.mjs CHANGED
@@ -6,14 +6,14 @@
6
6
  /**
7
7
  * A string containing the version of the GraphQL.js library
8
8
  */
9
- export var version = '15.2.0';
9
+ export var version = '15.3.0';
10
10
  /**
11
11
  * An object containing the components of the GraphQL.js version string
12
12
  */
13
13
 
14
14
  export var versionInfo = Object.freeze({
15
15
  major: 15,
16
- minor: 2,
16
+ minor: 3,
17
17
  patch: 0,
18
18
  preReleaseTag: null
19
19
  });