Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ plugins {
id "java-library"
id "signing"
id "maven-publish"
id "org.sonarqube" version "3.1.1"
id "org.sonarqube" version "3.2.0"
}

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

group = "io.github.kobylynskyi"
version = graphqlCodegenVersion
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.1.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.2.0"
}
```

Expand All @@ -31,7 +31,7 @@ buildscript {
}
}
dependencies {
classpath "io.github.kobylynskyi.graphql.codegen:graphql-codegen-gradle-plugin:5.1.0"
classpath "io.github.kobylynskyi.graphql.codegen:graphql-codegen-gradle-plugin:5.2.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.1.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.2.0"
}

def graphqlCodegenClientKotlinVersion = '5.1.0' // Variable used in the automatic release process
def graphqlCodegenClientKotlinVersion = '5.2.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.1.0"
implementation "io.github.kobylynskyi:graphql-java-codegen:5.2.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
4 changes: 2 additions & 2 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.1.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.2.0"
}

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

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

implementation "org.apache.httpcomponents:httpclient:4.5.13"
implementation "javax.validation:validation-api:2.0.1.Final"
Expand Down
2 changes: 1 addition & 1 deletion 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.1.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.2.0"
}

mainClassName = "io.github.kobylynskyi.product.Application"
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.1.0' // This variable used in the automatic release process
def graphqlCodegenGradlePluginVersion = '5.2.0' // This variable used in the automatic release process

group = "io.github.kobylynskyi"
version = graphqlCodegenGradlePluginVersion
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.1.0</version>
<version>5.2.0</version>
<executions>
<execution>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion 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.1.0</version>
<version>5.2.0</version>
<name>graphql-codegen-maven-plugin-example-client</name>

<build>
Expand Down
2 changes: 1 addition & 1 deletion 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.1.0</version>
<version>5.2.0</version>
<name>graphql-codegen-maven-plugin-example-server</name>

<build>
Expand Down
8 changes: 4 additions & 4 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.1.0</version>
<version>5.2.0</version>
<packaging>maven-plugin</packaging>

<name>graphql-codegen-maven-plugin</name>
Expand Down Expand Up @@ -69,10 +69,10 @@
<version.maven-release-plugin>2.5.3</version.maven-release-plugin>
<version.maven-build-helper-plugin>3.2.0</version.maven-build-helper-plugin>
<version.maven-scm-provider-gitexe>1.11.2</version.maven-scm-provider-gitexe>
<version.maven-gpg-plugin>1.6</version.maven-gpg-plugin>
<version.maven-shared-utils>3.3.3</version.maven-shared-utils>
<version.maven-gpg-plugin>3.0.1</version.maven-gpg-plugin>
<version.maven-shared-utils>3.3.4</version.maven-shared-utils>

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

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.1.0")
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.2.0")
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "5.1.0"
version in ThisBuild := "5.2.0"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.1.0")
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.2.0")
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "5.1.0"
version in ThisBuild := "5.2.0"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sys.props.get("plugin.version").orElse(Some("5.1.0")) match {
sys.props.get("plugin.version").orElse(Some("5.2.0")) match {
case Some(x) => addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % x)
case _ => sys.error("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "5.1.0"
version in ThisBuild := "5.2.0"
2 changes: 1 addition & 1 deletion plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "5.1.0"
version in ThisBuild := "5.2.0"
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@
*/
public class GraphQLRequest {

private final String operationName;
private final GraphQLOperationRequest request;
private final GraphQLResponseProjection responseProjection;

public GraphQLRequest(GraphQLOperationRequest request) {
this(request, null);
this(null, request, null);
}

public GraphQLRequest(String operationName, GraphQLOperationRequest request) {
this(operationName, request, null);
}

public GraphQLRequest(GraphQLOperationRequest request, GraphQLResponseProjection responseProjection) {
this(null, request, responseProjection);
}

public GraphQLRequest(String operationName, GraphQLOperationRequest request,
GraphQLResponseProjection responseProjection) {
this.operationName = operationName;
this.request = request;
this.responseProjection = responseProjection;
}
Expand All @@ -25,6 +36,10 @@ public GraphQLResponseProjection getResponseProjection() {
return responseProjection;
}

public String getOperationName() {
return operationName;
}

/**
* Serializes GraphQL request to be used as HTTP JSON body
* according to https://graphql.org/learn/serving-over-http specifications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static String toHttpJsonBody(GraphQLRequests graphQLRequests) {
}
return jsonQuery(operationWrapper(
firstRequest.getOperationType(),
null, // combined request does not have operation name
graphQLRequests.getOperationName(),
queryBuilder.toString()));
}

Expand Down Expand Up @@ -77,9 +77,13 @@ public static String toQueryString(GraphQLRequest graphQLRequest) {
if (graphQLRequest == null || graphQLRequest.getRequest() == null) {
return null;
}

String operationName = graphQLRequest.getOperationName() == null ?
graphQLRequest.getRequest().getOperationName() : graphQLRequest.getOperationName();

return operationWrapper(
graphQLRequest.getRequest().getOperationType(),
graphQLRequest.getRequest().getOperationName(),
operationName,
buildQuery(graphQLRequest));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
*/
public class GraphQLRequests {

private final String operationName;
private final List<GraphQLRequest> requests = new ArrayList<>();

public GraphQLRequests(GraphQLRequest... requests) {
this(null, requests);
}

public GraphQLRequests(String operationName, GraphQLRequest... requests) {
this.operationName = operationName;
this.requests.addAll(Arrays.asList(requests));
}

Expand All @@ -23,6 +29,10 @@ public List<GraphQLRequest> getRequests() {
return new ArrayList<>(requests);
}

public String getOperationName() {
return operationName;
}

/**
* Serializes multiple GraphQL requests to be used as HTTP JSON body
* according to https://graphql.org/learn/serving-over-http specifications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,27 @@ void serialize_withResponseProjectionAndParametrizedInputAndAlias(String name,
assertEquals(expectedQueryDecorator.apply(expectedQueryStr), serializedQuery);
}

@ParameterizedTest(name = "{0}")
@MethodSource("provideAllSerializers")
void serialize_withCustomOpertionName(String name, Function<GraphQLRequest, String> serializer,
Function<String, String> expectedQueryDecorator) {
EventsByIdsQueryRequest request = new EventsByIdsQueryRequest.Builder()
.setContextId("something")
.setIds(null)
.setTranslated(false)
.build();
GraphQLRequest graphQLRequest = new GraphQLRequest(
"customOperationName",
request,
new EventResponseProjection()
.id()
);
String serializedQuery = serializer.apply(graphQLRequest).replaceAll(" +", " ").trim();
String expectedQueryStr = "query customOperationName { " +
"eventsByIds(contextId: \"something\", translated: false){ id } }";
assertEquals(expectedQueryDecorator.apply(expectedQueryStr), serializedQuery);
}

@ParameterizedTest(name = "{0}")
@MethodSource("provideAllSerializers")
void serialize_complexRequestWithDefaultData(String name, Function<GraphQLRequest, String> serializer,
Expand Down Expand Up @@ -505,6 +526,38 @@ void serialize_multipleRequests(String name, Function<GraphQLRequests, String> s
assertEquals(expectedQueryDecorator.apply(expectedQueryStr), serializedQuery);
}

@ParameterizedTest(name = "{0}")
@MethodSource("provideStaticSerializerForMultiRequest")
void serialize_multipleRequestsWithCustomOperationName(String name, Function<GraphQLRequests, String> serializer,
Function<String, String> expectedQueryDecorator) {
EventsByCategoryAndStatusQueryRequest request1 = new EventsByCategoryAndStatusQueryRequest.Builder()
.alias("req1").setStatus(Status.OPEN).build();
GraphQLRequest graphQLRequest1 = new GraphQLRequest(request1, new EventResponseProjection().id());

EventsByCategoryAndStatusQueryRequest request2 = new EventsByCategoryAndStatusQueryRequest("req2");
GraphQLRequest graphQLRequest2 = new GraphQLRequest(request2, new EventResponseProjection().id().status());

EventsByCategoryAndStatusQueryRequest request21 = new EventsByCategoryAndStatusQueryRequest();
GraphQLRequest graphQLRequest21 = new GraphQLRequest(request21);

GraphQLRequests requests = new GraphQLRequests(
"customOperationName",
graphQLRequest1,
graphQLRequest2,
graphQLRequest21
);

String serializedQuery = serializer
.apply(requests).replaceAll(" +", " ")
.trim();
String expectedQueryStr = "query customOperationName { " +
"req1: eventsByCategoryAndStatus(status: OPEN){ id } " +
"req2: eventsByCategoryAndStatus{ id status } " +
"eventsByCategoryAndStatus " +
"}";
assertEquals(expectedQueryDecorator.apply(expectedQueryStr), serializedQuery);
}

@ParameterizedTest(name = "{0}")
@MethodSource("provideStaticSerializerForMultiRequest")
void serialize_multipleRequests_DiffTypes(String name, Function<GraphQLRequests, String> serializer,
Expand Down