Skip to content

Commit 569fba3

Browse files
committed
Change output message
1 parent 52eb425 commit 569fba3

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/main/java/com/kobylynskyi/graphql/codegen/GraphQLCodegen.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,19 @@ public List<File> generate() throws IOException {
148148

149149
if (!Utils.isEmpty(schemas)) {
150150
ExtendedDocument document = GraphQLDocumentParser.getDocumentFromSchemas(mappingConfig, schemas);
151-
List<File> generatedFiles = processDefinitions(document);
152-
System.out.printf("Finished processing %d schema(s) in %d ms%n", schemas.size(),
153-
System.currentTimeMillis() - startTime);
154-
return generatedFiles;
151+
return processDefinitions(document, schemas.size() + " schema(s)", startTime);
155152
} else if (introspectionResult != null) {
156153
ExtendedDocument document = GraphQLDocumentParser
157154
.getDocumentFromIntrospectionResult(mappingConfig, introspectionResult);
158-
List<File> generatedFiles = processDefinitions(document);
159-
System.out.printf("Finished processing introspection result in %d ms%n",
160-
System.currentTimeMillis() - startTime);
161-
return generatedFiles;
155+
return processDefinitions(document, "introspection result", startTime);
162156
} else {
163157
// either schemas or introspection result should be provided
164158
throw new IllegalArgumentException(
165159
"Either graphql schema path or introspection result path should be supplied");
166160
}
167161
}
168162

169-
private List<File> processDefinitions(ExtendedDocument document) {
163+
private List<File> processDefinitions(ExtendedDocument document, String source, long startTime) {
170164
initCustomTypeMappings(document.getScalarDefinitions());
171165
MappingContext context = MappingContext.builder()
172166
.setMappingConfig(mappingConfig)
@@ -180,11 +174,15 @@ private List<File> processDefinitions(ExtendedDocument document) {
180174
for (FilesGenerator generator : FilesGeneratorsFactory.getAll(context, dataModelMapperFactory)) {
181175
generatedFiles.addAll(generator.generate());
182176
}
183-
System.out.printf("Generated %d definition classes in folder %s%n", generatedFiles.size(),
184-
outputDir.getAbsolutePath());
177+
printOutputResult(source, generatedFiles.size(), System.currentTimeMillis() - startTime);
185178
return generatedFiles;
186179
}
187180

181+
private void printOutputResult(String source, int classesGenerated, long duration) {
182+
System.out.printf("Generated %d classes from %s in folder %s, took %d ms%n",
183+
classesGenerated, source, outputDir.getAbsolutePath(), duration);
184+
}
185+
188186
protected void initCustomTypeMappings(Collection<ExtendedScalarTypeDefinition> scalarTypeDefinitions) {
189187
for (ExtendedScalarTypeDefinition definition : scalarTypeDefinitions) {
190188
if (definition.getDefinition() != null) {

0 commit comments

Comments
 (0)