Skip to content
Snippets Groups Projects
Commit 8738a833 authored by Alex Kalderimis's avatar Alex Kalderimis
Browse files

Improves the graphql_helpers used in GraphQL tests

This improves the graphql test helpers, failing earlier and more
explicitly.
parent ab509c78
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -3,6 +3,8 @@
module GraphqlHelpers
MutationDefinition = Struct.new(:query, :variables)
 
NoData = Class.new(StandardError)
# makes an underscored string look like a fieldname
# "merge_request" => "mergeRequest"
def self.fieldnamerize(underscored_field_name)
Loading
Loading
@@ -158,8 +160,9 @@ module GraphqlHelpers
post_graphql(mutation.query, current_user: current_user, variables: mutation.variables)
end
 
# Raises an error if no data is found
def graphql_data
json_response['data']
json_response['data'] || (raise NoData, graphql_errors)
end
 
def graphql_errors
Loading
Loading
@@ -173,8 +176,9 @@ module GraphqlHelpers
end
end
 
# Raises an error if no response is found
def graphql_mutation_response(mutation_name)
graphql_data[GraphqlHelpers.fieldnamerize(mutation_name)]
graphql_data.fetch(GraphqlHelpers.fieldnamerize(mutation_name))
end
 
def nested_fields?(field)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment