Skip to content

Commit 81433b9

Browse files
committed
chore: rework graphql
1 parent 1d3cb58 commit 81433b9

File tree

65 files changed

+1432
-411
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1432
-411
lines changed

.checkstyle/suppressions.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
<suppress files="src[\\/]main[\\/]java[\\/]io[\\/]papermc[\\/]fill[\\/]controller[\\/]advice[\\/]ExceptionRestControllerAdvice.java" checks="Indentation"/>
66
<suppress files="src[\\/]main[\\/]java[\\/].*" checks="MissingJavadocMethod"/>
77
<suppress files="src[\\/]main[\\/]java[\\/].*" checks="MissingJavadocType"/>
8+
<suppress files="src[\\/]test[\\/]java[\\/].*" checks="MissingJavadocMethod"/>
9+
<suppress files="src[\\/]test[\\/]java[\\/].*" checks="MissingJavadocType"/>
810
</suppressions>

examples/graphql_paper_allFamilies.graphql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
# - The family id
33
# - The minimum required Java version and any recommended Java flags
44
query {
5-
project(id: "paper") {
5+
project(key: "paper") {
66
id
7+
key
78
families {
89
id
10+
key
911
java {
1012
version {
1113
minimum

examples/graphql_paper_allSupportedVersions_latestBuild.graphql

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,44 @@
99
# - file size (in bytes)
1010
# - direct download url
1111
query {
12-
project(id: "paper") {
12+
project(key: "paper") {
1313
id
14-
versions(filterBy: {supportStatus: SUPPORTED}) {
15-
id
16-
support {
17-
status
18-
end
19-
}
20-
java {
21-
version {
22-
minimum
23-
}
24-
flags {
25-
recommended
26-
}
27-
}
28-
builds(last: 1) {
29-
id
30-
download(name: "server:default") {
31-
name
32-
checksums {
33-
sha256
14+
key
15+
versions(filterBy: {supportStatus: SUPPORTED}, orderBy: {direction: DESC}, first: 1) {
16+
edges {
17+
node {
18+
id
19+
key
20+
support {
21+
status
22+
end
23+
}
24+
java {
25+
version {
26+
minimum
27+
}
28+
flags {
29+
recommended
30+
}
31+
}
32+
builds(orderBy: {direction: DESC}, first: 1) {
33+
edges {
34+
node {
35+
id
36+
number
37+
createdAt
38+
channel
39+
download(key: "server:default") {
40+
name
41+
checksums {
42+
sha256
43+
}
44+
size
45+
url
46+
}
47+
}
48+
}
3449
}
35-
size
36-
url
3750
}
3851
}
3952
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This GraphQL query retrieves information about the paper project, specifically focusing on its currently supported versions. For each supported version, it fetches:
2+
# - The version id
3+
# - The minimum required Java version and any recommended Java flags
4+
# - The most recent build (last: 1) including:
5+
# - build id
6+
# - The server:default download artifact, including:
7+
# - file name
8+
# - sha-256 checksum
9+
# - file size (in bytes)
10+
# - direct download url
11+
query {
12+
project(key: "paper") {
13+
id
14+
key
15+
versions(orderBy: {direction: DESC}, first: 100) {
16+
edges {
17+
node {
18+
key
19+
family {
20+
key
21+
java {
22+
version {
23+
minimum
24+
}
25+
flags {
26+
recommended
27+
}
28+
}
29+
}
30+
java {
31+
version {
32+
minimum
33+
}
34+
flags {
35+
recommended
36+
}
37+
}
38+
builds(orderBy: {direction: DESC}, first: 1) {
39+
edges {
40+
node {
41+
number
42+
channel
43+
download(key: "server:default") {
44+
name
45+
url
46+
}
47+
}
48+
}
49+
}
50+
}
51+
}
52+
}
53+
}
54+
}

src/main/java/io/papermc/fill/controller/Data2Controller.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,18 @@ public Data2Controller(
7373
@GetMapping("/v2/projects/{project:[a-z]+}/versions/{version:[0-9.]+-?(?:pre|SNAPSHOT)?(?:[0-9.]+)?}/builds/{build:\\d+}/downloads/{download:[a-zA-Z0-9._-]+}")
7474
public ResponseEntity<?> getDownload(
7575
@PathVariable("project")
76-
final String projectId,
76+
final String projectKey,
7777
@PathVariable("version")
78-
final String versionId,
78+
final String versionKey,
7979
@PathVariable("build")
8080
@PositiveOrZero
81-
final int buildId,
81+
final int buildNumber,
8282
@PathVariable("download")
8383
final String downloadName
8484
) {
85-
final ProjectEntity project = this.projects.findByName(projectId).orElseThrow(ProjectNotFoundException::new);
86-
final VersionEntity version = this.versions.findByProjectAndName(project, versionId).orElseThrow(VersionNotFoundException::new);
87-
final BuildEntity build = this.builds.findByVersionAndNumber(version, buildId).orElseThrow(BuildNotFoundException::new);
85+
final ProjectEntity project = this.projects.findByKey(projectKey).orElseThrow(ProjectNotFoundException::new);
86+
final VersionEntity version = this.versions.findByProjectAndKey(project, versionKey).orElseThrow(VersionNotFoundException::new);
87+
final BuildEntity build = this.builds.findByVersionAndNumber(version, buildNumber).orElseThrow(BuildNotFoundException::new);
8888

8989
final Download download = build.getDownloadByName(downloadName);
9090
if (download != null) {

src/main/java/io/papermc/fill/controller/GraphMutationController.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ public CreateFamilyPayload createFamily(
8585
@Argument
8686
final CreateFamilyInput input
8787
) {
88-
final ProjectEntity project = this.projects.findByName(input.project()).orElseThrow(ProjectNotFoundException::new);
89-
if (this.families.findByProjectAndName(project, input.id()).isPresent()) {
88+
final ProjectEntity project = this.projects.findByKey(input.project()).orElseThrow(ProjectNotFoundException::new);
89+
if (this.families.findByProjectAndKey(project, input.key()).isPresent()) {
9090
throw new DuplicateFamilyException();
9191
}
9292
final FamilyEntity entity = this.families.save(FamilyEntity.create(
9393
new ObjectId(),
9494
Instant.now(),
9595
project,
96-
input.id(),
96+
input.key(),
9797
input.java()
9898
));
9999
return new CreateFamilyPayload(entity);
@@ -105,8 +105,8 @@ public UpdateFamilyPayload updateFamily(
105105
@Argument
106106
final UpdateFamilyInput input
107107
) {
108-
final ProjectEntity project = this.projects.findByName(input.project()).orElseThrow(ProjectNotFoundException::new);
109-
FamilyEntity family = this.families.findByProjectAndName(project, input.id()).orElseThrow(FamilyNotFoundException::new);
108+
final ProjectEntity project = this.projects.findByKey(input.project()).orElseThrow(ProjectNotFoundException::new);
109+
FamilyEntity family = this.families.findByProjectAndKey(project, input.key()).orElseThrow(FamilyNotFoundException::new);
110110
final Java java = input.java();
111111
if (java != null) {
112112
family.setJava(java);
@@ -121,8 +121,8 @@ public DeleteFamilyPayload deleteFamily(
121121
@Argument
122122
final DeleteFamilyInput input
123123
) {
124-
final ProjectEntity project = this.projects.findByName(input.project()).orElseThrow(ProjectNotFoundException::new);
125-
final FamilyEntity family = this.families.findByProjectAndName(project, input.id()).orElseThrow(FamilyNotFoundException::new);
124+
final ProjectEntity project = this.projects.findByKey(input.project()).orElseThrow(ProjectNotFoundException::new);
125+
final FamilyEntity family = this.families.findByProjectAndKey(project, input.key()).orElseThrow(FamilyNotFoundException::new);
126126
if (this.versions.findAllByFamily(family).findAny().isPresent()) {
127127
throw new FamilyInUseException("Cannot delete this family because one or more versions are still associated with it.");
128128
}
@@ -135,17 +135,17 @@ public CreateVersionPayload createVersion(
135135
@Argument
136136
final CreateVersionInput input
137137
) {
138-
final ProjectEntity project = this.projects.findByName(input.project()).orElseThrow(ProjectNotFoundException::new);
139-
final FamilyEntity family = this.families.findByProjectAndName(project, input.family()).orElseThrow(FamilyNotFoundException::new);
140-
if (this.versions.findByProjectAndName(project, input.id()).isPresent()) {
138+
final ProjectEntity project = this.projects.findByKey(input.project()).orElseThrow(ProjectNotFoundException::new);
139+
final FamilyEntity family = this.families.findByProjectAndKey(project, input.family()).orElseThrow(FamilyNotFoundException::new);
140+
if (this.versions.findByProjectAndKey(project, input.key()).isPresent()) {
141141
throw new DuplicateVersionException();
142142
}
143143
final VersionEntity entity = this.versions.save(VersionEntity.create(
144144
new ObjectId(),
145145
Instant.now(),
146146
project,
147147
family,
148-
input.id(),
148+
input.key(),
149149
null,
150150
new Support(SupportStatus.SUPPORTED, null),
151151
input.java()
@@ -159,8 +159,8 @@ public UpdateVersionPayload updateVersion(
159159
@Argument
160160
final UpdateVersionInput input
161161
) {
162-
final ProjectEntity project = this.projects.findByName(input.project()).orElseThrow(ProjectNotFoundException::new);
163-
VersionEntity version = this.versions.findByProjectAndName(project, input.id()).orElseThrow(VersionNotFoundException::new);
162+
final ProjectEntity project = this.projects.findByKey(input.project()).orElseThrow(ProjectNotFoundException::new);
163+
VersionEntity version = this.versions.findByProjectAndKey(project, input.key()).orElseThrow(VersionNotFoundException::new);
164164
final Support newSupport = input.support();
165165
if (newSupport != null) {
166166
version.setSupport(newSupport);
@@ -176,8 +176,8 @@ public DeleteVersionPayload deleteVersion(
176176
@Argument
177177
final DeleteVersionInput input
178178
) {
179-
final ProjectEntity project = this.projects.findByName(input.project()).orElseThrow(ProjectNotFoundException::new);
180-
final VersionEntity version = this.versions.findByProjectAndName(project, input.id()).orElseThrow(VersionNotFoundException::new);
179+
final ProjectEntity project = this.projects.findByKey(input.project()).orElseThrow(ProjectNotFoundException::new);
180+
final VersionEntity version = this.versions.findByProjectAndKey(project, input.key()).orElseThrow(VersionNotFoundException::new);
181181
if (this.builds.findAllByVersion(version).findAny().isPresent()) {
182182
throw new VersionInUseException("Cannot delete this version because one or more builds are still associated with it.");
183183
}
@@ -190,16 +190,16 @@ public PromoteBuildPayload promoteBuild(
190190
@Argument
191191
final PromoteBuildInput input
192192
) {
193-
final ProjectEntity project = this.projects.findByName(input.project()).orElseThrow(ProjectNotFoundException::new);
194-
VersionEntity version = this.versions.findByProjectAndName(project, input.version()).orElseThrow(VersionNotFoundException::new);
195-
BuildEntity build = this.builds.findByVersionAndNumber(version, input.id()).orElseThrow(BuildNotFoundException::new);
193+
final ProjectEntity project = this.projects.findByKey(input.project()).orElseThrow(ProjectNotFoundException::new);
194+
VersionEntity version = this.versions.findByProjectAndKey(project, input.version()).orElseThrow(VersionNotFoundException::new);
195+
BuildEntity build = this.builds.findByVersionAndNumber(version, input.number()).orElseThrow(BuildNotFoundException::new);
196196

197197
build.setChannel(BuildChannel.RECOMMENDED);
198198
build = this.builds.save(build);
199199

200200
version.setMostRecentPromotedBuild(build);
201201
version = this.versions.save(version);
202202

203-
return new PromoteBuildPayload(version);
203+
return new PromoteBuildPayload(version, build);
204204
}
205205
}

0 commit comments

Comments
 (0)