-
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.
- Loading branch information
1 parent
2b6d027
commit c6040d3
Showing
1 changed file
with
20 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,30 @@ | ||
# NopGraphQL中的数据类型 | ||
|
||
## 扩展的Scalar类型 | ||
|
||
GraphQL缺省只有Float、Int、String、Boolean、ID这几种基本类型。NopGraphQL引入了更多的Scalar类型,以便于更好的支持业务数据模型。 | ||
比如区分了Float、Double、Int、Double、BigDecimal等。 | ||
|
||
## Long作为String返回 | ||
|
||
对于前台JS而言,超过一定大小的Long无法在前台正常处理,必须要转换成String类型。 | ||
|
||
1. 在Excel数据模型中定义一个domain,string-long,在【域定义中】设置它对应的Java类型为String。这样在生成实体属性的时候会修改为String类型。 | ||
2. 另外一种做法是在XMeta的prop上指定`graphql:type`为String,这样在GraphQL中返回的时候会自动转换成String类型。 | ||
|
||
## Java类型映射到GraphQL类型 | ||
|
||
有时会使用弱类型的Java属性,但是希望为它指定某个确定性的GraphQL类型。可以通过`@GraphQLReturn("MyObject")`这种注解来指定函数返回值类型中的对象类型为指定类型。如果返回类型是列表类型,则GraphQLReturn指定的是列表中的元素的类型。 | ||
|
||
|
||
|
||
```java | ||
static class ResultBean { | ||
List<IOrmEntity> list; | ||
|
||
@GraphQLReturn(bizObjName = "MyObject") | ||
public List<IPropGetMissingHook> getList() { | ||
return list; | ||
} | ||
} | ||
``` |