polen
Version:
A framework for delightful GraphQL developer portals
36 lines • 1.04 kB
JavaScript
import { Grafaid } from '#lib/grafaid/index';
import { GraphqlChange } from '#lib/graphql-change/index';
import { Path } from '@wollybeard/kit';
const defaultPaths = {
schemaFile: `./schema.graphql`,
};
export const normalizeConfig = (configInput) => {
const config = {
path: Path.ensureAbsolute(configInput.path ?? defaultPaths.schemaFile, configInput.projectRoot),
};
return config;
};
export const readOrThrow = async (configInput) => {
const config = normalizeConfig(configInput);
const schemaFile = await Grafaid.Schema.read(config.path);
if (!schemaFile)
return null;
const date = new Date();
const after = schemaFile.content;
const before = Grafaid.Schema.empty;
const changes = await GraphqlChange.calcChangeset({
before,
after,
});
const schemaVersion = {
date,
after,
before,
changes,
};
const schema = {
versions: [schemaVersion],
};
return schema;
};
//# sourceMappingURL=schema-file.js.map