2
2
3
3
import com .kobylynskyi .graphql .codegen .mapper .DataModelMapper ;
4
4
import com .kobylynskyi .graphql .codegen .mapper .DataModelMapperFactory ;
5
+ import com .kobylynskyi .graphql .codegen .mapper .FieldDefinitionToParameterMapper ;
5
6
import com .kobylynskyi .graphql .codegen .model .definitions .ExtendedDefinition ;
6
7
import com .kobylynskyi .graphql .codegen .model .definitions .ExtendedDocument ;
7
8
import com .kobylynskyi .graphql .codegen .model .definitions .ExtendedEnumTypeDefinition ;
8
9
import com .kobylynskyi .graphql .codegen .model .definitions .ExtendedFieldDefinition ;
9
10
import com .kobylynskyi .graphql .codegen .model .definitions .ExtendedInterfaceTypeDefinition ;
11
+ import com .kobylynskyi .graphql .codegen .model .definitions .ExtendedObjectTypeDefinition ;
10
12
11
13
import java .io .File ;
12
14
import java .util .HashMap ;
15
+ import java .util .HashSet ;
13
16
import java .util .List ;
14
17
import java .util .Map ;
15
18
import java .util .Set ;
@@ -26,11 +29,13 @@ public class MappingContext implements GraphQLCodegenConfiguration {
26
29
private final ExtendedDocument document ;
27
30
private final Set <String > typesUnionsInterfacesNames ;
28
31
private final Set <String > interfacesName ;
32
+ private final Set <String > operationsName ;
29
33
private final Map <String , Set <String >> interfaceChildren ;
30
34
private final GeneratedInformation generatedInformation ;
31
35
private final DataModelMapperFactory dataModelMapperFactory ;
32
36
private Set <String > enumImportItSelfInScala ;
33
37
private Map <String , Set <String >> parentInterfaceProperties ;
38
+ private Set <String > fieldNamesWithResolvers ;
34
39
35
40
private MappingContext (File outputDirectory ,
36
41
MappingConfig mappingConfig ,
@@ -44,6 +49,7 @@ private MappingContext(File outputDirectory,
44
49
this .interfacesName = document .getInterfacesNames ();
45
50
this .interfaceChildren = document .getInterfaceChildren ();
46
51
this .generatedInformation = generatedInformation ;
52
+ this .operationsName = document .getOperationsNames ();
47
53
this .dataModelMapperFactory = dataModelMapperFactory ;
48
54
}
49
55
@@ -63,7 +69,6 @@ public Boolean isInitializeNullableTypes() {
63
69
}
64
70
65
71
66
-
67
72
@ Override
68
73
public Boolean isGenerateSealedInterfaces () {
69
74
return config .isGenerateSealedInterfaces ();
@@ -309,6 +314,16 @@ public Set<String> getTypesAsInterfaces() {
309
314
return config .getTypesAsInterfaces ();
310
315
}
311
316
317
+ @ Override
318
+ public Set <String > getResolverArgumentAnnotations () {
319
+ return config .getResolverArgumentAnnotations ();
320
+ }
321
+
322
+ @ Override
323
+ public Set <String > getParametrizedResolverAnnotations () {
324
+ return config .getParametrizedResolverAnnotations ();
325
+ }
326
+
312
327
@ Override
313
328
public Boolean isSupportUnknownFields () {
314
329
return config .isSupportUnknownFields ();
@@ -331,6 +346,10 @@ public Set<String> getInterfacesName() {
331
346
return interfacesName ;
332
347
}
333
348
349
+ public Set <String > getOperationsName () {
350
+ return operationsName ;
351
+ }
352
+
334
353
public Map <String , Set <String >> getInterfaceChildren () {
335
354
return interfaceChildren ;
336
355
}
@@ -381,6 +400,25 @@ public Map<String, Set<String>> getParentInterfaceProperties() {
381
400
return parentInterfaceProperties ;
382
401
}
383
402
403
+ public Set <String > getFieldNamesWithResolvers () {
404
+ if (fieldNamesWithResolvers == null ) {
405
+ fieldNamesWithResolvers = new HashSet <>();
406
+ for (ExtendedObjectTypeDefinition definition : document .getTypeDefinitions ()) {
407
+ definition .getFieldDefinitions ().stream ()
408
+ .filter (fieldDef -> FieldDefinitionToParameterMapper .generateResolversForField (
409
+ this , fieldDef , definition ))
410
+ .forEach (fieldDef -> fieldNamesWithResolvers .add (definition .getName () + "." + fieldDef .getName ()));
411
+ }
412
+ for (ExtendedInterfaceTypeDefinition definition : document .getInterfaceDefinitions ()) {
413
+ definition .getFieldDefinitions ().stream ()
414
+ .filter (fieldDef -> FieldDefinitionToParameterMapper .generateResolversForField (
415
+ this , fieldDef , definition ))
416
+ .forEach (fieldDef -> fieldNamesWithResolvers .add (definition .getName () + "." + fieldDef .getName ()));
417
+ }
418
+ }
419
+ return fieldNamesWithResolvers ;
420
+ }
421
+
384
422
private String getModelClassNameWithPrefixAndSuffix (ExtendedEnumTypeDefinition extendedEnumTypeDefinition ) {
385
423
return DataModelMapper .getModelClassNameWithPrefixAndSuffix (this , extendedEnumTypeDefinition .getName ());
386
424
}
0 commit comments