Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-18 21:09:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-18 21:09:35 +0300
commit5bfb8d1fad825eec90b0af688c7cd1b352c9056e (patch)
tree385411919c4186d11a769385ad8dafeef6cc36a7 /spec/support/helpers
parentaaf59610548d9b0fd01acfd50e831cbe519ecba2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/helpers')
-rw-r--r--spec/support/helpers/graphql_helpers.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb
index 370162b45f0..1bb942ff39b 100644
--- a/spec/support/helpers/graphql_helpers.rb
+++ b/spec/support/helpers/graphql_helpers.rb
@@ -71,10 +71,10 @@ module GraphqlHelpers
mutation_name = GraphqlHelpers.fieldnamerize(name)
input_variable_name = "$#{input_variable_name_for_mutation(name)}"
mutation_field = GitlabSchema.mutation.fields[mutation_name]
- fields ||= all_graphql_fields_for(mutation_field.type)
+ fields ||= all_graphql_fields_for(mutation_field.type.to_graphql)
query = <<~MUTATION
- mutation(#{input_variable_name}: #{mutation_field.arguments['input'].type}) {
+ mutation(#{input_variable_name}: #{mutation_field.arguments['input'].type.to_graphql}) {
#{mutation_name}(input: #{input_variable_name}) {
#{fields}
}
@@ -118,15 +118,22 @@ module GraphqlHelpers
GraphqlHelpers.fieldnamerize(input_type)
end
- def query_graphql_field(name, attributes = {}, fields = nil)
- field_params = if attributes.present?
+ def field_with_params(name, attributes = {})
+ namerized = GraphqlHelpers.fieldnamerize(name.to_s)
+ return "#{namerized}" if attributes.blank?
+
+ field_params = if attributes.is_a?(Hash)
"(#{attributes_to_graphql(attributes)})"
else
- ''
+ "(#{attributes})"
end
+ "#{namerized}#{field_params}"
+ end
+
+ def query_graphql_field(name, attributes = {}, fields = nil)
<<~QUERY
- #{GraphqlHelpers.fieldnamerize(name.to_s)}#{field_params}
+ #{field_with_params(name, attributes)}
#{wrap_fields(fields || all_graphql_fields_for(name.to_s.classify))}
QUERY
end
@@ -300,7 +307,7 @@ module GraphqlHelpers
end
def field_type(field)
- field_type = field.type
+ field_type = field.type.respond_to?(:to_graphql) ? field.type.to_graphql : field.type
# The type could be nested. For example `[GraphQL::STRING_TYPE]`:
# - List