@apollo/gateway 2.0.0-preview.9 → 2.0.2-alpha.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.
Files changed (77) hide show
  1. package/dist/config.d.ts +2 -1
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js.map +1 -1
  4. package/dist/datasources/RemoteGraphQLDataSource.js +2 -2
  5. package/dist/datasources/RemoteGraphQLDataSource.js.map +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +5 -3
  8. package/dist/index.js.map +1 -1
  9. package/dist/schema-helper/addExtensions.d.ts +3 -0
  10. package/dist/schema-helper/addExtensions.d.ts.map +1 -0
  11. package/dist/schema-helper/addExtensions.js +20 -0
  12. package/dist/schema-helper/addExtensions.js.map +1 -0
  13. package/dist/supergraphManagers/IntrospectAndCompose/index.d.ts +1 -1
  14. package/dist/supergraphManagers/IntrospectAndCompose/index.d.ts.map +1 -1
  15. package/dist/supergraphManagers/LegacyFetcher/index.d.ts +1 -1
  16. package/dist/supergraphManagers/LegacyFetcher/index.d.ts.map +1 -1
  17. package/dist/supergraphManagers/LocalCompose/index.d.ts +1 -1
  18. package/dist/supergraphManagers/LocalCompose/index.d.ts.map +1 -1
  19. package/dist/supergraphManagers/UplinkFetcher/index.d.ts +1 -1
  20. package/dist/supergraphManagers/UplinkFetcher/index.d.ts.map +1 -1
  21. package/dist/typings/graphql.d.ts +34 -0
  22. package/dist/typings/graphql.d.ts.map +1 -0
  23. package/dist/{schema-helper/resolverMap.js → typings/graphql.js} +1 -1
  24. package/dist/typings/graphql.js.map +1 -0
  25. package/package.json +10 -8
  26. package/src/__tests__/executeQueryPlan.test.ts +4 -1
  27. package/src/__tests__/execution-utils.ts +5 -4
  28. package/src/__tests__/gateway/endToEnd.test.ts +364 -41
  29. package/src/__tests__/gateway/executor.test.ts +1 -1
  30. package/src/__tests__/gateway/extensions.test.ts +37 -0
  31. package/src/__tests__/gateway/lifecycle-hooks.test.ts +2 -2
  32. package/src/__tests__/gateway/reporting.test.ts +1 -1
  33. package/src/__tests__/gateway/supergraphSdl.test.ts +2 -2
  34. package/src/__tests__/integration/configuration.test.ts +1 -1
  35. package/src/__tests__/integration/logger.test.ts +1 -1
  36. package/src/__tests__/integration/networkRequests.test.ts +1 -1
  37. package/src/config.ts +2 -4
  38. package/src/datasources/RemoteGraphQLDataSource.ts +2 -2
  39. package/src/datasources/__tests__/LocalGraphQLDataSource.test.ts +1 -1
  40. package/src/index.ts +13 -5
  41. package/src/schema-helper/__tests__/addExtensions.test.ts +11 -0
  42. package/src/schema-helper/addExtensions.ts +17 -0
  43. package/src/supergraphManagers/IntrospectAndCompose/__tests__/IntrospectAndCompose.test.ts +1 -1
  44. package/src/supergraphManagers/IntrospectAndCompose/index.ts +1 -1
  45. package/src/supergraphManagers/LegacyFetcher/index.ts +1 -1
  46. package/src/supergraphManagers/LocalCompose/index.ts +1 -1
  47. package/src/supergraphManagers/UplinkFetcher/index.ts +1 -1
  48. package/src/typings/graphql.ts +43 -0
  49. package/dist/schema-helper/addResolversToSchema.d.ts +0 -4
  50. package/dist/schema-helper/addResolversToSchema.d.ts.map +0 -1
  51. package/dist/schema-helper/addResolversToSchema.js +0 -62
  52. package/dist/schema-helper/addResolversToSchema.js.map +0 -1
  53. package/dist/schema-helper/error.d.ts +0 -6
  54. package/dist/schema-helper/error.d.ts.map +0 -1
  55. package/dist/schema-helper/error.js +0 -14
  56. package/dist/schema-helper/error.js.map +0 -1
  57. package/dist/schema-helper/index.d.ts +0 -4
  58. package/dist/schema-helper/index.d.ts.map +0 -1
  59. package/dist/schema-helper/index.js +0 -20
  60. package/dist/schema-helper/index.js.map +0 -1
  61. package/dist/schema-helper/resolverMap.d.ts +0 -16
  62. package/dist/schema-helper/resolverMap.d.ts.map +0 -1
  63. package/dist/schema-helper/resolverMap.js.map +0 -1
  64. package/dist/utilities/createHash.d.ts +0 -2
  65. package/dist/utilities/createHash.d.ts.map +0 -1
  66. package/dist/utilities/createHash.js +0 -15
  67. package/dist/utilities/createHash.js.map +0 -1
  68. package/dist/utilities/isNodeLike.d.ts +0 -3
  69. package/dist/utilities/isNodeLike.d.ts.map +0 -1
  70. package/dist/utilities/isNodeLike.js +0 -8
  71. package/dist/utilities/isNodeLike.js.map +0 -1
  72. package/src/schema-helper/addResolversToSchema.ts +0 -83
  73. package/src/schema-helper/error.ts +0 -11
  74. package/src/schema-helper/index.ts +0 -3
  75. package/src/schema-helper/resolverMap.ts +0 -23
  76. package/src/utilities/createHash.ts +0 -10
  77. package/src/utilities/isNodeLike.ts +0 -11
@@ -1,4 +1,4 @@
1
- import { Logger } from 'apollo-server-types';
1
+ import type { Logger } from '@apollo/utils.logger';
2
2
  import { HeadersInit } from 'node-fetch';
3
3
  import resolvable from '@josephg/resolvable';
4
4
  import {
@@ -4,7 +4,7 @@
4
4
  * configuration options of the gateway and will be removed in a future release
5
5
  * along with those options.
6
6
  */
7
- import { Logger } from 'apollo-server-types';
7
+ import type { Logger } from '@apollo/utils.logger';
8
8
  import resolvable from '@josephg/resolvable';
9
9
  import {
10
10
  SupergraphManager,
@@ -1,5 +1,5 @@
1
1
  // TODO(trevor:removeServiceList) the whole file goes away
2
- import { Logger } from 'apollo-server-types';
2
+ import type { Logger } from '@apollo/utils.logger';
3
3
  import { composeServices } from '@apollo/composition';
4
4
  import {
5
5
  GetDataSourceFunction,
@@ -1,5 +1,5 @@
1
1
  import { fetch } from 'apollo-server-env';
2
- import { Logger } from 'apollo-server-types';
2
+ import type { Logger } from '@apollo/utils.logger';
3
3
  import resolvable from '@josephg/resolvable';
4
4
  import { SupergraphManager, SupergraphSdlHookOptions } from '../../config';
5
5
  import { SubgraphHealthCheckFunction, SupergraphSdlUpdateFunction } from '../..';
@@ -0,0 +1,43 @@
1
+ import { GraphQLResolveInfo } from 'graphql';
2
+
3
+ type GraphQLReferenceResolver<TContext> = (
4
+ reference: object,
5
+ context: TContext,
6
+ info: GraphQLResolveInfo,
7
+ ) => any;
8
+
9
+ interface ApolloSubgraphExtensions<TContext> {
10
+ resolveReference?: GraphQLReferenceResolver<TContext>;
11
+ }
12
+
13
+ interface ApolloGatewayExtensions {
14
+ version?: String;
15
+ }
16
+
17
+ declare module 'graphql/type/definition' {
18
+ interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
19
+ apollo?: {
20
+ subgraph?: ApolloSubgraphExtensions<_TContext>;
21
+ }
22
+ }
23
+
24
+ interface GraphQLInterfaceTypeExtensions<_TSource = any, _TContext = any> {
25
+ apollo?: {
26
+ subgraph?: ApolloSubgraphExtensions<_TContext>;
27
+ }
28
+ }
29
+
30
+ interface GraphQLUnionTypeExtensions<_TSource = any, _TContext = any> {
31
+ apollo?: {
32
+ subgraph?: ApolloSubgraphExtensions<_TContext>;
33
+ }
34
+ }
35
+ }
36
+
37
+ declare module 'graphql/type/schema' {
38
+ interface GraphQLSchemaExtensions {
39
+ apollo?: {
40
+ gateway?: ApolloGatewayExtensions;
41
+ }
42
+ }
43
+ }
@@ -1,4 +0,0 @@
1
- import { GraphQLSchema } from 'graphql';
2
- import { GraphQLResolverMap } from './resolverMap';
3
- export declare function addResolversToSchema(schema: GraphQLSchema, resolvers: GraphQLResolverMap<any>): void;
4
- //# sourceMappingURL=addResolversToSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addResolversToSchema.d.ts","sourceRoot":"","sources":["../../src/schema-helper/addResolversToSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAOd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,kBAAkB,CAAC,GAAG,CAAC,QAoEnC"}
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addResolversToSchema = void 0;
4
- const graphql_1 = require("graphql");
5
- function addResolversToSchema(schema, resolvers) {
6
- for (const [typeName, fieldConfigs] of Object.entries(resolvers)) {
7
- const type = schema.getType(typeName);
8
- if ((0, graphql_1.isAbstractType)(type)) {
9
- for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
10
- if (fieldName.startsWith("__")) {
11
- type[fieldName.substring(2)] = fieldConfig;
12
- }
13
- }
14
- }
15
- if ((0, graphql_1.isScalarType)(type)) {
16
- for (const fn in fieldConfigs) {
17
- type[fn] = fieldConfigs[fn];
18
- }
19
- }
20
- if ((0, graphql_1.isEnumType)(type)) {
21
- const values = type.getValues();
22
- const newValues = {};
23
- values.forEach(value => {
24
- let newValue = fieldConfigs[value.name];
25
- if (newValue === undefined) {
26
- newValue = value.name;
27
- }
28
- newValues[value.name] = {
29
- value: newValue,
30
- deprecationReason: value.deprecationReason,
31
- description: value.description,
32
- astNode: value.astNode,
33
- extensions: undefined
34
- };
35
- });
36
- Object.assign(type, new graphql_1.GraphQLEnumType({
37
- ...type.toConfig(),
38
- values: newValues
39
- }));
40
- }
41
- if (!(0, graphql_1.isObjectType)(type))
42
- continue;
43
- const fieldMap = type.getFields();
44
- for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
45
- if (fieldName.startsWith("__")) {
46
- type[fieldName.substring(2)] = fieldConfig;
47
- continue;
48
- }
49
- const field = fieldMap[fieldName];
50
- if (!field)
51
- continue;
52
- if (typeof fieldConfig === "function") {
53
- field.resolve = fieldConfig;
54
- }
55
- else {
56
- field.resolve = fieldConfig.resolve;
57
- }
58
- }
59
- }
60
- }
61
- exports.addResolversToSchema = addResolversToSchema;
62
- //# sourceMappingURL=addResolversToSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addResolversToSchema.js","sourceRoot":"","sources":["../../src/schema-helper/addResolversToSchema.ts"],"names":[],"mappings":";;;AAAA,qCAQiB;AAIjB,SAAgB,oBAAoB,CAClC,MAAqB,EACrB,SAAkC;IAElC,KAAK,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAChE,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEtC,IAAI,IAAA,wBAAc,EAAC,IAAI,CAAC,EAAE;YACxB,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;gBACnE,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;oBAC7B,IAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;iBACrD;aACF;SACF;QAED,IAAI,IAAA,sBAAY,EAAC,IAAI,CAAC,EAAE;YACtB,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE;gBAC5B,IAAY,CAAC,EAAE,CAAC,GAAI,YAAoB,CAAC,EAAE,CAAC,CAAC;aAC/C;SACF;QAED,IAAI,IAAA,oBAAU,EAAC,IAAI,CAAC,EAAE;YACpB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAChC,MAAM,SAAS,GAA8C,EAAE,CAAC;YAChE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACrB,IAAI,QAAQ,GAAI,YAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACjD,IAAI,QAAQ,KAAK,SAAS,EAAE;oBAC1B,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC;iBACvB;gBAED,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG;oBACtB,KAAK,EAAE,QAAQ;oBACf,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;oBAC1C,WAAW,EAAE,KAAK,CAAC,WAAW;oBAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,UAAU,EAAE,SAAS;iBACtB,CAAC;YACJ,CAAC,CAAC,CAAC;YAIH,MAAM,CAAC,MAAM,CACX,IAAI,EACJ,IAAI,yBAAe,CAAC;gBAClB,GAAG,IAAI,CAAC,QAAQ,EAAE;gBAClB,MAAM,EAAE,SAAS;aAClB,CAAC,CACH,CAAC;SACH;QAED,IAAI,CAAC,IAAA,sBAAY,EAAC,IAAI,CAAC;YAAE,SAAS;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAElC,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;YACnE,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBAC7B,IAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;gBACpD,SAAS;aACV;YAED,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;YAClC,IAAI,CAAC,KAAK;gBAAE,SAAS;YAErB,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;gBACrC,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC;aAC7B;iBAAM;gBACL,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;aACrC;SACF;KACF;AACH,CAAC;AAtED,oDAsEC"}
@@ -1,6 +0,0 @@
1
- import { GraphQLError } from "graphql";
2
- export declare class GraphQLSchemaValidationError extends Error {
3
- errors: ReadonlyArray<GraphQLError>;
4
- constructor(errors: ReadonlyArray<GraphQLError>);
5
- }
6
- //# sourceMappingURL=error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/schema-helper/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,qBAAa,4BAA6B,SAAQ,KAAK;IAClC,MAAM,EAAE,aAAa,CAAC,YAAY,CAAC;gBAAnC,MAAM,EAAE,aAAa,CAAC,YAAY,CAAC;CAOvD"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GraphQLSchemaValidationError = void 0;
4
- class GraphQLSchemaValidationError extends Error {
5
- constructor(errors) {
6
- super();
7
- this.errors = errors;
8
- this.name = this.constructor.name;
9
- Error.captureStackTrace(this, this.constructor);
10
- this.message = errors.map(error => error.message).join("\n\n");
11
- }
12
- }
13
- exports.GraphQLSchemaValidationError = GraphQLSchemaValidationError;
14
- //# sourceMappingURL=error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/schema-helper/error.ts"],"names":[],"mappings":";;;AAEA,MAAa,4BAA6B,SAAQ,KAAK;IACrD,YAAmB,MAAmC;QACpD,KAAK,EAAE,CAAC;QADS,WAAM,GAAN,MAAM,CAA6B;QAGpD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;CACF;AARD,oEAQC"}
@@ -1,4 +0,0 @@
1
- export * from './resolverMap';
2
- export * from './addResolversToSchema';
3
- export * from './error';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema-helper/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./resolverMap"), exports);
18
- __exportStar(require("./addResolversToSchema"), exports);
19
- __exportStar(require("./error"), exports);
20
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema-helper/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,yDAAuC;AACvC,0CAAwB"}
@@ -1,16 +0,0 @@
1
- import { GraphQLFieldResolver, GraphQLScalarType, DocumentNode } from 'graphql';
2
- export interface GraphQLSchemaModule {
3
- typeDefs: DocumentNode;
4
- resolvers?: GraphQLResolverMap<any>;
5
- }
6
- export interface GraphQLResolverMap<TContext = {}> {
7
- [typeName: string]: {
8
- [fieldName: string]: GraphQLFieldResolver<any, TContext> | {
9
- requires?: string;
10
- resolve: GraphQLFieldResolver<any, TContext>;
11
- };
12
- } | GraphQLScalarType | {
13
- [enumValue: string]: string | number;
14
- };
15
- }
16
- //# sourceMappingURL=resolverMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolverMap.d.ts","sourceRoot":"","sources":["../../src/schema-helper/resolverMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEhF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,CAAC,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC;CACrC;AAGD,MAAM,WAAW,kBAAkB,CAAC,QAAQ,GAAG,EAAE;IAC/C,CAAC,QAAQ,EAAE,MAAM,GACb;QACE,CAAC,SAAS,EAAE,MAAM,GACd,oBAAoB,CAAC,GAAG,EAAE,QAAQ,CAAC,GACnC;YACE,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,OAAO,EAAE,oBAAoB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;SAC9C,CAAC;KACP,GACD,iBAAiB,GACjB;QACE,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;KACtC,CAAC;CACP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolverMap.js","sourceRoot":"","sources":["../../src/schema-helper/resolverMap.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export declare function createHash(kind: string): import('crypto').Hash;
2
- //# sourceMappingURL=createHash.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createHash.d.ts","sourceRoot":"","sources":["../../src/utilities/createHash.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,QAAQ,EAAE,IAAI,CAO/D"}
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createHash = void 0;
7
- const isNodeLike_1 = __importDefault(require("./isNodeLike"));
8
- function createHash(kind) {
9
- if (isNodeLike_1.default) {
10
- return module.require('crypto').createHash(kind);
11
- }
12
- return require('sha.js')(kind);
13
- }
14
- exports.createHash = createHash;
15
- //# sourceMappingURL=createHash.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createHash.js","sourceRoot":"","sources":["../../src/utilities/createHash.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAsC;AAEtC,SAAgB,UAAU,CAAE,IAAY;IACtC,IAAI,oBAAU,EAAE;QAGd,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;KAClD;IACD,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAPD,gCAOC"}
@@ -1,3 +0,0 @@
1
- declare const _default: boolean;
2
- export default _default;
3
- //# sourceMappingURL=isNodeLike.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isNodeLike.d.ts","sourceRoot":"","sources":["../../src/utilities/isNodeLike.ts"],"names":[],"mappings":";AAAA,wBAU4C"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = typeof process === 'object' &&
4
- process &&
5
- process.release &&
6
- process.versions &&
7
- typeof process.versions.node === 'string';
8
- //# sourceMappingURL=isNodeLike.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isNodeLike.js","sourceRoot":"","sources":["../../src/utilities/isNodeLike.ts"],"names":[],"mappings":";;AAAA,kBAAe,OAAO,OAAO,KAAK,QAAQ;IACxC,OAAO;IAKP,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,QAAQ;IAGhB,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC"}
@@ -1,83 +0,0 @@
1
- import {
2
- GraphQLSchema,
3
- isObjectType,
4
- GraphQLEnumType,
5
- isAbstractType,
6
- isScalarType,
7
- isEnumType,
8
- GraphQLEnumValueConfig,
9
- } from 'graphql';
10
-
11
- import { GraphQLResolverMap } from './resolverMap';
12
-
13
- export function addResolversToSchema(
14
- schema: GraphQLSchema,
15
- resolvers: GraphQLResolverMap<any>
16
- ) {
17
- for (const [typeName, fieldConfigs] of Object.entries(resolvers)) {
18
- const type = schema.getType(typeName);
19
-
20
- if (isAbstractType(type)) {
21
- for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
22
- if (fieldName.startsWith("__")) {
23
- (type as any)[fieldName.substring(2)] = fieldConfig;
24
- }
25
- }
26
- }
27
-
28
- if (isScalarType(type)) {
29
- for (const fn in fieldConfigs) {
30
- (type as any)[fn] = (fieldConfigs as any)[fn];
31
- }
32
- }
33
-
34
- if (isEnumType(type)) {
35
- const values = type.getValues();
36
- const newValues: { [key: string]: GraphQLEnumValueConfig } = {};
37
- values.forEach(value => {
38
- let newValue = (fieldConfigs as any)[value.name];
39
- if (newValue === undefined) {
40
- newValue = value.name;
41
- }
42
-
43
- newValues[value.name] = {
44
- value: newValue,
45
- deprecationReason: value.deprecationReason,
46
- description: value.description,
47
- astNode: value.astNode,
48
- extensions: undefined
49
- };
50
- });
51
-
52
- // In place updating hack to get around pulling in the full
53
- // schema walking and immutable updating machinery from graphql-tools
54
- Object.assign(
55
- type,
56
- new GraphQLEnumType({
57
- ...type.toConfig(),
58
- values: newValues
59
- })
60
- );
61
- }
62
-
63
- if (!isObjectType(type)) continue;
64
-
65
- const fieldMap = type.getFields();
66
-
67
- for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
68
- if (fieldName.startsWith("__")) {
69
- (type as any)[fieldName.substring(2)] = fieldConfig;
70
- continue;
71
- }
72
-
73
- const field = fieldMap[fieldName];
74
- if (!field) continue;
75
-
76
- if (typeof fieldConfig === "function") {
77
- field.resolve = fieldConfig;
78
- } else {
79
- field.resolve = fieldConfig.resolve;
80
- }
81
- }
82
- }
83
- }
@@ -1,11 +0,0 @@
1
- import { GraphQLError } from "graphql";
2
-
3
- export class GraphQLSchemaValidationError extends Error {
4
- constructor(public errors: ReadonlyArray<GraphQLError>) {
5
- super();
6
-
7
- this.name = this.constructor.name;
8
- Error.captureStackTrace(this, this.constructor);
9
- this.message = errors.map(error => error.message).join("\n\n");
10
- }
11
- }
@@ -1,3 +0,0 @@
1
- export * from './resolverMap';
2
- export * from './addResolversToSchema';
3
- export * from './error';
@@ -1,23 +0,0 @@
1
- import { GraphQLFieldResolver, GraphQLScalarType, DocumentNode } from 'graphql';
2
-
3
- export interface GraphQLSchemaModule {
4
- typeDefs: DocumentNode;
5
- resolvers?: GraphQLResolverMap<any>;
6
- }
7
-
8
- // eslint-disable-next-line @typescript-eslint/ban-types
9
- export interface GraphQLResolverMap<TContext = {}> {
10
- [typeName: string]:
11
- | {
12
- [fieldName: string]:
13
- | GraphQLFieldResolver<any, TContext>
14
- | {
15
- requires?: string;
16
- resolve: GraphQLFieldResolver<any, TContext>;
17
- };
18
- }
19
- | GraphQLScalarType
20
- | {
21
- [enumValue: string]: string | number;
22
- };
23
- }
@@ -1,10 +0,0 @@
1
- import isNodeLike from './isNodeLike';
2
-
3
- export function createHash (kind: string): import('crypto').Hash {
4
- if (isNodeLike) {
5
- // Use module.require instead of just require to avoid bundling whatever
6
- // crypto polyfills a non-Node bundler might fall back to.
7
- return module.require('crypto').createHash(kind);
8
- }
9
- return require('sha.js')(kind);
10
- }
@@ -1,11 +0,0 @@
1
- export default typeof process === 'object' &&
2
- process &&
3
- // We used to check `process.release.name === "node"`, however that doesn't
4
- // account for certain forks of Node.js which are otherwise identical to
5
- // Node.js. For example, NodeSource's N|Solid reports itself as "nsolid",
6
- // though it's mostly the same build of Node.js with an extra addon.
7
- process.release &&
8
- process.versions &&
9
- // The one thing which is present on both Node.js and N|Solid (a fork of
10
- // Node.js), is `process.versions.node` being defined.
11
- typeof process.versions.node === 'string';