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:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-06-26 19:31:05 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-07-04 11:53:39 +0300
commit04b046587fe609cd889f3fa518f08299abc61267 (patch)
tree634fc7d5e2a416950868700a82c171ff4f54239b /spec/support
parentcd5789415b6e561564073693243e890e79596ed2 (diff)
Add pipeline lists to GraphQL
This adds Keyset pagination to GraphQL lists. PoC for that is pipelines on merge requests and projects. When paginating a list, the base-64 encoded id of the ordering field (in most cases the primary key) can be passed in the `before` or `after` GraphQL argument.
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/helpers/graphql_helpers.rb20
1 files changed, 16 insertions, 4 deletions
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb
index 0930b9da368..b9322975b5a 100644
--- a/spec/support/helpers/graphql_helpers.rb
+++ b/spec/support/helpers/graphql_helpers.rb
@@ -57,12 +57,12 @@ module GraphqlHelpers
type.fields.map do |name, field|
# We can't guess arguments, so skip fields that require them
- next if field.arguments.any?
+ next if required_arguments?(field)
- if scalar?(field)
- name
- else
+ if nested_fields?(field)
"#{name} { #{all_graphql_fields_for(field_type(field))} }"
+ else
+ name
end
end.compact.join("\n")
end
@@ -85,10 +85,22 @@ module GraphqlHelpers
json_response['data']
end
+ def nested_fields?(field)
+ !scalar?(field) && !enum?(field)
+ end
+
def scalar?(field)
field_type(field).kind.scalar?
end
+ def enum?(field)
+ field_type(field).kind.enum?
+ end
+
+ def required_arguments?(field)
+ field.arguments.values.any? { |argument| argument.type.non_null? }
+ end
+
def field_type(field)
if field.type.respond_to?(:of_type)
field.type.of_type