membphis commented on PR #13372:
URL: https://github.com/apache/apisix/pull/13372#issuecomment-4516257195

   `node_depth` currently walks the raw AST and takes the maximum `selections` 
nesting it sees, but it does not expand a `FragmentSpread` at the point where 
the fragment is used. This lets clients move deeply nested fields into a 
fragment and reference it from a shallow query, causing the calculated cost to 
be lower than the actual query depth.
   
   Example:
   
   ```graphql
   query {
     user {
       ...Deep
     }
   }
   
   fragment Deep on User {
     posts {
       comments {
         author {
           id
         }
       }
     }
   }
   ```
   
   The plugin should first build a fragment definition map, then calculate 
depth from the operation selection set. When it encounters a `FragmentSpread`, 
it should expand it in place; when it encounters an `InlineFragment`, it should 
continue calculating from that selection set; and it should guard against 
fragment cycles. Please also add tests for depth accounting with fragment 
spreads and inline fragments.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to