diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /lib/bulk_imports/common/graphql/get_members_query.rb | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'lib/bulk_imports/common/graphql/get_members_query.rb')
-rw-r--r-- | lib/bulk_imports/common/graphql/get_members_query.rb | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/lib/bulk_imports/common/graphql/get_members_query.rb b/lib/bulk_imports/common/graphql/get_members_query.rb new file mode 100644 index 00000000000..00977f694d7 --- /dev/null +++ b/lib/bulk_imports/common/graphql/get_members_query.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +module BulkImports + module Common + module Graphql + class GetMembersQuery + attr_reader :context + + def initialize(context:) + @context = context + end + + def to_s + <<-GRAPHQL + query($full_path: ID!, $cursor: String, $per_page: Int) { + portable: #{context.entity.entity_type}(fullPath: $full_path) { + members: #{members_type}(relations: [DIRECT, INHERITED], first: $per_page, after: $cursor) { + page_info: pageInfo { + next_page: endCursor + has_next_page: hasNextPage + } + nodes { + created_at: createdAt + updated_at: updatedAt + expires_at: expiresAt + access_level: accessLevel { + integer_value: integerValue + } + user { + user_gid: id + public_email: publicEmail + } + } + } + } + } + GRAPHQL + end + + def variables + { + full_path: context.entity.source_full_path, + cursor: context.tracker.next_page, + per_page: ::BulkImports::Tracker::DEFAULT_PAGE_SIZE + } + end + + def data_path + base_path << 'nodes' + end + + def page_info_path + base_path << 'page_info' + end + + private + + def base_path + %w[data portable members] + end + + def members_type + if context.entity.group? + 'groupMembers' + else + 'projectMembers' + end + end + end + end + end +end |