Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Graphql Java Codegen
提交
6b451dc1
G
Graphql Java Codegen
项目概览
梦境迷离
/
Graphql Java Codegen
10 个月 前同步成功
通知
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 搜索 >>
提交
6b451dc1
编写于
9月 13, 2022
作者:
M
msl-at-fcb
提交者:
Bogdan Kobylynskyi
2月 27, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added support for annotations in generated kotlin operations #1002 (#1003)
上级
4161d86d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
2 deletion
+76
-2
src/main/resources/templates/kotlin-lang/operations.ftl
src/main/resources/templates/kotlin-lang/operations.ftl
+1
-1
src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
...skyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
+49
-1
src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotation.kt.txt
...solver/AcceptTopicSuggestionMutationWithAnnotation.kt.txt
+13
-0
src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotations.kt.txt
...olver/AcceptTopicSuggestionMutationWithAnnotations.kt.txt
+13
-0
未找到文件。
src/main/resources/templates/kotlin-lang/operations.ftl
浏览文件 @
6b451dc1
...
...
@@ -38,7 +38,7 @@ interface ${className}<#if implements?has_content> : <#list implements as interf
<#
if
operation
.
throwsException
>
@
Throws
(
Exception
::
class
)
</#
if
>
fun
${
operation
.
name
}(<#
list
operation
.
parameters
as
param
>${
param
.
name
}:
${
param
.
type
}<#
if
param_has_next
>,
</#
if
></#
list
>):
${
operation
.
type
}
fun
${
operation
.
name
}(<#
list
operation
.
parameters
as
param
>
<#
list
param
.
annotations
as
paramAnnotation
>@${
paramAnnotation
}<#
if
param
.
annotations
?
has_content
>
</#
if
></#
list
>
${
param
.
name
}:
${
param
.
type
}<#
if
param_has_next
>,
</#
if
></#
list
>):
${
operation
.
type
}
</#
list
>
}
src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
浏览文件 @
6b451dc1
...
...
@@ -12,10 +12,13 @@ import org.junit.jupiter.api.Test;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Set
;
import
static
com
.
kobylynskyi
.
graphql
.
codegen
.
TestUtils
.
assertSameTrimmedContent
;
import
static
com
.
kobylynskyi
.
graphql
.
codegen
.
TestUtils
.
getFileByName
;
import
static
java
.
util
.
Collections
.
singleton
;
import
static
java
.
util
.
Collections
.
singletonList
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
...
...
@@ -188,6 +191,51 @@ class GraphQLCodegenGitHubTest {
getFileByName
(
files
,
"AcceptTopicSuggestionPayloadResolver.kt"
));
}
@Test
void
generate_CustomFieldsResolversWithAnnotation
()
throws
Exception
{
mappingConfig
.
setModelNamePrefix
(
"Github"
);
mappingConfig
.
setModelNameSuffix
(
"TO"
);
mappingConfig
.
setApiNameSuffix
(
"WithAnnotation"
);
mappingConfig
.
setResolverArgumentAnnotations
(
singleton
(
"some.Annotation"
));
mappingConfig
.
setGenerateDataFetchingEnvironmentArgumentInApis
(
true
);
mappingConfig
.
setFieldsWithResolvers
(
Collections
.
singleton
(
"AcceptTopicSuggestionPayload.topic"
));
new
KotlinGraphQLCodegen
(
singletonList
(
"src/test/resources/schemas/github.graphqls"
),
outputBuildDir
,
mappingConfig
,
TestUtils
.
getStaticGeneratedInfo
()).
generate
();
File
[]
files
=
Objects
.
requireNonNull
(
outputktClassesDir
.
listFiles
());
assertSameTrimmedContent
(
new
File
(
"src/test/resources/expected-classes/kt/field-resolver/"
+
"AcceptTopicSuggestionMutationWithAnnotation.kt.txt"
),
getFileByName
(
files
,
"AcceptTopicSuggestionMutationWithAnnotation.kt"
));
}
@Test
void
generate_CustomFieldsResolversWithMultipleAnnotations
()
throws
Exception
{
Set
<
String
>
annotations
=
new
HashSet
<>();
annotations
.
add
(
"some.Annotation"
);
annotations
.
add
(
"another.Annotation"
);
mappingConfig
.
setModelNamePrefix
(
"Github"
);
mappingConfig
.
setModelNameSuffix
(
"TO"
);
mappingConfig
.
setApiNameSuffix
(
"WithAnnotations"
);
mappingConfig
.
setResolverArgumentAnnotations
(
annotations
);
mappingConfig
.
setGenerateDataFetchingEnvironmentArgumentInApis
(
true
);
mappingConfig
.
setFieldsWithResolvers
(
Collections
.
singleton
(
"AcceptTopicSuggestionPayload.topic"
));
new
KotlinGraphQLCodegen
(
singletonList
(
"src/test/resources/schemas/github.graphqls"
),
outputBuildDir
,
mappingConfig
,
TestUtils
.
getStaticGeneratedInfo
()).
generate
();
File
[]
files
=
Objects
.
requireNonNull
(
outputktClassesDir
.
listFiles
());
assertSameTrimmedContent
(
new
File
(
"src/test/resources/expected-classes/kt/field-resolver/"
+
"AcceptTopicSuggestionMutationWithAnnotations.kt.txt"
),
getFileByName
(
files
,
"AcceptTopicSuggestionMutationWithAnnotations.kt"
));
}
@Test
void
generate_RequestWithDefaultValue
()
throws
Exception
{
mappingConfig
.
setGenerateBuilder
(
true
);
...
...
@@ -200,4 +248,4 @@ class GraphQLCodegenGitHubTest {
getFileByName
(
files
,
"FriendsQueryRequest.kt"
));
}
}
\ No newline at end of file
}
src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotation.kt.txt
0 → 100644
浏览文件 @
6b451dc1
package com.github.graphql
@javax.annotation.Generated(
value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
date = "2020-12-31T23:59:59-0500"
)
interface AcceptTopicSuggestionMutationWithAnnotation {
@Throws(Exception::class)
fun acceptTopicSuggestion(@some.Annotation input: GithubAcceptTopicSuggestionInputTO, env: graphql.schema.DataFetchingEnvironment): GithubAcceptTopicSuggestionPayloadTO?
}
src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotations.kt.txt
0 → 100644
浏览文件 @
6b451dc1
package com.github.graphql
@javax.annotation.Generated(
value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
date = "2020-12-31T23:59:59-0500"
)
interface AcceptTopicSuggestionMutationWithAnnotations {
@Throws(Exception::class)
fun acceptTopicSuggestion(@another.Annotation @some.Annotation input: GithubAcceptTopicSuggestionInputTO, env: graphql.schema.DataFetchingEnvironment): GithubAcceptTopicSuggestionPayloadTO?
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录