UNPKG

1.17 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var graphql_import_1 = require("graphql-import");
4var graphql_tools_1 = require("graphql-tools");
5var typeDefsCache = {};
6var remoteSchemaCache = {};
7function getCachedTypeDefs(schemaPath, disableCache) {
8 if (disableCache === void 0) { disableCache = false; }
9 if (typeDefsCache[schemaPath]) {
10 return typeDefsCache[schemaPath];
11 }
12 var schema = graphql_import_1.importSchema(schemaPath);
13 if (!disableCache) {
14 typeDefsCache[schemaPath] = schema;
15 }
16 return schema;
17}
18exports.getCachedTypeDefs = getCachedTypeDefs;
19function getCachedRemoteSchema(endpoint, typeDefs, link, disableCache) {
20 if (disableCache === void 0) { disableCache = false; }
21 if (remoteSchemaCache[endpoint]) {
22 return remoteSchemaCache[endpoint];
23 }
24 var remoteSchema = graphql_tools_1.makeRemoteExecutableSchema({
25 link: link,
26 schema: typeDefs,
27 });
28 if (!disableCache) {
29 remoteSchemaCache[endpoint] = remoteSchema;
30 }
31 return remoteSchema;
32}
33exports.getCachedRemoteSchema = getCachedRemoteSchema;
34//# sourceMappingURL=cache.js.map
\No newline at end of file