code: func validateMaxDepth(c *opContext, sels []query.Selection, depth int) bool {
  	// maxDepth checking is turned off when maxDepth is 0
  	if c.maxDepth == 0 {
  		return false
  	}
  
  	exceededMaxDepth := false
  
  	for _, sel := range sels {
  		switch sel := sel.(type) {
  		case *query.Field:
  			if depth > c.maxDepth {
  				exceededMaxDepth = true
  				c.addErr(sel.Alias.Loc, "MaxDepthExceeded", "Field %q has depth %d that exceeds max depth %d", sel.Name.Name, depth, c.maxDepth)
  				continue
  			}
  			exceededMaxDepth = exceededMaxDepth || validateMaxDepth(c, sel.Selections, depth+1)
  		case *query.InlineFragment:
  			// Depth is not checked because inline fragments resolve to other fields which are checked.
  			// Depth is not incremented because inline fragments have the same depth as neighboring fields
  			exceededMaxDepth = exceededMaxDepth || validateMaxDepth(c, sel.Selections, depth)
  		case *query.FragmentSpread:
  			// Depth is not checked because fragments resolve to other fields which are checked.
  			frag := c.doc.Fragments.Get(sel.Name.Name)
  			if frag == nil {
  				// In case of unknown fragment (invalid request), ignore max depth evaluation
  				c.addErr(sel.Loc, "MaxDepthEvaluationError", "Unknown fragment %q. Unable to evaluate depth.", sel.Name.Name)
  				continue
  			}
  			// Depth is not incremented because fragments have the same depth as surrounding fields
  			exceededMaxDepth = exceededMaxDepth || validateMaxDepth(c, frag.Selections, depth)
  		}
  	}
  
  	return exceededMaxDepth
  }
docs: // validates the query doesn't go deeper than maxDepth (if set). Returns whether
  // or not query validated max depth to avoid excessive recursion.