1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var graphql_import_1 = require("graphql-import");
|
4 | var graphql_tools_1 = require("graphql-tools");
|
5 | var typeDefsCache = {};
|
6 | var remoteSchemaCache = {};
|
7 | function 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 | }
|
18 | exports.getCachedTypeDefs = getCachedTypeDefs;
|
19 | function 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 | }
|
33 | exports.getCachedRemoteSchema = getCachedRemoteSchema;
|
34 |
|
\ | No newline at end of file |