diff
Schemaβ
hasChanges()β
function hasChanges(
schema,
tmpDir,
diffMethod,
diffModule): Promise<boolean>
Defined in: diff.ts:62
Determines if there are changes in the GraphQL schema by using a specified diff method and module.
Parametersβ
schemaβ
GraphQLSchema
The GraphQL schema to check for changes.
tmpDirβ
string
The temporary directory to store intermediate files during the diff process.
diffMethodβ
Maybe
<DiffMethodName
>
The name of the diff method to use. Must be a string or null
.
diffModuleβ
Maybe
<string
> = "@graphql-markdown/diff"
The module to import for performing the diff. Defaults to @graphql-markdown/diff
.
Returnsβ
Promise
<boolean
>
A promise that resolves to true
if changes are detected or if the diff method/module is invalid, otherwise false
.
Examplesβ
import { hasChanges } from "./diff";
import { buildSchema } from "graphql";
const schema = buildSchema(`
type Query {
hello: String
}
`);
const changesDetected = await hasChanges(schema, "/tmp", "methodName");
console.log(changesDetected); // true or false
import { hasChanges } from "./diff";
const schema = getMySchema();
const result = await hasChanges(
schema,
"/tmp/schema-diff",
"breaking",
"./my-custom-diff-module"
);
Throwsβ
Will log a warning if the specified diff module cannot be found.
Seeβ
- DiffMethodName for available diff methods
- FunctionCheckSchemaChanges for the signature of the function imported from the diff module
Sinceβ
1.0.0