Skip to content

Commit 081a8d9

Browse files
authored
add graphql-calculator (#118)
1 parent 7e895c5 commit 081a8d9

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
query basicMapValue($userIds:[Int]){
15+
userInfoList(userIds:$userIds)
16+
{
17+
id
18+
age
19+
firstName
20+
lastName
21+
fullName: stringHolder @map(mapper: "firstName + lastName")
22+
}
23+
}
24+
query filterUserByAge($userId:[Int]){
25+
userInfoList(userIds: $userId)
26+
@filter(predicate: "age>=18")
27+
{
28+
userId
29+
age
30+
firstName
31+
lastName
32+
}
33+
}
34+
query parseFetchedValueToAnotherFieldArgumentMap($itemIds:[Int]){
35+
itemList(itemIds: $itemIds){
36+
# save sellerId as List<Long> with unique name "sellerIdList"
37+
sellerId @fetchSource(name: "sellerIdList")
38+
name
39+
saleAmount
40+
salePrice
41+
}
42+
userInfoList(userIds: 1)
43+
# transform the argument of "userInfoList" named "userIds" according to expression "sellerIdList" and expression argument,
44+
# which mean replace userIds value by source named "sellerIdList"
45+
@argumentTransform(argumentName: "userIds",
46+
operateType: MAP,
47+
expression: "sellerIdList",
48+
dependencySources: ["sellerIdList"]
49+
){
50+
userId
51+
name
52+
age
53+
}
54+
}
55+
```
56+
57+
See [graphql-calculator README](https://github.com/graphql-calculator/graphql-calculator) for more information.

0 commit comments

Comments
 (0)