Merge branch 'ce-delete-designs-v2' into 'master'
Improves graphql_helpers See merge request gitlab-org/gitlab-ce!31251
This commit is contained in:
commit
9ba87676c8
1 changed files with 6 additions and 2 deletions
|
@ -3,6 +3,8 @@
|
||||||
module GraphqlHelpers
|
module GraphqlHelpers
|
||||||
MutationDefinition = Struct.new(:query, :variables)
|
MutationDefinition = Struct.new(:query, :variables)
|
||||||
|
|
||||||
|
NoData = Class.new(StandardError)
|
||||||
|
|
||||||
# makes an underscored string look like a fieldname
|
# makes an underscored string look like a fieldname
|
||||||
# "merge_request" => "mergeRequest"
|
# "merge_request" => "mergeRequest"
|
||||||
def self.fieldnamerize(underscored_field_name)
|
def self.fieldnamerize(underscored_field_name)
|
||||||
|
@ -158,8 +160,9 @@ module GraphqlHelpers
|
||||||
post_graphql(mutation.query, current_user: current_user, variables: mutation.variables)
|
post_graphql(mutation.query, current_user: current_user, variables: mutation.variables)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Raises an error if no data is found
|
||||||
def graphql_data
|
def graphql_data
|
||||||
json_response['data']
|
json_response['data'] || (raise NoData, graphql_errors)
|
||||||
end
|
end
|
||||||
|
|
||||||
def graphql_errors
|
def graphql_errors
|
||||||
|
@ -173,8 +176,9 @@ module GraphqlHelpers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Raises an error if no response is found
|
||||||
def graphql_mutation_response(mutation_name)
|
def graphql_mutation_response(mutation_name)
|
||||||
graphql_data[GraphqlHelpers.fieldnamerize(mutation_name)]
|
graphql_data.fetch(GraphqlHelpers.fieldnamerize(mutation_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
def nested_fields?(field)
|
def nested_fields?(field)
|
||||||
|
|
Loading…
Reference in a new issue