Skip to content

Commit 47007f1

Browse files
committed
add GraphQL Calculator
1 parent 693cc68 commit 47007f1

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: graphql-calculator
3+
description: A lightweight graphql calculation engine.
4+
url: https://github.com/graphql-calculator/graphql-calculator
5+
github: graphql-calculator/graphql-calculator
6+
---
7+
8+
GraphQL Calculator is a lightweight graphql calculation engine,
9+
which is used to alter execution behavior of graphql query.
10+
11+
Here are some examples on how to use GraphQL Calculator on graphql query.
12+
13+
```graphql
14+
15+
query basicMapValue($userIds:[Int]){
16+
userInfoList(userIds:$userIds)
17+
{
18+
id
19+
age
20+
firstName
21+
lastName
22+
fullName: stringHolder @map(mapper: "firstName + lastName")
23+
}
24+
}
25+
26+
27+
query filterUserByAge($userId:[Int]){
28+
userInfoList(userIds: $userId)
29+
@filter(predicate: "age>=18")
30+
{
31+
userId
32+
age
33+
firstName
34+
lastName
35+
}
36+
}
37+
38+
query parseFetchedValueToAnotherFieldArgumentMap($itemIds:[Int]){
39+
40+
itemList(itemIds: $itemIds){
41+
# save sellerId as List<Long> with unique name "sellerIdList"
42+
sellerId @fetchSource(name: "sellerIdList")
43+
name
44+
saleAmount
45+
salePrice
46+
}
47+
48+
userInfoList(userIds: 1)
49+
# transform the argument of "userInfoList" named "userIds" according to expression "sellerIdList" and expression argument,
50+
# which mean replace userIds value by source named "sellerIdList"
51+
@argumentTransform(argumentName: "userIds",
52+
operateType: MAP,
53+
expression: "sellerIdList",
54+
dependencySources: ["sellerIdList"]
55+
){
56+
userId
57+
name
58+
age
59+
}
60+
}
61+
```
62+
63+
See [graphql-calculator README](https://github.com/graphql-calculator/graphql-calculator) for more information.
64+

0 commit comments

Comments
 (0)