Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Graphql Java Codegen
提交
7f5b3c8a
G
Graphql Java Codegen
项目概览
梦境迷离
/
Graphql Java Codegen
11 个月 前同步成功
通知
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 搜索 >>
未验证
提交
7f5b3c8a
编写于
12月 02, 2021
作者:
梦境迷离
提交者:
GitHub
12月 01, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Kotlin: fix default value (#882)
上级
4fb7dbf9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
99 addition
and
1 deletion
+99
-1
src/main/resources/templates/kotlin-lang/request.ftl
src/main/resources/templates/kotlin-lang/request.ftl
+1
-1
src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
...skyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
+13
-0
src/test/resources/expected-classes/kt/default/FriendsQueryRequest.kt.txt
...es/expected-classes/kt/default/FriendsQueryRequest.kt.txt
+78
-0
src/test/resources/schemas/kt/default.graphqls
src/test/resources/schemas/kt/default.graphqls
+7
-0
未找到文件。
src/main/resources/templates/kotlin-lang/request.ftl
浏览文件 @
7f5b3c8a
...
...
@@ -107,7 +107,7 @@ open class ${className}(private val alias: String?) : GraphQLOperationRequest {
<#
else
>
<#
if
MapperUtil
.
isKotlinPrimitive
(
field
.
type
)>
<#
assign
default
=
MapperUtil
.
defaultValueKotlinPrimitive
(
field
.
type
)/>
private
var
${
field
.
name
}:
${
field
.
type
}
=
default
private
var
${
field
.
name
}:
${
field
.
type
}
=
${
default
}
<#
else
>
private
lateinit
var
${
field
.
name
}:
${
field
.
type
}
</#
if
>
...
...
src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
浏览文件 @
7f5b3c8a
...
...
@@ -19,6 +19,7 @@ import static com.kobylynskyi.graphql.codegen.TestUtils.getFileByName;
import
static
java
.
util
.
Collections
.
singletonList
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
class
GraphQLCodegenGitHubTest
{
private
final
File
outputBuildDir
=
new
File
(
"build/generated"
);
...
...
@@ -187,4 +188,16 @@ class GraphQLCodegenGitHubTest {
getFileByName
(
files
,
"AcceptTopicSuggestionPayloadResolver.kt"
));
}
@Test
void
generate_RequestWithDefaultValue
()
throws
Exception
{
mappingConfig
.
setGenerateBuilder
(
true
);
mappingConfig
.
setGenerateClient
(
true
);
new
KotlinGraphQLCodegen
(
singletonList
(
"src/test/resources/schemas/kt/default.graphqls"
),
outputBuildDir
,
mappingConfig
,
TestUtils
.
getStaticGeneratedInfo
()).
generate
();
File
[]
files
=
Objects
.
requireNonNull
(
outputktClassesDir
.
listFiles
());
assertSameTrimmedContent
(
new
File
(
"src/test/resources/expected-classes/kt/default/"
+
"FriendsQueryRequest.kt.txt"
),
getFileByName
(
files
,
"FriendsQueryRequest.kt"
));
}
}
\ No newline at end of file
src/test/resources/expected-classes/kt/default/FriendsQueryRequest.kt.txt
0 → 100644
浏览文件 @
7f5b3c8a
package com.github.graphql
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLOperation
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLOperationRequest
import java.util.Objects
@javax.annotation.Generated(
value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
date = "2020-12-31T23:59:59-0500"
)
open class FriendsQueryRequest(private val alias: String?) : GraphQLOperationRequest {
companion object {
const val OPERATION_NAME: String = "friends"
val OPERATION_TYPE: GraphQLOperation = GraphQLOperation.QUERY
@JvmStatic fun builder(): Builder = Builder()
}
private val input: MutableMap<String, Any?> = LinkedHashMap()
private val useObjectMapperForInputSerialization: MutableSet<String> = HashSet()
constructor(): this(null)
fun setNum(num: Int) {
this.input["num"] = num
}
override fun getOperationType(): GraphQLOperation = OPERATION_TYPE
override fun getOperationName(): String = OPERATION_NAME
override fun getAlias(): String? = alias ?: OPERATION_NAME
override fun getInput(): MutableMap<String, Any?> = input
override fun getUseObjectMapperForInputSerialization(): MutableSet<String> = useObjectMapperForInputSerialization
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
if (other == null || javaClass != other.javaClass) {
return false
}
val that = other as FriendsQueryRequest
return Objects.equals(operationType, that.operationType) &&
Objects.equals(operationName, that.operationName) &&
Objects.equals(input, that.input)
}
override fun hashCode(): Int = Objects.hash(operationType, operationName, input)
override fun toString(): String = Objects.toString(input)
class Builder {
private var `$alias`: String? = null
private var num: Int = 0
fun alias(alias: String?): Builder {
this.`$alias` = alias
return this
}
fun setNum(num: Int): Builder {
this.num = num
return this
}
fun build(): FriendsQueryRequest {
val obj = FriendsQueryRequest(`$alias`)
obj.setNum(num)
return obj
}
}
}
\ No newline at end of file
src/test/resources/schemas/kt/default.graphqls
0 → 100644
浏览文件 @
7f5b3c8a
type Query {
friends(num: Int!): [Friend]
}
type Friend {
name: String
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录