Add a PackageType type to graphql

- Package type
- Package type enum
- unit tests
Co-authored-by: default avatarTetiana Chupryna <tchupryna@gitlab.com>
Co-authored-by: default avatarDavid Fernandez <dfernandez@gitlab.com>
Co-authored-by: default avatarNick Kipling <nkipling@gitlab.com>
Co-authored-by: default avatarSteve Abrams <sabrams@gitlab.com>
parent 2f7e88df
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
class PackageType < BaseObject
graphql_name 'Package'
description 'Represents a package'
field :id, GraphQL::ID_TYPE, null: false, description: 'The ID of the package'
field :name, GraphQL::STRING_TYPE, null: false, description: 'The name of the package'
field :created_at, Types::TimeType, null: false, description: 'The created date'
field :updated_at, Types::TimeType, null: false, description: 'The update date'
field :version, GraphQL::STRING_TYPE, null: true, description: 'The version of the package'
field :package_type, Types::PackageTypeEnum, null: false, description: 'The type of the package'
end
# rubocop: enable Graphql/AuthorizeTypes
end
# frozen_string_literal: true
module Types
class PackageTypeEnum < BaseEnum
::Packages::Package.package_types.keys.each do |package_type|
value package_type.to_s.upcase, value: package_type.to_s
end
end
end
\ No newline at end of file
# frozen_string_literal: true
require 'spec_helper'
describe GitlabSchema.types['PackageTypeEnum'] do
it 'exposes all package types' do
expect(described_class.values.keys).to contain_exactly(*%w[MAVEN NPM CONAN NUGET PYPI COMPOSER])
end
end
# frozen_string_literal: true
require 'spec_helper'
describe GitlabSchema.types['Package'] do
it { expect(described_class.graphql_name).to eq('Package') }
it 'includes all the package fields' do
expected_fields = %w[
id name version created_at updated_at package_type
]
expect(described_class).to include_graphql_fields(*expected_fields)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment