summaryrefslogtreecommitdiff
path: root/spec/requests/api/graphql
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-05-31 11:59:21 +0000
committerSean McGivern <sean@gitlab.com>2019-05-31 11:59:21 +0000
commit4e888212a1cdf5898c5cef69f5a2de909a275d31 (patch)
tree1fcf81e451b9e33cdba234c3a4a582e51ac7ce72 /spec/requests/api/graphql
parent1523d0785755f4ba0679bc08ec370d8299b299f0 (diff)
parent699532232ca27e6079c553261e0ab1d17317472a (diff)
downloadgitlab-ce-4e888212a1cdf5898c5cef69f5a2de909a275d31.tar.gz
Merge branch '59587-add-graphql-logging' into 'master'
Add logging to GraphQL Closes #59587 See merge request gitlab-org/gitlab-ce!27885
Diffstat (limited to 'spec/requests/api/graphql')
-rw-r--r--spec/requests/api/graphql/gitlab_schema_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/requests/api/graphql/gitlab_schema_spec.rb b/spec/requests/api/graphql/gitlab_schema_spec.rb
index 9beea2e2594..b6ca9246399 100644
--- a/spec/requests/api/graphql/gitlab_schema_spec.rb
+++ b/spec/requests/api/graphql/gitlab_schema_spec.rb
@@ -111,4 +111,29 @@ describe 'GitlabSchema configurations' do
expect(graphql_errors).to be_nil
end
end
+
+ context 'logging' do
+ let(:query) { File.read(Rails.root.join('spec/fixtures/api/graphql/introspection.graphql')) }
+
+ it 'logs the query complexity and depth' do
+ analyzer_memo = {
+ query_string: query,
+ variables: {}.to_s,
+ complexity: 181,
+ depth: 0,
+ duration: 7
+ }
+
+ expect_any_instance_of(Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer).to receive(:duration).and_return(7)
+ expect(Gitlab::GraphqlLogger).to receive(:info).with(analyzer_memo)
+
+ post_graphql(query, current_user: nil)
+ end
+
+ it 'logs using `format_message`' do
+ expect_any_instance_of(Gitlab::GraphqlLogger).to receive(:format_message)
+
+ post_graphql(query, current_user: nil)
+ end
+ end
end