Copilot commented on code in PR #13830:
URL: https://github.com/apache/apisix/pull/13830#discussion_r3792004402


##########
apisix/plugins/graphql-limit-count.lua:
##########
@@ -101,30 +107,38 @@ local function node_depth(node, fragments, visited)
         if not name or visited[name] then
             return 0
         end
+        local cached = depths[name]
+        if cached then
+            return cached
+        end

Review Comment:
   `depths[name]` can legitimately be `0` (e.g., a fragment whose selections 
contain only leaf fields). The current cache check `if cached then` treats `0` 
as a cache miss, causing repeated recomputation and undermining the intended 
memoization for zero-depth fragments. Use a nil-check instead so `0` is cached 
correctly.



-- 
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