Initial Save
This commit is contained in:
21
node_modules/apollo-graphql/LICENSE
generated
vendored
Normal file
21
node_modules/apollo-graphql/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Meteor Development Group, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
1
node_modules/apollo-graphql/README.md
generated
vendored
Normal file
1
node_modules/apollo-graphql/README.md
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
# `apollo-graphql`
|
||||
4
node_modules/apollo-graphql/lib/index.d.ts
generated
vendored
Normal file
4
node_modules/apollo-graphql/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export { defaultOperationRegistrySignature, defaultUsageReportingSignature, operationRegistrySignature, operationHash, defaultUsageReportingSignature as defaultEngineReportingSignature, } from "./operationId";
|
||||
export * from "./schema";
|
||||
export { printWithReducedWhitespace, hideStringAndNumericLiterals, hideLiterals, } from "./transforms";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/index.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,8BAA8B,EAC9B,0BAA0B,EAC1B,aAAa,EAEb,8BAA8B,IAAI,+BAA+B,GAClE,MAAM,eAAe,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,YAAY,GACb,MAAM,cAAc,CAAC"}
|
||||
29
node_modules/apollo-graphql/lib/index.js
generated
vendored
Normal file
29
node_modules/apollo-graphql/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.hideLiterals = exports.hideStringAndNumericLiterals = exports.printWithReducedWhitespace = exports.defaultEngineReportingSignature = exports.operationHash = exports.operationRegistrySignature = exports.defaultUsageReportingSignature = exports.defaultOperationRegistrySignature = void 0;
|
||||
var operationId_1 = require("./operationId");
|
||||
Object.defineProperty(exports, "defaultOperationRegistrySignature", { enumerable: true, get: function () { return operationId_1.defaultOperationRegistrySignature; } });
|
||||
Object.defineProperty(exports, "defaultUsageReportingSignature", { enumerable: true, get: function () { return operationId_1.defaultUsageReportingSignature; } });
|
||||
Object.defineProperty(exports, "operationRegistrySignature", { enumerable: true, get: function () { return operationId_1.operationRegistrySignature; } });
|
||||
Object.defineProperty(exports, "operationHash", { enumerable: true, get: function () { return operationId_1.operationHash; } });
|
||||
Object.defineProperty(exports, "defaultEngineReportingSignature", { enumerable: true, get: function () { return operationId_1.defaultUsageReportingSignature; } });
|
||||
__exportStar(require("./schema"), exports);
|
||||
var transforms_1 = require("./transforms");
|
||||
Object.defineProperty(exports, "printWithReducedWhitespace", { enumerable: true, get: function () { return transforms_1.printWithReducedWhitespace; } });
|
||||
Object.defineProperty(exports, "hideStringAndNumericLiterals", { enumerable: true, get: function () { return transforms_1.hideStringAndNumericLiterals; } });
|
||||
Object.defineProperty(exports, "hideLiterals", { enumerable: true, get: function () { return transforms_1.hideLiterals; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/apollo-graphql/lib/index.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6CAOuB;AANrB,gIAAA,iCAAiC,OAAA;AACjC,6HAAA,8BAA8B,OAAA;AAC9B,yHAAA,0BAA0B,OAAA;AAC1B,4GAAA,aAAa,OAAA;AAEb,8HAAA,8BAA8B,OAAmC;AAEnE,2CAAyB;AACzB,2CAIsB;AAHpB,wHAAA,0BAA0B,OAAA;AAC1B,0HAAA,4BAA4B,OAAA;AAC5B,0GAAA,YAAY,OAAA"}
|
||||
8
node_modules/apollo-graphql/lib/operationId.d.ts
generated
vendored
Normal file
8
node_modules/apollo-graphql/lib/operationId.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { DocumentNode } from "graphql";
|
||||
export declare function defaultUsageReportingSignature(ast: DocumentNode, operationName: string): string;
|
||||
export declare function operationRegistrySignature(ast: DocumentNode, operationName: string, options?: {
|
||||
preserveStringAndNumericLiterals: boolean;
|
||||
}): string;
|
||||
export declare function defaultOperationRegistrySignature(ast: DocumentNode, operationName: string): string;
|
||||
export declare function operationHash(operation: string): string;
|
||||
//# sourceMappingURL=operationId.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/operationId.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/operationId.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"operationId.d.ts","sourceRoot":"","sources":["../src/operationId.ts"],"names":[],"mappings":"AAsDA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAcvC,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,YAAY,EACjB,aAAa,EAAE,MAAM,GACpB,MAAM,CAMR;AAMD,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,YAAY,EACjB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE;IAAE,gCAAgC,EAAE,OAAO,CAAA;CAEnD,GACA,MAAM,CAMR;AAED,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,YAAY,EACjB,aAAa,EAAE,MAAM,GACpB,MAAM,CAIR;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvD"}
|
||||
30
node_modules/apollo-graphql/lib/operationId.js
generated
vendored
Normal file
30
node_modules/apollo-graphql/lib/operationId.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.operationHash = exports.defaultOperationRegistrySignature = exports.operationRegistrySignature = exports.defaultUsageReportingSignature = void 0;
|
||||
const transforms_1 = require("./transforms");
|
||||
const createHash_1 = require("./utilities/createHash");
|
||||
function defaultUsageReportingSignature(ast, operationName) {
|
||||
return (0, transforms_1.printWithReducedWhitespace)((0, transforms_1.sortAST)((0, transforms_1.removeAliases)((0, transforms_1.hideLiterals)((0, transforms_1.dropUnusedDefinitions)(ast, operationName)))));
|
||||
}
|
||||
exports.defaultUsageReportingSignature = defaultUsageReportingSignature;
|
||||
function operationRegistrySignature(ast, operationName, options = {
|
||||
preserveStringAndNumericLiterals: false,
|
||||
}) {
|
||||
const withoutUnusedDefs = (0, transforms_1.dropUnusedDefinitions)(ast, operationName);
|
||||
const maybeWithLiterals = options.preserveStringAndNumericLiterals
|
||||
? withoutUnusedDefs
|
||||
: (0, transforms_1.hideStringAndNumericLiterals)(withoutUnusedDefs);
|
||||
return (0, transforms_1.printWithReducedWhitespace)((0, transforms_1.sortAST)(maybeWithLiterals));
|
||||
}
|
||||
exports.operationRegistrySignature = operationRegistrySignature;
|
||||
function defaultOperationRegistrySignature(ast, operationName) {
|
||||
return operationRegistrySignature(ast, operationName, {
|
||||
preserveStringAndNumericLiterals: false,
|
||||
});
|
||||
}
|
||||
exports.defaultOperationRegistrySignature = defaultOperationRegistrySignature;
|
||||
function operationHash(operation) {
|
||||
return (0, createHash_1.createHash)("sha256").update(operation).digest("hex");
|
||||
}
|
||||
exports.operationHash = operationHash;
|
||||
//# sourceMappingURL=operationId.js.map
|
||||
1
node_modules/apollo-graphql/lib/operationId.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/operationId.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"operationId.js","sourceRoot":"","sources":["../src/operationId.ts"],"names":[],"mappings":";;;AAuDA,6CAOsB;AACtB,uDAAoD;AAKpD,SAAgB,8BAA8B,CAC5C,GAAiB,EACjB,aAAqB;IAErB,OAAO,IAAA,uCAA0B,EAC/B,IAAA,oBAAO,EACL,IAAA,0BAAa,EAAC,IAAA,yBAAY,EAAC,IAAA,kCAAqB,EAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,CACvE,CACF,CAAC;AACJ,CAAC;AATD,wEASC;AAMD,SAAgB,0BAA0B,CACxC,GAAiB,EACjB,aAAqB,EACrB,UAAyD;IACvD,gCAAgC,EAAE,KAAK;CACxC;IAED,MAAM,iBAAiB,GAAG,IAAA,kCAAqB,EAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACpE,MAAM,iBAAiB,GAAG,OAAO,CAAC,gCAAgC;QAChE,CAAC,CAAC,iBAAiB;QACnB,CAAC,CAAC,IAAA,yCAA4B,EAAC,iBAAiB,CAAC,CAAC;IACpD,OAAO,IAAA,uCAA0B,EAAC,IAAA,oBAAO,EAAC,iBAAiB,CAAC,CAAC,CAAC;AAChE,CAAC;AAZD,gEAYC;AAED,SAAgB,iCAAiC,CAC/C,GAAiB,EACjB,aAAqB;IAErB,OAAO,0BAA0B,CAAC,GAAG,EAAE,aAAa,EAAE;QACpD,gCAAgC,EAAE,KAAK;KACxC,CAAC,CAAC;AACL,CAAC;AAPD,8EAOC;AAED,SAAgB,aAAa,CAAC,SAAiB;IAC7C,OAAO,IAAA,uBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAFD,sCAEC"}
|
||||
6
node_modules/apollo-graphql/lib/schema/GraphQLSchemaValidationError.d.ts
generated
vendored
Normal file
6
node_modules/apollo-graphql/lib/schema/GraphQLSchemaValidationError.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { GraphQLError } from "graphql";
|
||||
export declare class GraphQLSchemaValidationError extends Error {
|
||||
errors: ReadonlyArray<GraphQLError>;
|
||||
constructor(errors: ReadonlyArray<GraphQLError>);
|
||||
}
|
||||
//# sourceMappingURL=GraphQLSchemaValidationError.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/schema/GraphQLSchemaValidationError.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/GraphQLSchemaValidationError.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GraphQLSchemaValidationError.d.ts","sourceRoot":"","sources":["../../src/schema/GraphQLSchemaValidationError.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"}
|
||||
14
node_modules/apollo-graphql/lib/schema/GraphQLSchemaValidationError.js
generated
vendored
Normal file
14
node_modules/apollo-graphql/lib/schema/GraphQLSchemaValidationError.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GraphQLSchemaValidationError = void 0;
|
||||
class GraphQLSchemaValidationError extends Error {
|
||||
constructor(errors) {
|
||||
super();
|
||||
this.errors = errors;
|
||||
this.name = this.constructor.name;
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
this.message = errors.map((error) => error.message).join("\n\n");
|
||||
}
|
||||
}
|
||||
exports.GraphQLSchemaValidationError = GraphQLSchemaValidationError;
|
||||
//# sourceMappingURL=GraphQLSchemaValidationError.js.map
|
||||
1
node_modules/apollo-graphql/lib/schema/GraphQLSchemaValidationError.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/GraphQLSchemaValidationError.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GraphQLSchemaValidationError.js","sourceRoot":"","sources":["../../src/schema/GraphQLSchemaValidationError.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,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;CACF;AARD,oEAQC"}
|
||||
10
node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.d.ts
generated
vendored
Normal file
10
node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { DocumentNode, GraphQLSchema } from "graphql";
|
||||
import { GraphQLResolverMap } from "./resolverMap";
|
||||
export interface GraphQLSchemaModule {
|
||||
typeDefs: DocumentNode;
|
||||
resolvers?: GraphQLResolverMap<any>;
|
||||
}
|
||||
export declare function modulesFromSDL(modulesOrSDL: (GraphQLSchemaModule | DocumentNode)[] | DocumentNode): GraphQLSchemaModule[];
|
||||
export declare function buildSchemaFromSDL(modulesOrSDL: (GraphQLSchemaModule | DocumentNode)[] | DocumentNode, schemaToExtend?: GraphQLSchema): GraphQLSchema;
|
||||
export declare function addResolversToSchema(schema: GraphQLSchema, resolvers: GraphQLResolverMap<any>): void;
|
||||
//# sourceMappingURL=buildSchemaFromSDL.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"buildSchemaFromSDL.d.ts","sourceRoot":"","sources":["../../src/schema/buildSchemaFromSDL.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAEZ,aAAa,EAkBd,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAgBnD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,CAAC,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC;CACrC;AA0BD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,CAAC,mBAAmB,GAAG,YAAY,CAAC,EAAE,GAAG,YAAY,GAClE,mBAAmB,EAAE,CAYvB;AAED,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,CAAC,mBAAmB,GAAG,YAAY,CAAC,EAAE,GAAG,YAAY,EACnE,cAAc,CAAC,EAAE,aAAa,GAC7B,aAAa,CA+If;AAWD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,kBAAkB,CAAC,GAAG,CAAC,QAoEnC"}
|
||||
217
node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js
generated
vendored
Normal file
217
node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js
generated
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addResolversToSchema = exports.buildSchemaFromSDL = exports.modulesFromSDL = void 0;
|
||||
const graphql_1 = require("graphql");
|
||||
const validate_1 = require("graphql/validation/validate");
|
||||
const graphql_2 = require("../utilities/graphql");
|
||||
const GraphQLSchemaValidationError_1 = require("./GraphQLSchemaValidationError");
|
||||
const specifiedRules_1 = require("graphql/validation/specifiedRules");
|
||||
const flat_1 = __importDefault(require("core-js-pure/features/array/flat"));
|
||||
const validation_1 = require("graphql/validation");
|
||||
const mapValues_1 = require("../utilities/mapValues");
|
||||
const skippedSDLRules = [
|
||||
validation_1.KnownTypeNamesRule,
|
||||
validation_1.UniqueDirectivesPerLocationRule,
|
||||
];
|
||||
try {
|
||||
const PossibleTypeExtensions = require("graphql/validation/rules/PossibleTypeExtensions").PossibleTypeExtensions;
|
||||
if (PossibleTypeExtensions) {
|
||||
skippedSDLRules.push(PossibleTypeExtensions);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
const sdlRules = specifiedRules_1.specifiedSDLRules.filter((rule) => !skippedSDLRules.includes(rule));
|
||||
function modulesFromSDL(modulesOrSDL) {
|
||||
if (Array.isArray(modulesOrSDL)) {
|
||||
return modulesOrSDL.map((moduleOrSDL) => {
|
||||
if ((0, graphql_2.isNode)(moduleOrSDL) && (0, graphql_2.isDocumentNode)(moduleOrSDL)) {
|
||||
return { typeDefs: moduleOrSDL };
|
||||
}
|
||||
else {
|
||||
return moduleOrSDL;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
return [{ typeDefs: modulesOrSDL }];
|
||||
}
|
||||
}
|
||||
exports.modulesFromSDL = modulesFromSDL;
|
||||
function buildSchemaFromSDL(modulesOrSDL, schemaToExtend) {
|
||||
const modules = modulesFromSDL(modulesOrSDL);
|
||||
const documentAST = (0, graphql_1.concatAST)(modules.map((module) => module.typeDefs));
|
||||
const errors = (0, validate_1.validateSDL)(documentAST, schemaToExtend, sdlRules);
|
||||
if (errors.length > 0) {
|
||||
throw new GraphQLSchemaValidationError_1.GraphQLSchemaValidationError(errors);
|
||||
}
|
||||
const definitionsMap = Object.create(null);
|
||||
const extensionsMap = Object.create(null);
|
||||
const directiveDefinitions = [];
|
||||
const schemaDefinitions = [];
|
||||
const schemaExtensions = [];
|
||||
const schemaDirectives = [];
|
||||
for (const definition of documentAST.definitions) {
|
||||
if ((0, graphql_1.isTypeDefinitionNode)(definition)) {
|
||||
const typeName = definition.name.value;
|
||||
if (definitionsMap[typeName]) {
|
||||
definitionsMap[typeName].push(definition);
|
||||
}
|
||||
else {
|
||||
definitionsMap[typeName] = [definition];
|
||||
}
|
||||
}
|
||||
else if ((0, graphql_1.isTypeExtensionNode)(definition)) {
|
||||
const typeName = definition.name.value;
|
||||
if (extensionsMap[typeName]) {
|
||||
extensionsMap[typeName].push(definition);
|
||||
}
|
||||
else {
|
||||
extensionsMap[typeName] = [definition];
|
||||
}
|
||||
}
|
||||
else if (definition.kind === graphql_1.Kind.DIRECTIVE_DEFINITION) {
|
||||
directiveDefinitions.push(definition);
|
||||
}
|
||||
else if (definition.kind === graphql_1.Kind.SCHEMA_DEFINITION) {
|
||||
schemaDefinitions.push(definition);
|
||||
schemaDirectives.push(...(definition.directives ? definition.directives : []));
|
||||
}
|
||||
else if (definition.kind === graphql_1.Kind.SCHEMA_EXTENSION) {
|
||||
schemaExtensions.push(definition);
|
||||
}
|
||||
}
|
||||
let schema = schemaToExtend
|
||||
? schemaToExtend
|
||||
: new graphql_1.GraphQLSchema({
|
||||
query: undefined,
|
||||
});
|
||||
const missingTypeDefinitions = [];
|
||||
for (const [extendedTypeName, extensions] of Object.entries(extensionsMap)) {
|
||||
if (!definitionsMap[extendedTypeName]) {
|
||||
const extension = extensions[0];
|
||||
const kind = extension.kind;
|
||||
const definition = {
|
||||
kind: extKindToDefKind[kind],
|
||||
name: extension.name,
|
||||
};
|
||||
missingTypeDefinitions.push(definition);
|
||||
}
|
||||
}
|
||||
schema = (0, graphql_1.extendSchema)(schema, {
|
||||
kind: graphql_1.Kind.DOCUMENT,
|
||||
definitions: [
|
||||
...(0, flat_1.default)(Object.values(definitionsMap)),
|
||||
...missingTypeDefinitions,
|
||||
...directiveDefinitions,
|
||||
],
|
||||
}, {
|
||||
assumeValidSDL: true,
|
||||
});
|
||||
schema = (0, graphql_1.extendSchema)(schema, {
|
||||
kind: graphql_1.Kind.DOCUMENT,
|
||||
definitions: (0, flat_1.default)(Object.values(extensionsMap)),
|
||||
}, {
|
||||
assumeValidSDL: true,
|
||||
});
|
||||
let operationTypeMap;
|
||||
if (schemaDefinitions.length > 0 || schemaExtensions.length > 0) {
|
||||
operationTypeMap = {};
|
||||
const operationTypes = (0, flat_1.default)([...schemaDefinitions, ...schemaExtensions]
|
||||
.map((node) => node.operationTypes)
|
||||
.filter(isNotNullOrUndefined));
|
||||
for (const { operation, type } of operationTypes) {
|
||||
operationTypeMap[operation] = type.name.value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
operationTypeMap = {
|
||||
query: "Query",
|
||||
mutation: "Mutation",
|
||||
subscription: "Subscription",
|
||||
};
|
||||
}
|
||||
schema = new graphql_1.GraphQLSchema(Object.assign(Object.assign(Object.assign({}, schema.toConfig()), (0, mapValues_1.mapValues)(operationTypeMap, (typeName) => typeName
|
||||
? schema.getType(typeName)
|
||||
: undefined)), { astNode: {
|
||||
kind: graphql_1.Kind.SCHEMA_DEFINITION,
|
||||
directives: schemaDirectives,
|
||||
operationTypes: [],
|
||||
} }));
|
||||
for (const module of modules) {
|
||||
if (!module.resolvers)
|
||||
continue;
|
||||
addResolversToSchema(schema, module.resolvers);
|
||||
}
|
||||
return schema;
|
||||
}
|
||||
exports.buildSchemaFromSDL = buildSchemaFromSDL;
|
||||
const extKindToDefKind = {
|
||||
[graphql_1.Kind.SCALAR_TYPE_EXTENSION]: graphql_1.Kind.SCALAR_TYPE_DEFINITION,
|
||||
[graphql_1.Kind.OBJECT_TYPE_EXTENSION]: graphql_1.Kind.OBJECT_TYPE_DEFINITION,
|
||||
[graphql_1.Kind.INTERFACE_TYPE_EXTENSION]: graphql_1.Kind.INTERFACE_TYPE_DEFINITION,
|
||||
[graphql_1.Kind.UNION_TYPE_EXTENSION]: graphql_1.Kind.UNION_TYPE_DEFINITION,
|
||||
[graphql_1.Kind.ENUM_TYPE_EXTENSION]: graphql_1.Kind.ENUM_TYPE_DEFINITION,
|
||||
[graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION]: graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
||||
};
|
||||
function addResolversToSchema(schema, resolvers) {
|
||||
for (const [typeName, fieldConfigs] of Object.entries(resolvers)) {
|
||||
const type = schema.getType(typeName);
|
||||
if ((0, graphql_1.isAbstractType)(type)) {
|
||||
for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
|
||||
if (fieldName.startsWith("__")) {
|
||||
type[fieldName.substring(2)] = fieldConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((0, graphql_1.isScalarType)(type)) {
|
||||
for (const fn in fieldConfigs) {
|
||||
type[fn] = fieldConfigs[fn];
|
||||
}
|
||||
}
|
||||
if ((0, graphql_1.isEnumType)(type)) {
|
||||
const values = type.getValues();
|
||||
const newValues = {};
|
||||
values.forEach((value) => {
|
||||
let newValue = fieldConfigs[value.name];
|
||||
if (newValue === undefined) {
|
||||
newValue = value.name;
|
||||
}
|
||||
newValues[value.name] = {
|
||||
value: newValue,
|
||||
deprecationReason: value.deprecationReason,
|
||||
description: value.description,
|
||||
astNode: value.astNode,
|
||||
extensions: undefined,
|
||||
};
|
||||
});
|
||||
Object.assign(type, new graphql_1.GraphQLEnumType(Object.assign(Object.assign({}, type.toConfig()), { values: newValues })));
|
||||
}
|
||||
if (!(0, graphql_1.isObjectType)(type))
|
||||
continue;
|
||||
const fieldMap = type.getFields();
|
||||
for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
|
||||
if (fieldName.startsWith("__")) {
|
||||
type[fieldName.substring(2)] = fieldConfig;
|
||||
continue;
|
||||
}
|
||||
const field = fieldMap[fieldName];
|
||||
if (!field)
|
||||
continue;
|
||||
if (typeof fieldConfig === "function") {
|
||||
field.resolve = fieldConfig;
|
||||
}
|
||||
else {
|
||||
field.resolve = fieldConfig.resolve;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.addResolversToSchema = addResolversToSchema;
|
||||
function isNotNullOrUndefined(value) {
|
||||
return value !== null && typeof value !== "undefined";
|
||||
}
|
||||
//# sourceMappingURL=buildSchemaFromSDL.js.map
|
||||
1
node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/apollo-graphql/lib/schema/index.d.ts
generated
vendored
Normal file
6
node_modules/apollo-graphql/lib/schema/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from "./buildSchemaFromSDL";
|
||||
export * from "./GraphQLSchemaValidationError";
|
||||
export * from "./transformSchema";
|
||||
export * from "./resolverMap";
|
||||
export * from "./resolveObject";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/schema/index.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
|
||||
22
node_modules/apollo-graphql/lib/schema/index.js
generated
vendored
Normal file
22
node_modules/apollo-graphql/lib/schema/index.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./buildSchemaFromSDL"), exports);
|
||||
__exportStar(require("./GraphQLSchemaValidationError"), exports);
|
||||
__exportStar(require("./transformSchema"), exports);
|
||||
__exportStar(require("./resolverMap"), exports);
|
||||
__exportStar(require("./resolveObject"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/apollo-graphql/lib/schema/index.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,iEAA+C;AAC/C,oDAAkC;AAClC,gDAA8B;AAC9B,kDAAgC"}
|
||||
11
node_modules/apollo-graphql/lib/schema/resolveObject.d.ts
generated
vendored
Normal file
11
node_modules/apollo-graphql/lib/schema/resolveObject.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { GraphQLResolveInfo, FieldNode } from "graphql";
|
||||
export declare type GraphQLObjectResolver<TSource, TContext> = (source: TSource, fields: Record<string, ReadonlyArray<FieldNode>>, context: TContext, info: GraphQLResolveInfo) => any;
|
||||
declare module "graphql/type/definition" {
|
||||
interface GraphQLObjectType {
|
||||
resolveObject?: GraphQLObjectResolver<any, any>;
|
||||
}
|
||||
interface GraphQLObjectTypeConfig<TSource, TContext> {
|
||||
resolveObject?: GraphQLObjectResolver<TSource, TContext>;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=resolveObject.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/schema/resolveObject.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/resolveObject.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"resolveObject.d.ts","sourceRoot":"","sources":["../../src/schema/resolveObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAExD,oBAAY,qBAAqB,CAAC,OAAO,EAAE,QAAQ,IAAI,CACrD,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC,EAChD,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,kBAAkB,KACrB,GAAG,CAAC;AAET,OAAO,QAAQ,yBAAyB,CAAC;IACvC,UAAU,iBAAiB;QACzB,aAAa,CAAC,EAAE,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KACjD;IAED,UAAU,uBAAuB,CAAC,OAAO,EAAE,QAAQ;QACjD,aAAa,CAAC,EAAE,qBAAqB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;KAC1D;CACF"}
|
||||
3
node_modules/apollo-graphql/lib/schema/resolveObject.js
generated
vendored
Normal file
3
node_modules/apollo-graphql/lib/schema/resolveObject.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=resolveObject.js.map
|
||||
1
node_modules/apollo-graphql/lib/schema/resolveObject.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/resolveObject.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"resolveObject.js","sourceRoot":"","sources":["../../src/schema/resolveObject.ts"],"names":[],"mappings":""}
|
||||
12
node_modules/apollo-graphql/lib/schema/resolverMap.d.ts
generated
vendored
Normal file
12
node_modules/apollo-graphql/lib/schema/resolverMap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { GraphQLFieldResolver, GraphQLScalarType } from "graphql";
|
||||
export interface GraphQLResolverMap<TContext = {}> {
|
||||
[typeName: string]: {
|
||||
[fieldName: string]: GraphQLFieldResolver<any, TContext> | {
|
||||
requires?: string;
|
||||
resolve: GraphQLFieldResolver<any, TContext>;
|
||||
};
|
||||
} | GraphQLScalarType | {
|
||||
[enumValue: string]: string | number;
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=resolverMap.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/schema/resolverMap.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/resolverMap.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"resolverMap.d.ts","sourceRoot":"","sources":["../../src/schema/resolverMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAElE,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"}
|
||||
3
node_modules/apollo-graphql/lib/schema/resolverMap.js
generated
vendored
Normal file
3
node_modules/apollo-graphql/lib/schema/resolverMap.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=resolverMap.js.map
|
||||
1
node_modules/apollo-graphql/lib/schema/resolverMap.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/resolverMap.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"resolverMap.js","sourceRoot":"","sources":["../../src/schema/resolverMap.ts"],"names":[],"mappings":""}
|
||||
5
node_modules/apollo-graphql/lib/schema/transformSchema.d.ts
generated
vendored
Normal file
5
node_modules/apollo-graphql/lib/schema/transformSchema.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { GraphQLSchema, GraphQLNamedType } from "graphql";
|
||||
declare type TypeTransformer = (type: GraphQLNamedType) => GraphQLNamedType | null | undefined;
|
||||
export declare function transformSchema(schema: GraphQLSchema, transformType: TypeTransformer): GraphQLSchema;
|
||||
export {};
|
||||
//# sourceMappingURL=transformSchema.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/schema/transformSchema.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/transformSchema.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"transformSchema.d.ts","sourceRoot":"","sources":["../../src/schema/transformSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,gBAAgB,EAqBjB,MAAM,SAAS,CAAC;AAGjB,aAAK,eAAe,GAAG,CACrB,IAAI,EAAE,gBAAgB,KACnB,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC;AAEzC,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,eAAe,GAC7B,aAAa,CA+Hf"}
|
||||
71
node_modules/apollo-graphql/lib/schema/transformSchema.js
generated
vendored
Normal file
71
node_modules/apollo-graphql/lib/schema/transformSchema.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.transformSchema = void 0;
|
||||
const graphql_1 = require("graphql");
|
||||
const mapValues_1 = require("../utilities/mapValues");
|
||||
function transformSchema(schema, transformType) {
|
||||
const typeMap = Object.create(null);
|
||||
for (const oldType of Object.values(schema.getTypeMap())) {
|
||||
if ((0, graphql_1.isIntrospectionType)(oldType))
|
||||
continue;
|
||||
const result = transformType(oldType);
|
||||
if (result === null)
|
||||
continue;
|
||||
const newType = result || oldType;
|
||||
typeMap[newType.name] = recreateNamedType(newType);
|
||||
}
|
||||
const schemaConfig = schema.toConfig();
|
||||
return new graphql_1.GraphQLSchema(Object.assign(Object.assign({}, schemaConfig), { types: Object.values(typeMap), query: replaceMaybeType(schemaConfig.query), mutation: replaceMaybeType(schemaConfig.mutation), subscription: replaceMaybeType(schemaConfig.subscription), directives: replaceDirectives(schemaConfig.directives) }));
|
||||
function recreateNamedType(type) {
|
||||
if ((0, graphql_1.isObjectType)(type)) {
|
||||
const config = type.toConfig();
|
||||
return new graphql_1.GraphQLObjectType(Object.assign(Object.assign({}, config), { interfaces: () => config.interfaces.map(replaceNamedType), fields: () => replaceFields(config.fields) }));
|
||||
}
|
||||
else if ((0, graphql_1.isInterfaceType)(type)) {
|
||||
const config = type.toConfig();
|
||||
return new graphql_1.GraphQLInterfaceType(Object.assign(Object.assign({}, config), { interfaces: () => config.interfaces.map(replaceNamedType), fields: () => replaceFields(config.fields) }));
|
||||
}
|
||||
else if ((0, graphql_1.isUnionType)(type)) {
|
||||
const config = type.toConfig();
|
||||
return new graphql_1.GraphQLUnionType(Object.assign(Object.assign({}, config), { types: () => config.types.map(replaceNamedType) }));
|
||||
}
|
||||
else if ((0, graphql_1.isInputObjectType)(type)) {
|
||||
const config = type.toConfig();
|
||||
return new graphql_1.GraphQLInputObjectType(Object.assign(Object.assign({}, config), { fields: () => replaceInputFields(config.fields) }));
|
||||
}
|
||||
return type;
|
||||
}
|
||||
function replaceType(type) {
|
||||
if ((0, graphql_1.isListType)(type)) {
|
||||
return new graphql_1.GraphQLList(replaceType(type.ofType));
|
||||
}
|
||||
else if ((0, graphql_1.isNonNullType)(type)) {
|
||||
return new graphql_1.GraphQLNonNull(replaceType(type.ofType));
|
||||
}
|
||||
return replaceNamedType(type);
|
||||
}
|
||||
function replaceNamedType(type) {
|
||||
const newType = typeMap[type.name];
|
||||
return newType ? newType : type;
|
||||
}
|
||||
function replaceMaybeType(type) {
|
||||
return type ? replaceNamedType(type) : undefined;
|
||||
}
|
||||
function replaceFields(fieldsMap) {
|
||||
return (0, mapValues_1.mapValues)(fieldsMap, (field) => (Object.assign(Object.assign({}, field), { type: replaceType(field.type), args: field.args ? replaceArgs(field.args) : undefined })));
|
||||
}
|
||||
function replaceInputFields(fieldsMap) {
|
||||
return (0, mapValues_1.mapValues)(fieldsMap, (field) => (Object.assign(Object.assign({}, field), { type: replaceType(field.type) })));
|
||||
}
|
||||
function replaceArgs(args) {
|
||||
return (0, mapValues_1.mapValues)(args, (arg) => (Object.assign(Object.assign({}, arg), { type: replaceType(arg.type) })));
|
||||
}
|
||||
function replaceDirectives(directives) {
|
||||
return directives.map((directive) => {
|
||||
const config = directive.toConfig();
|
||||
return new graphql_1.GraphQLDirective(Object.assign(Object.assign({}, config), { args: replaceArgs(config.args) }));
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.transformSchema = transformSchema;
|
||||
//# sourceMappingURL=transformSchema.js.map
|
||||
1
node_modules/apollo-graphql/lib/schema/transformSchema.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/schema/transformSchema.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"transformSchema.js","sourceRoot":"","sources":["../../src/schema/transformSchema.ts"],"names":[],"mappings":"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"}
|
||||
8
node_modules/apollo-graphql/lib/transforms.d.ts
generated
vendored
Normal file
8
node_modules/apollo-graphql/lib/transforms.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { DocumentNode } from "graphql/language/ast";
|
||||
export declare function hideLiterals(ast: DocumentNode): DocumentNode;
|
||||
export declare function hideStringAndNumericLiterals(ast: DocumentNode): DocumentNode;
|
||||
export declare function dropUnusedDefinitions(ast: DocumentNode, operationName: string): DocumentNode;
|
||||
export declare function sortAST(ast: DocumentNode): DocumentNode;
|
||||
export declare function removeAliases(ast: DocumentNode): DocumentNode;
|
||||
export declare function printWithReducedWhitespace(ast: DocumentNode): string;
|
||||
//# sourceMappingURL=transforms.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/transforms.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/transforms.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EAab,MAAM,sBAAsB,CAAC;AAe9B,wBAAgB,YAAY,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CAkB5D;AAID,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CAY5E;AAOD,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,YAAY,EACjB,aAAa,EAAE,MAAM,GACpB,YAAY,CAQd;AAmBD,wBAAgB,OAAO,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CAyDvD;AAMD,wBAAgB,aAAa,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CAS7D;AAMD,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CA2BpE"}
|
||||
110
node_modules/apollo-graphql/lib/transforms.js
generated
vendored
Normal file
110
node_modules/apollo-graphql/lib/transforms.js
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.printWithReducedWhitespace = exports.removeAliases = exports.sortAST = exports.dropUnusedDefinitions = exports.hideStringAndNumericLiterals = exports.hideLiterals = void 0;
|
||||
const visitor_1 = require("graphql/language/visitor");
|
||||
const printer_1 = require("graphql/language/printer");
|
||||
const utilities_1 = require("graphql/utilities");
|
||||
const lodash_sortby_1 = __importDefault(require("lodash.sortby"));
|
||||
function hideLiterals(ast) {
|
||||
return (0, visitor_1.visit)(ast, {
|
||||
IntValue(node) {
|
||||
return Object.assign(Object.assign({}, node), { value: "0" });
|
||||
},
|
||||
FloatValue(node) {
|
||||
return Object.assign(Object.assign({}, node), { value: "0" });
|
||||
},
|
||||
StringValue(node) {
|
||||
return Object.assign(Object.assign({}, node), { value: "", block: false });
|
||||
},
|
||||
ListValue(node) {
|
||||
return Object.assign(Object.assign({}, node), { values: [] });
|
||||
},
|
||||
ObjectValue(node) {
|
||||
return Object.assign(Object.assign({}, node), { fields: [] });
|
||||
},
|
||||
});
|
||||
}
|
||||
exports.hideLiterals = hideLiterals;
|
||||
function hideStringAndNumericLiterals(ast) {
|
||||
return (0, visitor_1.visit)(ast, {
|
||||
IntValue(node) {
|
||||
return Object.assign(Object.assign({}, node), { value: "0" });
|
||||
},
|
||||
FloatValue(node) {
|
||||
return Object.assign(Object.assign({}, node), { value: "0" });
|
||||
},
|
||||
StringValue(node) {
|
||||
return Object.assign(Object.assign({}, node), { value: "", block: false });
|
||||
},
|
||||
});
|
||||
}
|
||||
exports.hideStringAndNumericLiterals = hideStringAndNumericLiterals;
|
||||
function dropUnusedDefinitions(ast, operationName) {
|
||||
const separated = (0, utilities_1.separateOperations)(ast)[operationName];
|
||||
if (!separated) {
|
||||
return ast;
|
||||
}
|
||||
return separated;
|
||||
}
|
||||
exports.dropUnusedDefinitions = dropUnusedDefinitions;
|
||||
function sorted(items, ...iteratees) {
|
||||
if (items) {
|
||||
return (0, lodash_sortby_1.default)(items, ...iteratees);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function sortAST(ast) {
|
||||
return (0, visitor_1.visit)(ast, {
|
||||
Document(node) {
|
||||
return Object.assign(Object.assign({}, node), { definitions: (0, lodash_sortby_1.default)(node.definitions, "kind", "name.value") });
|
||||
},
|
||||
OperationDefinition(node) {
|
||||
return Object.assign(Object.assign({}, node), { variableDefinitions: sorted(node.variableDefinitions, "variable.name.value") });
|
||||
},
|
||||
SelectionSet(node) {
|
||||
return Object.assign(Object.assign({}, node), { selections: (0, lodash_sortby_1.default)(node.selections, "kind", "name.value") });
|
||||
},
|
||||
Field(node) {
|
||||
return Object.assign(Object.assign({}, node), { arguments: sorted(node.arguments, "name.value") });
|
||||
},
|
||||
FragmentSpread(node) {
|
||||
return Object.assign(Object.assign({}, node), { directives: sorted(node.directives, "name.value") });
|
||||
},
|
||||
InlineFragment(node) {
|
||||
return Object.assign(Object.assign({}, node), { directives: sorted(node.directives, "name.value") });
|
||||
},
|
||||
FragmentDefinition(node) {
|
||||
return Object.assign(Object.assign({}, node), { directives: sorted(node.directives, "name.value"), variableDefinitions: sorted(node.variableDefinitions, "variable.name.value") });
|
||||
},
|
||||
Directive(node) {
|
||||
return Object.assign(Object.assign({}, node), { arguments: sorted(node.arguments, "name.value") });
|
||||
},
|
||||
});
|
||||
}
|
||||
exports.sortAST = sortAST;
|
||||
function removeAliases(ast) {
|
||||
return (0, visitor_1.visit)(ast, {
|
||||
Field(node) {
|
||||
return Object.assign(Object.assign({}, node), { alias: undefined });
|
||||
},
|
||||
});
|
||||
}
|
||||
exports.removeAliases = removeAliases;
|
||||
function printWithReducedWhitespace(ast) {
|
||||
const sanitizedAST = (0, visitor_1.visit)(ast, {
|
||||
StringValue(node) {
|
||||
return Object.assign(Object.assign({}, node), { value: Buffer.from(node.value, "utf8").toString("hex"), block: false });
|
||||
},
|
||||
});
|
||||
const withWhitespace = (0, printer_1.print)(sanitizedAST);
|
||||
const minimizedButStillHex = withWhitespace
|
||||
.replace(/\s+/g, " ")
|
||||
.replace(/([^_a-zA-Z0-9]) /g, (_, c) => c)
|
||||
.replace(/ ([^_a-zA-Z0-9])/g, (_, c) => c);
|
||||
return minimizedButStillHex.replace(/"([a-f0-9]+)"/g, (_, hex) => JSON.stringify(Buffer.from(hex, "hex").toString("utf8")));
|
||||
}
|
||||
exports.printWithReducedWhitespace = printWithReducedWhitespace;
|
||||
//# sourceMappingURL=transforms.js.map
|
||||
1
node_modules/apollo-graphql/lib/transforms.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/transforms.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"transforms.js","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"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"}
|
||||
2
node_modules/apollo-graphql/lib/utilities/createHash.d.ts
generated
vendored
Normal file
2
node_modules/apollo-graphql/lib/utilities/createHash.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare function createHash(kind: string): import("crypto").Hash;
|
||||
//# sourceMappingURL=createHash.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/utilities/createHash.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/utilities/createHash.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"createHash.d.ts","sourceRoot":"","sources":["../../src/utilities/createHash.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,QAAQ,EAAE,IAAI,CAU9D"}
|
||||
12
node_modules/apollo-graphql/lib/utilities/createHash.js
generated
vendored
Normal file
12
node_modules/apollo-graphql/lib/utilities/createHash.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createHash = void 0;
|
||||
const isNodeLike_1 = require("./isNodeLike");
|
||||
function createHash(kind) {
|
||||
if (isNodeLike_1.isNodeLike) {
|
||||
return module.require("crypto").createHash(kind);
|
||||
}
|
||||
return require("sha.js")(kind);
|
||||
}
|
||||
exports.createHash = createHash;
|
||||
//# sourceMappingURL=createHash.js.map
|
||||
1
node_modules/apollo-graphql/lib/utilities/createHash.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/utilities/createHash.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"createHash.js","sourceRoot":"","sources":["../../src/utilities/createHash.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAE1C,SAAgB,UAAU,CAAC,IAAY;IACrC,IAAI,uBAAU,EAAE;QAGd,OAAQ,MAAM,CAAC,OAAO,CAAC,QAAQ,CAA6B,CAAC,UAAU,CACrE,IAAI,CACL,CAAC;KACH;IAED,OAAQ,OAAO,CAAC,QAAQ,CAA6B,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC;AAVD,gCAUC"}
|
||||
4
node_modules/apollo-graphql/lib/utilities/graphql.d.ts
generated
vendored
Normal file
4
node_modules/apollo-graphql/lib/utilities/graphql.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { ASTNode, DocumentNode } from "graphql";
|
||||
export declare function isNode(maybeNode: any): maybeNode is ASTNode;
|
||||
export declare function isDocumentNode(node: ASTNode): node is DocumentNode;
|
||||
//# sourceMappingURL=graphql.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/utilities/graphql.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/utilities/graphql.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/utilities/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAQ,MAAM,SAAS,CAAC;AAEtD,wBAAgB,MAAM,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,IAAI,OAAO,CAE3D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,YAAY,CAElE"}
|
||||
13
node_modules/apollo-graphql/lib/utilities/graphql.js
generated
vendored
Normal file
13
node_modules/apollo-graphql/lib/utilities/graphql.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isDocumentNode = exports.isNode = void 0;
|
||||
const graphql_1 = require("graphql");
|
||||
function isNode(maybeNode) {
|
||||
return maybeNode && typeof maybeNode.kind === "string";
|
||||
}
|
||||
exports.isNode = isNode;
|
||||
function isDocumentNode(node) {
|
||||
return isNode(node) && node.kind === graphql_1.Kind.DOCUMENT;
|
||||
}
|
||||
exports.isDocumentNode = isDocumentNode;
|
||||
//# sourceMappingURL=graphql.js.map
|
||||
1
node_modules/apollo-graphql/lib/utilities/graphql.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/utilities/graphql.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/utilities/graphql.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AAEtD,SAAgB,MAAM,CAAC,SAAc;IACnC,OAAO,SAAS,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ,CAAC;AACzD,CAAC;AAFD,wBAEC;AAED,SAAgB,cAAc,CAAC,IAAa;IAC1C,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,cAAI,CAAC,QAAQ,CAAC;AACrD,CAAC;AAFD,wCAEC"}
|
||||
2
node_modules/apollo-graphql/lib/utilities/isNodeLike.d.ts
generated
vendored
Normal file
2
node_modules/apollo-graphql/lib/utilities/isNodeLike.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare const isNodeLike: boolean;
|
||||
//# sourceMappingURL=isNodeLike.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/utilities/isNodeLike.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/utilities/isNodeLike.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"isNodeLike.d.ts","sourceRoot":"","sources":["../../src/utilities/isNodeLike.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,SAKoB,CAAC"}
|
||||
9
node_modules/apollo-graphql/lib/utilities/isNodeLike.js
generated
vendored
Normal file
9
node_modules/apollo-graphql/lib/utilities/isNodeLike.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isNodeLike = void 0;
|
||||
exports.isNodeLike = typeof process === "object" &&
|
||||
process &&
|
||||
process.release &&
|
||||
process.versions &&
|
||||
typeof process.versions.node === "string";
|
||||
//# sourceMappingURL=isNodeLike.js.map
|
||||
1
node_modules/apollo-graphql/lib/utilities/isNodeLike.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/utilities/isNodeLike.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"isNodeLike.js","sourceRoot":"","sources":["../../src/utilities/isNodeLike.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GACrB,OAAO,OAAO,KAAK,QAAQ;IAC3B,OAAO;IACP,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,QAAQ;IAChB,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC"}
|
||||
2
node_modules/apollo-graphql/lib/utilities/mapValues.d.ts
generated
vendored
Normal file
2
node_modules/apollo-graphql/lib/utilities/mapValues.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare function mapValues<T, U = T>(object: Record<string, T>, callback: (value: T) => U): Record<string, U>;
|
||||
//# sourceMappingURL=mapValues.d.ts.map
|
||||
1
node_modules/apollo-graphql/lib/utilities/mapValues.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/utilities/mapValues.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mapValues.d.ts","sourceRoot":"","sources":["../../src/utilities/mapValues.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GACxB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAQnB"}
|
||||
12
node_modules/apollo-graphql/lib/utilities/mapValues.js
generated
vendored
Normal file
12
node_modules/apollo-graphql/lib/utilities/mapValues.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.mapValues = void 0;
|
||||
function mapValues(object, callback) {
|
||||
const result = Object.create(null);
|
||||
for (const [key, value] of Object.entries(object)) {
|
||||
result[key] = callback(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.mapValues = mapValues;
|
||||
//# sourceMappingURL=mapValues.js.map
|
||||
1
node_modules/apollo-graphql/lib/utilities/mapValues.js.map
generated
vendored
Normal file
1
node_modules/apollo-graphql/lib/utilities/mapValues.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mapValues.js","sourceRoot":"","sources":["../../src/utilities/mapValues.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CACvB,MAAyB,EACzB,QAAyB;IAEzB,MAAM,MAAM,GAAsB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEtD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACjD,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;KAC/B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAXD,8BAWC"}
|
||||
48
node_modules/apollo-graphql/package.json
generated
vendored
Normal file
48
node_modules/apollo-graphql/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "apollo-graphql",
|
||||
"version": "0.9.7",
|
||||
"description": "Apollo GraphQL utility library",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"keywords": [],
|
||||
"author": "Apollo <packages@apollographql.com>",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"dependencies": {
|
||||
"core-js-pure": "^3.10.2",
|
||||
"lodash.sortby": "^4.7.0",
|
||||
"sha.js": "^2.4.11"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"graphql": "^14.2.1 || ^15.0.0"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"transformIgnorePatterns": [
|
||||
"/node_modules/"
|
||||
],
|
||||
"testEnvironment": "node",
|
||||
"testMatch": [
|
||||
"**/__tests__/*.(js|ts)"
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"<rootDir>/node_modules/",
|
||||
"<rootDir>/lib/",
|
||||
"<rootDir>/test/fixtures/",
|
||||
"<rootDir>/test/test-utils"
|
||||
],
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"js"
|
||||
],
|
||||
"globals": {
|
||||
"ts-jest": {
|
||||
"tsconfig": "<rootDir>/tsconfig.test.json",
|
||||
"diagnostics": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitHead": "58b96377de23b35f31264fda805d967a63a800c7"
|
||||
}
|
||||
35
node_modules/apollo-graphql/src/__tests__/__snapshots__/operationId.test.ts.snap
generated
vendored
Normal file
35
node_modules/apollo-graphql/src/__tests__/__snapshots__/operationId.test.ts.snap
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`defaultUsageReportingSignature basic test 1`] = `"{user{name}}"`;
|
||||
|
||||
exports[`defaultUsageReportingSignature basic test with query 1`] = `"{user{name}}"`;
|
||||
|
||||
exports[`defaultUsageReportingSignature basic with operation name 1`] = `"query OpName{user{name}}"`;
|
||||
|
||||
exports[`defaultUsageReportingSignature fragment 1`] = `"fragment Bar on User{asd}{user{name...Bar}}"`;
|
||||
|
||||
exports[`defaultUsageReportingSignature fragments in various order 1`] = `"fragment Bar on User{asd}{user{name...Bar}}"`;
|
||||
|
||||
exports[`defaultUsageReportingSignature full test 1`] = `"fragment Bar on User{age@skip(if:$a)...Nested}fragment Nested on User{blah}query Foo($a:Boolean,$b:Int){user(age:0,name:\\"\\"){name tz...Bar...on User{bee hello}}}"`;
|
||||
|
||||
exports[`defaultUsageReportingSignature with various argument types 1`] = `"query OpName($a:[[Boolean!]!],$b:EnumType,$c:Int!){user{name(apple:$a,bag:$b,cat:$c)}}"`;
|
||||
|
||||
exports[`defaultUsageReportingSignature with various inline types 1`] = `"query OpName{user{name(apple:[],bag:{},cat:ENUM_VALUE)}}"`;
|
||||
|
||||
exports[`operationRegistrySignature basic test 1`] = `"{user{name}}"`;
|
||||
|
||||
exports[`operationRegistrySignature basic test with query 1`] = `"{user{name}}"`;
|
||||
|
||||
exports[`operationRegistrySignature basic with operation name 1`] = `"query OpName{user{name}}"`;
|
||||
|
||||
exports[`operationRegistrySignature fragment 1`] = `"fragment Bar on User{asd}{user{name...Bar}}"`;
|
||||
|
||||
exports[`operationRegistrySignature fragments in various order 1`] = `"fragment Bar on User{asd}{user{name...Bar}}"`;
|
||||
|
||||
exports[`operationRegistrySignature full test 1`] = `"fragment Bar on User{age@skip(if:$a)...Nested}fragment Nested on User{blah}query Foo($a:Boolean,$b:Int){user(age:0,name:\\"\\"){aliased:name tz...Bar...on User{bee hello}}}"`;
|
||||
|
||||
exports[`operationRegistrySignature test with preserveStringAndNumericLiterals=true 1`] = `"query Foo($b:Int){user(age:5,name:\\"hello\\"){a@skip(if:true)b@include(if:false)c(value:4){d}...Bar...on User{hello@directive(arg:\\"Value!\\")}}}"`;
|
||||
|
||||
exports[`operationRegistrySignature with various argument types 1`] = `"query OpName($a:[[Boolean!]!],$b:EnumType,$c:Int!){user{name(apple:$a,bag:$b,cat:$c)}}"`;
|
||||
|
||||
exports[`operationRegistrySignature with various inline types 1`] = `"query OpName{user{name(apple:[[0]],bag:{input:\\"\\"},cat:ENUM_VALUE)}}"`;
|
||||
305
node_modules/apollo-graphql/src/__tests__/operationId.test.ts
generated
vendored
Normal file
305
node_modules/apollo-graphql/src/__tests__/operationId.test.ts
generated
vendored
Normal file
@@ -0,0 +1,305 @@
|
||||
import { default as gql, disableFragmentWarnings } from "graphql-tag";
|
||||
import {
|
||||
defaultUsageReportingSignature,
|
||||
operationRegistrySignature,
|
||||
} from "../operationId";
|
||||
|
||||
// The gql duplicate fragment warning feature really is just warnings; nothing
|
||||
// breaks if you turn it off in tests.
|
||||
disableFragmentWarnings();
|
||||
|
||||
describe("defaultUsageReportingSignature", () => {
|
||||
const cases = [
|
||||
// Test cases borrowed from optics-agent-js.
|
||||
{
|
||||
name: "basic test",
|
||||
operationName: "",
|
||||
input: gql`
|
||||
{
|
||||
user {
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "basic test with query",
|
||||
operationName: "",
|
||||
input: gql`
|
||||
query {
|
||||
user {
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "basic with operation name",
|
||||
operationName: "OpName",
|
||||
input: gql`
|
||||
query OpName {
|
||||
user {
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "with various inline types",
|
||||
operationName: "OpName",
|
||||
input: gql`
|
||||
query OpName {
|
||||
user {
|
||||
name(apple: [[10]], cat: ENUM_VALUE, bag: { input: "value" })
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "with various argument types",
|
||||
operationName: "OpName",
|
||||
input: gql`
|
||||
query OpName($c: Int!, $a: [[Boolean!]!], $b: EnumType) {
|
||||
user {
|
||||
name(apple: $a, cat: $c, bag: $b)
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "fragment",
|
||||
operationName: "",
|
||||
input: gql`
|
||||
{
|
||||
user {
|
||||
name
|
||||
...Bar
|
||||
}
|
||||
}
|
||||
|
||||
fragment Bar on User {
|
||||
asd
|
||||
}
|
||||
|
||||
fragment Baz on User {
|
||||
jkl
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "fragments in various order",
|
||||
operationName: "",
|
||||
input: gql`
|
||||
fragment Bar on User {
|
||||
asd
|
||||
}
|
||||
|
||||
{
|
||||
user {
|
||||
name
|
||||
...Bar
|
||||
}
|
||||
}
|
||||
|
||||
fragment Baz on User {
|
||||
jkl
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "full test",
|
||||
operationName: "Foo",
|
||||
input: gql`
|
||||
query Foo($b: Int, $a: Boolean) {
|
||||
user(name: "hello", age: 5) {
|
||||
...Bar
|
||||
... on User {
|
||||
hello
|
||||
bee
|
||||
}
|
||||
tz
|
||||
aliased: name
|
||||
}
|
||||
}
|
||||
|
||||
fragment Baz on User {
|
||||
asd
|
||||
}
|
||||
|
||||
fragment Bar on User {
|
||||
age @skip(if: $a)
|
||||
...Nested
|
||||
}
|
||||
|
||||
fragment Nested on User {
|
||||
blah
|
||||
}
|
||||
`,
|
||||
},
|
||||
];
|
||||
cases.forEach(({ name, operationName, input }) => {
|
||||
test(name, () => {
|
||||
expect(
|
||||
defaultUsageReportingSignature(input, operationName)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("operationRegistrySignature", () => {
|
||||
const cases = [
|
||||
// Test cases borrowed from optics-agent-js.
|
||||
{
|
||||
name: "basic test",
|
||||
operationName: "",
|
||||
input: gql`
|
||||
{
|
||||
user {
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "basic test with query",
|
||||
operationName: "",
|
||||
input: gql`
|
||||
query {
|
||||
user {
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "basic with operation name",
|
||||
operationName: "OpName",
|
||||
input: gql`
|
||||
query OpName {
|
||||
user {
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "with various inline types",
|
||||
operationName: "OpName",
|
||||
input: gql`
|
||||
query OpName {
|
||||
user {
|
||||
name(apple: [[10]], cat: ENUM_VALUE, bag: { input: "value" })
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "with various argument types",
|
||||
operationName: "OpName",
|
||||
input: gql`
|
||||
query OpName($c: Int!, $a: [[Boolean!]!], $b: EnumType) {
|
||||
user {
|
||||
name(apple: $a, cat: $c, bag: $b)
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "fragment",
|
||||
operationName: "",
|
||||
input: gql`
|
||||
{
|
||||
user {
|
||||
name
|
||||
...Bar
|
||||
}
|
||||
}
|
||||
|
||||
fragment Bar on User {
|
||||
asd
|
||||
}
|
||||
|
||||
fragment Baz on User {
|
||||
jkl
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "fragments in various order",
|
||||
operationName: "",
|
||||
input: gql`
|
||||
fragment Bar on User {
|
||||
asd
|
||||
}
|
||||
|
||||
{
|
||||
user {
|
||||
name
|
||||
...Bar
|
||||
}
|
||||
}
|
||||
|
||||
fragment Baz on User {
|
||||
jkl
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "full test",
|
||||
operationName: "Foo",
|
||||
input: gql`
|
||||
query Foo($b: Int, $a: Boolean) {
|
||||
user(name: "hello", age: 5) {
|
||||
...Bar
|
||||
... on User {
|
||||
hello
|
||||
bee
|
||||
}
|
||||
tz
|
||||
aliased: name
|
||||
}
|
||||
}
|
||||
|
||||
fragment Baz on User {
|
||||
asd
|
||||
}
|
||||
|
||||
fragment Bar on User {
|
||||
age @skip(if: $a)
|
||||
...Nested
|
||||
}
|
||||
|
||||
fragment Nested on User {
|
||||
blah
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "test with preserveStringAndNumericLiterals=true",
|
||||
operationName: "Foo",
|
||||
input: gql`
|
||||
query Foo($b: Int) {
|
||||
user(name: "hello", age: 5) {
|
||||
...Bar
|
||||
a @skip(if: true)
|
||||
b @include(if: false)
|
||||
c(value: 4) {
|
||||
d
|
||||
}
|
||||
... on User {
|
||||
hello @directive(arg: "Value!")
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
options: { preserveStringAndNumericLiterals: true },
|
||||
},
|
||||
];
|
||||
cases.forEach(({ name, operationName, input, options }) => {
|
||||
test(name, () => {
|
||||
expect(
|
||||
operationRegistrySignature(input, operationName, options)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
149
node_modules/apollo-graphql/src/__tests__/transforms.test.ts
generated
vendored
Normal file
149
node_modules/apollo-graphql/src/__tests__/transforms.test.ts
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
import { default as gql, disableFragmentWarnings } from "graphql-tag";
|
||||
|
||||
import {
|
||||
printWithReducedWhitespace,
|
||||
hideLiterals,
|
||||
hideStringAndNumericLiterals,
|
||||
} from "../transforms";
|
||||
|
||||
// The gql duplicate fragment warning feature really is just warnings; nothing
|
||||
// breaks if you turn it off in tests.
|
||||
disableFragmentWarnings();
|
||||
|
||||
describe("printWithReducedWhitespace", () => {
|
||||
const cases = [
|
||||
{
|
||||
name: "lots of whitespace",
|
||||
// Note: there's a tab after "tab->", which prettier wants to keep as a
|
||||
// literal tab rather than \t. In the output, there should be a literal
|
||||
// backslash-t.
|
||||
input: gql`
|
||||
query Foo($a: Int) {
|
||||
user(
|
||||
name: " tab-> yay"
|
||||
other: """
|
||||
apple
|
||||
bag
|
||||
cat
|
||||
"""
|
||||
) {
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
output:
|
||||
'query Foo($a:Int){user(name:" tab->\\tyay",other:"apple\\n bag\\ncat"){name}}',
|
||||
},
|
||||
];
|
||||
cases.forEach(({ name, input, output }) => {
|
||||
test(name, () => {
|
||||
expect(printWithReducedWhitespace(input)).toEqual(output);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("hideLiterals", () => {
|
||||
const cases = [
|
||||
{
|
||||
name: "full test",
|
||||
input: gql`
|
||||
query Foo($b: Int, $a: Boolean) {
|
||||
user(
|
||||
name: "hello"
|
||||
age: 5
|
||||
pct: 0.4
|
||||
lst: ["a", "b", "c"]
|
||||
obj: { a: "a", b: 1 }
|
||||
) {
|
||||
...Bar
|
||||
... on User {
|
||||
hello
|
||||
bee
|
||||
}
|
||||
tz
|
||||
aliased: name
|
||||
withInputs(
|
||||
str: "hi"
|
||||
int: 2
|
||||
flt: 0.3
|
||||
lst: ["x", "y", "z"]
|
||||
obj: { q: "r", s: 1 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fragment Bar on User {
|
||||
age @skip(if: $a)
|
||||
...Nested
|
||||
}
|
||||
|
||||
fragment Nested on User {
|
||||
blah
|
||||
}
|
||||
`,
|
||||
output:
|
||||
'query Foo($b:Int,$a:Boolean){user(name:"",age:0,pct:0,lst:[],obj:{}){...Bar...on User{hello bee}tz aliased:name ' +
|
||||
'withInputs(str:"",int:0,flt:0,lst:[],obj:{})}}' +
|
||||
"fragment Bar on User{age@skip(if:$a)...Nested}fragment Nested on User{blah}",
|
||||
},
|
||||
];
|
||||
cases.forEach(({ name, input, output }) => {
|
||||
test(name, () => {
|
||||
expect(printWithReducedWhitespace(hideLiterals(input))).toEqual(output);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("hideStringAndNumericLiterals", () => {
|
||||
const cases = [
|
||||
{
|
||||
name: "full test",
|
||||
input: gql`
|
||||
query Foo($b: Int, $a: Boolean) {
|
||||
user(
|
||||
name: "hello"
|
||||
age: 5
|
||||
pct: 0.4
|
||||
lst: ["a", "b", "c"]
|
||||
obj: { a: "a", b: 1 }
|
||||
) {
|
||||
...Bar
|
||||
... on User {
|
||||
hello
|
||||
bee
|
||||
}
|
||||
tz
|
||||
aliased: name
|
||||
withInputs(
|
||||
str: "hi"
|
||||
int: 2
|
||||
flt: 0.3
|
||||
lst: ["", "", ""]
|
||||
obj: { q: "", s: 0 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fragment Bar on User {
|
||||
age @skip(if: $a)
|
||||
...Nested
|
||||
}
|
||||
|
||||
fragment Nested on User {
|
||||
blah
|
||||
}
|
||||
`,
|
||||
output:
|
||||
'query Foo($b:Int,$a:Boolean){user(name:"",age:0,pct:0,lst:["","",""],obj:{a:"",b:0}){...Bar...on User{hello bee}tz aliased:name ' +
|
||||
'withInputs(str:"",int:0,flt:0,lst:["","",""],obj:{q:"",s:0})}}' +
|
||||
"fragment Bar on User{age@skip(if:$a)...Nested}fragment Nested on User{blah}",
|
||||
},
|
||||
];
|
||||
cases.forEach(({ name, input, output }) => {
|
||||
test(name, () => {
|
||||
expect(
|
||||
printWithReducedWhitespace(hideStringAndNumericLiterals(input))
|
||||
).toEqual(output);
|
||||
});
|
||||
});
|
||||
});
|
||||
7
node_modules/apollo-graphql/src/__tests__/tsconfig.json
generated
vendored
Normal file
7
node_modules/apollo-graphql/src/__tests__/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.test",
|
||||
"include": ["**/*"],
|
||||
"references": [
|
||||
{ "path": "../../" }
|
||||
]
|
||||
}
|
||||
14
node_modules/apollo-graphql/src/index.ts
generated
vendored
Normal file
14
node_modules/apollo-graphql/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export {
|
||||
defaultOperationRegistrySignature,
|
||||
defaultUsageReportingSignature,
|
||||
operationRegistrySignature,
|
||||
operationHash,
|
||||
// deprecated name for this function:
|
||||
defaultUsageReportingSignature as defaultEngineReportingSignature,
|
||||
} from "./operationId";
|
||||
export * from "./schema";
|
||||
export {
|
||||
printWithReducedWhitespace,
|
||||
hideStringAndNumericLiterals,
|
||||
hideLiterals,
|
||||
} from "./transforms";
|
||||
109
node_modules/apollo-graphql/src/operationId.ts
generated
vendored
Normal file
109
node_modules/apollo-graphql/src/operationId.ts
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
// In Apollo Studio, we want to group requests making the same query together,
|
||||
// and treat different queries distinctly. But what does it mean for two queries
|
||||
// to be "the same"? And what if you don't want to send the full text of the
|
||||
// query to Apollo's servers, either because it contains sensitive data
|
||||
// or because it contains extraneous operations or fragments?
|
||||
//
|
||||
// To solve these problems, ApolloServerPluginUsageReporting has the concept of
|
||||
// "signatures". We don't (by default) send the full query string of queries to
|
||||
// Apollo's servers. Instead, each trace has its query string's "signature".
|
||||
//
|
||||
// You can technically specify any function mapping a GraphQL query AST
|
||||
// (DocumentNode) to string as your signature algorithm by providing it as the
|
||||
// 'calculateSignature' option to ApolloServerPluginUsageReporting. (This option
|
||||
// is not recommended, because Apollo's servers make some assumptions about the
|
||||
// semantics of your operation based on the signature.) This file defines the
|
||||
// default function used for this purpose: defaultUsageReportingSignature
|
||||
// (formerly known as defaultEngineReportingSignature).
|
||||
//
|
||||
// This module utilizes several AST transformations from the adjacent
|
||||
// 'transforms' module (which are also for writing your own signature method).
|
||||
|
||||
// - dropUnusedDefinitions, which removes operations and fragments that
|
||||
// aren't going to be used in execution
|
||||
// - hideLiterals, which replaces all numeric and string literals as well
|
||||
// as list and object input values with "empty" values
|
||||
// - removeAliases, which removes field aliasing from the query
|
||||
// - sortAST, which sorts the children of most multi-child nodes
|
||||
// consistently
|
||||
// - printWithReducedWhitespace, a variant on graphql-js's 'print'
|
||||
// which gets rid of unneeded whitespace
|
||||
//
|
||||
// defaultUsageReportingSignature consists of applying all of these building
|
||||
// blocks.
|
||||
//
|
||||
// Historical note: the default signature algorithm of the Go engineproxy
|
||||
// performed all of the above operations, and Apollo's servers then re-ran a
|
||||
// mostly identical signature implementation on received traces. This was
|
||||
// primarily to deal with edge cases where some users used literal interpolation
|
||||
// instead of GraphQL variables, included randomized alias names, etc. In
|
||||
// addition, the servers relied on the fact that dropUnusedDefinitions had been
|
||||
// called in order (and that the signature could be parsed as GraphQL) to
|
||||
// extract the name of the operation for display. This caused confusion, as the
|
||||
// query document shown in the Studio UI wasn't the same as the one actually
|
||||
// sent. ApolloServerPluginUsageReporting (previously apollo-engine-reporting)
|
||||
// uses a reporting API which requires it to explicitly include the operation
|
||||
// name with each signature; this means that the server no longer needs to parse
|
||||
// the signature or run its own signature algorithm on it, and the details of
|
||||
// the signature algorithm are now up to the reporting agent. That said, not all
|
||||
// Studio features will work properly if your signature function changes the
|
||||
// signature in unexpected ways.
|
||||
//
|
||||
// This file also exports operationRegistrySignature and
|
||||
// defaultOperationRegistrySignature, which are slightly different normalization
|
||||
// functions used in other contextes.
|
||||
import { DocumentNode } from "graphql";
|
||||
import {
|
||||
printWithReducedWhitespace,
|
||||
dropUnusedDefinitions,
|
||||
sortAST,
|
||||
hideStringAndNumericLiterals,
|
||||
removeAliases,
|
||||
hideLiterals,
|
||||
} from "./transforms";
|
||||
import { createHash } from "./utilities/createHash";
|
||||
|
||||
// The usage reporting signature function consists of removing extra whitespace,
|
||||
// sorting the AST in a deterministic manner, hiding literals, and removing
|
||||
// unused definitions.
|
||||
export function defaultUsageReportingSignature(
|
||||
ast: DocumentNode,
|
||||
operationName: string
|
||||
): string {
|
||||
return printWithReducedWhitespace(
|
||||
sortAST(
|
||||
removeAliases(hideLiterals(dropUnusedDefinitions(ast, operationName)))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// The operation registry signature function consists of removing extra whitespace,
|
||||
// sorting the AST in a deterministic manner, potentially hiding string and numeric
|
||||
// literals, and removing unused definitions. This is a less aggressive transform
|
||||
// than its usage reporting signature counterpart.
|
||||
export function operationRegistrySignature(
|
||||
ast: DocumentNode,
|
||||
operationName: string,
|
||||
options: { preserveStringAndNumericLiterals: boolean } = {
|
||||
preserveStringAndNumericLiterals: false,
|
||||
}
|
||||
): string {
|
||||
const withoutUnusedDefs = dropUnusedDefinitions(ast, operationName);
|
||||
const maybeWithLiterals = options.preserveStringAndNumericLiterals
|
||||
? withoutUnusedDefs
|
||||
: hideStringAndNumericLiterals(withoutUnusedDefs);
|
||||
return printWithReducedWhitespace(sortAST(maybeWithLiterals));
|
||||
}
|
||||
|
||||
export function defaultOperationRegistrySignature(
|
||||
ast: DocumentNode,
|
||||
operationName: string
|
||||
): string {
|
||||
return operationRegistrySignature(ast, operationName, {
|
||||
preserveStringAndNumericLiterals: false,
|
||||
});
|
||||
}
|
||||
|
||||
export function operationHash(operation: string): string {
|
||||
return createHash("sha256").update(operation).digest("hex");
|
||||
}
|
||||
11
node_modules/apollo-graphql/src/schema/GraphQLSchemaValidationError.ts
generated
vendored
Normal file
11
node_modules/apollo-graphql/src/schema/GraphQLSchemaValidationError.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { GraphQLError } from "graphql";
|
||||
|
||||
export class GraphQLSchemaValidationError extends Error {
|
||||
constructor(public errors: ReadonlyArray<GraphQLError>) {
|
||||
super();
|
||||
|
||||
this.name = this.constructor.name;
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
this.message = errors.map((error) => error.message).join("\n\n");
|
||||
}
|
||||
}
|
||||
577
node_modules/apollo-graphql/src/schema/__tests__/buildSchemaFromSDL.test.ts
generated
vendored
Normal file
577
node_modules/apollo-graphql/src/schema/__tests__/buildSchemaFromSDL.test.ts
generated
vendored
Normal file
@@ -0,0 +1,577 @@
|
||||
import gql from "graphql-tag";
|
||||
import { buildSchemaFromSDL } from "../buildSchemaFromSDL";
|
||||
import {
|
||||
GraphQLSchema,
|
||||
GraphQLDirective,
|
||||
DirectiveLocation,
|
||||
GraphQLObjectType,
|
||||
GraphQLAbstractType,
|
||||
GraphQLScalarType,
|
||||
GraphQLScalarTypeConfig,
|
||||
GraphQLEnumType,
|
||||
Kind,
|
||||
execute,
|
||||
ExecutionResult,
|
||||
} from "graphql";
|
||||
|
||||
import astSerializer from "./snapshotSerializers/astSerializer";
|
||||
import graphQLTypeSerializer from "./snapshotSerializers/graphQLTypeSerializer";
|
||||
import selectionSetSerializer from "./snapshotSerializers/selectionSetSerializer";
|
||||
|
||||
expect.addSnapshotSerializer(astSerializer);
|
||||
expect.addSnapshotSerializer(graphQLTypeSerializer);
|
||||
expect.addSnapshotSerializer(selectionSetSerializer);
|
||||
|
||||
describe("buildSchemaFromSDL", () => {
|
||||
describe(`type definitions`, () => {
|
||||
it(`should construct types from definitions`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
type User {
|
||||
name: String
|
||||
}
|
||||
|
||||
type Post {
|
||||
title: String
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
expect(schema.getType("User")).toMatchInlineSnapshot(`
|
||||
type User {
|
||||
name: String
|
||||
}
|
||||
`);
|
||||
|
||||
expect(schema.getType("Post")).toMatchInlineSnapshot(`
|
||||
type Post {
|
||||
title: String
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it(`should not allow multiple type definitions with the same name`, () => {
|
||||
expect(() =>
|
||||
buildSchemaFromSDL(
|
||||
gql`
|
||||
type User {
|
||||
name: String
|
||||
}
|
||||
|
||||
type User {
|
||||
title: String
|
||||
}
|
||||
`
|
||||
)
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"There can be only one type named \\"User\\"."`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe(`type extension`, () => {
|
||||
it(`should allow extending a type defined in the same document`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
type User {
|
||||
name: String
|
||||
}
|
||||
|
||||
extend type User {
|
||||
email: String
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
expect(schema.getType("User")).toMatchInlineSnapshot(`
|
||||
type User {
|
||||
name: String
|
||||
email: String
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it(`should allow extending a non-existent type`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
extend type User {
|
||||
email: String
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
expect(schema.getType("User")).toMatchInlineSnapshot(`
|
||||
type User {
|
||||
email: String
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it.skip(`should report an error when extending a non-existent type`, () => {
|
||||
expect(() =>
|
||||
buildSchemaFromSDL(
|
||||
gql`
|
||||
extend type User {
|
||||
email: String
|
||||
}
|
||||
`
|
||||
)
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Cannot extend type \\"User\\" because it is not defined."`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe(`root operation types`, () => {
|
||||
it(`should include a root type with a default type name`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
type Query {
|
||||
rootField: String
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
expect(schema.getType("Query")).toMatchInlineSnapshot(`
|
||||
type Query {
|
||||
rootField: String
|
||||
}
|
||||
`);
|
||||
|
||||
expect(schema.getQueryType()).toEqual(schema.getType("Query"));
|
||||
});
|
||||
|
||||
it(`should include a root type with a non-default type name`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
schema {
|
||||
query: Query
|
||||
}
|
||||
|
||||
type Query {
|
||||
rootField: String
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
expect(schema.getType("Query")).toMatchInlineSnapshot(`
|
||||
type Query {
|
||||
rootField: String
|
||||
}
|
||||
`);
|
||||
|
||||
expect(schema.getQueryType()).toEqual(schema.getType("Query"));
|
||||
});
|
||||
|
||||
it(`should include a root type with a non-default type name specified in a schema extension`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
extend schema {
|
||||
query: Query
|
||||
}
|
||||
|
||||
type Query {
|
||||
rootField: String
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
expect(schema.getType("Query")).toMatchInlineSnapshot(`
|
||||
type Query {
|
||||
rootField: String
|
||||
}
|
||||
`);
|
||||
|
||||
expect(schema.getQueryType()).toEqual(schema.getType("Query"));
|
||||
});
|
||||
|
||||
describe(`extending root operation types that aren't defined elsewhere`, () => {
|
||||
it(`should be allowed`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
extend type Query {
|
||||
rootField: String
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
expect(schema.getType("Query")).toMatchInlineSnapshot(`
|
||||
type Query {
|
||||
rootField: String
|
||||
}
|
||||
`);
|
||||
expect(schema.getQueryType()).toEqual(schema.getType("Query"));
|
||||
});
|
||||
|
||||
it(`should be allowed with a non-default type name`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
schema {
|
||||
query: QueryRoot
|
||||
}
|
||||
extend type QueryRoot {
|
||||
rootField: String
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
expect(schema.getType("QueryRoot")).toMatchInlineSnapshot(`
|
||||
type QueryRoot {
|
||||
rootField: String
|
||||
}
|
||||
`);
|
||||
expect(schema.getQueryType()).toEqual(schema.getType("QueryRoot"));
|
||||
});
|
||||
|
||||
it(`should be allowed with a non-default name specified in a schema extension`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
schema {
|
||||
query: QueryRoot
|
||||
}
|
||||
type QueryRoot {
|
||||
rootField: String
|
||||
}
|
||||
|
||||
extend schema {
|
||||
mutation: MutationRoot
|
||||
}
|
||||
extend type MutationRoot {
|
||||
rootField: String
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
expect(schema.getType("MutationRoot")).toMatchInlineSnapshot(`
|
||||
type MutationRoot {
|
||||
rootField: String
|
||||
}
|
||||
`);
|
||||
expect(schema.getQueryType()).toEqual(schema.getType("QueryRoot"));
|
||||
expect(schema.getMutationType()).toEqual(
|
||||
schema.getType("MutationRoot")
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(`directives`, () => {
|
||||
it(`should construct directives from definitions`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
directive @something on FIELD_DEFINITION
|
||||
directive @another on FIELD_DEFINITION
|
||||
`
|
||||
);
|
||||
|
||||
expect(schema.getDirective("something")).toMatchInlineSnapshot(
|
||||
`"@something"`
|
||||
);
|
||||
|
||||
expect(schema.getDirective("another")).toMatchInlineSnapshot(
|
||||
`"@another"`
|
||||
);
|
||||
});
|
||||
|
||||
it(`should not allow multiple directive definitions with the same name`, () => {
|
||||
expect(() =>
|
||||
buildSchemaFromSDL(
|
||||
gql`
|
||||
directive @something on FIELD_DEFINITION
|
||||
directive @something on FIELD_DEFINITION
|
||||
`
|
||||
)
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"There can be only one directive named \\"@something\\"."`
|
||||
);
|
||||
});
|
||||
|
||||
it(`should not allow a directive definition with the same name as a predefined schema directive`, () => {
|
||||
expect(() =>
|
||||
buildSchemaFromSDL(
|
||||
gql`
|
||||
directive @something on FIELD_DEFINITION
|
||||
`,
|
||||
new GraphQLSchema({
|
||||
query: undefined,
|
||||
directives: [
|
||||
new GraphQLDirective({
|
||||
name: "something",
|
||||
locations: [DirectiveLocation.FIELD_DEFINITION],
|
||||
}),
|
||||
],
|
||||
})
|
||||
)
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Directive \\"@something\\" already exists in the schema. It cannot be redefined."`
|
||||
);
|
||||
});
|
||||
|
||||
it(`should allow predefined schema directives to be used`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
type User {
|
||||
name: String @something
|
||||
}
|
||||
`,
|
||||
new GraphQLSchema({
|
||||
query: undefined,
|
||||
directives: [
|
||||
new GraphQLDirective({
|
||||
name: "something",
|
||||
locations: [DirectiveLocation.FIELD_DEFINITION],
|
||||
}),
|
||||
],
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it(`should allow schema directives to be used in the same document they are defined in`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
directive @something on FIELD_DEFINITION
|
||||
|
||||
type User {
|
||||
name: String @something
|
||||
}
|
||||
`
|
||||
);
|
||||
});
|
||||
|
||||
it(`should report an error for unknown schema directives`, () => {
|
||||
expect(() =>
|
||||
buildSchemaFromSDL(
|
||||
gql`
|
||||
type User {
|
||||
name: String @something
|
||||
}
|
||||
`
|
||||
)
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Unknown directive \\"@something\\"."`
|
||||
);
|
||||
});
|
||||
|
||||
it(`should preserve directive usages from the schema definition node`, () => {
|
||||
const schema = buildSchemaFromSDL(
|
||||
gql`
|
||||
directive @contact(
|
||||
name: String!
|
||||
url: String!
|
||||
description: String
|
||||
) on SCHEMA
|
||||
|
||||
schema
|
||||
@contact(
|
||||
name: "Contact"
|
||||
url: "http://example.com/contact"
|
||||
description: "Testing"
|
||||
) {
|
||||
query: Query
|
||||
}
|
||||
`
|
||||
);
|
||||
expect(schema.astNode!.directives).toHaveLength(1);
|
||||
expect(schema.astNode!.directives![0].name.value).toEqual("contact");
|
||||
});
|
||||
});
|
||||
|
||||
describe(`resolvers`, () => {
|
||||
it(`should add a resolver for a field`, () => {
|
||||
const name = () => {};
|
||||
|
||||
const schema = buildSchemaFromSDL([
|
||||
{
|
||||
typeDefs: gql`
|
||||
type User {
|
||||
name: String
|
||||
}
|
||||
`,
|
||||
resolvers: {
|
||||
User: {
|
||||
name,
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const userType = schema.getType("User");
|
||||
expect(userType).toBeDefined();
|
||||
|
||||
const nameField = (userType! as GraphQLObjectType).getFields()["name"];
|
||||
expect(nameField).toBeDefined();
|
||||
|
||||
expect(nameField.resolve).toEqual(name);
|
||||
});
|
||||
|
||||
it(`should add meta fields to abstract types`, () => {
|
||||
const typeDefs = gql`
|
||||
union Animal = Dog
|
||||
|
||||
interface Creature {
|
||||
name: String!
|
||||
legs: Int!
|
||||
}
|
||||
|
||||
type Dog {
|
||||
id: ID!
|
||||
}
|
||||
|
||||
type Cat implements Creature {
|
||||
meow: Boolean!
|
||||
}
|
||||
`;
|
||||
|
||||
const resolveTypeUnion = (obj: any) => {
|
||||
return "Dog";
|
||||
};
|
||||
|
||||
const resolveTypeInterface = (obj: any) => {
|
||||
if (obj.meow) {
|
||||
return "Cat";
|
||||
}
|
||||
throw Error("Couldn't resolve interface");
|
||||
};
|
||||
|
||||
const resolvers = {
|
||||
Animal: {
|
||||
__resolveType: resolveTypeUnion,
|
||||
},
|
||||
Creature: {
|
||||
__resolveType: resolveTypeInterface,
|
||||
},
|
||||
};
|
||||
|
||||
const schema = buildSchemaFromSDL([{ typeDefs, resolvers }]);
|
||||
const animalUnion = schema.getType("Animal") as GraphQLAbstractType;
|
||||
const creatureInterface = schema.getType(
|
||||
"Creature"
|
||||
) as GraphQLAbstractType;
|
||||
|
||||
expect(animalUnion.resolveType).toBe(resolveTypeUnion);
|
||||
expect(creatureInterface.resolveType).toBe(resolveTypeInterface);
|
||||
});
|
||||
|
||||
it(`should add resolvers for scalar types`, () => {
|
||||
const typeDefs = gql`
|
||||
scalar Custom
|
||||
`;
|
||||
|
||||
const customTypeConfig: GraphQLScalarTypeConfig<string, string> = {
|
||||
name: "Custom",
|
||||
serialize: (value) => value,
|
||||
parseValue: (value) => value,
|
||||
parseLiteral: (input) => {
|
||||
if (input.kind !== Kind.STRING) {
|
||||
throw new Error("Expected value to be string");
|
||||
}
|
||||
return input.value;
|
||||
},
|
||||
};
|
||||
|
||||
const CustomType = new GraphQLScalarType(customTypeConfig);
|
||||
|
||||
const resolvers = { Custom: CustomType };
|
||||
|
||||
const schema = buildSchemaFromSDL([{ typeDefs, resolvers }]);
|
||||
const custom = schema.getType("Custom") as GraphQLScalarType;
|
||||
|
||||
expect(custom.parseLiteral).toBe(CustomType.parseLiteral);
|
||||
expect(custom.parseValue).toBe(CustomType.parseValue);
|
||||
expect(custom.serialize).toBe(CustomType.serialize);
|
||||
});
|
||||
|
||||
it(`should add resolvers to enum types`, () => {
|
||||
const typeDefs = gql`
|
||||
enum AllowedColor {
|
||||
RED
|
||||
GREEN
|
||||
BLUE
|
||||
}
|
||||
|
||||
type Query {
|
||||
favoriteColor: AllowedColor
|
||||
avatar(borderColor: AllowedColor): String
|
||||
}
|
||||
`;
|
||||
|
||||
const mockResolver = jest.fn();
|
||||
|
||||
const resolvers = {
|
||||
AllowedColor: {
|
||||
RED: "#f00",
|
||||
GREEN: "#0f0",
|
||||
BLUE: "#00f",
|
||||
},
|
||||
Query: {
|
||||
favoriteColor: () => "#f00",
|
||||
avatar: (_: any, params: any) => mockResolver(_, params),
|
||||
},
|
||||
};
|
||||
|
||||
const schema = buildSchemaFromSDL([{ typeDefs, resolvers }]);
|
||||
const colorEnum = schema.getType("AllowedColor") as GraphQLEnumType;
|
||||
|
||||
let result = execute(
|
||||
schema,
|
||||
gql`
|
||||
query {
|
||||
favoriteColor
|
||||
avatar(borderColor: RED)
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
expect((result as ExecutionResult).data!.favoriteColor).toBe("RED");
|
||||
expect(colorEnum.getValue("RED")!.value).toBe("#f00");
|
||||
expect(mockResolver).toBeCalledWith(undefined, { borderColor: "#f00" });
|
||||
});
|
||||
|
||||
it(`should add resolvers to enum types with 0 value`, () => {
|
||||
const typeDefs = gql`
|
||||
enum CustomerType {
|
||||
EXISTING
|
||||
NEW
|
||||
}
|
||||
|
||||
type Query {
|
||||
existingCustomer: CustomerType
|
||||
newCustomer: CustomerType
|
||||
}
|
||||
`;
|
||||
|
||||
const resolvers = {
|
||||
CustomerType: {
|
||||
EXISTING: 0,
|
||||
NEW: 1,
|
||||
},
|
||||
Query: {
|
||||
existingCustomer: () => 0,
|
||||
newCustomer: () => 1,
|
||||
},
|
||||
};
|
||||
|
||||
const schema = buildSchemaFromSDL([{ typeDefs, resolvers }]);
|
||||
const customerTypeEnum = schema.getType(
|
||||
"CustomerType"
|
||||
) as GraphQLEnumType;
|
||||
|
||||
let result = execute(
|
||||
schema,
|
||||
gql`
|
||||
query {
|
||||
existingCustomer
|
||||
newCustomer
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
expect((result as ExecutionResult).data!.existingCustomer).toBe(
|
||||
"EXISTING"
|
||||
);
|
||||
expect(customerTypeEnum.getValue("EXISTING")!.value).toBe(0);
|
||||
expect((result as ExecutionResult).data!.newCustomer).toBe("NEW");
|
||||
expect(customerTypeEnum.getValue("NEW")!.value).toBe(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
24
node_modules/apollo-graphql/src/schema/__tests__/snapshotSerializers/astSerializer.ts
generated
vendored
Normal file
24
node_modules/apollo-graphql/src/schema/__tests__/snapshotSerializers/astSerializer.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { ASTNode, print } from "graphql";
|
||||
import { Plugin, Config, Refs, Printer } from "pretty-format";
|
||||
|
||||
export = {
|
||||
test(value: any) {
|
||||
return value && typeof value.kind === "string";
|
||||
},
|
||||
|
||||
serialize(
|
||||
value: ASTNode,
|
||||
config: Config,
|
||||
indentation: string,
|
||||
depth: number,
|
||||
refs: Refs,
|
||||
printer: Printer
|
||||
): string {
|
||||
return (
|
||||
indentation +
|
||||
print(value)
|
||||
.trim()
|
||||
.replace(/\n/g, "\n" + indentation)
|
||||
);
|
||||
},
|
||||
} as Plugin as unknown as jest.SnapshotSerializerPlugin;
|
||||
19
node_modules/apollo-graphql/src/schema/__tests__/snapshotSerializers/graphQLTypeSerializer.ts
generated
vendored
Normal file
19
node_modules/apollo-graphql/src/schema/__tests__/snapshotSerializers/graphQLTypeSerializer.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { isNamedType, GraphQLNamedType, printType } from "graphql";
|
||||
import { Plugin, Config, Refs, Printer } from "pretty-format";
|
||||
|
||||
export = {
|
||||
test(value: any) {
|
||||
return value && isNamedType(value);
|
||||
},
|
||||
|
||||
serialize(
|
||||
value: GraphQLNamedType,
|
||||
config: Config,
|
||||
indentation: string,
|
||||
depth: number,
|
||||
refs: Refs,
|
||||
printer: Printer
|
||||
): string {
|
||||
return printType(value);
|
||||
},
|
||||
} as Plugin as unknown as jest.SnapshotSerializerPlugin;
|
||||
21
node_modules/apollo-graphql/src/schema/__tests__/snapshotSerializers/selectionSetSerializer.ts
generated
vendored
Normal file
21
node_modules/apollo-graphql/src/schema/__tests__/snapshotSerializers/selectionSetSerializer.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { print, SelectionNode, isSelectionNode } from "graphql";
|
||||
import { Plugin, Config, Refs, Printer } from "pretty-format";
|
||||
|
||||
export = {
|
||||
test(value: any) {
|
||||
return (
|
||||
Array.isArray(value) && value.length > 0 && value.every(isSelectionNode)
|
||||
);
|
||||
},
|
||||
|
||||
serialize(
|
||||
value: SelectionNode[],
|
||||
config: Config,
|
||||
indentation: string,
|
||||
depth: number,
|
||||
refs: Refs,
|
||||
printer: Printer
|
||||
): string {
|
||||
return String(print(value)).replace(",", "\n");
|
||||
},
|
||||
} as Plugin as unknown as jest.SnapshotSerializerPlugin;
|
||||
40
node_modules/apollo-graphql/src/schema/__tests__/transformSchema.test.ts
generated
vendored
Normal file
40
node_modules/apollo-graphql/src/schema/__tests__/transformSchema.test.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { buildSchema, printSchema } from "graphql";
|
||||
import { transformSchema } from "../transformSchema";
|
||||
|
||||
describe("transformSchema", () => {
|
||||
test("no-op transform leaves types untouched", () => {
|
||||
const schema = buildSchema(`#graphql
|
||||
type Query {
|
||||
foo: String @test(baz: { bar: "hello" })
|
||||
}
|
||||
|
||||
input DirectiveArg {
|
||||
bar: String
|
||||
}
|
||||
|
||||
# https://github.com/apollographql/apollo-tooling/issues/2162
|
||||
directive @test(baz: DirectiveArg) on FIELD_DEFINITION
|
||||
|
||||
interface FooInterface {
|
||||
foo: String
|
||||
}
|
||||
|
||||
interface BarInterface implements FooInterface {
|
||||
foo: String
|
||||
bar: Boolean
|
||||
}
|
||||
|
||||
type FooBarBazType implements FooInterface & BarInterface {
|
||||
foo: String
|
||||
bar: Boolean
|
||||
baz: Float
|
||||
}
|
||||
`);
|
||||
|
||||
const originalSDL = printSchema(schema);
|
||||
const newSchema = transformSchema(schema, (namedType) => namedType);
|
||||
|
||||
expect(printSchema(schema)).toEqual(originalSDL);
|
||||
expect(printSchema(newSchema)).toEqual(originalSDL);
|
||||
});
|
||||
});
|
||||
7
node_modules/apollo-graphql/src/schema/__tests__/tsconfig.json
generated
vendored
Normal file
7
node_modules/apollo-graphql/src/schema/__tests__/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.test",
|
||||
"include": ["**/*"],
|
||||
"references": [
|
||||
{ "path": "../../../" },
|
||||
]
|
||||
}
|
||||
318
node_modules/apollo-graphql/src/schema/buildSchemaFromSDL.ts
generated
vendored
Normal file
318
node_modules/apollo-graphql/src/schema/buildSchemaFromSDL.ts
generated
vendored
Normal file
@@ -0,0 +1,318 @@
|
||||
import {
|
||||
concatAST,
|
||||
DocumentNode,
|
||||
extendSchema,
|
||||
GraphQLSchema,
|
||||
isObjectType,
|
||||
isTypeDefinitionNode,
|
||||
isTypeExtensionNode,
|
||||
Kind,
|
||||
TypeDefinitionNode,
|
||||
TypeExtensionNode,
|
||||
DirectiveDefinitionNode,
|
||||
SchemaDefinitionNode,
|
||||
SchemaExtensionNode,
|
||||
OperationTypeNode,
|
||||
GraphQLObjectType,
|
||||
GraphQLEnumType,
|
||||
isAbstractType,
|
||||
isScalarType,
|
||||
isEnumType,
|
||||
GraphQLEnumValueConfig,
|
||||
DirectiveNode,
|
||||
} from "graphql";
|
||||
import { validateSDL } from "graphql/validation/validate";
|
||||
import { isDocumentNode, isNode } from "../utilities/graphql";
|
||||
import { GraphQLResolverMap } from "./resolverMap";
|
||||
import { GraphQLSchemaValidationError } from "./GraphQLSchemaValidationError";
|
||||
import { specifiedSDLRules } from "graphql/validation/specifiedRules";
|
||||
|
||||
// TODO(Node.js 10): When we deprecate Node.js 10, remove this and switch
|
||||
// to using `Array.prototype.flat`. When doing this, deleting the hand-rolled
|
||||
// types in `./packages/apollo-gateway/src/types/` that go with it.
|
||||
import flat from "core-js-pure/features/array/flat";
|
||||
|
||||
import {
|
||||
KnownTypeNamesRule,
|
||||
UniqueDirectivesPerLocationRule,
|
||||
ValidationRule,
|
||||
} from "graphql/validation";
|
||||
import { mapValues } from "../utilities/mapValues";
|
||||
|
||||
export interface GraphQLSchemaModule {
|
||||
typeDefs: DocumentNode;
|
||||
resolvers?: GraphQLResolverMap<any>;
|
||||
}
|
||||
|
||||
const skippedSDLRules: ValidationRule[] = [
|
||||
KnownTypeNamesRule,
|
||||
UniqueDirectivesPerLocationRule,
|
||||
];
|
||||
|
||||
// BREAKING VERSION: Remove this when graphql-js 15 is minimum version.
|
||||
// Currently, this PossibleTypeExtensions rule is experimental and thus not
|
||||
// exposed directly from the rules module above. This may change in the future!
|
||||
// Additionally, it does not exist in prior graphql versions. Thus this try/catch.
|
||||
try {
|
||||
const PossibleTypeExtensions: typeof import("graphql/validation/rules/PossibleTypeExtensions").PossibleTypeExtensions =
|
||||
require("graphql/validation/rules/PossibleTypeExtensions").PossibleTypeExtensions;
|
||||
if (PossibleTypeExtensions) {
|
||||
skippedSDLRules.push(PossibleTypeExtensions);
|
||||
}
|
||||
} catch (e) {
|
||||
// No need to fail in this case. Instead, if this validation rule is missing, we will assume its not used
|
||||
// by the version of `graphql` that is available to us.
|
||||
}
|
||||
|
||||
const sdlRules = specifiedSDLRules.filter(
|
||||
(rule) => !skippedSDLRules.includes(rule)
|
||||
);
|
||||
|
||||
export function modulesFromSDL(
|
||||
modulesOrSDL: (GraphQLSchemaModule | DocumentNode)[] | DocumentNode
|
||||
): GraphQLSchemaModule[] {
|
||||
if (Array.isArray(modulesOrSDL)) {
|
||||
return modulesOrSDL.map((moduleOrSDL) => {
|
||||
if (isNode(moduleOrSDL) && isDocumentNode(moduleOrSDL)) {
|
||||
return { typeDefs: moduleOrSDL };
|
||||
} else {
|
||||
return moduleOrSDL;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return [{ typeDefs: modulesOrSDL }];
|
||||
}
|
||||
}
|
||||
|
||||
export function buildSchemaFromSDL(
|
||||
modulesOrSDL: (GraphQLSchemaModule | DocumentNode)[] | DocumentNode,
|
||||
schemaToExtend?: GraphQLSchema
|
||||
): GraphQLSchema {
|
||||
const modules = modulesFromSDL(modulesOrSDL);
|
||||
|
||||
const documentAST = concatAST(modules.map((module) => module.typeDefs));
|
||||
|
||||
const errors = validateSDL(documentAST, schemaToExtend, sdlRules);
|
||||
if (errors.length > 0) {
|
||||
throw new GraphQLSchemaValidationError(errors);
|
||||
}
|
||||
|
||||
const definitionsMap: {
|
||||
[name: string]: TypeDefinitionNode[];
|
||||
} = Object.create(null);
|
||||
|
||||
const extensionsMap: {
|
||||
[name: string]: TypeExtensionNode[];
|
||||
} = Object.create(null);
|
||||
|
||||
const directiveDefinitions: DirectiveDefinitionNode[] = [];
|
||||
|
||||
const schemaDefinitions: SchemaDefinitionNode[] = [];
|
||||
const schemaExtensions: SchemaExtensionNode[] = [];
|
||||
const schemaDirectives: DirectiveNode[] = [];
|
||||
|
||||
for (const definition of documentAST.definitions) {
|
||||
if (isTypeDefinitionNode(definition)) {
|
||||
const typeName = definition.name.value;
|
||||
|
||||
if (definitionsMap[typeName]) {
|
||||
definitionsMap[typeName].push(definition);
|
||||
} else {
|
||||
definitionsMap[typeName] = [definition];
|
||||
}
|
||||
} else if (isTypeExtensionNode(definition)) {
|
||||
const typeName = definition.name.value;
|
||||
|
||||
if (extensionsMap[typeName]) {
|
||||
extensionsMap[typeName].push(definition);
|
||||
} else {
|
||||
extensionsMap[typeName] = [definition];
|
||||
}
|
||||
} else if (definition.kind === Kind.DIRECTIVE_DEFINITION) {
|
||||
directiveDefinitions.push(definition);
|
||||
} else if (definition.kind === Kind.SCHEMA_DEFINITION) {
|
||||
schemaDefinitions.push(definition);
|
||||
schemaDirectives.push(
|
||||
...(definition.directives ? definition.directives : [])
|
||||
);
|
||||
} else if (definition.kind === Kind.SCHEMA_EXTENSION) {
|
||||
schemaExtensions.push(definition);
|
||||
}
|
||||
}
|
||||
|
||||
let schema = schemaToExtend
|
||||
? schemaToExtend
|
||||
: new GraphQLSchema({
|
||||
query: undefined,
|
||||
});
|
||||
|
||||
const missingTypeDefinitions: TypeDefinitionNode[] = [];
|
||||
|
||||
for (const [extendedTypeName, extensions] of Object.entries(extensionsMap)) {
|
||||
if (!definitionsMap[extendedTypeName]) {
|
||||
const extension = extensions[0];
|
||||
|
||||
const kind = extension.kind;
|
||||
const definition = {
|
||||
kind: extKindToDefKind[kind],
|
||||
name: extension.name,
|
||||
} as TypeDefinitionNode;
|
||||
|
||||
missingTypeDefinitions.push(definition);
|
||||
}
|
||||
}
|
||||
|
||||
schema = extendSchema(
|
||||
schema,
|
||||
{
|
||||
kind: Kind.DOCUMENT,
|
||||
definitions: [
|
||||
...flat(Object.values(definitionsMap)),
|
||||
...missingTypeDefinitions,
|
||||
...directiveDefinitions,
|
||||
],
|
||||
},
|
||||
{
|
||||
assumeValidSDL: true,
|
||||
}
|
||||
);
|
||||
|
||||
schema = extendSchema(
|
||||
schema,
|
||||
{
|
||||
kind: Kind.DOCUMENT,
|
||||
definitions: flat(Object.values(extensionsMap)),
|
||||
},
|
||||
{
|
||||
assumeValidSDL: true,
|
||||
}
|
||||
);
|
||||
|
||||
let operationTypeMap: { [operation in OperationTypeNode]?: string };
|
||||
|
||||
if (schemaDefinitions.length > 0 || schemaExtensions.length > 0) {
|
||||
operationTypeMap = {};
|
||||
|
||||
const operationTypes = flat(
|
||||
[...schemaDefinitions, ...schemaExtensions]
|
||||
.map((node) => node.operationTypes)
|
||||
.filter(isNotNullOrUndefined)
|
||||
);
|
||||
|
||||
for (const { operation, type } of operationTypes) {
|
||||
operationTypeMap[operation] = type.name.value;
|
||||
}
|
||||
} else {
|
||||
operationTypeMap = {
|
||||
query: "Query",
|
||||
mutation: "Mutation",
|
||||
subscription: "Subscription",
|
||||
};
|
||||
}
|
||||
|
||||
schema = new GraphQLSchema({
|
||||
...schema.toConfig(),
|
||||
...mapValues(operationTypeMap, (typeName) =>
|
||||
typeName
|
||||
? (schema.getType(typeName) as GraphQLObjectType<any, any>)
|
||||
: undefined
|
||||
),
|
||||
astNode: {
|
||||
kind: Kind.SCHEMA_DEFINITION,
|
||||
directives: schemaDirectives,
|
||||
operationTypes: [], // satisfies typescript, will be ignored
|
||||
},
|
||||
});
|
||||
|
||||
for (const module of modules) {
|
||||
if (!module.resolvers) continue;
|
||||
addResolversToSchema(schema, module.resolvers);
|
||||
}
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
const extKindToDefKind = {
|
||||
[Kind.SCALAR_TYPE_EXTENSION]: Kind.SCALAR_TYPE_DEFINITION,
|
||||
[Kind.OBJECT_TYPE_EXTENSION]: Kind.OBJECT_TYPE_DEFINITION,
|
||||
[Kind.INTERFACE_TYPE_EXTENSION]: Kind.INTERFACE_TYPE_DEFINITION,
|
||||
[Kind.UNION_TYPE_EXTENSION]: Kind.UNION_TYPE_DEFINITION,
|
||||
[Kind.ENUM_TYPE_EXTENSION]: Kind.ENUM_TYPE_DEFINITION,
|
||||
[Kind.INPUT_OBJECT_TYPE_EXTENSION]: Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
||||
};
|
||||
|
||||
export function addResolversToSchema(
|
||||
schema: GraphQLSchema,
|
||||
resolvers: GraphQLResolverMap<any>
|
||||
) {
|
||||
for (const [typeName, fieldConfigs] of Object.entries(resolvers)) {
|
||||
const type = schema.getType(typeName);
|
||||
|
||||
if (isAbstractType(type)) {
|
||||
for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
|
||||
if (fieldName.startsWith("__")) {
|
||||
(type as any)[fieldName.substring(2)] = fieldConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isScalarType(type)) {
|
||||
for (const fn in fieldConfigs) {
|
||||
(type as any)[fn] = (fieldConfigs as any)[fn];
|
||||
}
|
||||
}
|
||||
|
||||
if (isEnumType(type)) {
|
||||
const values = type.getValues();
|
||||
const newValues: { [key: string]: GraphQLEnumValueConfig } = {};
|
||||
values.forEach((value) => {
|
||||
let newValue = (fieldConfigs as any)[value.name];
|
||||
if (newValue === undefined) {
|
||||
newValue = value.name;
|
||||
}
|
||||
|
||||
newValues[value.name] = {
|
||||
value: newValue,
|
||||
deprecationReason: value.deprecationReason,
|
||||
description: value.description,
|
||||
astNode: value.astNode,
|
||||
extensions: undefined,
|
||||
};
|
||||
});
|
||||
|
||||
// In place updating hack to get around pulling in the full
|
||||
// schema walking and immutable updating machinery from graphql-tools
|
||||
Object.assign(
|
||||
type,
|
||||
new GraphQLEnumType({
|
||||
...type.toConfig(),
|
||||
values: newValues,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (!isObjectType(type)) continue;
|
||||
|
||||
const fieldMap = type.getFields();
|
||||
|
||||
for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
|
||||
if (fieldName.startsWith("__")) {
|
||||
(type as any)[fieldName.substring(2)] = fieldConfig;
|
||||
continue;
|
||||
}
|
||||
|
||||
const field = fieldMap[fieldName];
|
||||
if (!field) continue;
|
||||
|
||||
if (typeof fieldConfig === "function") {
|
||||
field.resolve = fieldConfig;
|
||||
} else {
|
||||
field.resolve = fieldConfig.resolve;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isNotNullOrUndefined<T>(value: T | null | undefined): value is T {
|
||||
return value !== null && typeof value !== "undefined";
|
||||
}
|
||||
5
node_modules/apollo-graphql/src/schema/index.ts
generated
vendored
Normal file
5
node_modules/apollo-graphql/src/schema/index.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from "./buildSchemaFromSDL";
|
||||
export * from "./GraphQLSchemaValidationError";
|
||||
export * from "./transformSchema";
|
||||
export * from "./resolverMap";
|
||||
export * from "./resolveObject";
|
||||
18
node_modules/apollo-graphql/src/schema/resolveObject.ts
generated
vendored
Normal file
18
node_modules/apollo-graphql/src/schema/resolveObject.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { GraphQLResolveInfo, FieldNode } from "graphql";
|
||||
|
||||
export type GraphQLObjectResolver<TSource, TContext> = (
|
||||
source: TSource,
|
||||
fields: Record<string, ReadonlyArray<FieldNode>>,
|
||||
context: TContext,
|
||||
info: GraphQLResolveInfo
|
||||
) => any;
|
||||
|
||||
declare module "graphql/type/definition" {
|
||||
interface GraphQLObjectType {
|
||||
resolveObject?: GraphQLObjectResolver<any, any>;
|
||||
}
|
||||
|
||||
interface GraphQLObjectTypeConfig<TSource, TContext> {
|
||||
resolveObject?: GraphQLObjectResolver<TSource, TContext>;
|
||||
}
|
||||
}
|
||||
17
node_modules/apollo-graphql/src/schema/resolverMap.ts
generated
vendored
Normal file
17
node_modules/apollo-graphql/src/schema/resolverMap.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { GraphQLFieldResolver, GraphQLScalarType } from "graphql";
|
||||
|
||||
export interface GraphQLResolverMap<TContext = {}> {
|
||||
[typeName: string]:
|
||||
| {
|
||||
[fieldName: string]:
|
||||
| GraphQLFieldResolver<any, TContext>
|
||||
| {
|
||||
requires?: string;
|
||||
resolve: GraphQLFieldResolver<any, TContext>;
|
||||
};
|
||||
}
|
||||
| GraphQLScalarType
|
||||
| {
|
||||
[enumValue: string]: string | number;
|
||||
};
|
||||
}
|
||||
161
node_modules/apollo-graphql/src/schema/transformSchema.ts
generated
vendored
Normal file
161
node_modules/apollo-graphql/src/schema/transformSchema.ts
generated
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
import {
|
||||
GraphQLSchema,
|
||||
GraphQLNamedType,
|
||||
isIntrospectionType,
|
||||
isObjectType,
|
||||
GraphQLObjectType,
|
||||
GraphQLType,
|
||||
isListType,
|
||||
GraphQLList,
|
||||
isNonNullType,
|
||||
GraphQLNonNull,
|
||||
GraphQLFieldConfigMap,
|
||||
GraphQLFieldConfigArgumentMap,
|
||||
GraphQLOutputType,
|
||||
GraphQLInputType,
|
||||
isInterfaceType,
|
||||
GraphQLInterfaceType,
|
||||
isUnionType,
|
||||
GraphQLUnionType,
|
||||
isInputObjectType,
|
||||
GraphQLInputObjectType,
|
||||
GraphQLInputFieldConfigMap,
|
||||
GraphQLDirective,
|
||||
} from "graphql";
|
||||
import { mapValues } from "../utilities/mapValues";
|
||||
|
||||
type TypeTransformer = (
|
||||
type: GraphQLNamedType
|
||||
) => GraphQLNamedType | null | undefined;
|
||||
|
||||
export function transformSchema(
|
||||
schema: GraphQLSchema,
|
||||
transformType: TypeTransformer
|
||||
): GraphQLSchema {
|
||||
const typeMap: { [typeName: string]: GraphQLNamedType } = Object.create(null);
|
||||
|
||||
for (const oldType of Object.values(schema.getTypeMap())) {
|
||||
if (isIntrospectionType(oldType)) continue;
|
||||
|
||||
const result = transformType(oldType);
|
||||
|
||||
// Returning `null` removes the type.
|
||||
if (result === null) continue;
|
||||
|
||||
// Returning `undefined` keeps the old type.
|
||||
const newType = result || oldType;
|
||||
typeMap[newType.name] = recreateNamedType(newType);
|
||||
}
|
||||
|
||||
const schemaConfig = schema.toConfig();
|
||||
|
||||
return new GraphQLSchema({
|
||||
...schemaConfig,
|
||||
types: Object.values(typeMap),
|
||||
query: replaceMaybeType(schemaConfig.query),
|
||||
mutation: replaceMaybeType(schemaConfig.mutation),
|
||||
subscription: replaceMaybeType(schemaConfig.subscription),
|
||||
directives: replaceDirectives(schemaConfig.directives),
|
||||
});
|
||||
|
||||
function recreateNamedType(type: GraphQLNamedType): GraphQLNamedType {
|
||||
if (isObjectType(type)) {
|
||||
const config = type.toConfig();
|
||||
|
||||
return new GraphQLObjectType({
|
||||
...config,
|
||||
interfaces: () => config.interfaces.map(replaceNamedType),
|
||||
fields: () => replaceFields(config.fields),
|
||||
});
|
||||
} else if (isInterfaceType(type)) {
|
||||
const config = type.toConfig();
|
||||
|
||||
return new GraphQLInterfaceType({
|
||||
...config,
|
||||
interfaces: () => config.interfaces.map(replaceNamedType),
|
||||
fields: () => replaceFields(config.fields),
|
||||
});
|
||||
} else if (isUnionType(type)) {
|
||||
const config = type.toConfig();
|
||||
|
||||
return new GraphQLUnionType({
|
||||
...config,
|
||||
types: () => config.types.map(replaceNamedType),
|
||||
});
|
||||
} else if (isInputObjectType(type)) {
|
||||
const config = type.toConfig();
|
||||
|
||||
return new GraphQLInputObjectType({
|
||||
...config,
|
||||
fields: () => replaceInputFields(config.fields),
|
||||
});
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
function replaceType<T extends GraphQLType>(
|
||||
type: GraphQLList<T>
|
||||
): GraphQLList<T>;
|
||||
function replaceType<T extends GraphQLType>(
|
||||
type: GraphQLNonNull<T>
|
||||
): GraphQLNonNull<T>;
|
||||
function replaceType(type: GraphQLNamedType): GraphQLNamedType;
|
||||
function replaceType(type: GraphQLOutputType): GraphQLOutputType;
|
||||
function replaceType(type: GraphQLInputType): GraphQLInputType;
|
||||
function replaceType(type: GraphQLType): GraphQLType {
|
||||
if (isListType(type)) {
|
||||
return new GraphQLList(replaceType(type.ofType));
|
||||
} else if (isNonNullType(type)) {
|
||||
return new GraphQLNonNull(replaceType(type.ofType));
|
||||
}
|
||||
return replaceNamedType(type);
|
||||
}
|
||||
|
||||
function replaceNamedType<T extends GraphQLNamedType>(type: T): T {
|
||||
const newType = typeMap[type.name] as T;
|
||||
return newType ? newType : type;
|
||||
}
|
||||
|
||||
function replaceMaybeType<T extends GraphQLNamedType>(
|
||||
type: T | null | undefined
|
||||
): T | undefined {
|
||||
return type ? replaceNamedType(type) : undefined;
|
||||
}
|
||||
|
||||
function replaceFields<TSource, TContext>(
|
||||
fieldsMap: GraphQLFieldConfigMap<TSource, TContext>
|
||||
): GraphQLFieldConfigMap<TSource, TContext> {
|
||||
return mapValues(fieldsMap, (field) => ({
|
||||
...field,
|
||||
type: replaceType(field.type),
|
||||
args: field.args ? replaceArgs(field.args) : undefined,
|
||||
}));
|
||||
}
|
||||
|
||||
function replaceInputFields(
|
||||
fieldsMap: GraphQLInputFieldConfigMap
|
||||
): GraphQLInputFieldConfigMap {
|
||||
return mapValues(fieldsMap, (field) => ({
|
||||
...field,
|
||||
type: replaceType(field.type),
|
||||
}));
|
||||
}
|
||||
|
||||
function replaceArgs(args: GraphQLFieldConfigArgumentMap) {
|
||||
return mapValues(args, (arg) => ({
|
||||
...arg,
|
||||
type: replaceType(arg.type),
|
||||
}));
|
||||
}
|
||||
|
||||
function replaceDirectives(directives: GraphQLDirective[]) {
|
||||
return directives.map((directive) => {
|
||||
const config = directive.toConfig();
|
||||
return new GraphQLDirective({
|
||||
...config,
|
||||
args: replaceArgs(config.args),
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
207
node_modules/apollo-graphql/src/transforms.ts
generated
vendored
Normal file
207
node_modules/apollo-graphql/src/transforms.ts
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
import { visit } from "graphql/language/visitor";
|
||||
import {
|
||||
DocumentNode,
|
||||
FloatValueNode,
|
||||
IntValueNode,
|
||||
StringValueNode,
|
||||
OperationDefinitionNode,
|
||||
SelectionSetNode,
|
||||
FragmentSpreadNode,
|
||||
InlineFragmentNode,
|
||||
DirectiveNode,
|
||||
FieldNode,
|
||||
FragmentDefinitionNode,
|
||||
ObjectValueNode,
|
||||
ListValueNode,
|
||||
} from "graphql/language/ast";
|
||||
import { print } from "graphql/language/printer";
|
||||
import { separateOperations } from "graphql/utilities";
|
||||
// We'll only fetch the `ListIteratee` type from the `@types/lodash`, but get
|
||||
// `sortBy` from the modularized version of the package to avoid bringing in
|
||||
// all of `lodash`.
|
||||
import { ListIteratee } from "lodash";
|
||||
import sortBy from "lodash.sortby";
|
||||
|
||||
// Replace numeric, string, list, and object literals with "empty"
|
||||
// values. Leaves enums alone (since there's no consistent "zero" enum). This
|
||||
// can help combine similar queries if you substitute values directly into
|
||||
// queries rather than use GraphQL variables, and can hide sensitive data in
|
||||
// your query (say, a hardcoded API key) from Apollo's servers, but in general
|
||||
// avoiding those situations is better than working around them.
|
||||
export function hideLiterals(ast: DocumentNode): DocumentNode {
|
||||
return visit(ast, {
|
||||
IntValue(node: IntValueNode): IntValueNode {
|
||||
return { ...node, value: "0" };
|
||||
},
|
||||
FloatValue(node: FloatValueNode): FloatValueNode {
|
||||
return { ...node, value: "0" };
|
||||
},
|
||||
StringValue(node: StringValueNode): StringValueNode {
|
||||
return { ...node, value: "", block: false };
|
||||
},
|
||||
ListValue(node: ListValueNode): ListValueNode {
|
||||
return { ...node, values: [] };
|
||||
},
|
||||
ObjectValue(node: ObjectValueNode): ObjectValueNode {
|
||||
return { ...node, fields: [] };
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// In the same spirit as the similarly named `hideLiterals` function, only
|
||||
// hide string and numeric literals.
|
||||
export function hideStringAndNumericLiterals(ast: DocumentNode): DocumentNode {
|
||||
return visit(ast, {
|
||||
IntValue(node: IntValueNode): IntValueNode {
|
||||
return { ...node, value: "0" };
|
||||
},
|
||||
FloatValue(node: FloatValueNode): FloatValueNode {
|
||||
return { ...node, value: "0" };
|
||||
},
|
||||
StringValue(node: StringValueNode): StringValueNode {
|
||||
return { ...node, value: "", block: false };
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// A GraphQL query may contain multiple named operations, with the operation to
|
||||
// use specified separately by the client. This transformation drops unused
|
||||
// operations from the query, as well as any fragment definitions that are not
|
||||
// referenced. (In general we recommend that unused definitions are dropped on
|
||||
// the client before sending to the server to save bandwidth and parsing time.)
|
||||
export function dropUnusedDefinitions(
|
||||
ast: DocumentNode,
|
||||
operationName: string
|
||||
): DocumentNode {
|
||||
const separated = separateOperations(ast)[operationName];
|
||||
if (!separated) {
|
||||
// If the given operationName isn't found, just make this whole transform a
|
||||
// no-op instead of crashing.
|
||||
return ast;
|
||||
}
|
||||
return separated;
|
||||
}
|
||||
|
||||
// Like lodash's sortBy, but sorted(undefined) === undefined rather than []. It
|
||||
// is a stable non-in-place sort.
|
||||
function sorted<T>(
|
||||
items: ReadonlyArray<T> | undefined,
|
||||
...iteratees: Array<ListIteratee<T>>
|
||||
): Array<T> | undefined {
|
||||
if (items) {
|
||||
return sortBy(items, ...iteratees);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// sortAST sorts most multi-child nodes alphabetically. Using this as part of
|
||||
// your signature calculation function may make it easier to tell the difference
|
||||
// between queries that are similar to each other, and if for some reason your
|
||||
// GraphQL client generates query strings with elements in nondeterministic
|
||||
// order, it can make sure the queries are treated as identical.
|
||||
export function sortAST(ast: DocumentNode): DocumentNode {
|
||||
return visit(ast, {
|
||||
Document(node: DocumentNode) {
|
||||
return {
|
||||
...node,
|
||||
// Use sortBy because 'definitions' is not optional.
|
||||
// The sort on "kind" places fragments before operations within the document
|
||||
definitions: sortBy(node.definitions, "kind", "name.value"),
|
||||
};
|
||||
},
|
||||
OperationDefinition(
|
||||
node: OperationDefinitionNode
|
||||
): OperationDefinitionNode {
|
||||
return {
|
||||
...node,
|
||||
variableDefinitions: sorted(
|
||||
node.variableDefinitions,
|
||||
"variable.name.value"
|
||||
),
|
||||
};
|
||||
},
|
||||
SelectionSet(node: SelectionSetNode): SelectionSetNode {
|
||||
return {
|
||||
...node,
|
||||
// Define an ordering for field names in a SelectionSet. Field first,
|
||||
// then FragmentSpread, then InlineFragment. By a lovely coincidence,
|
||||
// the order we want them to appear in is alphabetical by node.kind.
|
||||
// Use sortBy instead of sorted because 'selections' is not optional.
|
||||
selections: sortBy(node.selections, "kind", "name.value"),
|
||||
};
|
||||
},
|
||||
Field(node: FieldNode): FieldNode {
|
||||
return {
|
||||
...node,
|
||||
arguments: sorted(node.arguments, "name.value"),
|
||||
};
|
||||
},
|
||||
FragmentSpread(node: FragmentSpreadNode): FragmentSpreadNode {
|
||||
return { ...node, directives: sorted(node.directives, "name.value") };
|
||||
},
|
||||
InlineFragment(node: InlineFragmentNode): InlineFragmentNode {
|
||||
return { ...node, directives: sorted(node.directives, "name.value") };
|
||||
},
|
||||
FragmentDefinition(node: FragmentDefinitionNode): FragmentDefinitionNode {
|
||||
return {
|
||||
...node,
|
||||
directives: sorted(node.directives, "name.value"),
|
||||
variableDefinitions: sorted(
|
||||
node.variableDefinitions,
|
||||
"variable.name.value"
|
||||
),
|
||||
};
|
||||
},
|
||||
Directive(node: DirectiveNode): DirectiveNode {
|
||||
return { ...node, arguments: sorted(node.arguments, "name.value") };
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// removeAliases gets rid of GraphQL aliases, a feature by which you can tell a
|
||||
// server to return a field's data under a different name from the field
|
||||
// name. Maybe this is useful if somebody somewhere inserts random aliases into
|
||||
// their queries.
|
||||
export function removeAliases(ast: DocumentNode): DocumentNode {
|
||||
return visit(ast, {
|
||||
Field(node: FieldNode): FieldNode {
|
||||
return {
|
||||
...node,
|
||||
alias: undefined,
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Like the graphql-js print function, but deleting whitespace wherever
|
||||
// feasible. Specifically, all whitespace (outside of string literals) is
|
||||
// reduced to at most one space, and even that space is removed anywhere except
|
||||
// for between two alphanumerics.
|
||||
export function printWithReducedWhitespace(ast: DocumentNode): string {
|
||||
// In a GraphQL AST (which notably does not contain comments), the only place
|
||||
// where meaningful whitespace (or double quotes) can exist is in
|
||||
// StringNodes. So to print with reduced whitespace, we:
|
||||
// - temporarily sanitize strings by replacing their contents with hex
|
||||
// - use the default GraphQL printer
|
||||
// - minimize the whitespace with a simple regexp replacement
|
||||
// - convert strings back to their actual value
|
||||
// We normalize all strings to non-block strings for simplicity.
|
||||
|
||||
const sanitizedAST = visit(ast, {
|
||||
StringValue(node: StringValueNode): StringValueNode {
|
||||
return {
|
||||
...node,
|
||||
value: Buffer.from(node.value, "utf8").toString("hex"),
|
||||
block: false,
|
||||
};
|
||||
},
|
||||
});
|
||||
const withWhitespace = print(sanitizedAST);
|
||||
const minimizedButStillHex = withWhitespace
|
||||
.replace(/\s+/g, " ")
|
||||
.replace(/([^_a-zA-Z0-9]) /g, (_, c) => c)
|
||||
.replace(/ ([^_a-zA-Z0-9])/g, (_, c) => c);
|
||||
return minimizedButStillHex.replace(/"([a-f0-9]+)"/g, (_, hex) =>
|
||||
JSON.stringify(Buffer.from(hex, "hex").toString("utf8"))
|
||||
);
|
||||
}
|
||||
7
node_modules/apollo-graphql/src/types/core-js-pure.d.ts
generated
vendored
Normal file
7
node_modules/apollo-graphql/src/types/core-js-pure.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
declare module "core-js-pure/features/array/flat" {
|
||||
function flat<A>(
|
||||
array: A[],
|
||||
...args: Parameters<typeof Array.prototype.flat>
|
||||
): A;
|
||||
export = flat;
|
||||
}
|
||||
13
node_modules/apollo-graphql/src/utilities/createHash.ts
generated
vendored
Normal file
13
node_modules/apollo-graphql/src/utilities/createHash.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { isNodeLike } from "./isNodeLike";
|
||||
|
||||
export function createHash(kind: string): import("crypto").Hash {
|
||||
if (isNodeLike) {
|
||||
// Use module.require instead of just require to avoid bundling whatever
|
||||
// crypto polyfills a non-Node bundler might fall back to.
|
||||
return (module.require("crypto") as typeof import("crypto")).createHash(
|
||||
kind
|
||||
);
|
||||
}
|
||||
|
||||
return (require("sha.js") as typeof import("sha.js"))(kind);
|
||||
}
|
||||
9
node_modules/apollo-graphql/src/utilities/graphql.ts
generated
vendored
Normal file
9
node_modules/apollo-graphql/src/utilities/graphql.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { ASTNode, DocumentNode, Kind } from "graphql";
|
||||
|
||||
export function isNode(maybeNode: any): maybeNode is ASTNode {
|
||||
return maybeNode && typeof maybeNode.kind === "string";
|
||||
}
|
||||
|
||||
export function isDocumentNode(node: ASTNode): node is DocumentNode {
|
||||
return isNode(node) && node.kind === Kind.DOCUMENT;
|
||||
}
|
||||
6
node_modules/apollo-graphql/src/utilities/isNodeLike.ts
generated
vendored
Normal file
6
node_modules/apollo-graphql/src/utilities/isNodeLike.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export const isNodeLike =
|
||||
typeof process === "object" &&
|
||||
process &&
|
||||
process.release &&
|
||||
process.versions &&
|
||||
typeof process.versions.node === "string";
|
||||
12
node_modules/apollo-graphql/src/utilities/mapValues.ts
generated
vendored
Normal file
12
node_modules/apollo-graphql/src/utilities/mapValues.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export function mapValues<T, U = T>(
|
||||
object: Record<string, T>,
|
||||
callback: (value: T) => U
|
||||
): Record<string, U> {
|
||||
const result: Record<string, U> = Object.create(null);
|
||||
|
||||
for (const [key, value] of Object.entries(object)) {
|
||||
result[key] = callback(value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user