summaryrefslogtreecommitdiff
path: root/spec/support/helpers/graphql_helpers.rb
diff options
context:
space:
mode:
authorRyan Cobb <rcobb@gitlab.com>2019-05-29 10:56:38 -0600
committerRyan Cobb <rcobb@gitlab.com>2019-05-29 10:56:38 -0600
commit0393c5059de2ce03f706fbf28056e1d80304b73a (patch)
treef47c4daaf9315c89cc6b039988d57e1fbd14c322 /spec/support/helpers/graphql_helpers.rb
parent4fae62b9efa985e4cf6a09cb6bd4b9cf665e6b32 (diff)
parent70d1537dda66da8b319ceefde36195047b26a8fd (diff)
downloadgitlab-ce-0393c5059de2ce03f706fbf28056e1d80304b73a.tar.gz
Merge branch 'master' into 61964-unicorn-instrumentation
Diffstat (limited to 'spec/support/helpers/graphql_helpers.rb')
-rw-r--r--spec/support/helpers/graphql_helpers.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb
index 44ed9da25fc..e95c7f2a6d6 100644
--- a/spec/support/helpers/graphql_helpers.rb
+++ b/spec/support/helpers/graphql_helpers.rb
@@ -134,6 +134,10 @@ module GraphqlHelpers
end.join(", ")
end
+ def post_multiplex(queries, current_user: nil, headers: {})
+ post api('/', current_user, version: 'graphql'), params: { _json: queries }, headers: headers
+ end
+
def post_graphql(query, current_user: nil, variables: nil, headers: {})
post api('/', current_user, version: 'graphql'), params: { query: query, variables: variables }, headers: headers
end
@@ -147,7 +151,14 @@ module GraphqlHelpers
end
def graphql_errors
- json_response['errors']
+ case json_response
+ when Hash # regular query
+ json_response['errors']
+ when Array # multiplexed queries
+ json_response.map { |response| response['errors'] }
+ else
+ raise "Unkown GraphQL response type #{json_response.class}"
+ end
end
def graphql_mutation_response(mutation_name)