Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
79b09c19
Commit
79b09c19
authored
May 04, 2021
by
Nicolò Maria Mezzopera
Committed by
Matthias Käppler
May 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Maven to Package Graphql types
parent
c4aae485
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
186 additions
and
1 deletion
+186
-1
app/graphql/types/packages/maven/metadatum_type.rb
app/graphql/types/packages/maven/metadatum_type.rb
+22
-0
app/graphql/types/packages/metadata_type.rb
app/graphql/types/packages/metadata_type.rb
+3
-1
app/graphql/types/packages/package_type.rb
app/graphql/types/packages/package_type.rb
+2
-0
app/policies/packages/maven/metadatum_policy.rb
app/policies/packages/maven/metadatum_policy.rb
+8
-0
changelogs/unreleased/285467-package-registry-graphql-api.yml
...gelogs/unreleased/285467-package-registry-graphql-api.yml
+5
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+23
-0
spec/fixtures/api/schemas/graphql/packages/package_details.json
...ixtures/api/schemas/graphql/packages/package_details.json
+1
-0
spec/fixtures/api/schemas/graphql/packages/package_maven_metadata.json
.../api/schemas/graphql/packages/package_maven_metadata.json
+28
-0
spec/requests/api/graphql/packages/maven_spec.rb
spec/requests/api/graphql/packages/maven_spec.rb
+94
-0
No files found.
app/graphql/types/packages/maven/metadatum_type.rb
0 → 100644
View file @
79b09c19
# frozen_string_literal: true
module
Types
module
Packages
module
Maven
class
MetadatumType
<
BaseObject
graphql_name
'MavenMetadata'
description
'Maven metadata'
authorize
:read_package
field
:id
,
::
Types
::
GlobalIDType
[
::
Packages
::
Maven
::
Metadatum
],
null:
false
,
description:
'ID of the metadatum.'
field
:created_at
,
Types
::
TimeType
,
null:
false
,
description:
'Date of creation.'
field
:updated_at
,
Types
::
TimeType
,
null:
false
,
description:
'Date of most recent update.'
field
:path
,
GraphQL
::
STRING_TYPE
,
null:
false
,
description:
'Path of the Maven package.'
field
:app_group
,
GraphQL
::
STRING_TYPE
,
null:
false
,
description:
'App group of the Maven package.'
field
:app_version
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'App version of the Maven package.'
field
:app_name
,
GraphQL
::
STRING_TYPE
,
null:
false
,
description:
'App name of the Maven package.'
end
end
end
end
app/graphql/types/packages/metadata_type.rb
View file @
79b09c19
...
...
@@ -6,7 +6,7 @@ module Types
graphql_name
'PackageMetadata'
description
'Represents metadata associated with a Package'
possible_types
::
Types
::
Packages
::
Composer
::
MetadatumType
,
::
Types
::
Packages
::
Conan
::
MetadatumType
possible_types
::
Types
::
Packages
::
Composer
::
MetadatumType
,
::
Types
::
Packages
::
Conan
::
MetadatumType
,
::
Types
::
Packages
::
Maven
::
MetadatumType
def
self
.
resolve_type
(
object
,
context
)
case
object
...
...
@@ -14,6 +14,8 @@ module Types
::
Types
::
Packages
::
Composer
::
MetadatumType
when
::
Packages
::
Conan
::
Metadatum
::
Types
::
Packages
::
Conan
::
MetadatumType
when
::
Packages
::
Maven
::
Metadatum
::
Types
::
Packages
::
Maven
::
MetadatumType
else
# NOTE: This method must be kept in sync with `PackageWithoutVersionsType#metadata`,
# which must never produce data that this discriminator cannot handle.
...
...
app/graphql/types/packages/package_type.rb
View file @
79b09c19
...
...
@@ -44,6 +44,8 @@ module Types
object
.
composer_metadatum
when
'conan'
object
.
conan_metadatum
when
'maven'
object
.
maven_metadatum
else
nil
end
...
...
app/policies/packages/maven/metadatum_policy.rb
0 → 100644
View file @
79b09c19
# frozen_string_literal: true
module
Packages
module
Maven
class
MetadatumPolicy
<
BasePolicy
delegate
{
@subject
.
package
}
end
end
end
changelogs/unreleased/285467-package-registry-graphql-api.yml
0 → 100644
View file @
79b09c19
---
title
:
Add Maven to Package Graphql types
merge_request
:
60808
author
:
type
:
added
doc/api/graphql/reference/index.md
View file @
79b09c19
...
...
@@ -9506,6 +9506,22 @@ Represents an entry from the Cloud License history.
|
<a
id=
"licensehistoryentrytype"
></a>
`type`
|
[
`String!`
](
#string
)
| Type of the license. |
|
<a
id=
"licensehistoryentryusersinlicensecount"
></a>
`usersInLicenseCount`
|
[
`Int`
](
#int
)
| Number of paid users in the license. |
### `MavenMetadata`
Maven metadata.
#### Fields
| Name | Type | Description |
| ---- | ---- | ----------- |
|
<a
id=
"mavenmetadataappgroup"
></a>
`appGroup`
|
[
`String!`
](
#string
)
| App group of the Maven package. |
|
<a
id=
"mavenmetadataappname"
></a>
`appName`
|
[
`String!`
](
#string
)
| App name of the Maven package. |
|
<a
id=
"mavenmetadataappversion"
></a>
`appVersion`
|
[
`String`
](
#string
)
| App version of the Maven package. |
|
<a
id=
"mavenmetadatacreatedat"
></a>
`createdAt`
|
[
`Time!`
](
#time
)
| Date of creation. |
|
<a
id=
"mavenmetadataid"
></a>
`id`
|
[
`PackagesMavenMetadatumID!`
](
#packagesmavenmetadatumid
)
| ID of the metadatum. |
|
<a
id=
"mavenmetadatapath"
></a>
`path`
|
[
`String!`
](
#string
)
| Path of the Maven package. |
|
<a
id=
"mavenmetadataupdatedat"
></a>
`updatedAt`
|
[
`Time!`
](
#time
)
| Date of most recent update. |
### `MergeRequest`
#### Fields
...
...
@@ -14705,6 +14721,12 @@ A `PackagesConanMetadatumID` is a global ID. It is encoded as a string.
An example
`PackagesConanMetadatumID`
is:
`"gid://gitlab/Packages::Conan::Metadatum/1"`
.
### `PackagesMavenMetadatumID`
A
`PackagesMavenMetadatumID`
is a global ID. It is encoded as a string.
An example
`PackagesMavenMetadatumID`
is:
`"gid://gitlab/Packages::Maven::Metadatum/1"`
.
### `PackagesPackageFileID`
A
`PackagesPackageFileID`
is a global ID. It is encoded as a string.
...
...
@@ -14840,6 +14862,7 @@ One of:
-
[
`ComposerMetadata`
](
#composermetadata
)
-
[
`ConanMetadata`
](
#conanmetadata
)
-
[
`MavenMetadata`
](
#mavenmetadata
)
#### `VulnerabilityDetail`
...
...
spec/fixtures/api/schemas/graphql/packages/package_details.json
View file @
79b09c19
...
...
@@ -80,6 +80,7 @@
"anyOf"
:
[
{
"$ref"
:
"./package_composer_metadata.json"
},
{
"$ref"
:
"./package_conan_metadata.json"
},
{
"$ref"
:
"./package_maven_metadata.json"
},
{
"type"
:
"null"
}
]
},
...
...
spec/fixtures/api/schemas/graphql/packages/package_maven_metadata.json
0 → 100644
View file @
79b09c19
{
"type"
:
"object"
,
"additionalProperties"
:
false
,
"required"
:
[
"id"
,
"createdAt"
,
"updatedAt"
,
"path"
,
"appGroup"
,
"appName"
],
"properties"
:
{
"id"
:
{
"type"
:
"string"
},
"createdAt"
:
{
"type"
:
"string"
},
"updatedAt"
:
{
"type"
:
"string"
},
"path"
:
{
"type"
:
"string"
},
"appGroup"
:
{
"type"
:
"string"
},
"appVersion"
:
{
"type"
:
[
"string"
,
"null"
]
},
"appName"
:
{
"type"
:
"string"
}
}
}
spec/requests/api/graphql/packages/maven_spec.rb
0 → 100644
View file @
79b09c19
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'maven package details'
do
include
GraphqlHelpers
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:maven_package
)
{
create
(
:maven_package
,
project:
project
)
}
let
(
:package_global_id
)
{
global_id_of
(
maven_package
)
}
let
(
:metadata
)
{
query_graphql_fragment
(
'MavenMetadata'
)
}
let
(
:first_file
)
{
maven_package
.
package_files
.
find
{
|
f
|
global_id_of
(
f
)
==
first_file_response
[
'id'
]
}
}
let
(
:depth
)
{
3
}
let
(
:excluded
)
{
%w[metadata apiFuzzingCiConfiguration pipeline packageFiles]
}
let
(
:package_files
)
{
all_graphql_fields_for
(
'PackageFile'
)
}
let
(
:user
)
{
project
.
owner
}
let
(
:package_details
)
{
graphql_data_at
(
:package
)
}
let
(
:metadata_response
)
{
graphql_data_at
(
:package
,
:metadata
)
}
let
(
:package_files_response
)
{
graphql_data_at
(
:package
,
:package_files
,
:nodes
)
}
let
(
:first_file_response
)
{
graphql_data_at
(
:package
,
:package_files
,
:nodes
,
0
)}
let
(
:query
)
do
graphql_query_for
(
:package
,
{
id:
package_global_id
},
<<~
FIELDS
)
#{
all_graphql_fields_for
(
'PackageDetailsType'
,
max_depth:
depth
,
excluded:
excluded
)
}
metadata {
#{
metadata
}
}
packageFiles {
nodes {
#{
package_files
}
}
}
FIELDS
end
subject
{
post_graphql
(
query
,
current_user:
user
)
}
shared_examples
'a working maven package'
do
before
do
subject
end
it_behaves_like
'a working graphql query'
do
it
'matches the JSON schema'
do
expect
(
package_details
).
to
match_schema
(
'graphql/packages/package_details'
)
end
end
it
'has the correct metadata'
do
expect
(
metadata_response
).
to
include
(
'id'
=>
global_id_of
(
maven_package
.
maven_metadatum
),
'path'
=>
maven_package
.
maven_metadatum
.
path
,
'appGroup'
=>
maven_package
.
maven_metadatum
.
app_group
,
'appVersion'
=>
maven_package
.
maven_metadatum
.
app_version
,
'appName'
=>
maven_package
.
maven_metadatum
.
app_name
)
end
it
'has the right amount of files'
do
expect
(
package_files_response
.
length
).
to
be
(
maven_package
.
package_files
.
length
)
end
it
'has the basic package files data'
do
expect
(
first_file_response
).
to
include
(
'id'
=>
global_id_of
(
first_file
),
'fileName'
=>
first_file
.
file_name
,
'size'
=>
first_file
.
size
.
to_s
,
'downloadPath'
=>
first_file
.
download_path
,
'fileSha1'
=>
first_file
.
file_sha1
,
'fileMd5'
=>
first_file
.
file_md5
,
'fileSha256'
=>
first_file
.
file_sha256
)
end
end
context
'a maven package with version'
do
it_behaves_like
"a working maven package"
end
context
'a versionless maven package'
do
let_it_be
(
:maven_metadatum
)
{
create
(
:maven_metadatum
,
app_version:
nil
)
}
let_it_be
(
:maven_package
)
{
create
(
:maven_package
,
project:
project
,
version:
nil
,
maven_metadatum:
maven_metadatum
)
}
it_behaves_like
"a working maven package"
it
"has an empty version"
do
subject
expect
(
metadata_response
[
'appVersion'
]).
to
eq
(
nil
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment