oslabs-beta / GraphQL-Gate

A GraphQL rate limiting library with query complexity analysisfor Node.js

Home Page:http://graphqlgate.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Complexity of nested lists adds complexities instead of multiplying

shalarewicz opened this issue · comments

Nested results should multiply the complexity of inner results. Currently these are added.

For example the below query should have a complexity of 17 (1 query + 1 human + 5 * 3 (friends * children) );

 query { 
      human(id: 1) { 
          name, 
          friends(first: 5) { 
              name, 
              children(first: 3){ 
                  name 
              } 
          } 
      }
  }

Nested results with a complexity of 0 should not zero out outer results. In the above example if children resolved to a list of scalars, which have weight 0 then the overall complexity should be 7 (1 query + 1 human + 5 (friends ) and not 2 (1 query + 1 human + 5 * 0 (friends * children) );
;

TODO

  • Enable the "with nested lists" tests in typeComplexityAnalysis.test.ts to verify resolution of this issue. (tests updated by #61).