@@ -10,6 +10,7 @@ import { Config } from '@/Configuration/index.js';
1010import fetch from 'node-fetch' ;
1111import { COMMON_FILES } from '@/gshared/constants/index.js' ;
1212import ora from 'ora' ;
13+ import { mergeSDLs } from 'graphql-js-tree' ;
1314
1415export 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