@graphql-markdown/diff 1.1.17 → 1.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,3 +5,50 @@
|
|
|
5
5
|
[](https://sonarcloud.io/summary/new_code?id=graphql-markdown_diff)
|
|
6
6
|
[](https://sonarcloud.io/summary/new_code?id=graphql-markdown_diff)
|
|
7
7
|
[](https://dashboard.stryker-mutator.io/reports/github.com/graphql-markdown/graphql-markdown/main?module=diff)
|
|
8
|
+
|
|
9
|
+
Schema comparison utilities for GraphQL-Markdown. Detects whether a **GraphQL schema** has changed since the last documentation generation, so tools like [`@graphql-markdown/core`](https://www.npmjs.com/package/@graphql-markdown/core) can skip regeneration when nothing changed.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
npm install @graphql-markdown/diff
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
|
|
21
|
+
import { checkSchemaChanges, CompareMethod } from "@graphql-markdown/diff";
|
|
22
|
+
import { loadSchema } from "@graphql-markdown/graphql";
|
|
23
|
+
|
|
24
|
+
const schema = await loadSchema("./schema.graphql", {
|
|
25
|
+
loaders: [new GraphQLFileLoader()],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const hasChanged = await checkSchemaChanges(
|
|
29
|
+
schema,
|
|
30
|
+
"./docs",
|
|
31
|
+
CompareMethod.DIFF,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
if (!hasChanged) {
|
|
35
|
+
console.log("Schema is unchanged, skipping documentation generation.");
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Comparison methods
|
|
40
|
+
|
|
41
|
+
- `CompareMethod.DIFF` — diffs the printed schema against a saved `schema.graphql` reference file (default).
|
|
42
|
+
- `CompareMethod.HASH` — compares a SHA-256 hash of the printed schema against a saved `.schema` file.
|
|
43
|
+
- `CompareMethod.FORCE` — always reports a change, forcing regeneration.
|
|
44
|
+
- `CompareMethod.NONE` — always reports no change, skipping regeneration.
|
|
45
|
+
|
|
46
|
+
## Documentation
|
|
47
|
+
|
|
48
|
+
- [Configuration Options](https://graphql-markdown.dev/docs/settings)
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
GraphQL-Markdown packages are 100% free and open-source, under the [MIT license](https://github.com/graphql-markdown/graphql-markdown/blob/main/LICENSE).
|
|
53
|
+
|
|
54
|
+
This package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/graphql-markdown/graphql-markdown) to thank us for our work. By contributing to the Treeware forest, you'll be creating employment for local families and restoring wildlife habitats.
|