Skip to content

Commit 8d09a5c

Browse files
committed
added a chart to describe the AST node connections
1 parent 6923c53 commit 8d09a5c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/analysis/ASTnodefunctions.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from 'graphql';
1111

1212
// TODO: handle variables and arguments
13+
// ! this is not functional
1314
const getArgObj = (args: ArgumentNode[]): { [index: string]: any } => {
1415
const argObj: { [index: string]: any } = {};
1516
for (let i = 0; i < args.length; i + 1) {
@@ -23,6 +24,25 @@ const getArgObj = (args: ArgumentNode[]): { [index: string]: any } => {
2324
}
2425
return argObj;
2526
};
27+
/**
28+
* The AST node functions call each other following the nested structure below
29+
* Each function handles a specific GraphQL AST node type
30+
*
31+
* AST nodes call each other in the following way
32+
*
33+
* Document Node
34+
* |
35+
* Definiton Node
36+
* (operation and fragment definitons)
37+
* / \
38+
* |-----> Selection Set Node not done
39+
* | /
40+
* | Selection Node
41+
* | (Field, Inline fragment and fragment spread)
42+
* | | \ \
43+
* |--Field Node not done not done
44+
*
45+
*/
2646

2747
export function fieldNode(
2848
node: FieldNode,
@@ -54,6 +74,7 @@ export function fieldNode(
5474
} else {
5575
// otherwise the the feild weight is a list, invoke the function with variables
5676
// TODO: calculate the complexity for lists with arguments and varibales
77+
// ! this is not functional
5778
// iterate through the arguments to build the object to
5879
// eslint-disable-next-line no-lonely-if
5980
if (node.arguments) {

0 commit comments

Comments
 (0)