Skip to content

Commit

Permalink
修正rpc调用模式下bean的selection自动展开中层次判断不一致的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Nov 8, 2023
1 parent 2c29d9e commit cd807f8
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 15 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.nop.auth.service;

import io.nop.api.core.annotations.autotest.EnableSnapshot;
import io.nop.api.core.annotations.autotest.NopTestConfig;
import io.nop.api.core.beans.ApiRequest;
import io.nop.autotest.junit.JunitAutoTestCase;
import io.nop.graphql.core.IGraphQLExecutionContext;
import io.nop.graphql.core.engine.IGraphQLEngine;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;

import java.util.Map;

@NopTestConfig(localDb = true)
public class TestSiteMapApi extends JunitAutoTestCase {
@Inject
IGraphQLEngine graphQLEngine;

@EnableSnapshot
@Test
public void testRpc(){
ApiRequest<Map<String,Object>> request = new ApiRequest<>();
// 测试children自动展开到6层
IGraphQLExecutionContext context = graphQLEngine.newRpcContext(null,
"SiteMapApi__getSiteMap", request);
System.out.print(context.getFieldSelection().toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14356,6 +14356,14 @@
"io.nop.core.context.IServiceContext"
]
},
{
"name": "findLogicalDeleted",
"parameterTypes": [
"java.util.Map",
"io.nop.dao.api.IEntityDao",
"io.nop.xlang.xmeta.IObjMeta"
]
},
{
"name": "findPage",
"parameterTypes": [
Expand Down Expand Up @@ -17019,6 +17027,181 @@
"name": "io.nop.commons.type.StdDataType",
"unsafeAllocated": false
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicConstructors": true,
"allPublicMethods": true,
"fields": [
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "ANY"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "ARRAY"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "BIGINT"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "BOOLEAN"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "CHAR"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "DATE"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "DATETIME"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "DECIMAL"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "DOUBLE"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "FLOAT"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "GEOMETRY"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "INTEGER"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "JSON"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "NUMERIC"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "OTHER"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "REAL"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "SMALLINT"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "TIME"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "TIMESTAMP"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "TINYINT"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "VARBINARY"
},
{
"allowUnsafeAccess": false,
"allowWrite": false,
"name": "VARCHAR"
}
],
"methods": [
{
"name": "convert",
"parameterTypes": [
"java.lang.Object",
"java.util.function.Function"
]
},
{
"name": "fromJdbcType",
"parameterTypes": [
"int"
]
},
{
"name": "fromStdName",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "getJdbcType",
"parameterTypes": []
},
{
"name": "getName",
"parameterTypes": []
},
{
"name": "getNames",
"parameterTypes": []
},
{
"name": "getStdDataType",
"parameterTypes": []
},
{
"name": "isAllowPrecision",
"parameterTypes": []
},
{
"name": "isAllowScale",
"parameterTypes": []
},
{
"name": "valueOf",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "values",
"parameterTypes": []
}
],
"name": "io.nop.commons.type.StdSqlType",
"unsafeAllocated": false
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
Expand Down Expand Up @@ -25628,6 +25811,25 @@
"name": "io.nop.dao.dialect.json.H2JsonTypeHandler",
"unsafeAllocated": false
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicConstructors": true,
"allPublicMethods": true,
"fields": [],
"methods": [
{
"name": "setValue",
"parameterTypes": [
"io.nop.dataset.binder.IDataParameters",
"int",
"java.lang.Object"
]
}
],
"name": "io.nop.dao.dialect.json.MySqlJsonTypeHandler",
"unsafeAllocated": false
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
Expand Down Expand Up @@ -37761,6 +37963,10 @@
"name": "getDeleteFlagPropId",
"parameterTypes": []
},
{
"name": "getDeleteVersionProp",
"parameterTypes": []
},
{
"name": "getEagerLoadProps",
"parameterTypes": []
Expand Down Expand Up @@ -39682,6 +39888,10 @@
"name": "getDeleteFlagProp",
"parameterTypes": []
},
{
"name": "getDeleteVersionProp",
"parameterTypes": []
},
{
"name": "getDimensionalType",
"parameterTypes": []
Expand Down Expand Up @@ -40010,6 +40220,12 @@
"java.lang.String"
]
},
{
"name": "setDeleteVersionProp",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "setDimensionalType",
"parameterTypes": [
Expand Down
10 changes: 5 additions & 5 deletions nop-demo/nop-quarkus-demo/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ nop:
auth:
login:
allow-create-default-user: true # 如果用户表为空,则自动创建缺省账户nop, 密码nop-test
datasource:
driver-class-name: org.h2.Driver
jdbc-url: jdbc:h2:./db/test
username: sa
password:
# datasource:
# driver-class-name: org.h2.Driver
# jdbc-url: jdbc:h2:./db/test
# username: sa
# password:

web:
validate-page-model: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void resolveSelection(GraphQLDocument doc) {

for (GraphQLDefinition def : doc.getDefinitions()) {
if (def instanceof GraphQLOperation) {
resolveOperation(doc, (GraphQLOperation) def, 0);
resolveOperation(doc, (GraphQLOperation) def);
}
}
}
Expand All @@ -59,7 +59,7 @@ private void resolveFragment(GraphQLDocument doc, GraphQLFragment fragment, int
resolveSelections(doc, fragment.getOnType(), fragment.getSelectionSet(), new HashMap<>(), level - 1);
}

private void resolveOperation(GraphQLDocument doc, GraphQLOperation op, int level) {
private void resolveOperation(GraphQLDocument doc, GraphQLOperation op) {
for (GraphQLSelection selection : op.getSelectionSet().getSelections()) {
if (selection instanceof GraphQLFieldSelection) {
GraphQLFieldSelection fieldSelection = (GraphQLFieldSelection) selection;
Expand All @@ -73,7 +73,7 @@ private void resolveOperation(GraphQLDocument doc, GraphQLOperation op, int leve
int index = fieldSelection.getName().indexOf(OBJ_ACTION_SEPARATOR);
String objName = index < 0 ? BIZ_OBJ_NAME_ROOT : fieldSelection.getName().substring(0, index);
resolveFieldSelection(doc, objName, fieldDef,
fieldSelection, op.getVars(), level + 1);
fieldSelection, op.getVars(), 0);
} else {
throw new NopException(ERR_GRAPHQL_UNSUPPORTED_AST).param(ARG_AST_NODE, selection);
}
Expand All @@ -92,7 +92,7 @@ public void resolveSelections(GraphQLDocument doc, String objName, GraphQLSelect
.param(ARG_SELECTION_SET, selectionSet.toSource());
}

if (level >= maxDepth) {
if (level > maxDepth) {
throw new NopException(ERR_GRAPHQL_QUERY_EXCEED_MAX_DEPTH).source(selectionSet).param(ARG_TYPE, objName)
.param(ARG_SELECTION_SET, selectionSet.toSource()).param(ARG_MAX_DEPTH, maxDepth)
.param(ARG_LEVEL, level);
Expand Down
Loading

0 comments on commit cd807f8

Please sign in to comment.