Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Graphql Java Codegen
提交
3b430786
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 搜索 >>
未验证
提交
3b430786
编写于
4月 22, 2021
作者:
R
Robbert Noordzij
提交者:
GitHub
4月 22, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add directive support for types #660 (#665)
Co-authored-by:
N
Robbert Noordzij
<
robbert@robbertnoordzij.nl
>
上级
e15ac840
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
217 addition
and
1 deletion
+217
-1
src/main/java/com/kobylynskyi/graphql/codegen/mapper/GraphQLTypeMapper.java
...kobylynskyi/graphql/codegen/mapper/GraphQLTypeMapper.java
+1
-1
src/main/java/com/kobylynskyi/graphql/codegen/model/definitions/ExtendedDefinition.java
...graphql/codegen/model/definitions/ExtendedDefinition.java
+20
-0
src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenAnnotationsTest.java
...ynskyi/graphql/codegen/GraphQLCodegenAnnotationsTest.java
+4
-0
src/test/resources/expected-classes/annotation/EventProperty.java.txt
...ources/expected-classes/annotation/EventProperty.java.txt
+192
-0
未找到文件。
src/main/java/com/kobylynskyi/graphql/codegen/mapper/GraphQLTypeMapper.java
浏览文件 @
3b430786
...
...
@@ -272,7 +272,7 @@ public interface GraphQLTypeMapper {
default
List
<
String
>
getAnnotations
(
MappingContext
mappingContext
,
ExtendedDefinition
<?,
?>
extendedDefinition
)
{
NamedNode
def
=
extendedDefinition
!=
null
?
extendedDefinition
.
getDefinition
()
:
null
;
return
getAnnotations
(
mappingContext
,
extendedDefinition
.
getName
(),
extendedDefinition
.
getName
(),
null
,
Collections
.
emptyList
(),
false
,
def
);
extendedDefinition
.
getDirectives
(),
false
,
def
);
}
default
List
<
String
>
getAnnotations
(
MappingContext
mappingContext
,
String
name
)
{
...
...
src/main/java/com/kobylynskyi/graphql/codegen/model/definitions/ExtendedDefinition.java
浏览文件 @
3b430786
...
...
@@ -115,6 +115,26 @@ public abstract class ExtendedDefinition<T extends NamedNode<T>, E extends T> {
return
directives
;
}
/**
* Return all directives for this definition
*
* @return list of directive names
*/
public
List
<
Directive
>
getDirectives
()
{
List
<
Directive
>
directives
=
new
ArrayList
<>();
if
(
this
.
definition
instanceof
DirectivesContainer
)
{
List
<
Directive
>
definitionDirectives
=
((
DirectivesContainer
<?>)
this
.
definition
).
getDirectives
();
if
(!
Utils
.
isEmpty
(
definitionDirectives
))
{
directives
.
addAll
(
definitionDirectives
);
}
this
.
extensions
.
stream
().
filter
(
Objects:
:
nonNull
)
.
map
(
DirectivesContainer
.
class
::
cast
)
.
map
(
DirectivesContainer:
:
getDirectives
).
filter
(
Objects:
:
nonNull
)
.
forEach
(
ds
->
ds
.
forEach
(
d
->
directives
.
add
(((
Directive
)
d
))));
}
return
directives
;
}
public
T
getDefinition
()
{
return
definition
;
}
...
...
src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenAnnotationsTest.java
浏览文件 @
3b430786
...
...
@@ -209,6 +209,7 @@ class GraphQLCodegenAnnotationsTest {
"int={{int}}, "
+
"n={{n?toString}})"
));
directiveAnnotationsMapping
.
put
(
"valid"
,
singletonList
(
"@javax.validation.Valid"
));
directiveAnnotationsMapping
.
put
(
"customResolver"
,
singletonList
(
"@com.example.CustomAnnotation"
));
mappingConfig
.
setDirectiveAnnotationsMapping
(
directiveAnnotationsMapping
);
new
JavaGraphQLCodegen
(
singletonList
(
"src/test/resources/schemas/test.graphqls"
),
...
...
@@ -221,6 +222,9 @@ class GraphQLCodegenAnnotationsTest {
assertSameTrimmedContent
(
new
File
(
"src/test/resources/expected-classes/annotation/MutationResolver.java.txt"
),
getFileByName
(
files
,
"MutationResolver.java"
));
assertSameTrimmedContent
(
new
File
(
"src/test/resources/expected-classes/annotation/EventProperty.java.txt"
),
getFileByName
(
files
,
"EventProperty.java"
));
}
}
src/test/resources/expected-classes/annotation/EventProperty.java.txt
0 → 100644
浏览文件 @
3b430786
package com.kobylynskyi.graphql.test1;
/**
* An event property have all possible types
*/
@javax.annotation.Generated(
value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
date = "2020-12-31T23:59:59-0500"
)
@com.example.CustomAnnotation
public class EventProperty implements java.io.Serializable {
private Double floatVal;
private Boolean booleanVal;
private int intVal;
private java.util.List<Integer> intVals;
private String stringVal;
private java.util.List<EventProperty> child;
private Event parent;
public EventProperty() {
}
public EventProperty(Double floatVal, Boolean booleanVal, int intVal, java.util.List<Integer> intVals, String stringVal, java.util.List<EventProperty> child, Event parent) {
this.floatVal = floatVal;
this.booleanVal = booleanVal;
this.intVal = intVal;
this.intVals = intVals;
this.stringVal = stringVal;
this.child = child;
this.parent = parent;
}
/**
* Float property
* with multiline comment
*/
public Double getFloatVal() {
return floatVal;
}
/**
* Float property
* with multiline comment
*/
public void setFloatVal(Double floatVal) {
this.floatVal = floatVal;
}
public Boolean getBooleanVal() {
return booleanVal;
}
public void setBooleanVal(Boolean booleanVal) {
this.booleanVal = booleanVal;
}
public int getIntVal() {
return intVal;
}
public void setIntVal(int intVal) {
this.intVal = intVal;
}
/**
* primitive should not be generated
*/
public java.util.List<Integer> getIntVals() {
return intVals;
}
/**
* primitive should not be generated
*/
public void setIntVals(java.util.List<Integer> intVals) {
this.intVals = intVals;
}
/**
* String comment
*/
public String getStringVal() {
return stringVal;
}
/**
* String comment
*/
public void setStringVal(String stringVal) {
this.stringVal = stringVal;
}
/**
* Properties
*/
public java.util.List<EventProperty> getChild() {
return child;
}
/**
* Properties
*/
public void setChild(java.util.List<EventProperty> child) {
this.child = child;
}
/**
* Parent event of the property
*/
public Event getParent() {
return parent;
}
/**
* Parent event of the property
*/
public void setParent(Event parent) {
this.parent = parent;
}
public static EventProperty.Builder builder() {
return new EventProperty.Builder();
}
public static class Builder {
private Double floatVal;
private Boolean booleanVal;
private int intVal;
private java.util.List<Integer> intVals;
private String stringVal;
private java.util.List<EventProperty> child;
private Event parent;
public Builder() {
}
/**
* Float property
* with multiline comment
*/
public Builder setFloatVal(Double floatVal) {
this.floatVal = floatVal;
return this;
}
public Builder setBooleanVal(Boolean booleanVal) {
this.booleanVal = booleanVal;
return this;
}
public Builder setIntVal(int intVal) {
this.intVal = intVal;
return this;
}
/**
* primitive should not be generated
*/
public Builder setIntVals(java.util.List<Integer> intVals) {
this.intVals = intVals;
return this;
}
/**
* String comment
*/
public Builder setStringVal(String stringVal) {
this.stringVal = stringVal;
return this;
}
/**
* Properties
*/
public Builder setChild(java.util.List<EventProperty> child) {
this.child = child;
return this;
}
/**
* Parent event of the property
*/
public Builder setParent(Event parent) {
this.parent = parent;
return this;
}
public EventProperty build() {
return new EventProperty(floatVal, booleanVal, intVal, intVals, stringVal, child, parent);
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录