Skip to content

Commit 919b52b

Browse files
committed
Upgrade grats
1 parent 02b4055 commit 919b52b

13 files changed

+75
-65
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api/graphql/schema.ts

packages/skin-database/api/graphql/ModernSkinsConnection.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ export default class ModernSkinsConnection {
3131
/**
3232
* The list of skins
3333
* @gqlField */
34-
async nodes(
35-
_args: unknown,
36-
{ ctx }: Ctx
37-
): Promise<Array<ModernSkinResolver | null>> {
34+
async nodes({ ctx }: Ctx): Promise<Array<ModernSkinResolver | null>> {
3835
const skins = await this._getQuery()
3936
.select()
4037
.limit(this._first)

packages/skin-database/api/graphql/SkinsConnection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class SkinsConnection {
103103
* The list of skins
104104
* @gqlField
105105
*/
106-
async nodes(args: unknown, { ctx }: Ctx): Promise<Array<ISkin | null>> {
106+
async nodes({ ctx }: Ctx): Promise<Array<ISkin | null>> {
107107
if (this._sort === "MUSEUM") {
108108
if (this._filter) {
109109
throw new Error(

packages/skin-database/api/graphql/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { graphqlHTTP } from "express-graphql";
44
import DEFAULT_QUERY from "./defaultQuery";
55
import { getSchema } from "./schema";
66

7+
/** @gqlContext */
78
export type Ctx = Express.Request;
89

910
const router = Router();

packages/skin-database/api/graphql/resolvers/ClassicSkinResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import SkinModel from "../../../data/SkinModel";
1010
* @gqlType ClassicSkin */
1111
export default class ClassicSkinResolver implements NodeResolver, ISkin {
1212
_model: SkinModel;
13-
__typename = "ClassicSkin";
13+
__typename = "ClassicSkin" as const;
1414

1515
constructor(model: SkinModel) {
1616
this._model = model;

packages/skin-database/api/graphql/resolvers/ModernSkinResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { XMLParser } from "fast-xml-parser";
1313
* @gqlType ModernSkin */
1414
export default class ModernSkinResolver implements NodeResolver, ISkin {
1515
_model: SkinModel;
16-
__typename = "ModernSkin";
16+
__typename = "ModernSkin" as const;
1717

1818
constructor(model: SkinModel) {
1919
this._model = model;

packages/skin-database/api/graphql/resolvers/ReviewMutations.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ function requireAuthed(handler) {
2020
* @gqlField */
2121
export function reject_skin(
2222
_: Mutation,
23-
args: { md5: string },
23+
md5: string,
2424
req: Ctx
2525
): Promise<boolean> {
26-
return _reject_skin(args, req);
26+
return _reject_skin(md5, req);
2727
}
2828

29-
const _reject_skin = requireAuthed(async ({ md5 }, req: Ctx) => {
29+
const _reject_skin = requireAuthed(async (md5: string, req: Ctx) => {
3030
req.log(`Rejecting skin with hash "${md5}"`);
3131
const skin = await SkinModel.fromMd5Assert(req.ctx, md5);
3232
if (skin == null) {
@@ -44,13 +44,13 @@ const _reject_skin = requireAuthed(async ({ md5 }, req: Ctx) => {
4444
* @gqlField */
4545
export function approve_skin(
4646
_: Mutation,
47-
args: { md5: string },
47+
md5: string,
4848
req: Ctx
4949
): Promise<boolean> {
50-
return _approve_skin(args, req);
50+
return _approve_skin(md5, req);
5151
}
5252

53-
const _approve_skin = requireAuthed(async ({ md5 }, req: Ctx) => {
53+
const _approve_skin = requireAuthed(async (md5: string, req: Ctx) => {
5454
req.log(`Approving skin with hash "${md5}"`);
5555
const skin = await SkinModel.fromMd5(req.ctx, md5);
5656
if (skin == null) {
@@ -68,13 +68,13 @@ const _approve_skin = requireAuthed(async ({ md5 }, req: Ctx) => {
6868
* @gqlField */
6969
export function mark_skin_nsfw(
7070
_: Mutation,
71-
args: { md5: string },
71+
md5: string,
7272
req: Ctx
7373
): Promise<boolean> {
74-
return _mark_skin_nsfw(args, req);
74+
return _mark_skin_nsfw(md5, req);
7575
}
7676

77-
const _mark_skin_nsfw = requireAuthed(async ({ md5 }, req: Ctx) => {
77+
const _mark_skin_nsfw = requireAuthed(async (md5: string, req: Ctx) => {
7878
req.log(`Approving skin with hash "${md5}"`);
7979
const skin = await SkinModel.fromMd5(req.ctx, md5);
8080
if (skin == null) {

packages/skin-database/api/graphql/resolvers/ReviewResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class ReviewResolver {
1717
* The skin that was reviewed
1818
* @gqlField
1919
*/
20-
skin(args: unknown, { ctx }: Ctx): Promise<ISkin | null> {
20+
skin({ ctx }: Ctx): Promise<ISkin | null> {
2121
return SkinResolver.fromMd5(ctx, this._model.skin_md5);
2222
}
2323

packages/skin-database/api/graphql/resolvers/SkinResolver.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export async function search_skins(
8686
* @gqlField */
8787
export async function skin_to_review(
8888
_: Query,
89-
_args: unknown,
9089
{ ctx }: Ctx
9190
): Promise<ISkin | null> {
9291
if (!ctx.authed()) {

packages/skin-database/api/graphql/resolvers/UserResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Query } from "./QueryResolver";
44
/** @gqlType User */
55
export default class UserResolver {
66
/** @gqlField */
7-
username(_args: unknown, { ctx }: Ctx): string | null {
7+
username({ ctx }: Ctx): string | null {
88
return ctx.username;
99
}
1010
}

packages/skin-database/api/graphql/schema.ts

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -68,32 +68,32 @@ export function getSchema(): GraphQLSchema {
6868
description: "The Internet Archive's unique identifier for this item",
6969
name: "identifier",
7070
type: GraphQLString,
71-
resolve(source, args, context, info) {
72-
return assertNonNull(source.getIdentifier(source, args, context, info));
71+
resolve(source) {
72+
return assertNonNull(source.getIdentifier());
7373
}
7474
},
7575
last_metadata_scrape_date_UNSTABLE: {
7676
description: "The date and time that we last scraped this item's metadata.\n**Note:** This field is temporary and will be removed in the future.\nThe date format is just what we get from the database, and it's ambiguous.",
7777
name: "last_metadata_scrape_date_UNSTABLE",
7878
type: GraphQLString,
79-
resolve(source, args, context, info) {
80-
return source.getMetadataTimestamp(source, args, context, info);
79+
resolve(source) {
80+
return source.getMetadataTimestamp();
8181
}
8282
},
8383
metadata_url: {
8484
description: "URL to get the Internet Archive's metadata for this item in JSON form.",
8585
name: "metadata_url",
8686
type: GraphQLString,
87-
resolve(source, args, context, info) {
88-
return assertNonNull(source.getMetadataUrl(source, args, context, info));
87+
resolve(source) {
88+
return assertNonNull(source.getMetadataUrl());
8989
}
9090
},
9191
raw_metadata_json: {
9292
description: "Our cached version of the metadata available at \\`metadata_url\\` (above)",
9393
name: "raw_metadata_json",
9494
type: GraphQLString,
95-
resolve(source, args, context, info) {
96-
return source.getMetadataJSON(source, args, context, info);
95+
resolve(source) {
96+
return source.getMetadataJSON();
9797
}
9898
},
9999
skin: {
@@ -105,8 +105,8 @@ export function getSchema(): GraphQLSchema {
105105
description: "The URL where this item can be viewed on the Internet Archive",
106106
name: "url",
107107
type: GraphQLString,
108-
resolve(source, args, context, info) {
109-
return assertNonNull(source.getUrl(source, args, context, info));
108+
resolve(source) {
109+
return assertNonNull(source.getUrl());
110110
}
111111
}
112112
};
@@ -151,7 +151,10 @@ export function getSchema(): GraphQLSchema {
151151
skin: {
152152
description: "The skin that was reviewed",
153153
name: "skin",
154-
type: SkinType
154+
type: SkinType,
155+
resolve(source, _args, context) {
156+
return source.skin(context);
157+
}
155158
}
156159
};
157160
}
@@ -165,16 +168,16 @@ export function getSchema(): GraphQLSchema {
165168
description: "Number of likes the tweet has received. Updated nightly. (Note: Recent likes on older tweets may not be reflected here)",
166169
name: "likes",
167170
type: GraphQLInt,
168-
resolve(source, args, context, info) {
169-
return assertNonNull(source.getLikes(source, args, context, info));
171+
resolve(source) {
172+
return assertNonNull(source.getLikes());
170173
}
171174
},
172175
retweets: {
173176
description: "Number of retweets the tweet has received. Updated nightly. (Note: Recent retweets on older tweets may not be reflected here)",
174177
name: "retweets",
175178
type: GraphQLInt,
176-
resolve(source, args, context, info) {
177-
return assertNonNull(source.getRetweets(source, args, context, info));
179+
resolve(source) {
180+
return assertNonNull(source.getRetweets());
178181
}
179182
},
180183
skin: {
@@ -186,8 +189,8 @@ export function getSchema(): GraphQLSchema {
186189
description: "URL of the tweet. **Note:** Early on in the bot's life we just recorded\n_which_ skins were tweeted, not any info about the actual tweet. This means we\ndon't always know the URL of the tweet.",
187190
name: "url",
188191
type: GraphQLString,
189-
resolve(source, args, context, info) {
190-
return source.getUrl(source, args, context, info);
192+
resolve(source) {
193+
return source.getUrl();
191194
}
192195
}
193196
};
@@ -293,40 +296,40 @@ export function getSchema(): GraphQLSchema {
293296
description: "The date on the file inside the archive. Given in simplified extended ISO\nformat (ISO 8601).",
294297
name: "date",
295298
type: GraphQLString,
296-
resolve(source, args, context, info) {
297-
return assertNonNull(source.getIsoDate(source, args, context, info));
299+
resolve(source) {
300+
return assertNonNull(source.getIsoDate());
298301
}
299302
},
300303
file_md5: {
301304
description: "The md5 hash of the file within the archive",
302305
name: "file_md5",
303306
type: GraphQLString,
304-
resolve(source, args, context, info) {
305-
return assertNonNull(source.getFileMd5(source, args, context, info));
307+
resolve(source) {
308+
return assertNonNull(source.getFileMd5());
306309
}
307310
},
308311
filename: {
309312
description: "Filename of the file within the archive",
310313
name: "filename",
311314
type: GraphQLString,
312-
resolve(source, args, context, info) {
313-
return assertNonNull(source.getFileName(source, args, context, info));
315+
resolve(source) {
316+
return assertNonNull(source.getFileName());
314317
}
315318
},
316319
is_directory: {
317320
description: "Is the file a directory?",
318321
name: "is_directory",
319322
type: GraphQLBoolean,
320-
resolve(source, args, context, info) {
321-
return assertNonNull(source.getIsDirectory(source, args, context, info));
323+
resolve(source) {
324+
return assertNonNull(source.getIsDirectory());
322325
}
323326
},
324327
size: {
325328
description: "The uncompressed size of the file in bytes.\n\n**Note:** Will be `null` for directories",
326329
name: "size",
327330
type: GraphQLInt,
328-
resolve(source, args, context, info) {
329-
return source.getFileSize(source, args, context, info);
331+
resolve(source) {
332+
return source.getFileSize();
330333
}
331334
},
332335
skin: {
@@ -338,16 +341,16 @@ export function getSchema(): GraphQLSchema {
338341
description: "The content of the file, if it's a text file",
339342
name: "text_content",
340343
type: GraphQLString,
341-
resolve(source, args, context, info) {
342-
return source.getTextContent(source, args, context, info);
344+
resolve(source) {
345+
return source.getTextContent();
343346
}
344347
},
345348
url: {
346349
description: "A URL to download the file. **Note:** This is powered by a little\nserverless Cloudflare function which tries to exctact the file on the fly.\nIt may not work for all files.",
347350
name: "url",
348351
type: GraphQLString,
349-
resolve(source, args, context, info) {
350-
return assertNonNull(source.getUrl(source, args, context, info));
352+
resolve(source) {
353+
return assertNonNull(source.getUrl());
351354
}
352355
}
353356
};
@@ -359,7 +362,10 @@ export function getSchema(): GraphQLSchema {
359362
return {
360363
username: {
361364
name: "username",
362-
type: GraphQLString
365+
type: GraphQLString,
366+
resolve(source, _args, context) {
367+
return source.username(context);
368+
}
363369
}
364370
};
365371
}
@@ -532,8 +538,8 @@ export function getSchema(): GraphQLSchema {
532538
description: "The list of skins",
533539
name: "nodes",
534540
type: new GraphQLList(ModernSkinType),
535-
resolve(source, args, context, info) {
536-
return assertNonNull(defaultFieldResolver(source, args, context, info));
541+
resolve(source, _args, context) {
542+
return assertNonNull(source.nodes(context));
537543
}
538544
}
539545
};
@@ -556,8 +562,8 @@ export function getSchema(): GraphQLSchema {
556562
description: "The list of skins",
557563
name: "nodes",
558564
type: new GraphQLList(SkinType),
559-
resolve(source, args, context, info) {
560-
return assertNonNull(defaultFieldResolver(source, args, context, info));
565+
resolve(source, _args, context) {
566+
return assertNonNull(source.nodes(context));
561567
}
562568
}
563569
};
@@ -897,8 +903,8 @@ export function getSchema(): GraphQLSchema {
897903
description: "A random skin that needs to be reviewed",
898904
name: "skin_to_review",
899905
type: SkinType,
900-
resolve(source, args, context) {
901-
return querySkin_to_reviewResolver(source, args, context);
906+
resolve(source, _args, context) {
907+
return querySkin_to_reviewResolver(source, context);
902908
}
903909
},
904910
skins: {

packages/skin-database/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"express-sitemap-xml": "^2.0.0",
2323
"fast-xml-parser": "^4.2.2",
2424
"graphql": "^16.8.1",
25+
"grats": "^0.0.28",
2526
"imagemin": "^7.0.0",
2627
"imagemin-optipng": "^7.0.0",
2728
"knex": "^0.21.1",

yarn.lock

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14851,19 +14851,19 @@ graphql-ws@5.12.1:
1485114851
resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.12.1.tgz#c62d5ac54dbd409cc6520b0b39de374b3d59d0dd"
1485214852
integrity sha512-umt4f5NnMK46ChM2coO36PTFhHouBrK9stWWBczERguwYrGnPNxJ9dimU6IyOBfOkC6Izhkg4H8+F51W/8CYDg==
1485314853

14854-
graphql@^16.6.0, graphql@^16.8.1:
14854+
graphql@16.8.1, graphql@^16.8.1, graphql@^16.9.0:
1485514855
version "16.8.1"
1485614856
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.8.1.tgz#1930a965bef1170603702acdb68aedd3f3cf6f07"
1485714857
integrity sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==
1485814858

14859-
grats@^0.0.25:
14860-
version "0.0.25"
14861-
resolved "https://registry.yarnpkg.com/grats/-/grats-0.0.25.tgz#c2f872d3843d67f7c5ed957775bd2c58b476cc07"
14862-
integrity sha512-kwI4BHauMXIZc4iigVUFyZIqW12fKrBojGvX9ZrJxnvf1CYMkc+WgH2NfLozLcu2EmbGNX5Ss/TeWJH6xP8wHg==
14859+
grats@^0.0.28:
14860+
version "0.0.28"
14861+
resolved "https://registry.yarnpkg.com/grats/-/grats-0.0.28.tgz#232fa29cc4387607950e2e408e18c26582586e1b"
14862+
integrity sha512-rNsUJv2V2CtjFrMsfYWHz/0v5ndv2zfaEWj5NdzUzEsezQsCu8CTkKFTyz9DIUZfeU32YaScj2a96Q6yXGFpiQ==
1486314863
dependencies:
1486414864
commander "^10.0.0"
14865-
graphql "^16.6.0"
14866-
typescript "^5.0.2"
14865+
graphql "^16.9.0"
14866+
typescript "5.5.4"
1486714867

1486814868
gulp-eslint@^3.0.1:
1486914869
version "3.0.1"
@@ -27415,6 +27415,11 @@ typescript@4.3.4:
2741527415
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.4.tgz#3f85b986945bcf31071decdd96cf8bfa65f9dcbc"
2741627416
integrity sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==
2741727417

27418+
typescript@5.5.4:
27419+
version "5.5.4"
27420+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
27421+
integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==
27422+
2741827423
typescript@^3.8.3, typescript@^3.9.10:
2741927424
version "3.9.10"
2742027425
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8"
@@ -27425,7 +27430,7 @@ typescript@^4.1.5, typescript@^4.4.3:
2742527430
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
2742627431
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
2742727432

27428-
typescript@^5.0.2, typescript@^5.3.3:
27433+
typescript@^5.3.3:
2742927434
version "5.4.3"
2743027435
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.3.tgz#5c6fedd4c87bee01cd7a528a30145521f8e0feff"
2743127436
integrity sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==

0 commit comments

Comments
 (0)