4
4
using System . Text ;
5
5
using System . Threading . Channels ;
6
6
using HotChocolate . Fusion . Logging ;
7
+ using HotChocolate . Fusion . Options ;
7
8
using static HotChocolate . Fusion . Properties . CommandLineResources ;
8
9
9
10
namespace HotChocolate . Fusion . Commands ;
@@ -48,6 +49,11 @@ public ComposeCommand() : base("compose")
48
49
compositeSchemaFileOption . AddAlias ( "-c" ) ;
49
50
compositeSchemaFileOption . LegalFilePathsOnly ( ) ;
50
51
52
+ var enableGlobalObjectIdentificationOption = new Option < bool > ( "--enable-global-object-identification" )
53
+ {
54
+ Description = ComposeCommand_EnableGlobalObjectIdentification_Description
55
+ } ;
56
+
51
57
var watchModeOption = new Option < bool > ( "--watch" )
52
58
{
53
59
Arity = ArgumentArity . ZeroOrOne
@@ -56,20 +62,24 @@ public ComposeCommand() : base("compose")
56
62
AddOption ( workingDirectoryOption ) ;
57
63
AddOption ( sourceSchemaFileOption ) ;
58
64
AddOption ( compositeSchemaFileOption ) ;
65
+ AddOption ( enableGlobalObjectIdentificationOption ) ;
59
66
AddOption ( watchModeOption ) ;
60
67
61
68
this . SetHandler ( async context =>
62
69
{
63
70
var workingDirectory = context . ParseResult . GetValueForOption ( workingDirectoryOption ) ! ;
64
71
var sourceSchemaFiles = context . ParseResult . GetValueForOption ( sourceSchemaFileOption ) ! ;
65
72
var compositeSchemaFile = context . ParseResult . GetValueForOption ( compositeSchemaFileOption ) ;
73
+ var enableGlobalObjectIdentification =
74
+ context . ParseResult . GetValueForOption ( enableGlobalObjectIdentificationOption ) ;
66
75
var watchMode = context . ParseResult . GetValueForOption ( watchModeOption ) ;
67
76
68
77
context . ExitCode = await ExecuteAsync (
69
78
context . Console ,
70
79
workingDirectory ,
71
80
sourceSchemaFiles ,
72
81
compositeSchemaFile ,
82
+ enableGlobalObjectIdentification ,
73
83
watchMode ,
74
84
context . GetCancellationToken ( ) ) ;
75
85
} ) ;
@@ -80,6 +90,7 @@ private static async Task<int> ExecuteAsync(
80
90
string workingDirectory ,
81
91
List < string > sourceSchemaFiles ,
82
92
string ? compositeSchemaFile ,
93
+ bool enableGlobalObjectIdentification ,
83
94
bool watchMode ,
84
95
CancellationToken cancellationToken )
85
96
{
@@ -90,6 +101,7 @@ private static async Task<int> ExecuteAsync(
90
101
workingDirectory ,
91
102
sourceSchemaFiles ,
92
103
compositeSchemaFile ,
104
+ enableGlobalObjectIdentification ,
93
105
cancellationToken ) ;
94
106
}
95
107
@@ -98,6 +110,7 @@ private static async Task<int> ExecuteAsync(
98
110
workingDirectory ,
99
111
sourceSchemaFiles ,
100
112
compositeSchemaFile ,
113
+ enableGlobalObjectIdentification ,
101
114
cancellationToken ) ;
102
115
}
103
116
@@ -106,12 +119,19 @@ private static async Task<int> WatchComposeAsync(
106
119
string workingDirectory ,
107
120
List < string > sourceSchemaFiles ,
108
121
string ? compositeSchemaFile ,
122
+ bool enableGlobalObjectIdentification ,
109
123
CancellationToken cancellationToken )
110
124
{
111
125
console . Out . WriteLine ( "🔍 Starting watch mode..." ) ;
112
126
113
127
// Initial composition
114
- await ComposeAsync ( console , workingDirectory , sourceSchemaFiles , compositeSchemaFile , cancellationToken ) ;
128
+ await ComposeAsync (
129
+ console ,
130
+ workingDirectory ,
131
+ sourceSchemaFiles ,
132
+ compositeSchemaFile ,
133
+ enableGlobalObjectIdentification ,
134
+ cancellationToken ) ;
115
135
116
136
ImmutableSortedSet < string > sourceSchemaFilePaths ;
117
137
@@ -144,6 +164,7 @@ private static async Task<int> WatchComposeAsync(
144
164
workingDirectory ,
145
165
sourceSchemaFiles ,
146
166
compositeSchemaFile ,
167
+ enableGlobalObjectIdentification ,
147
168
cancellationToken ) ;
148
169
149
170
// set up file watcher for source schema files
@@ -254,6 +275,7 @@ private static async Task ProcessCompositionRequestsAsync(
254
275
string workingDirectory ,
255
276
List < string > sourceSchemaFiles ,
256
277
string ? compositeSchemaFile ,
278
+ bool enableGlobalObjectIdentification ,
257
279
CancellationToken cancellationToken )
258
280
{
259
281
var lastComposition = DateTime . MinValue ;
@@ -284,6 +306,7 @@ await ComposeAsync(
284
306
workingDirectory ,
285
307
sourceSchemaFiles ,
286
308
compositeSchemaFile ,
309
+ enableGlobalObjectIdentification ,
287
310
cancellationToken ) ;
288
311
}
289
312
catch ( Exception ex ) when ( ex is not OperationCanceledException )
@@ -339,6 +362,7 @@ private static async Task<int> ComposeAsync(
339
362
string workingDirectory ,
340
363
List < string > sourceSchemaFiles ,
341
364
string ? compositeSchemaFile ,
365
+ bool enableGlobalObjectIdentification ,
342
366
CancellationToken cancellationToken )
343
367
{
344
368
IEnumerable < string > sourceSchemas ;
@@ -356,8 +380,13 @@ private static async Task<int> ComposeAsync(
356
380
return 1 ;
357
381
}
358
382
383
+ var schemaComposerOptions = new SchemaComposerOptions
384
+ {
385
+ EnableGlobalObjectIdentification = enableGlobalObjectIdentification
386
+ } ;
359
387
var compositionLog = new CompositionLog ( ) ;
360
- var schemaComposer = new SchemaComposer ( sourceSchemas , compositionLog ) ;
388
+ var schemaComposer = new SchemaComposer ( sourceSchemas , schemaComposerOptions , compositionLog ) ;
389
+
361
390
var result = schemaComposer . Compose ( ) ;
362
391
363
392
WriteCompositionLog (
0 commit comments