Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Graphql Java Codegen
提交
f291209d
G
Graphql Java Codegen
项目概览
梦境迷离
/
Graphql Java Codegen
9 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Graphql Java Codegen
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
f291209d
编写于
6月 16, 2021
作者:
B
Bogdan Kobylynskyi
提交者:
GitHub
6月 16, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #728 from kobylynskyi/develop
Release 5.2.0
上级
2faf31de
26700c96
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
110 addition
and
28 deletion
+110
-28
build.gradle
build.gradle
+2
-2
plugins/gradle/README.md
plugins/gradle/README.md
+2
-2
plugins/gradle/example-client-kotlin/build.gradle
plugins/gradle/example-client-kotlin/build.gradle
+3
-3
plugins/gradle/example-client/build.gradle
plugins/gradle/example-client/build.gradle
+2
-2
plugins/gradle/example-server/build.gradle
plugins/gradle/example-server/build.gradle
+1
-1
plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle
...ns/gradle/graphql-java-codegen-gradle-plugin/build.gradle
+1
-1
plugins/maven/README.md
plugins/maven/README.md
+1
-1
plugins/maven/example-client/pom.xml
plugins/maven/example-client/pom.xml
+1
-1
plugins/maven/example-server/pom.xml
plugins/maven/example-server/pom.xml
+1
-1
plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
+4
-4
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/project/plugins.sbt
...degen-sbt-plugin/example-client-scala/project/plugins.sbt
+1
-1
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/version.sbt
...aphql-codegen-sbt-plugin/example-client-scala/version.sbt
+1
-1
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/project/plugins.sbt
...hql-codegen-sbt-plugin/example-client/project/plugins.sbt
+1
-1
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/version.sbt
...est/graphql-codegen-sbt-plugin/example-client/version.sbt
+1
-1
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt
...est/graphql-codegen-sbt-plugin/simple/project/plugins.sbt
+1
-1
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt
...rc/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt
+1
-1
plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt
plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt
+1
-1
src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLRequest.java
...lynskyi/graphql/codegen/model/graphql/GraphQLRequest.java
+16
-1
src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLRequestSerializer.java
...aphql/codegen/model/graphql/GraphQLRequestSerializer.java
+6
-2
src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLRequests.java
...ynskyi/graphql/codegen/model/graphql/GraphQLRequests.java
+10
-0
src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLRequestSerializerTest.java
...l/codegen/model/graphql/GraphQLRequestSerializerTest.java
+53
-0
未找到文件。
build.gradle
浏览文件 @
f291209d
...
...
@@ -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
...
...
plugins/gradle/README.md
浏览文件 @
f291209d
...
...
@@ -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"
}
}
...
...
plugins/gradle/example-client-kotlin/build.gradle
浏览文件 @
f291209d
...
...
@@ -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"
...
...
plugins/gradle/example-client/build.gradle
浏览文件 @
f291209d
...
...
@@ -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"
...
...
plugins/gradle/example-server/build.gradle
浏览文件 @
f291209d
...
...
@@ -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"
...
...
plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle
浏览文件 @
f291209d
...
...
@@ -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
...
...
plugins/maven/README.md
浏览文件 @
f291209d
...
...
@@ -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>
...
...
plugins/maven/example-client/pom.xml
浏览文件 @
f291209d
...
...
@@ -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>
...
...
plugins/maven/example-server/pom.xml
浏览文件 @
f291209d
...
...
@@ -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>
...
...
plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
浏览文件 @
f291209d
...
...
@@ -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>
...
...
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/project/plugins.sbt
浏览文件 @
f291209d
addSbtPlugin
(
"io.github.jxnu-liguobin"
%
"graphql-codegen-sbt-plugin"
%
"5.
1
.0"
)
addSbtPlugin
(
"io.github.jxnu-liguobin"
%
"graphql-codegen-sbt-plugin"
%
"5.
2
.0"
)
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/version.sbt
浏览文件 @
f291209d
version
in
ThisBuild
:=
"5.
1
.0"
version
in
ThisBuild
:=
"5.
2
.0"
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/project/plugins.sbt
浏览文件 @
f291209d
addSbtPlugin
(
"io.github.jxnu-liguobin"
%
"graphql-codegen-sbt-plugin"
%
"5.
1
.0"
)
addSbtPlugin
(
"io.github.jxnu-liguobin"
%
"graphql-codegen-sbt-plugin"
%
"5.
2
.0"
)
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/version.sbt
浏览文件 @
f291209d
version
in
ThisBuild
:=
"5.
1
.0"
version
in
ThisBuild
:=
"5.
2
.0"
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt
浏览文件 @
f291209d
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
)
...
...
plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt
浏览文件 @
f291209d
version
in
ThisBuild
:=
"5.
1
.0"
version
in
ThisBuild
:=
"5.
2
.0"
plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt
浏览文件 @
f291209d
version
in
ThisBuild
:=
"5.
1
.0"
version
in
ThisBuild
:=
"5.
2
.0"
src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLRequest.java
浏览文件 @
f291209d
...
...
@@ -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
...
...
src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLRequestSerializer.java
浏览文件 @
f291209d
...
...
@@ -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
));
}
...
...
src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLRequests.java
浏览文件 @
f291209d
...
...
@@ -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
...
...
src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLRequestSerializerTest.java
浏览文件 @
f291209d
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录