diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 09:08:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 09:08:47 +0000 |
commit | 66d4203791a01fdedf668a78818a229ea2c07aad (patch) | |
tree | 374fc9f6c5e709cf6ab48e257e6bfe4a504d6bbb /spec/requests | |
parent | a496f41f60e12a0a5c31482b7594ad547e0ade42 (diff) | |
download | gitlab-ce-66d4203791a01fdedf668a78818a229ea2c07aad.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/graphql_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/requests/api/graphql_spec.rb b/spec/requests/api/graphql_spec.rb index ece80424791..92c5c52be7d 100644 --- a/spec/requests/api/graphql_spec.rb +++ b/spec/requests/api/graphql_spec.rb @@ -152,4 +152,52 @@ describe 'GraphQL' do end end end + + describe 'resolver complexity' do + let_it_be(:project) { create(:project, :public) } + let(:query) do + graphql_query_for( + 'project', + { 'fullPath' => project.full_path }, + query_graphql_field(resource, {}, 'edges { node { iid } }') + ) + end + + before do + stub_const('GitlabSchema::DEFAULT_MAX_COMPLEXITY', 6) + stub_feature_flags(graphql_resolver_complexity: true) + end + + context 'when fetching single resource' do + let(:resource) { 'issues(first: 1)' } + + it 'processes the query' do + post_graphql(query) + + expect(graphql_errors).to be_nil + end + end + + context 'when fetching too many resources' do + let(:resource) { 'issues(first: 100)' } + + it 'returns an error' do + post_graphql(query) + + expect_graphql_errors_to_include(/which exceeds max complexity/) + end + + context 'when graphql_resolver_complexity is disabled' do + before do + stub_feature_flags(graphql_resolver_complexity: false) + end + + it 'processes the query' do + post_graphql(query) + + expect(graphql_errors).to be_nil + end + end + end + end end |