diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-04-08 18:47:20 +0000 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-04-08 18:47:20 +0000 |
commit | b28d6d8ab886016e37ca0d9d51df25ffe1b7d3b6 (patch) | |
tree | 67c44cebf51ad73116ec353449f1c618ee2c3238 /spec | |
parent | 4101ee0105f6a2e64537699f81eacbf7c39ae61d (diff) | |
parent | e86a2e7eb27468de8357f27752a9f86ee926807e (diff) | |
download | gitlab-ce-b28d6d8ab886016e37ca0d9d51df25ffe1b7d3b6.tar.gz |
Merge branch '60123-graphql-complexity-limit-too-low-for-schema-load' into 'master'
GraphQL complexity limit too low for Schema load / IntrospectionQuery
Closes #60123
See merge request gitlab-org/gitlab-ce!27063
Diffstat (limited to 'spec')
-rw-r--r-- | spec/fixtures/api/graphql/introspection.graphql | 92 | ||||
-rw-r--r-- | spec/requests/api/graphql/gitlab_schema_spec.rb | 16 |
2 files changed, 105 insertions, 3 deletions
diff --git a/spec/fixtures/api/graphql/introspection.graphql b/spec/fixtures/api/graphql/introspection.graphql new file mode 100644 index 00000000000..7b712068fcd --- /dev/null +++ b/spec/fixtures/api/graphql/introspection.graphql @@ -0,0 +1,92 @@ +# pulled from GraphiQL query +query IntrospectionQuery { + __schema { + queryType { name } + mutationType { name } + subscriptionType { name } + types { + ...FullType + } + directives { + name + description + locations + args { + ...InputValue + } + } + } +} + +fragment FullType on __Type { + kind + name + description + fields(includeDeprecated: true) { + name + description + args { + ...InputValue + } + type { + ...TypeRef + } + isDeprecated + deprecationReason + } + inputFields { + ...InputValue + } + interfaces { + ...TypeRef + } + enumValues(includeDeprecated: true) { + name + description + isDeprecated + deprecationReason + } + possibleTypes { + ...TypeRef + } +} + +fragment InputValue on __InputValue { + name + description + type { ...TypeRef } + defaultValue +} + +fragment TypeRef on __Type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } +} diff --git a/spec/requests/api/graphql/gitlab_schema_spec.rb b/spec/requests/api/graphql/gitlab_schema_spec.rb index 708a000532b..f95f460fd14 100644 --- a/spec/requests/api/graphql/gitlab_schema_spec.rb +++ b/spec/requests/api/graphql/gitlab_schema_spec.rb @@ -3,14 +3,24 @@ require 'spec_helper' describe 'GitlabSchema configurations' do include GraphqlHelpers - let(:project) { create(:project, :repository) } - let!(:query) { graphql_query_for('project', 'fullPath' => project.full_path) } + it 'shows an error if complexity is too high' do + project = create(:project, :repository) + query = graphql_query_for('project', { 'fullPath' => project.full_path }, "id\nname\ndescription") - it 'shows an error if complexity it too high' do allow(GitlabSchema).to receive(:max_query_complexity).and_return 1 post_graphql(query, current_user: nil) expect(graphql_errors.first['message']).to include('which exceeds max complexity of 1') end + + context 'when IntrospectionQuery' do + it 'is not too complex' do + query = File.read(Rails.root.join('spec/fixtures/api/graphql/introspection.graphql')) + + post_graphql(query, current_user: nil) + + expect(graphql_errors).to be_nil + end + end end |