@graphql-eslint/eslint-plugin
Version:
GraphQL plugin for ESLint
27 lines (26 loc) • 871 B
JavaScript
import debugFactory from "debug";
import fg from "fast-glob";
import { GraphQLSchema } from "graphql";
import { ModuleCache } from "./cache.js";
const schemaCache = new ModuleCache(), debug = debugFactory("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 GraphQLSchema);
const schemaPaths = fg.sync(project.schema, { absolute: !0 });
debug("Schema pointers %O", schemaPaths);
}
return schemaCache.set(schemaKey, schema), schema;
}
export {
getSchema
};