@graphql-eslint/eslint-plugin
Version:
GraphQL plugin for ESLint
27 lines (24 loc) • 1.2 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
var _graphql = require('graphql');
var _cachejs = require('./cache.js');
const schemaCache = new (0, _cachejs.ModuleCache)(), debug = _debug2.default.call(void 0, "graphql-eslint:schema");
function getSchema(project) {
const schemaKey = project.schema;
if (!schemaKey)
return null;
const cache = schemaCache.get(schemaKey);
if (cache)
return cache;
debug("Loading schema from %o", project.schema);
const schema = project.loadSchemaSync(project.schema, "GraphQLSchema", {
pluckConfig: project.extensions.pluckConfig
});
if (debug.enabled) {
debug("Schema loaded: %o", schema instanceof _graphql.GraphQLSchema);
const schemaPaths = _fastglob2.default.sync(project.schema, { absolute: !0 });
debug("Schema pointers %O", schemaPaths);
}
return schemaCache.set(schemaKey, schema), schema;
}
exports.getSchema = getSchema;