Skip to content

Commit e21606c

Browse files
committed
✨ Schema linking
1 parent e325e0c commit e21606c

File tree

3 files changed

+58
-134
lines changed

3 files changed

+58
-134
lines changed

package-lock.json

+46-125
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-editor-cli",
3-
"version": "0.8.6",
3+
"version": "0.8.7",
44
"description": "GraphQL -> anything. Use GraphQL as your source of truth. GraphQL Editor Official CLI.",
55
"main": "lib/api.js",
66
"author": "Artur Czemiel",
@@ -54,9 +54,9 @@
5454
"express": "^4.18.1",
5555
"fast-glob": "^3.2.12",
5656
"figures": "^5.0.0",
57-
"graphql-js-tree": "^0.1.7",
58-
"graphql-zeus": "^5.2.8",
59-
"graphql-zeus-core": "^5.2.8",
57+
"graphql-js-tree": "^1.0.5",
58+
"graphql-zeus": "^5.3.1",
59+
"graphql-zeus-core": "^5.3.1",
6060
"inquirer": "^9.1.2",
6161
"mime": "^3.0.0",
6262
"node-fetch": "^3.2.10",

packages/cli/src/Editor.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Config } from '@/Configuration/index.js';
1010
import fetch from 'node-fetch';
1111
import { COMMON_FILES } from '@/gshared/constants/index.js';
1212
import ora from 'ora';
13+
import { mergeSDLs } from 'graphql-js-tree';
1314

1415
export interface FileArray {
1516
name: string;
@@ -21,8 +22,8 @@ const jolt = () => {
2122
const token = Config.getTokenOptions('token');
2223
const headers: Record<string, string> = token
2324
? {
24-
Authorization: `Bearer ${token}`,
25-
}
25+
Authorization: `Bearer ${token}`,
26+
}
2627
: {};
2728
return Chain('https://api.staging.project.graphqleditor.com/graphql', {
2829
headers,
@@ -33,8 +34,8 @@ const joltSubscription = () => {
3334
const token = Config.getTokenOptions('token');
3435
const headers: Record<string, string> = token
3536
? {
36-
Authorization: `Bearer ${token}`,
37-
}
37+
Authorization: `Bearer ${token}`,
38+
}
3839
: {};
3940
return Subscription('https://api.staging.project.graphqleditor.com/graphql', {
4041
headers,
@@ -183,7 +184,9 @@ export class Editor {
183184
? (await fetch(libraryURL.getUrl!)).text()
184185
: new Promise<string>((resolve) => resolve('')),
185186
]);
186-
return [libraryFile, graphqlFile].join('\n\n');
187+
const sdlMerge = mergeSDLs(graphqlFile, libraryFile)
188+
if (sdlMerge.__typename === 'error') throw new Error(sdlMerge.errors.map(e => `Conflict on: ${e.conflictingNode}.${e.conflictingField}`).join("\n"))
189+
return sdlMerge.sdl
187190
};
188191

189192
public static getSchema = async (resolve: {

0 commit comments

Comments
 (0)