Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
kobylynskyi committed Apr 27, 2021
2 parents 7f0fd75 + d23aed9 commit 96c8c7f
Show file tree
Hide file tree
Showing 126 changed files with 1,932 additions and 242 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
id "org.sonarqube" version "3.1.1"
}

def graphqlCodegenVersion = '5.0.0' // This variable used in the automatic release process
def graphqlCodegenVersion = '5.1.0' // This variable used in the automatic release process

group = "io.github.kobylynskyi"
version = graphqlCodegenVersion
Expand Down
18 changes: 9 additions & 9 deletions docs/client-side-cases-by-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {
/**
* this is graphql request need that what response fields.
*/
private GraphQLResponseProjection projection;
private final GraphQLResponseProjection projection;

/**
* this graphql request that need request params. (if have)
*/
private GraphQLOperationRequest request;
private final GraphQLOperationRequest request;

/**
* should limit max depth when invoke method on projection.
*/
private int maxDepth;
private final int maxDepth;

DynamicProxy(GraphQLResponseProjection projection, GraphQLOperationRequest request, int maxDepth) {
this.projection = projection;
Expand All @@ -79,7 +79,7 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {

/**
* proxy invoke
*
*
* <p>when handle projection, we use reflect to invoke method directly
* but when handle request(need set parameters), we use reflect to get field which is a internal implementation of set method
*
Expand Down Expand Up @@ -166,10 +166,10 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {
//if this method have no parameter, then do not need invoke on request instance
//other wise, we need append parameters to request field which use hashmap store params
if (!parameters.isEmpty()) {
for (Parameter parameter : parameters) {
Object argsCopy = args[i++];
request.getInput().put(parameter.getName(), argsCopy);
}
for (Parameter parameter : parameters) {
Object argsCopy = args[i++];
request.getInput().put(parameter.getName(), argsCopy);
}
}
try {
field = projection.getClass().getSuperclass().getDeclaredField("fields");
Expand All @@ -191,7 +191,7 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {
}

return executeByHttp(entityClazzName, request, projection);// request and projection for creating GraphQLRequest, entityClazzName for deserialize
}
}
}
```

Expand Down
2 changes: 2 additions & 0 deletions docs/codegen-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
| `generateImmutableModels` | Boolean | False | Specifies whether generated model classes should be immutable. |
| `generateToString` | Boolean | False | Specifies whether generated model classes should have toString method defined. |
| `addGeneratedAnnotation` | Boolean | True | Specifies whether generated classes should have `@Generated` annotation. |
| `generateJacksonTypeIdResolver` | Boolean | False | Specifies whether generated union interfaces should be annotated with a custom Jackson type id resolver generated in model package. |
| `apiNamePrefix` | String | Empty | Sets the prefix for GraphQL api classes (query, mutation, subscription). |
| `apiNameSuffix` | String | `Resolver` | Sets the suffix for GraphQL api classes (query, mutation, subscription). |
| `apiInterfaceStrategy` | *See<br>[ApiInterfaceStrategy](#option-apiinterfacestrategy)* | `INTERFACE_PER_OPERATION` | *See [ApiInterfaceStrategy](#option-apiinterfacestrategy)* |
Expand Down Expand Up @@ -51,6 +52,7 @@ See [DirectiveAnnotationsMapping](#option-directiveannotationsmapping)* |
| `responseProjectionSuffix` | String | ResponseProjection | Sets the suffix for `ResponseProjection` classes. |
| `parametrizedInputSuffix` | String | ParametrizedInput | Sets the suffix for `ParametrizedInput` classes. |
| `parentInterfaces` | *See<br>[parentInterfaces](#option-parentinterfaces)* | Empty | Block to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). *See [parentInterfaces](#option-parentinterfaces)* |
| `generateAllMethodInProjection` | Boolean | true | Enables whether the `all$()` method should be generated in the projection classes. Disabling enforces the client to select the fields manually. |
| `responseProjectionMaxDepth` | Integer | 3 | Sets max depth when use `all$()` which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use `all$(max)` to set for each method. For self recursive types, too big depth may result in a large number of returned data!|
| `generatedLanguage` | Enum | GeneratedLanguage.JAVA | Choose which language you want to generate, Java,Scala,Kotlin were supported. Note that due to language features, there are slight differences in default values between languages.|
| `generateModelOpenClasses` | Boolean | false | The class type of the generated model. If true, generate normal classes, else generate data classes. It only support in kotlin(```data class```) and scala(```case class```). Maybe we will consider to support Java ```record``` in the future.|
Expand Down
4 changes: 2 additions & 2 deletions plugins/gradle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

```groovy
plugins {
id "io.github.kobylynskyi.graphql.codegen" version "5.0.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.1.0"
}
```

Expand All @@ -31,7 +31,7 @@ buildscript {
}
}
dependencies {
classpath "io.github.kobylynskyi.graphql.codegen:graphql-codegen-gradle-plugin:5.0.0"
classpath "io.github.kobylynskyi.graphql.codegen:graphql-codegen-gradle-plugin:5.1.0"
}
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/gradle/example-client-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import io.github.kobylynskyi.graphql.codegen.gradle.GraphQLCodegenGradleTask
plugins {
id 'java'
id "org.jetbrains.kotlin.jvm" version "1.3.71"
id "io.github.kobylynskyi.graphql.codegen" version "5.0.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.1.0"
}

def graphqlCodegenClientKotlinVersion = '5.0.0' // Variable used in the automatic release process
def graphqlCodegenClientKotlinVersion = '5.1.0' // Variable used in the automatic release process

group = 'io.github.dreamylost'
version = graphqlCodegenClientKotlinVersion
Expand All @@ -29,7 +29,7 @@ repositories {


dependencies {
implementation "io.github.kobylynskyi:graphql-java-codegen:5.0.0"
implementation "io.github.kobylynskyi:graphql-java-codegen:5.1.0"
implementation "javax.validation:validation-api:2.0.1.Final"
implementation "com.squareup.okhttp3:okhttp:4.2.2"
implementation "com.fasterxml.jackson.core:jackson-core:2.12.0"
Expand Down
6 changes: 3 additions & 3 deletions plugins/gradle/example-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

// use the latest available version:
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
id "io.github.kobylynskyi.graphql.codegen" version "5.0.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.1.0"
}

mainClassName = "io.github.kobylynskyi.order.Application"
Expand All @@ -18,11 +18,11 @@ dependencies {

implementation "com.graphql-java-kickstart:graphql-spring-boot-starter:11.0.0"
implementation "com.graphql-java-kickstart:graphiql-spring-boot-starter:11.0.0"
implementation "com.graphql-java:graphql-java-extended-scalars:16.0.0"
implementation "com.graphql-java:graphql-java-extended-scalars:16.0.1"

// use the latest available version:
// https://search.maven.org/artifact/io.github.kobylynskyi/graphql-java-codegen
implementation "io.github.kobylynskyi:graphql-java-codegen:5.0.0"
implementation "io.github.kobylynskyi:graphql-java-codegen:5.1.0"

implementation "org.apache.httpcomponents:httpclient:4.5.13"
implementation "javax.validation:validation-api:2.0.1.Final"
Expand Down
4 changes: 2 additions & 2 deletions plugins/gradle/example-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
//
// use the latest available version:
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
id "io.github.kobylynskyi.graphql.codegen" version "5.0.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.1.0"
}

mainClassName = "io.github.kobylynskyi.product.Application"
Expand All @@ -17,7 +17,7 @@ dependencies {

implementation "com.graphql-java-kickstart:graphql-spring-boot-starter:11.0.0"
implementation "com.graphql-java-kickstart:graphiql-spring-boot-starter:11.0.0"
implementation "com.graphql-java:graphql-java-extended-scalars:16.0.0"
implementation "com.graphql-java:graphql-java-extended-scalars:16.0.1"

implementation "javax.validation:validation-api:2.0.1.Final"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apply plugin: "java"
apply plugin: "idea"
apply plugin: "maven-publish"

def graphqlCodegenGradlePluginVersion = '5.0.0' // This variable used in the automatic release process
def graphqlCodegenGradlePluginVersion = '5.1.0' // This variable used in the automatic release process

group = "io.github.kobylynskyi"
version = graphqlCodegenGradlePluginVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,19 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
private Boolean useOptionalForNullableReturnTypes = MappingConfigConstants.DEFAULT_USE_OPTIONAL_FOR_NULLABLE_RETURN_TYPES;
private Boolean generateApisWithThrowsException = MappingConfigConstants.DEFAULT_GENERATE_APIS_WITH_THROWS_EXCEPTION;
private Boolean addGeneratedAnnotation = MappingConfigConstants.DEFAULT_ADD_GENERATED_ANNOTATION;
private Boolean generateJacksonTypeIdResolver = MappingConfigConstants.DEFAULT_GENERATE_JACKSON_TYPE_ID_RESOLVER;
private Set<String> fieldsWithResolvers = new HashSet<>();
private Set<String> fieldsWithoutResolvers = new HashSet<>();
private Set<String> typesAsInterfaces = new HashSet<>();
private RelayConfig relayConfig = new RelayConfig();
private final RelayConfig relayConfig = new RelayConfig();


private Boolean generateClient;
private String requestSuffix;
private String responseSuffix;
private String responseProjectionSuffix;
private String parametrizedInputSuffix;
private Boolean generateAllMethodInProjection = MappingConfigConstants.DEFAULT_GENERATE_ALL_METHOD;
private int responseProjectionMaxDepth = MappingConfigConstants.DEFAULT_RESPONSE_PROJECTION_MAX_DEPTH;
private Set<String> useObjectMapperForRequestSerialization = new HashSet<>();

Expand Down Expand Up @@ -143,6 +145,7 @@ public void generate() throws Exception {
mappingConfig.setUseOptionalForNullableReturnTypes(useOptionalForNullableReturnTypes);
mappingConfig.setGenerateApisWithThrowsException(generateApisWithThrowsException);
mappingConfig.setAddGeneratedAnnotation(addGeneratedAnnotation);
mappingConfig.setGenerateJacksonTypeIdResolver(generateJacksonTypeIdResolver);
mappingConfig.setApiReturnType(apiReturnType);
mappingConfig.setApiReturnListType(apiReturnListType);
mappingConfig.setSubscriptionReturnType(subscriptionReturnType);
Expand All @@ -165,6 +168,7 @@ public void generate() throws Exception {
mappingConfig.setParametrizedInputSuffix(parametrizedInputSuffix);
mappingConfig.setUseObjectMapperForRequestSerialization(useObjectMapperForRequestSerialization != null ?
useObjectMapperForRequestSerialization : new HashSet<>());
mappingConfig.setGenerateAllMethodInProjection(generateAllMethodInProjection);
mappingConfig.setResponseProjectionMaxDepth(responseProjectionMaxDepth);

mappingConfig.setResolverParentInterface(getResolverParentInterface());
Expand Down Expand Up @@ -632,6 +636,17 @@ public void setAddGeneratedAnnotation(Boolean addGeneratedAnnotation) {
this.addGeneratedAnnotation = addGeneratedAnnotation;
}

@Input
@Optional
@Override
public Boolean getGenerateJacksonTypeIdResolver() {
return generateJacksonTypeIdResolver;
}

public void setGenerateJacksonTypeIdResolver(Boolean generateJacksonTypeIdResolver) {
this.generateJacksonTypeIdResolver = generateJacksonTypeIdResolver;
}

@Input
@Optional
@Override
Expand Down Expand Up @@ -742,6 +757,17 @@ public void setUseObjectMapperForRequestSerialization(Set<String> useObjectMappe
this.useObjectMapperForRequestSerialization = useObjectMapperForRequestSerialization;
}

@Input
@Optional
@Override
public Boolean getGenerateAllMethodInProjection() {
return generateAllMethodInProjection;
}

public void setGenerateAllMethodInProjection(boolean generateAllMethodInProjection) {
this.generateAllMethodInProjection = generateAllMethodInProjection;
}

@Input
@Optional
@Override
Expand Down
2 changes: 1 addition & 1 deletion plugins/maven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<plugin>
<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin</artifactId>
<version>5.0.0</version>
<version>5.1.0</version>
<executions>
<execution>
<goals>
Expand Down
4 changes: 2 additions & 2 deletions plugins/maven/example-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin-example-client</artifactId>
<version>5.0.0</version>
<version>5.1.0</version>
<name>graphql-codegen-maven-plugin-example-client</name>

<build>
Expand Down Expand Up @@ -144,7 +144,7 @@
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
<version>16.0.0</version>
<version>16.0.1</version>
</dependency>


Expand Down
4 changes: 2 additions & 2 deletions plugins/maven/example-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin-example-server</artifactId>
<version>5.0.0</version>
<version>5.1.0</version>
<name>graphql-codegen-maven-plugin-example-server</name>

<build>
Expand Down Expand Up @@ -97,7 +97,7 @@
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
<version>16.0.0</version>
<version>16.0.1</version>
</dependency>

<dependency>
Expand Down
12 changes: 6 additions & 6 deletions plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin</artifactId>
<version>5.0.0</version>
<version>5.1.0</version>
<packaging>maven-plugin</packaging>

<name>graphql-codegen-maven-plugin</name>
Expand Down Expand Up @@ -56,10 +56,10 @@
</ciManagement>

<properties>
<version.maven-plugin-api>3.6.3</version.maven-plugin-api>
<version.maven-core>3.6.3</version.maven-core>
<version.maven-plugin-annotations>3.6.0</version.maven-plugin-annotations>
<version.maven-plugin-plugin>3.6.0</version.maven-plugin-plugin>
<version.maven-plugin-api>3.8.1</version.maven-plugin-api>
<version.maven-core>3.8.1</version.maven-core>
<version.maven-plugin-annotations>3.6.1</version.maven-plugin-annotations>
<version.maven-plugin-plugin>3.6.1</version.maven-plugin-plugin>
<version.maven-compiler-plugin>3.8.1</version.maven-compiler-plugin>
<version.maven-resources-plugin>3.2.0</version.maven-resources-plugin>
<version.maven-source-plugin>3.2.1</version.maven-source-plugin>
Expand All @@ -72,7 +72,7 @@
<version.maven-gpg-plugin>1.6</version.maven-gpg-plugin>
<version.maven-shared-utils>3.3.3</version.maven-shared-utils>

<version.graphql-java-codegen>5.0.0</version.graphql-java-codegen>
<version.graphql-java-codegen>5.1.0</version.graphql-java-codegen>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_ADD_GENERATED_ANNOTATION_STRING)
private boolean addGeneratedAnnotation;

@Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_JACKSON_TYPE_ID_RESOLVER_STRING)
private boolean generateJacksonTypeIdResolver;

@Parameter
private String[] fieldsWithResolvers;

Expand Down Expand Up @@ -185,6 +188,9 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_RESPONSE_PROJECTION_MAX_DEPTH_STRING)
private int responseProjectionMaxDepth;

@Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_ALL_METHOD_STRING)
private boolean generateAllMethodInProjection;

@Parameter
private ParentInterfacesConfig parentInterfaces = new ParentInterfacesConfig();

Expand Down Expand Up @@ -239,6 +245,7 @@ public void execute() throws MojoExecutionException {
mappingConfig.setUseOptionalForNullableReturnTypes(useOptionalForNullableReturnTypes);
mappingConfig.setGenerateApisWithThrowsException(generateApisWithThrowsException);
mappingConfig.setAddGeneratedAnnotation(addGeneratedAnnotation);
mappingConfig.setGenerateJacksonTypeIdResolver(generateJacksonTypeIdResolver);
mappingConfig.setFieldsWithResolvers(mapToHashSet(fieldsWithResolvers));
mappingConfig.setFieldsWithoutResolvers(mapToHashSet(fieldsWithoutResolvers));
mappingConfig.setRelayConfig(relayConfig);
Expand All @@ -248,6 +255,7 @@ public void execute() throws MojoExecutionException {
mappingConfig.setResponseSuffix(responseSuffix);
mappingConfig.setResponseProjectionSuffix(responseProjectionSuffix);
mappingConfig.setParametrizedInputSuffix(parametrizedInputSuffix);
mappingConfig.setGenerateAllMethodInProjection(generateAllMethodInProjection);
mappingConfig.setResponseProjectionMaxDepth(responseProjectionMaxDepth);
mappingConfig.setUseObjectMapperForRequestSerialization(mapToHashSet(useObjectMapperForRequestSerialization));
mappingConfig.setTypesAsInterfaces(mapToHashSet(typesAsInterfaces));
Expand Down Expand Up @@ -490,6 +498,11 @@ public Boolean getAddGeneratedAnnotation() {
return addGeneratedAnnotation;
}

@Override
public Boolean getGenerateJacksonTypeIdResolver() {
return generateJacksonTypeIdResolver;
}

@Override
public ApiRootInterfaceStrategy getApiRootInterfaceStrategy() {
return apiRootInterfaceStrategy;
Expand All @@ -515,6 +528,11 @@ public Set<String> getFieldsWithoutResolvers() {
return mapToHashSet(fieldsWithoutResolvers);
}

@Override
public Boolean getGenerateAllMethodInProjection() {
return generateAllMethodInProjection;
}

@Override
public Integer getResponseProjectionMaxDepth() {
return responseProjectionMaxDepth;
Expand Down
Loading

0 comments on commit 96c8c7f

Please sign in to comment.