Коммит 1046422b создал по автору James Fargher's avatar James Fargher
Просмотр файлов

Merge branch '342882-graphql-remove-pipelines-from-versions-packages' into 'master'

Remove the pipelines field from the package versions connection

See merge request gitlab-org/gitlab!86773
владельцы d368b681 66a4cc9b
# frozen_string_literal: true
module Types
module Packages
class PackageBaseType < ::Types::BaseObject
graphql_name 'PackageBase'
description 'Represents a package in the Package Registry'
connection_type_class(Types::CountableConnectionType)
authorize :read_package
field :id, ::Types::GlobalIDType[::Packages::Package], null: false,
description: 'ID of the package.'
field :can_destroy, GraphQL::Types::Boolean, null: false, description: 'Whether the user can destroy the package.'
field :created_at, Types::TimeType, null: false, description: 'Date of creation.'
field :metadata, Types::Packages::MetadataType, null: true,
description: 'Package metadata.'
field :name, GraphQL::Types::String, null: false, description: 'Name of the package.'
field :package_type, Types::Packages::PackageTypeEnum, null: false, description: 'Package type.'
field :project, Types::ProjectType, null: false, description: 'Project where the package is stored.'
field :status, Types::Packages::PackageStatusEnum, null: false, description: 'Package status.'
field :tags, Types::Packages::PackageTagType.connection_type, null: true, description: 'Package tags.'
field :updated_at, Types::TimeType, null: false, description: 'Date of most recent update.'
field :version, GraphQL::Types::String, null: true, description: 'Version string.'
def project
Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find
end
def can_destroy
Ability.allowed?(current_user, :destroy_package, object)
end
# 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
def metadata
case object.package_type
when 'composer'
object.composer_metadatum
when 'conan'
object.conan_metadatum
when 'maven'
object.maven_metadatum
when 'nuget'
object.nuget_metadatum
when 'pypi'
object.pypi_metadatum
else
nil
end
end
# rubocop: enable GraphQL/ResolverMethodLength
end
end
end
......@@ -4,13 +4,13 @@ module Types
module Packages
class PackageDetailsType < PackageType
graphql_name 'PackageDetailsType'
description 'Represents a package details in the Package Registry. Note that this type is in beta and susceptible to changes'
description 'Represents a package details in the Package Registry'
include ::PackagesHelper
authorize :read_package
field :versions, ::Types::Packages::PackageType.connection_type, null: true,
field :versions, ::Types::Packages::PackageBaseType.connection_type, null: true,
description: 'Other versions of the package.'
field :package_files, Types::Packages::PackageFileType.connection_type, null: true, method: :installable_package_files, description: 'Package files.'
......
......@@ -2,60 +2,17 @@
module Types
module Packages
class PackageType < ::Types::BaseObject
class PackageType < Types::Packages::PackageBaseType
graphql_name 'Package'
description 'Represents a package in the Package Registry. Note that this type is in beta and susceptible to changes'
connection_type_class(Types::CountableConnectionType)
description 'Represents a package with pipelines in the Package Registry'
authorize :read_package
field :id, ::Types::GlobalIDType[::Packages::Package], null: false,
description: 'ID of the package.'
field :can_destroy, GraphQL::Types::Boolean, null: false, description: 'Whether the user can destroy the package.'
field :created_at, Types::TimeType, null: false, description: 'Date of creation.'
field :metadata, Types::Packages::MetadataType, null: true,
description: 'Package metadata.'
field :name, GraphQL::Types::String, null: false, description: 'Name of the package.'
field :package_type, Types::Packages::PackageTypeEnum, null: false, description: 'Package type.'
field :pipelines,
resolver: Resolvers::PackagePipelinesResolver,
description: "Pipelines that built the package. Max page size #{Resolvers::PackagePipelinesResolver::MAX_PAGE_SIZE}."
field :project, Types::ProjectType, null: false, description: 'Project where the package is stored.'
field :status, Types::Packages::PackageStatusEnum, null: false, description: 'Package status.'
field :tags, Types::Packages::PackageTagType.connection_type, null: true, description: 'Package tags.'
field :updated_at, Types::TimeType, null: false, description: 'Date of most recent update.'
field :version, GraphQL::Types::String, null: true, description: 'Version string.'
def project
Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find
end
def can_destroy
Ability.allowed?(current_user, :destroy_package, object)
end
# 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.
def metadata
case object.package_type
when 'composer'
object.composer_metadatum
when 'conan'
object.conan_metadatum
when 'maven'
object.maven_metadatum
when 'nuget'
object.nuget_metadatum
when 'pypi'
object.pypi_metadatum
else
nil
end
end
description: <<-DESC
Pipelines that built the package. Max page size #{Resolvers::PackagePipelinesResolver::MAX_PAGE_SIZE}.
DESC
end
end
end
......@@ -7446,6 +7446,30 @@ The edge type for [`OncallParticipantType`](#oncallparticipanttype).
| <a id="oncallparticipanttypeedgecursor"></a>`cursor` | [`String!`](#string) | A cursor for use in pagination. |
| <a id="oncallparticipanttypeedgenode"></a>`node` | [`OncallParticipantType`](#oncallparticipanttype) | The item at the end of the edge. |
 
#### `PackageBaseConnection`
The connection type for [`PackageBase`](#packagebase).
##### Fields
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="packagebaseconnectioncount"></a>`count` | [`Int!`](#int) | Total count of collection. |
| <a id="packagebaseconnectionedges"></a>`edges` | [`[PackageBaseEdge]`](#packagebaseedge) | A list of edges. |
| <a id="packagebaseconnectionnodes"></a>`nodes` | [`[PackageBase]`](#packagebase) | A list of nodes. |
| <a id="packagebaseconnectionpageinfo"></a>`pageInfo` | [`PageInfo!`](#pageinfo) | Information to aid in pagination. |
#### `PackageBaseEdge`
The edge type for [`PackageBase`](#packagebase).
##### Fields
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="packagebaseedgecursor"></a>`cursor` | [`String!`](#string) | A cursor for use in pagination. |
| <a id="packagebaseedgenode"></a>`node` | [`PackageBase`](#packagebase) | The item at the end of the edge. |
#### `PackageConnection`
 
The connection type for [`Package`](#package).
......@@ -14020,7 +14044,7 @@ Active period time range for on-call rotation.
 
### `Package`
 
Represents a package in the Package Registry. Note that this type is in beta and susceptible to changes.
Represents a package with pipelines in the Package Registry.
 
#### Fields
 
......@@ -14039,6 +14063,26 @@ Represents a package in the Package Registry. Note that this type is in beta and
| <a id="packageupdatedat"></a>`updatedAt` | [`Time!`](#time) | Date of most recent update. |
| <a id="packageversion"></a>`version` | [`String`](#string) | Version string. |
 
### `PackageBase`
Represents a package in the Package Registry.
#### Fields
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="packagebasecandestroy"></a>`canDestroy` | [`Boolean!`](#boolean) | Whether the user can destroy the package. |
| <a id="packagebasecreatedat"></a>`createdAt` | [`Time!`](#time) | Date of creation. |
| <a id="packagebaseid"></a>`id` | [`PackagesPackageID!`](#packagespackageid) | ID of the package. |
| <a id="packagebasemetadata"></a>`metadata` | [`PackageMetadata`](#packagemetadata) | Package metadata. |
| <a id="packagebasename"></a>`name` | [`String!`](#string) | Name of the package. |
| <a id="packagebasepackagetype"></a>`packageType` | [`PackageTypeEnum!`](#packagetypeenum) | Package type. |
| <a id="packagebaseproject"></a>`project` | [`Project!`](#project) | Project where the package is stored. |
| <a id="packagebasestatus"></a>`status` | [`PackageStatus!`](#packagestatus) | Package status. |
| <a id="packagebasetags"></a>`tags` | [`PackageTagConnection`](#packagetagconnection) | Package tags. (see [Connections](#connections)) |
| <a id="packagebaseupdatedat"></a>`updatedAt` | [`Time!`](#time) | Date of most recent update. |
| <a id="packagebaseversion"></a>`version` | [`String`](#string) | Version string. |
### `PackageComposerJsonType`
 
Represents a composer JSON file.
......@@ -14079,7 +14123,7 @@ Represents a package dependency link.
 
### `PackageDetailsType`
 
Represents a package details in the Package Registry. Note that this type is in beta and susceptible to changes.
Represents a package details in the Package Registry.
 
#### Fields
 
......@@ -14107,7 +14151,7 @@ Represents a package details in the Package Registry. Note that this type is in
| <a id="packagedetailstypetags"></a>`tags` | [`PackageTagConnection`](#packagetagconnection) | Package tags. (see [Connections](#connections)) |
| <a id="packagedetailstypeupdatedat"></a>`updatedAt` | [`Time!`](#time) | Date of most recent update. |
| <a id="packagedetailstypeversion"></a>`version` | [`String`](#string) | Version string. |
| <a id="packagedetailstypeversions"></a>`versions` | [`PackageConnection`](#packageconnection) | Other versions of the package. (see [Connections](#connections)) |
| <a id="packagedetailstypeversions"></a>`versions` | [`PackageBaseConnection`](#packagebaseconnection) | Other versions of the package. (see [Connections](#connections)) |
 
### `PackageFile`
 
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['PackageBase'] do
specify { expect(described_class.description).to eq('Represents a package in the Package Registry') }
specify { expect(described_class).to require_graphql_authorizations(:read_package) }
it 'includes all expected fields' do
expected_fields = %w[
id name version package_type
created_at updated_at
project
tags metadata
status can_destroy
]
expect(described_class).to include_graphql_fields(*expected_fields)
end
end
......@@ -3,6 +3,10 @@
require 'spec_helper'
RSpec.describe GitlabSchema.types['PackageDetailsType'] do
specify { expect(described_class.description).to eq('Represents a package details in the Package Registry') }
specify { expect(described_class).to require_graphql_authorizations(:read_package) }
it 'includes all the package fields' do
expected_fields = %w[
id name version created_at updated_at package_type tags project
......@@ -13,13 +17,4 @@
expect(described_class).to include_graphql_fields(*expected_fields)
end
it 'overrides the pipelines field' do
field = described_class.fields['pipelines']
expect(field).to have_graphql_type(Types::Ci::PipelineType.connection_type)
expect(field).to have_graphql_extension(Gitlab::Graphql::Extensions::ExternallyPaginatedArrayExtension)
expect(field).to have_graphql_resolver(Resolvers::PackagePipelinesResolver)
expect(field).not_to be_connection
end
end
......@@ -3,7 +3,11 @@
require 'spec_helper'
RSpec.describe GitlabSchema.types['Package'] do
it 'includes all the package fields' do
specify { expect(described_class.description).to eq('Represents a package with pipelines in the Package Registry') }
specify { expect(described_class).to require_graphql_authorizations(:read_package) }
it 'includes all the package fields and pipelines' do
expected_fields = %w[
id name version package_type
created_at updated_at
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать