未验证 提交 e3996e80 编写于 作者: B Bogdan Kobylynskyi 提交者: GitHub

Fix code generation from introspection result #535 (#536)

上级 5846fe20
......@@ -32,6 +32,7 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
......@@ -180,6 +181,9 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
if (graphqlSchemaPaths != null) {
return graphqlSchemaPaths;
}
if (graphqlQueryIntrospectionResultPath != null) {
return Collections.emptyList();
}
Path rootDir = getSchemasRootDir();
SchemaFinder finder = new SchemaFinder(rootDir);
finder.setRecursive(graphqlSchemas.isRecursive());
......
......@@ -273,6 +273,9 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
if (graphqlSchemaPaths != null) {
return Arrays.asList(graphqlSchemaPaths);
}
if (graphqlQueryIntrospectionResultPath != null) {
return Collections.emptyList();
}
Path schemasRootDir = getSchemasRootDir();
SchemaFinder finder = new SchemaFinder(schemasRootDir);
finder.setRecursive(graphqlSchemas.isRecursive());
......
......@@ -228,8 +228,14 @@ class GraphQLCodegenPlugin(configuration: Configuration, private[codegen] val co
}
def getSchemas: util.List[String] = {
if ((graphqlSchemaPaths in GraphQLCodegenConfig).value != null && (graphqlSchemaPaths in GraphQLCodegenConfig).value.nonEmpty)
if ((graphqlSchemaPaths in GraphQLCodegenConfig).value != null &&
(graphqlSchemaPaths in GraphQLCodegenConfig).value.nonEmpty) {
return (graphqlSchemaPaths in GraphQLCodegenConfig).value.asJava
}
if ((graphqlQueryIntrospectionResultPath in GraphQLCodegenConfig).value != null &&
!(graphqlQueryIntrospectionResultPath in GraphQLCodegenConfig).value.isEmpty) {
return List[String]().asJava
}
val schemasRootDir: Path = getSchemasRootDir
val finder: SchemaFinder = new SchemaFinder(schemasRootDir)
finder.setRecursive((graphqlSchemas in GraphQLCodegenConfig).value.recursive)
......
......@@ -53,40 +53,40 @@ public abstract class GraphQLCodegen {
// used in tests
protected GraphQLCodegen(List<String> schemas,
File outputDir,
MappingConfig mappingConfig,
GeneratedInformation generatedInformation,
MapperFactory mapperFactory) {
File outputDir,
MappingConfig mappingConfig,
GeneratedInformation generatedInformation,
MapperFactory mapperFactory) {
this(schemas, null, outputDir, mappingConfig, null, generatedInformation, mapperFactory);
}
// used in tests
protected GraphQLCodegen(String introspectionResult,
File outputDir,
MappingConfig mappingConfig,
GeneratedInformation generatedInformation,
MapperFactory mapperFactory) {
File outputDir,
MappingConfig mappingConfig,
GeneratedInformation generatedInformation,
MapperFactory mapperFactory) {
this(null, introspectionResult, outputDir, mappingConfig, null, generatedInformation, mapperFactory);
}
// used in plugins
protected GraphQLCodegen(List<String> schemas,
String introspectionResult,
File outputDir,
MappingConfig mappingConfig,
MappingConfigSupplier externalMappingConfigSupplier,
MapperFactory mapperFactory) {
String introspectionResult,
File outputDir,
MappingConfig mappingConfig,
MappingConfigSupplier externalMappingConfigSupplier,
MapperFactory mapperFactory) {
this(schemas, introspectionResult, outputDir, mappingConfig, externalMappingConfigSupplier, new GeneratedInformation(), mapperFactory);
}
// used by other constructors
protected GraphQLCodegen(List<String> schemas,
String introspectionResult,
File outputDir,
MappingConfig mappingConfig,
MappingConfigSupplier externalMappingConfigSupplier,
GeneratedInformation generatedInformation,
MapperFactory mapperFactory) {
String introspectionResult,
File outputDir,
MappingConfig mappingConfig,
MappingConfigSupplier externalMappingConfigSupplier,
GeneratedInformation generatedInformation,
MapperFactory mapperFactory) {
this.schemas = schemas;
this.introspectionResult = introspectionResult;
this.outputDir = outputDir;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册