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

Merge pull request #728 from kobylynskyi/develop

Release 5.2.0
......@@ -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
......
......@@ -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"
}
```
......@@ -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"
}
}
......
......@@ -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
......@@ -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"
......
......@@ -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"
......@@ -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"
......
......@@ -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"
......
......@@ -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
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......@@ -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>
......
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.1.0")
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.2.0")
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.1.0")
addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.2.0")
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)
......
version in ThisBuild := "5.1.0"
version in ThisBuild := "5.2.0"
......@@ -5,14 +5,25 @@ package com.kobylynskyi.graphql.codegen.model.graphql;
*/
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;
}
......@@ -25,6 +36,10 @@ public class GraphQLRequest {
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
......
......@@ -49,7 +49,7 @@ public class GraphQLRequestSerializer {
}
return jsonQuery(operationWrapper(
firstRequest.getOperationType(),
null, // combined request does not have operation name
graphQLRequests.getOperationName(),
queryBuilder.toString()));
}
......@@ -77,9 +77,13 @@ public class GraphQLRequestSerializer {
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));
}
......
......@@ -9,9 +9,15 @@ import java.util.List;
*/
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));
}
......@@ -23,6 +29,10 @@ public class GraphQLRequests {
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
......
......@@ -256,6 +256,27 @@ class GraphQLRequestSerializerTest {
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,
......@@ -505,6 +526,38 @@ class GraphQLRequestSerializerTest {
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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册