Class: Types::Packages::PackageBaseType
- Inherits:
-
BaseObject
- Object
- GraphQL::Schema::Object
- BaseObject
- Types::Packages::PackageBaseType
- Defined in:
- app/graphql/types/packages/package_base_type.rb
Direct Known Subclasses
Constant Summary collapse
- PROTECTION_RULE_EXISTS_BATCH_SIZE =
20
Instance Method Summary collapse
-
#metadata ⇒ Object
NOTE: This method must be kept in sync with the union type:
Types::Packages::MetadataType. - #project ⇒ Object
- #protection_rule_exists ⇒ Object
Methods inherited from BaseObject
accepts, assignable?, authorization, authorization_scopes, authorize, authorized?, #current_user, #id
Methods included from Gitlab::Graphql::Present
Instance Method Details
#metadata ⇒ Object
NOTE: This method must be kept in sync with the union type: Types::Packages::MetadataType.
‘Types::Packages::MetadataType.resolve_type(metadata, ctx)` must never raise. rubocop: disable GraphQL/ResolverMethodLength
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/graphql/types/packages/package_base_type.rb', line 60 def case object.package_type when 'composer' object. when 'conan' object. when 'maven' object. when 'nuget' object. when 'pypi' object. when 'terraform_module' object. end end |
#project ⇒ Object
37 38 39 |
# File 'app/graphql/types/packages/package_base_type.rb', line 37 def project Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find end |
#protection_rule_exists ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/graphql/types/packages/package_base_type.rb', line 41 def protection_rule_exists object_package_type_value = ::Packages::Package.package_types[object.package_type] BatchLoader::GraphQL.for([object.project_id, object.name, object_package_type_value]).batch do |tuples, loader| tuples.each_slice(PROTECTION_RULE_EXISTS_BATCH_SIZE) do |projects_and_packages| ::Packages::Protection::Rule .for_push_exists_for_projects_and_packages(projects_and_packages) .each do |row| loader.call([row['project_id'], row['package_name'], row['package_type']], row['protected']) end end end end |