@graphql-eslint/eslint-plugin
Version:
GraphQL plugin for ESLint
33 lines (32 loc) • 960 B
JavaScript
import "./chunk-BMTV3EA2.js";
import debugFactory from "debug";
import fg from "fast-glob";
import { GraphQLSchema } from "graphql";
import { ModuleCache } from "./cache.js";
const schemaCache = new ModuleCache();
const debug = debugFactory("graphql-eslint:schema");
function getSchema(project, schemaOptions) {
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", {
...schemaOptions,
pluckConfig: project.extensions.pluckConfig
});
if (debug.enabled) {
debug("Schema loaded: %o", schema instanceof GraphQLSchema);
const schemaPaths = fg.sync(project.schema, { absolute: true });
debug("Schema pointers %O", schemaPaths);
}
schemaCache.set(schemaKey, schema);
return schema;
}
export {
getSchema
};