Skip to content

Commit 1036c08

Browse files
committed
修正GraphQL的返回类型设置, 没有设置type时根据stdDomain猜测
1 parent d007d15 commit 1036c08

File tree

7 files changed

+29
-12
lines changed

7 files changed

+29
-12
lines changed

nop-demo/nop-quarkus-demo/src/main/resources/nop-vfs-index.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@
617617
/nop/report/xlib/xpt-rt.xlib
618618
/nop/report/xlib/xpt.xlib
619619
/nop/rpc/imp/api.imp.xml
620+
/nop/rpc/imp/api.imp.xml.rej
620621
/nop/rpc/imp/template.api.xlsx
621622
/nop/rule/_module
622623
/nop/rule/auth/_nop-rule-api.action-auth.xml
@@ -1049,6 +1050,7 @@
10491050
/nop/web/xlib/view-gen.xlib
10501051
/nop/web/xlib/view-gen/impl_GenFromMeta.xpl
10511052
/nop/web/xlib/web.xlib
1053+
/nop/web/xlib/web.xlib.rej
10521054
/nop/web/xlib/web/grid_crud.xpl
10531055
/nop/web/xlib/web/impl_GenForm.xpl
10541056
/nop/web/xlib/web/impl_GenGrid.xpl

nop-graphql/nop-graphql-core/src/main/java/io/nop/graphql/core/schema/meta/ObjMetaToGraphQLDefinition.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.nop.graphql.core.schema.TypeRegistry;
3131
import io.nop.graphql.core.utils.GraphQLObjMetaHelper;
3232
import io.nop.graphql.core.utils.GraphQLTypeHelper;
33+
import io.nop.xlang.xdef.domain.StdDomainRegistry;
3334
import io.nop.xlang.xmeta.IObjMeta;
3435
import io.nop.xlang.xmeta.IObjPropMeta;
3536
import io.nop.xlang.xmeta.ISchema;
@@ -195,12 +196,15 @@ public GraphQLType toGraphQLType(String thisObjName, ISchema schema, boolean man
195196
if (bizObjName != null)
196197
return GraphQLTypeHelper.namedType(bizObjName);
197198

198-
StdDataType stdDataType = schema.getStdDataType();
199-
if (stdDataType != null)
200-
gqlType = GraphQLTypeHelper.scalarType(GraphQLScalarType.fromStdDataType(stdDataType));
201-
if (gqlType == null)
202-
gqlType = GraphQLTypeHelper.scalarType(GraphQLScalarType.String);
203-
return gqlType;
199+
type = guessType(schema);
200+
if (type == null) {
201+
StdDataType stdDataType = schema.getStdDataType();
202+
if (stdDataType != null)
203+
gqlType = GraphQLTypeHelper.scalarType(GraphQLScalarType.fromStdDataType(stdDataType));
204+
if (gqlType == null)
205+
gqlType = GraphQLTypeHelper.scalarType(GraphQLScalarType.String);
206+
return gqlType;
207+
}
204208
}
205209
gqlType = ReflectionGraphQLTypeFactory.INSTANCE.buildGraphQLType(type, thisObjName, bizObjName,
206210
typeRegistry, input);
@@ -213,6 +217,13 @@ public GraphQLType toGraphQLType(String thisObjName, ISchema schema, boolean man
213217
return gqlType;
214218
}
215219

220+
IGenericType guessType(ISchema schema) {
221+
String stdDomain = schema.getStdDomain();
222+
if (stdDomain == null)
223+
return null;
224+
return StdDomainRegistry.instance().getStdDomainHandler(stdDomain).getGenericType(false, null);
225+
}
226+
216227
private GraphQLType buildObjType(String thisObjName, ISchema schema, TypeRegistry registry, boolean input) {
217228
GraphQLObjectDefinition def = new GraphQLObjectDefinition();
218229
def.setLocation(schema.getLocation());

nop-graphql/nop-graphql-core/src/main/java/io/nop/graphql/core/schema/utils/GraphQLSourcePrinter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,11 @@ private void printArgDefs(List<GraphQLArgumentDefinition> args) {
341341
public void visitGraphQLArgumentDefinition(GraphQLArgumentDefinition node) {
342342
out.append(node.getName());
343343
out.append(':');
344-
visit(node.getType());
344+
if(node.getType() == null){
345+
out.append("Any");
346+
}else {
347+
visit(node.getType());
348+
}
345349
if (node.getDefaultValue() != null) {
346350
out.append(" = ");
347351
visit(node.getDefaultValue());

nop-rule/nop-rule-meta/src/main/resources/_vfs/nop/rule/model/NopRuleDefinition/NopRuleDefinition.xmeta

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</prop>
1717

1818
<prop name="beforeExecute" displayName="初始化代码" ui:show="L" insertable="true" updatable="true">
19-
<schema stdDomain="xpl"/>
19+
<schema stdDomain="xpl" type="String"/>
2020
</prop>
2121

2222
<prop name="importFile" displayName="Excel规则文件" published="false" updatable="false" insertable="false"
@@ -31,7 +31,7 @@
3131
</prop>
3232

3333
<prop name="decisionMatrix" displayName="决策矩阵配置" ui:show="L" insertable="true" updatable="true">
34-
<schema stdDomain="xml"/>
34+
<schema stdDomain="xml" type="String"/>
3535
</prop>
3636
</props>
3737
</meta>

nop-rule/nop-rule-meta/src/main/resources/_vfs/nop/rule/model/NopRuleInput/NopRuleInput.xmeta

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</prop>
2424

2525
<prop name="defaultExpr" displayName="缺省值" insertable="true" updatable="true">
26-
<schema stdDomain="xpl"/>
26+
<schema stdDomain="xpl" type="String"/>
2727
</prop>
2828

2929
<prop name="description" displayName="描述" insertable="true" updatable="true">

nop-rule/nop-rule-meta/src/main/resources/_vfs/nop/rule/model/NopRuleOutputValue/NopRuleOutputValue.xmeta

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</prop>
88

99
<prop name="valueExpr" displayName="变量表达式" mandatory="true">
10-
<schema stdDomain="xpl"/>
10+
<schema stdDomain="xpl" type="String"/>
1111
</prop>
1212
</props>
1313
</meta>

nop-rule/nop-rule-service/src/main/resources/_vfs/nop/rule/model/NopRuleDefinition/NopRuleDefinition.xbiz

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<actions>
55
<query name="getOutputFieldsEditSchema">
6-
<arg name="ruleId" mandatory="true" />
6+
<arg name="ruleId" mandatory="true" type="String" />
77
<arg name="selection" kind="FieldSelection"/>
88
<arg name="svcCtx" kind="ServiceContext" />
99

0 commit comments

Comments
 (0)