@graphql-mesh/odata
Version:
37 lines (36 loc) • 1.31 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const store_1 = require("@graphql-mesh/store");
const odata_1 = require("@omnigraph/odata");
class ODataHandler {
constructor({ name, config, baseDir, importFn, logger, store, }) {
this.name = name;
this.config = config;
this.baseDir = baseDir;
this.importFn = importFn;
this.logger = logger;
this.schema = store.proxy('schema.graphql', store_1.PredefinedProxyOptions.GraphQLSchemaWithDiffing);
}
async getMeshSource({ fetchFn }) {
let schema = await this.schema.getWithSet(() => (0, odata_1.loadNonExecutableGraphQLSchemaFromOData)(this.name, {
endpoint: this.config.endpoint,
source: this.config.source,
baseDir: this.baseDir,
schemaHeaders: this.config.schemaHeaders,
operationHeaders: this.config.operationHeaders,
fetchFn,
logger: this.logger,
importFn: this.importFn,
batch: this.config.batch,
expandNavProps: this.config.expandNavProps,
}));
schema = (0, odata_1.processDirectives)({
schema,
fetchFn,
});
return {
schema,
};
}
}
exports.default = ODataHandler;