-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
通过@GraphQLReturn来指定动态属性的graphQL的列表元素对象类型
- Loading branch information
1 parent
a7eca10
commit 2b6d027
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...l-core/src/test/java/io/nop/graphql/core/reflection/TestReflectionGraphQLTypeFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.nop.graphql.core.reflection; | ||
|
||
import io.nop.api.core.annotations.graphql.GraphQLReturn; | ||
import io.nop.core.reflect.hook.IPropGetMissingHook; | ||
import io.nop.graphql.core.ast.GraphQLType; | ||
import io.nop.graphql.core.schema.TypeRegistry; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class TestReflectionGraphQLTypeFactory { | ||
@Test | ||
public void testDynamicObjName() { | ||
TypeRegistry registry = new TypeRegistry(); | ||
GraphQLType type = ReflectionGraphQLTypeFactory.INSTANCE.buildGraphQLType(ResultBean.class, registry, false); | ||
String source = registry.getType(type.getNamedTypeName()).toSource(); | ||
System.out.println(source); | ||
assertTrue(source.contains("[MyObject]")); | ||
} | ||
|
||
public static class ResultBean { | ||
List<IPropGetMissingHook> list; | ||
|
||
@GraphQLReturn(bizObjName = "MyObject") | ||
public List<IPropGetMissingHook> getList() { | ||
return list; | ||
} | ||
} | ||
} |