@graphql-markdown/diff
v1.1.22
Published
GraphQL-Markdown diff package.
Readme
@graphql-markdown/diff
Schema comparison utilities for GraphQL-Markdown. Detects whether a GraphQL schema has changed since the last documentation generation, so tools like @graphql-markdown/core can skip regeneration when nothing changed.
Installation
npm install @graphql-markdown/diffUsage
import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
import { checkSchemaChanges, CompareMethod } from "@graphql-markdown/diff";
import { loadSchema } from "@graphql-markdown/graphql";
const schema = await loadSchema("./schema.graphql", {
loaders: [new GraphQLFileLoader()],
});
const hasChanged = await checkSchemaChanges(
schema,
"./docs",
CompareMethod.DIFF,
);
if (!hasChanged) {
console.log("Schema is unchanged, skipping documentation generation.");
}Comparison methods
CompareMethod.DIFF— diffs the printed schema against a savedschema.graphqlreference file (default).CompareMethod.HASH— compares a SHA-256 hash of the printed schema against a saved.schemafile.CompareMethod.FORCE— always reports a change, forcing regeneration.CompareMethod.NONE— always reports no change, skipping regeneration.
Documentation
License
GraphQL-Markdown packages are 100% free and open-source, under the MIT license.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest, you'll be creating employment for local families and restoring wildlife habitats.
