Browse Source

Maintenance: Increase GQL max query depth to allow for common introspection queries.

Co-authored-by: Martin Gruner <mg@zammad.com>
Rolf Schmidt 9 months ago
parent
commit
a262c56ff7
2 changed files with 2 additions and 49 deletions
  1. 2 2
      app/graphql/gql/zammad_schema.rb
  2. 0 47
      spec/graphql/gql/zammad_schema_max_depth_spec.rb

+ 2 - 2
app/graphql/gql/zammad_schema.rb

@@ -18,8 +18,8 @@ class Gql::ZammadSchema < GraphQL::Schema
   default_page_size 100
   max_complexity 10_000
 
-  # The GraphQL introspection query has a depth of 13, so allow that in the development env.
-  max_depth Rails.env.eql?('development') ? 13 : 10
+  # Depth of 15 is needed for commmon introspection queries like Insomnia.
+  max_depth 15
 
   TYPE_MAP = {
     ::Store => ::Gql::Types::StoredFileType

+ 0 - 47
spec/graphql/gql/zammad_schema_max_depth_spec.rb

@@ -1,47 +0,0 @@
-# Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
-
-require 'rails_helper'
-
-RSpec.describe Gql::ZammadSchema, type: :graphql do
-
-  context 'when making queries that are too complex', authenticated_as: :agent do
-    let(:agent) { create(:agent, department: 'TestDepartment') }
-    let(:query) do
-      <<~QUERY
-        query currentUser {
-          currentUser {
-            organization {
-              members(first: 40) {
-                edges {
-                  node {
-                    firstname
-                    organization {
-                      members(first: 40) {
-                        edges {
-                          node {
-                            firstname
-                            organization {
-                              name
-                            }
-                          }
-                        }
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      QUERY
-    end
-
-    before do
-      gql.execute(query)
-    end
-
-    it 'has data' do
-      expect(gql.result.error_message).to eq('Query has depth of 11, which exceeds max depth of 10')
-    end
-  end
-end