@embrace-ai/infra-api-schema-sync 1.0.3 → 1.0.4
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.4](https://github.com/Embrace-AI/infra-api-schema-sync/compare/v1.0.3...v1.0.4) (2025-10-14)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **fetch-schema:** use GET and remove introspection for schema fetch ([#17](https://github.com/Embrace-AI/infra-api-schema-sync/issues/17)) ([023c64f](https://github.com/Embrace-AI/infra-api-schema-sync/commit/023c64f3d5a05dba31ef817cbbb26d6fee675b9e))
|
|
9
|
+
|
|
3
10
|
## [1.0.3](https://github.com/Embrace-AI/infra-api-schema-sync/compare/v1.0.2...v1.0.3) (2025-10-08)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-schema.d.ts","sourceRoot":"","sources":["../../src/fetch-schema.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch-schema.d.ts","sourceRoot":"","sources":["../../src/fetch-schema.js"],"names":[],"mappings":"AAIO;;;kBA+BN"}
|
package/dist/src/fetch-schema.js
CHANGED
|
@@ -1,38 +1,23 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import fse from "fs-extra";
|
|
3
|
-
import { buildClientSchema, getIntrospectionQuery, printSchema } from "graphql";
|
|
4
3
|
import path from "path";
|
|
5
4
|
export const fetchSchema = async ({ url, output }) => {
|
|
6
5
|
try {
|
|
7
6
|
console.log(`🔄 Fetching GraphQL schema from ${url}...`);
|
|
8
|
-
const introspectionQuery = getIntrospectionQuery();
|
|
9
7
|
const response = await fetch(url, {
|
|
10
|
-
method: "
|
|
8
|
+
method: "GET",
|
|
11
9
|
headers: {
|
|
12
|
-
|
|
13
|
-
Accept: "application/json",
|
|
10
|
+
Accept: "application/graphql, text/plain",
|
|
14
11
|
},
|
|
15
|
-
body: JSON.stringify({
|
|
16
|
-
query: introspectionQuery,
|
|
17
|
-
}),
|
|
18
12
|
});
|
|
19
13
|
if (!response.ok) {
|
|
20
14
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
21
15
|
}
|
|
22
|
-
const
|
|
23
|
-
if (result.errors) {
|
|
24
|
-
throw new Error(`GraphQL errors: ${result.errors.map((e) => e.message).join(", ")}`);
|
|
25
|
-
}
|
|
26
|
-
if (!result.data) {
|
|
27
|
-
throw new Error("No data returned from introspection query");
|
|
28
|
-
}
|
|
29
|
-
const schema = buildClientSchema(result.data);
|
|
30
|
-
const schemaSDL = printSchema(schema);
|
|
16
|
+
const schemaSDL = await response.text();
|
|
31
17
|
const outputDir = path.dirname(output);
|
|
32
18
|
fse.ensureDirSync(outputDir);
|
|
33
19
|
fs.writeFileSync(output, schemaSDL, "utf8");
|
|
34
20
|
console.log(`✅ Schema successfully saved to ${output}`);
|
|
35
|
-
console.log(`📊 Schema contains ${Object.keys(schema.getTypeMap()).length} types`);
|
|
36
21
|
}
|
|
37
22
|
catch (error) {
|
|
38
23
|
console.error(`❌ Failed to fetch schema: ${error.message}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-schema.js","sourceRoot":"","sources":["../../src/fetch-schema.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,
|
|
1
|
+
{"version":3,"file":"fetch-schema.js","sourceRoot":"","sources":["../../src/fetch-schema.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE;IACnD,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,mCAAmC,GAAG,KAAK,CAAC,CAAC;QAGzD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAChC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,MAAM,EAAE,iCAAiC;aAC1C;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QACrE,CAAC;QAGD,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAGxC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvC,GAAG,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAG7B,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAE5C,OAAO,CAAC,GAAG,CAAC,kCAAkC,MAAM,EAAE,CAAC,CAAC;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC;AAGF,eAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
package/src/fetch-schema.js
CHANGED
|
@@ -1,48 +1,25 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import fse from "fs-extra";
|
|
3
|
-
import { buildClientSchema, getIntrospectionQuery, printSchema } from "graphql";
|
|
4
3
|
import path from "path";
|
|
5
4
|
|
|
6
5
|
export const fetchSchema = async ({ url, output }) => {
|
|
7
6
|
try {
|
|
8
7
|
console.log(`🔄 Fetching GraphQL schema from ${url}...`);
|
|
9
8
|
|
|
10
|
-
//
|
|
11
|
-
const introspectionQuery = getIntrospectionQuery();
|
|
12
|
-
|
|
13
|
-
// Fetch schema using introspection
|
|
9
|
+
// Fetch schema SDL directly via GET
|
|
14
10
|
const response = await fetch(url, {
|
|
15
|
-
method: "
|
|
11
|
+
method: "GET",
|
|
16
12
|
headers: {
|
|
17
|
-
|
|
18
|
-
Accept: "application/json",
|
|
13
|
+
Accept: "application/graphql, text/plain",
|
|
19
14
|
},
|
|
20
|
-
body: JSON.stringify({
|
|
21
|
-
query: introspectionQuery,
|
|
22
|
-
}),
|
|
23
15
|
});
|
|
24
16
|
|
|
25
17
|
if (!response.ok) {
|
|
26
18
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
27
19
|
}
|
|
28
20
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (result.errors) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
`GraphQL errors: ${result.errors.map((e) => e.message).join(", ")}`,
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!result.data) {
|
|
38
|
-
throw new Error("No data returned from introspection query");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Build schema from introspection result
|
|
42
|
-
const schema = buildClientSchema(result.data);
|
|
43
|
-
|
|
44
|
-
// Convert schema to SDL (Schema Definition Language)
|
|
45
|
-
const schemaSDL = printSchema(schema);
|
|
21
|
+
// Read response as text (schema SDL)
|
|
22
|
+
const schemaSDL = await response.text();
|
|
46
23
|
|
|
47
24
|
// Ensure output directory exists
|
|
48
25
|
const outputDir = path.dirname(output);
|
|
@@ -52,9 +29,6 @@ export const fetchSchema = async ({ url, output }) => {
|
|
|
52
29
|
fs.writeFileSync(output, schemaSDL, "utf8");
|
|
53
30
|
|
|
54
31
|
console.log(`✅ Schema successfully saved to ${output}`);
|
|
55
|
-
console.log(
|
|
56
|
-
`📊 Schema contains ${Object.keys(schema.getTypeMap()).length} types`,
|
|
57
|
-
);
|
|
58
32
|
} catch (error) {
|
|
59
33
|
console.error(`❌ Failed to fetch schema: ${error.message}`);
|
|
60
34
|
process.exit(1);
|