diff --git a/packages/skin-database/api/graphql/ModernSkinsConnection.ts b/packages/skin-database/api/graphql/ModernSkinsConnection.ts index 9b7d8df5c..76f91a858 100644 --- a/packages/skin-database/api/graphql/ModernSkinsConnection.ts +++ b/packages/skin-database/api/graphql/ModernSkinsConnection.ts @@ -3,7 +3,6 @@ import SkinModel from "../../data/SkinModel"; import { knex } from "../../db"; import ModernSkinResolver from "./resolvers/ModernSkinResolver"; import { Ctx } from "."; -import { Query } from "./resolvers/QueryResolver"; /** * A collection of "modern" Winamp skins @@ -44,16 +43,10 @@ export default class ModernSkinsConnection { /** * All modern skins in the database - * @gqlField */ + * @gqlQueryField */ export async function modern_skins( - _: Query, - { - first = 10, - offset = 0, - }: { - first?: Int; - offset?: Int; - } + first: Int = 10, + offset: Int = 0 ): Promise { if (first > 1000) { throw new Error("Maximum limit is 1000"); diff --git a/packages/skin-database/api/graphql/SkinsConnection.ts b/packages/skin-database/api/graphql/SkinsConnection.ts index 26b402043..eb16d26e6 100644 --- a/packages/skin-database/api/graphql/SkinsConnection.ts +++ b/packages/skin-database/api/graphql/SkinsConnection.ts @@ -6,7 +6,6 @@ import LRU from "lru-cache"; import { Int } from "grats"; import { ISkin } from "./resolvers/CommonSkinResolver"; import { Ctx } from "."; -import { Query } from "./resolvers/QueryResolver"; const options = { max: 100, @@ -171,21 +170,18 @@ Only the skins that have been tweeted * All classic skins in the database * * **Note:** We don't currently support combining sorting and filtering. - * @gqlField */ -export function skins( - _: Query, - { - first = 10, - offset = 0, - sort, - filter, - }: { - first?: Int; - offset?: Int; - sort?: SkinsSortOption | null; - filter?: SkinsFilterOption | null; - } -): SkinsConnection { + * @gqlQueryField */ +export function skins({ + first = 10, + offset = 0, + sort, + filter, +}: { + first?: Int; + offset?: Int; + sort?: SkinsSortOption | null; + filter?: SkinsFilterOption | null; +}): SkinsConnection { if (first > 1000) { throw new Error("Maximum limit is 1000"); } diff --git a/packages/skin-database/api/graphql/TweetsConnection.ts b/packages/skin-database/api/graphql/TweetsConnection.ts index b13a1ce45..9b02976a4 100644 --- a/packages/skin-database/api/graphql/TweetsConnection.ts +++ b/packages/skin-database/api/graphql/TweetsConnection.ts @@ -1,7 +1,6 @@ import { Int } from "grats"; import TweetModel from "../../data/TweetModel"; import { knex } from "../../db"; -import { Query } from "./resolvers/QueryResolver"; /** @gqlEnum */ export type TweetsSortOption = "LIKES" | "RETWEETS"; @@ -51,20 +50,17 @@ export default class TweetsConnection { /** * Tweets tweeted by @winampskins - * @gqlField + * @gqlQueryField */ -export async function tweets( - _: Query, - { - first = 10, - offset = 0, - sort, - }: { - first?: Int; - offset?: Int; - sort?: TweetsSortOption | null; - } -): Promise { +export async function tweets({ + first = 10, + offset = 0, + sort, +}: { + first?: Int; + offset?: Int; + sort?: TweetsSortOption | null; +}): Promise { if (first > 1000) { throw new Error("Maximum limit is 1000"); } diff --git a/packages/skin-database/api/graphql/resolvers/DatabaseStatisticsResolver.ts b/packages/skin-database/api/graphql/resolvers/DatabaseStatisticsResolver.ts index 25c2f95bf..6a9e19d34 100644 --- a/packages/skin-database/api/graphql/resolvers/DatabaseStatisticsResolver.ts +++ b/packages/skin-database/api/graphql/resolvers/DatabaseStatisticsResolver.ts @@ -1,6 +1,5 @@ import { Int } from "grats"; import * as Skins from "../../../data/skins"; -import { Query } from "./QueryResolver"; /** * Statistics about the contents of the Museum's database. @@ -92,7 +91,7 @@ export default class DatabaseStatisticsResolver { /** * A namespace for statistics about the database - * @gqlField */ -export function statistics(_: Query): DatabaseStatisticsResolver { + * @gqlQueryField */ +export function statistics(): DatabaseStatisticsResolver { return new DatabaseStatisticsResolver(); } diff --git a/packages/skin-database/api/graphql/resolvers/FeedbackMutation.ts b/packages/skin-database/api/graphql/resolvers/FeedbackMutation.ts index fabb7e397..926c6fb19 100644 --- a/packages/skin-database/api/graphql/resolvers/FeedbackMutation.ts +++ b/packages/skin-database/api/graphql/resolvers/FeedbackMutation.ts @@ -1,17 +1,13 @@ import { Ctx } from ".."; -import { Mutation } from "./MutationResolver"; /** * Send a message to the admin of the site. Currently this appears in Discord. - * @gqlField */ + * @gqlMutationField */ export async function send_feedback( - _: Mutation, - { - message, - email, - url, - }: { message: string; email?: string | null; url?: string | null }, - req: Ctx + req: Ctx, + message: string, + email?: string | null, + url?: string | null ): Promise { req.notify({ type: "GOT_FEEDBACK", diff --git a/packages/skin-database/api/graphql/resolvers/MutationResolver.ts b/packages/skin-database/api/graphql/resolvers/MutationResolver.ts deleted file mode 100644 index a9c277a7e..000000000 --- a/packages/skin-database/api/graphql/resolvers/MutationResolver.ts +++ /dev/null @@ -1,2 +0,0 @@ -/** @gqlType Mutation */ -export type Mutation = unknown; diff --git a/packages/skin-database/api/graphql/resolvers/NodeResolver.ts b/packages/skin-database/api/graphql/resolvers/NodeResolver.ts index 8021c7866..b1e5a9dc1 100644 --- a/packages/skin-database/api/graphql/resolvers/NodeResolver.ts +++ b/packages/skin-database/api/graphql/resolvers/NodeResolver.ts @@ -34,13 +34,9 @@ export function fromId(base64Id: string): { graphqlType: string; id: string } { * Get a globally unique object by its ID. * * https://graphql.org/learn/global-object-identification/ - * @gqlField + * @gqlQueryField */ -export async function node( - _: Query, - { id }: { id: ID }, - { ctx }: Ctx -): Promise { +export async function node(id: ID, { ctx }: Ctx): Promise { const { graphqlType, id: localId } = fromId(id); // TODO Use typeResolver switch (graphqlType) { diff --git a/packages/skin-database/api/graphql/resolvers/QueryResolver.ts b/packages/skin-database/api/graphql/resolvers/QueryResolver.ts deleted file mode 100644 index 8658a14aa..000000000 --- a/packages/skin-database/api/graphql/resolvers/QueryResolver.ts +++ /dev/null @@ -1,2 +0,0 @@ -/** @gqlType Query */ -export type Query = unknown; diff --git a/packages/skin-database/api/graphql/resolvers/ReviewMutations.ts b/packages/skin-database/api/graphql/resolvers/ReviewMutations.ts index b35309dc2..a349deea5 100644 --- a/packages/skin-database/api/graphql/resolvers/ReviewMutations.ts +++ b/packages/skin-database/api/graphql/resolvers/ReviewMutations.ts @@ -1,7 +1,6 @@ import SkinModel from "../../../data/SkinModel"; import * as Skins from "../../../data/skins"; import { Ctx } from ".."; -import { Mutation } from "./MutationResolver"; function requireAuthed(handler) { return (args, req: Ctx) => { @@ -17,12 +16,8 @@ function requireAuthed(handler) { * Reject skin for tweeting * * **Note:** Requires being logged in - * @gqlField */ -export function reject_skin( - _: Mutation, - md5: string, - req: Ctx -): Promise { + * @gqlMutationField */ +export function reject_skin(md5: string, req: Ctx): Promise { return _reject_skin(md5, req); } @@ -41,12 +36,8 @@ const _reject_skin = requireAuthed(async (md5: string, req: Ctx) => { * Approve skin for tweeting * * **Note:** Requires being logged in - * @gqlField */ -export function approve_skin( - _: Mutation, - md5: string, - req: Ctx -): Promise { + * @gqlMutationField */ +export function approve_skin(md5: string, req: Ctx): Promise { return _approve_skin(md5, req); } @@ -65,12 +56,8 @@ const _approve_skin = requireAuthed(async (md5: string, req: Ctx) => { * Mark a skin as NSFW * * **Note:** Requires being logged in - * @gqlField */ -export function mark_skin_nsfw( - _: Mutation, - md5: string, - req: Ctx -): Promise { + * @gqlMutationField */ +export function mark_skin_nsfw(md5: string, req: Ctx): Promise { return _mark_skin_nsfw(md5, req); } @@ -89,10 +76,9 @@ const _mark_skin_nsfw = requireAuthed(async (md5: string, req: Ctx) => { * Request that an admin check if this skin is NSFW. * Unlike other review mutation endpoints, this one does not require being logged * in. - * @gqlField */ + * @gqlMutationField */ export async function request_nsfw_review_for_skin( - _: Mutation, - { md5 }: { md5: string }, + md5: string, req: Ctx ): Promise { req.log(`Reporting skin with hash "${md5}"`); diff --git a/packages/skin-database/api/graphql/resolvers/SkinResolver.ts b/packages/skin-database/api/graphql/resolvers/SkinResolver.ts index d3b4d19f1..e46a309b5 100644 --- a/packages/skin-database/api/graphql/resolvers/SkinResolver.ts +++ b/packages/skin-database/api/graphql/resolvers/SkinResolver.ts @@ -5,7 +5,6 @@ import UserContext from "../../../data/UserContext"; import ClassicSkinResolver from "./ClassicSkinResolver"; import { ISkin } from "./CommonSkinResolver"; import ModernSkinResolver from "./ModernSkinResolver"; -import { Query } from "./QueryResolver"; import algoliasearch from "algoliasearch"; import * as Skins from "../../../data/skins"; @@ -35,11 +34,10 @@ export default class SkinResolver { /** * Get a skin by its MD5 hash - * @gqlField + * @gqlQueryField */ export async function fetch_skin_by_md5( - _: Query, - { md5 }: { md5: string }, + md5: string, { ctx }: Ctx ): Promise { const skin = await SkinModel.fromMd5(ctx, md5); @@ -53,10 +51,9 @@ export async function fetch_skin_by_md5( * Search the database using the Algolia search index used by the Museum. * * Useful for locating a particular skin. - * @gqlField + * @gqlQueryField */ export async function search_skins( - _: Query, { query, first = 10, @@ -83,11 +80,8 @@ export async function search_skins( } /** * A random skin that needs to be reviewed - * @gqlField */ -export async function skin_to_review( - _: Query, - { ctx }: Ctx -): Promise { + * @gqlQueryField */ +export async function skin_to_review({ ctx }: Ctx): Promise { if (!ctx.authed()) { return null; } diff --git a/packages/skin-database/api/graphql/resolvers/SkinUpload.ts b/packages/skin-database/api/graphql/resolvers/SkinUpload.ts index 24c844524..2a02ea1ec 100644 --- a/packages/skin-database/api/graphql/resolvers/SkinUpload.ts +++ b/packages/skin-database/api/graphql/resolvers/SkinUpload.ts @@ -3,16 +3,14 @@ import SkinModel from "../../../data/SkinModel"; import UserContext from "../../../data/UserContext"; import { knex } from "../../../db"; import { ISkin } from "./CommonSkinResolver"; -import { Query } from "./QueryResolver"; import SkinResolver from "./SkinResolver"; /** * Get the status of a batch of uploads by md5s - * @gqlField + * @gqlQueryField * @deprecated Prefer `upload_statuses` instead, were we operate on ids. */ export async function upload_statuses_by_md5( - _: Query, { md5s }: { md5s: string[] }, { ctx }: Ctx ): Promise> { @@ -21,10 +19,9 @@ export async function upload_statuses_by_md5( /** * Get the status of a batch of uploads by ids - * @gqlField */ + * @gqlQueryField */ export async function upload_statuses( - _: Query, - { ids }: { ids: string[] }, + ids: string[], { ctx }: Ctx ): Promise> { return _upload_statuses({ keyName: "id", keys: ids }, ctx); diff --git a/packages/skin-database/api/graphql/resolvers/UploadMutation.ts b/packages/skin-database/api/graphql/resolvers/UploadMutation.ts index 1e3d0affd..2cf120a53 100644 --- a/packages/skin-database/api/graphql/resolvers/UploadMutation.ts +++ b/packages/skin-database/api/graphql/resolvers/UploadMutation.ts @@ -4,7 +4,6 @@ import * as S3 from "../../../s3"; import * as Skins from "../../../data/skins"; import { processUserUploads } from "../../processUserUploads"; import { Ctx } from ".."; -import { Mutation } from "./MutationResolver"; // We don't use a resolver here, just return the value directly. /** @@ -83,7 +82,7 @@ class UploadMutationResolver { /** * Mutations for the upload flow - * @gqlField */ -export async function upload(_: Mutation): Promise { + * @gqlMutationField */ +export async function upload(): Promise { return new UploadMutationResolver(); } diff --git a/packages/skin-database/api/graphql/resolvers/UserResolver.ts b/packages/skin-database/api/graphql/resolvers/UserResolver.ts index 9dc12dde9..eaa37a747 100644 --- a/packages/skin-database/api/graphql/resolvers/UserResolver.ts +++ b/packages/skin-database/api/graphql/resolvers/UserResolver.ts @@ -1,5 +1,4 @@ import { Ctx } from ".."; -import { Query } from "./QueryResolver"; /** @gqlType User */ export default class UserResolver { @@ -11,8 +10,8 @@ export default class UserResolver { /** * The currently authenticated user, if any. - * @gqlField + * @gqlQueryField */ -export function me(_: Query): UserResolver | null { +export function me(): UserResolver | null { return new UserResolver(); } diff --git a/packages/skin-database/api/graphql/schema.ts b/packages/skin-database/api/graphql/schema.ts index 4ac98e5cc..8ac24cbcb 100644 --- a/packages/skin-database/api/graphql/schema.ts +++ b/packages/skin-database/api/graphql/schema.ts @@ -2,57 +2,22 @@ * Executable schema generated by Grats (https://grats.capt.dev) * Do not manually edit. Regenerate by running `npx grats`. */ +import { defaultFieldResolver, GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLBoolean, GraphQLInt, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLID, GraphQLEnumType, GraphQLInputObjectType } from "graphql"; import { fetch_archive_file_by_md5 as queryFetch_archive_file_by_md5Resolver } from "./../../data/ArchiveFileModel"; import { fetch_internet_archive_item_by_identifier as queryFetch_internet_archive_item_by_identifierResolver } from "./../../data/IaItemModel"; -import { fetch_skin_by_md5 as queryFetch_skin_by_md5Resolver } from "./resolvers/SkinResolver"; +import { fetch_skin_by_md5 as queryFetch_skin_by_md5Resolver, search_skins as querySearch_skinsResolver, skin_to_review as querySkin_to_reviewResolver } from "./resolvers/SkinResolver"; import { fetch_tweet_by_url as queryFetch_tweet_by_urlResolver } from "./../../data/TweetModel"; import { me as queryMeResolver } from "./resolvers/UserResolver"; -import { archive_files as modernSkinArchive_filesResolver } from "./resolvers/CommonSkinResolver"; -import { average_color as modernSkinAverage_colorResolver } from "./resolvers/CommonSkinResolver"; -import { download_url as modernSkinDownload_urlResolver } from "./resolvers/CommonSkinResolver"; -import { filename as modernSkinFilenameResolver } from "./resolvers/CommonSkinResolver"; -import { id as modernSkinIdResolver } from "./resolvers/CommonSkinResolver"; -import { internet_archive_item as modernSkinInternet_archive_itemResolver } from "./resolvers/CommonSkinResolver"; -import { md5 as modernSkinMd5Resolver } from "./resolvers/CommonSkinResolver"; -import { museum_url as modernSkinMuseum_urlResolver } from "./resolvers/CommonSkinResolver"; -import { nsfw as modernSkinNsfwResolver } from "./resolvers/CommonSkinResolver"; -import { readme_text as modernSkinReadme_textResolver } from "./resolvers/CommonSkinResolver"; -import { reviews as modernSkinReviewsResolver } from "./resolvers/CommonSkinResolver"; -import { screenshot_url as modernSkinScreenshot_urlResolver } from "./resolvers/CommonSkinResolver"; -import { tweeted as modernSkinTweetedResolver } from "./resolvers/CommonSkinResolver"; -import { tweets as modernSkinTweetsResolver } from "./resolvers/CommonSkinResolver"; -import { webamp_url as modernSkinWebamp_urlResolver } from "./resolvers/CommonSkinResolver"; +import { archive_files as modernSkinArchive_filesResolver, average_color as modernSkinAverage_colorResolver, download_url as modernSkinDownload_urlResolver, filename as modernSkinFilenameResolver, id as modernSkinIdResolver, internet_archive_item as modernSkinInternet_archive_itemResolver, md5 as modernSkinMd5Resolver, museum_url as modernSkinMuseum_urlResolver, nsfw as modernSkinNsfwResolver, readme_text as modernSkinReadme_textResolver, reviews as modernSkinReviewsResolver, screenshot_url as modernSkinScreenshot_urlResolver, tweeted as modernSkinTweetedResolver, tweets as modernSkinTweetsResolver, webamp_url as modernSkinWebamp_urlResolver, archive_files as classicSkinArchive_filesResolver, average_color as classicSkinAverage_colorResolver, download_url as classicSkinDownload_urlResolver, filename as classicSkinFilenameResolver, id as classicSkinIdResolver, internet_archive_item as classicSkinInternet_archive_itemResolver, md5 as classicSkinMd5Resolver, museum_url as classicSkinMuseum_urlResolver, nsfw as classicSkinNsfwResolver, readme_text as classicSkinReadme_textResolver, reviews as classicSkinReviewsResolver, screenshot_url as classicSkinScreenshot_urlResolver, tweeted as classicSkinTweetedResolver, tweets as classicSkinTweetsResolver, webamp_url as classicSkinWebamp_urlResolver } from "./resolvers/CommonSkinResolver"; import { modern_skins as queryModern_skinsResolver } from "./ModernSkinsConnection"; import { node as queryNodeResolver } from "./resolvers/NodeResolver"; -import { search_skins as querySearch_skinsResolver } from "./resolvers/SkinResolver"; -import { skin_to_review as querySkin_to_reviewResolver } from "./resolvers/SkinResolver"; import { skins as querySkinsResolver } from "./SkinsConnection"; import { statistics as queryStatisticsResolver } from "./resolvers/DatabaseStatisticsResolver"; import { tweets as queryTweetsResolver } from "./TweetsConnection"; -import { upload_statuses as queryUpload_statusesResolver } from "./resolvers/SkinUpload"; -import { upload_statuses_by_md5 as queryUpload_statuses_by_md5Resolver } from "./resolvers/SkinUpload"; -import { approve_skin as mutationApprove_skinResolver } from "./resolvers/ReviewMutations"; -import { mark_skin_nsfw as mutationMark_skin_nsfwResolver } from "./resolvers/ReviewMutations"; -import { reject_skin as mutationReject_skinResolver } from "./resolvers/ReviewMutations"; -import { request_nsfw_review_for_skin as mutationRequest_nsfw_review_for_skinResolver } from "./resolvers/ReviewMutations"; +import { upload_statuses as queryUpload_statusesResolver, upload_statuses_by_md5 as queryUpload_statuses_by_md5Resolver } from "./resolvers/SkinUpload"; +import { approve_skin as mutationApprove_skinResolver, mark_skin_nsfw as mutationMark_skin_nsfwResolver, reject_skin as mutationReject_skinResolver, request_nsfw_review_for_skin as mutationRequest_nsfw_review_for_skinResolver } from "./resolvers/ReviewMutations"; import { send_feedback as mutationSend_feedbackResolver } from "./resolvers/FeedbackMutation"; import { upload as mutationUploadResolver } from "./resolvers/UploadMutation"; -import { archive_files as classicSkinArchive_filesResolver } from "./resolvers/CommonSkinResolver"; -import { average_color as classicSkinAverage_colorResolver } from "./resolvers/CommonSkinResolver"; -import { download_url as classicSkinDownload_urlResolver } from "./resolvers/CommonSkinResolver"; -import { filename as classicSkinFilenameResolver } from "./resolvers/CommonSkinResolver"; -import { id as classicSkinIdResolver } from "./resolvers/CommonSkinResolver"; -import { internet_archive_item as classicSkinInternet_archive_itemResolver } from "./resolvers/CommonSkinResolver"; -import { md5 as classicSkinMd5Resolver } from "./resolvers/CommonSkinResolver"; -import { museum_url as classicSkinMuseum_urlResolver } from "./resolvers/CommonSkinResolver"; -import { nsfw as classicSkinNsfwResolver } from "./resolvers/CommonSkinResolver"; -import { readme_text as classicSkinReadme_textResolver } from "./resolvers/CommonSkinResolver"; -import { reviews as classicSkinReviewsResolver } from "./resolvers/CommonSkinResolver"; -import { screenshot_url as classicSkinScreenshot_urlResolver } from "./resolvers/CommonSkinResolver"; -import { tweeted as classicSkinTweetedResolver } from "./resolvers/CommonSkinResolver"; -import { tweets as classicSkinTweetsResolver } from "./resolvers/CommonSkinResolver"; -import { webamp_url as classicSkinWebamp_urlResolver } from "./resolvers/CommonSkinResolver"; -import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLBoolean, GraphQLInt, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLID, GraphQLEnumType, defaultFieldResolver, GraphQLInputObjectType } from "graphql"; async function assertNonNull(value: T | Promise): Promise { const awaited = await value; if (awaited == null) @@ -787,8 +752,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(GraphQLString) } }, - resolve(source, args, context) { - return queryFetch_archive_file_by_md5Resolver(source, args, context); + resolve(_source, args, context) { + return queryFetch_archive_file_by_md5Resolver(args.md5, context); } }, fetch_internet_archive_item_by_identifier: { @@ -801,8 +766,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(GraphQLString) } }, - resolve(source, args, context) { - return queryFetch_internet_archive_item_by_identifierResolver(source, args, context); + resolve(_source, args, context) { + return queryFetch_internet_archive_item_by_identifierResolver(args.identifier, context); } }, fetch_skin_by_md5: { @@ -815,8 +780,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(GraphQLString) } }, - resolve(source, args, context) { - return queryFetch_skin_by_md5Resolver(source, args, context); + resolve(_source, args, context) { + return queryFetch_skin_by_md5Resolver(args.md5, context); } }, fetch_tweet_by_url: { @@ -829,16 +794,16 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(GraphQLString) } }, - resolve(source, args, context) { - return queryFetch_tweet_by_urlResolver(source, args, context); + resolve(_source, args, context) { + return queryFetch_tweet_by_urlResolver(args.url, context); } }, me: { description: "The currently authenticated user, if any.", name: "me", type: UserType, - resolve(source) { - return queryMeResolver(source); + resolve() { + return queryMeResolver(); } }, modern_skins: { @@ -857,8 +822,8 @@ export function getSchema(): GraphQLSchema { defaultValue: 0 } }, - resolve(source, args) { - return assertNonNull(queryModern_skinsResolver(source, args)); + resolve(_source, args) { + return assertNonNull(queryModern_skinsResolver(args.first, args.offset)); } }, node: { @@ -871,8 +836,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(GraphQLID) } }, - resolve(source, args, context) { - return queryNodeResolver(source, args, context); + resolve(_source, args, context) { + return queryNodeResolver(args.id, context); } }, search_skins: { @@ -895,16 +860,16 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(GraphQLString) } }, - resolve(source, args, context) { - return assertNonNull(querySearch_skinsResolver(source, args, context)); + resolve(_source, args, context) { + return assertNonNull(querySearch_skinsResolver(args, context)); } }, skin_to_review: { description: "A random skin that needs to be reviewed", name: "skin_to_review", type: SkinType, - resolve(source, _args, context) { - return querySkin_to_reviewResolver(source, context); + resolve(_source, _args, context) { + return querySkin_to_reviewResolver(context); } }, skins: { @@ -931,16 +896,16 @@ export function getSchema(): GraphQLSchema { type: SkinsSortOptionType } }, - resolve(source, args) { - return assertNonNull(querySkinsResolver(source, args)); + resolve(_source, args) { + return assertNonNull(querySkinsResolver(args)); } }, statistics: { description: "A namespace for statistics about the database", name: "statistics", type: DatabaseStatisticsType, - resolve(source) { - return assertNonNull(queryStatisticsResolver(source)); + resolve() { + return assertNonNull(queryStatisticsResolver()); } }, tweets: { @@ -963,8 +928,8 @@ export function getSchema(): GraphQLSchema { type: TweetsSortOptionType } }, - resolve(source, args) { - return assertNonNull(queryTweetsResolver(source, args)); + resolve(_source, args) { + return assertNonNull(queryTweetsResolver(args)); } }, upload_statuses: { @@ -977,8 +942,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(GraphQLString))) } }, - resolve(source, args, context) { - return assertNonNull(queryUpload_statusesResolver(source, args, context)); + resolve(_source, args, context) { + return assertNonNull(queryUpload_statusesResolver(args.ids, context)); } }, upload_statuses_by_md5: { @@ -992,8 +957,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(GraphQLString))) } }, - resolve(source, args, context) { - return assertNonNull(queryUpload_statuses_by_md5Resolver(source, args, context)); + resolve(_source, args, context) { + return assertNonNull(queryUpload_statuses_by_md5Resolver(args, context)); } } }; @@ -1059,8 +1024,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(UploadUrlRequestType))) } }, - resolve(source, args, context, info) { - return assertNonNull(defaultFieldResolver(source, args, context, info)); + resolve(source, args, context) { + return assertNonNull(source.get_upload_urls(args, context)); } }, report_skin_uploaded: { @@ -1077,8 +1042,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(GraphQLString) } }, - resolve(source, args, context, info) { - return assertNonNull(defaultFieldResolver(source, args, context, info)); + resolve(source, args, context) { + return assertNonNull(source.report_skin_uploaded(args, context)); } } }; @@ -1098,8 +1063,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(GraphQLString) } }, - resolve(source, args, context) { - return assertNonNull(mutationApprove_skinResolver(source, args.md5, context)); + resolve(_source, args, context) { + return assertNonNull(mutationApprove_skinResolver(args.md5, context)); } }, mark_skin_nsfw: { @@ -1112,8 +1077,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(GraphQLString) } }, - resolve(source, args, context) { - return assertNonNull(mutationMark_skin_nsfwResolver(source, args.md5, context)); + resolve(_source, args, context) { + return assertNonNull(mutationMark_skin_nsfwResolver(args.md5, context)); } }, reject_skin: { @@ -1126,8 +1091,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(GraphQLString) } }, - resolve(source, args, context) { - return assertNonNull(mutationReject_skinResolver(source, args.md5, context)); + resolve(_source, args, context) { + return assertNonNull(mutationReject_skinResolver(args.md5, context)); } }, request_nsfw_review_for_skin: { @@ -1140,8 +1105,8 @@ export function getSchema(): GraphQLSchema { type: new GraphQLNonNull(GraphQLString) } }, - resolve(source, args, context) { - return assertNonNull(mutationRequest_nsfw_review_for_skinResolver(source, args, context)); + resolve(_source, args, context) { + return assertNonNull(mutationRequest_nsfw_review_for_skinResolver(args.md5, context)); } }, send_feedback: { @@ -1162,16 +1127,16 @@ export function getSchema(): GraphQLSchema { type: GraphQLString } }, - resolve(source, args, context) { - return assertNonNull(mutationSend_feedbackResolver(source, args, context)); + resolve(_source, args, context) { + return assertNonNull(mutationSend_feedbackResolver(context, args.message, args.email, args.url)); } }, upload: { description: "Mutations for the upload flow", name: "upload", type: UploadMutationsType, - resolve(source) { - return assertNonNull(mutationUploadResolver(source)); + resolve() { + return assertNonNull(mutationUploadResolver()); } } }; diff --git a/packages/skin-database/data/ArchiveFileModel.ts b/packages/skin-database/data/ArchiveFileModel.ts index b22390322..4bc9e61b5 100644 --- a/packages/skin-database/data/ArchiveFileModel.ts +++ b/packages/skin-database/data/ArchiveFileModel.ts @@ -8,7 +8,6 @@ import { ISkin } from "../api/graphql/resolvers/CommonSkinResolver"; import SkinResolver from "../api/graphql/resolvers/SkinResolver"; import { Int } from "grats"; import { Ctx } from "../api/graphql"; -import { Query } from "../api/graphql/resolvers/QueryResolver"; export type ArchiveFileDebugData = { row: ArchiveFileRow; @@ -150,11 +149,10 @@ export default class ArchiveFileModel { * Fetch archive file by it's MD5 hash * * Get information about a file found within a skin's wsz/wal/zip archive. - * @gqlField + * @gqlQueryField */ export async function fetch_archive_file_by_md5( - _: Query, - { md5 }: { md5: string }, + md5: string, { ctx }: Ctx ): Promise { return ArchiveFileModel.fromFileMd5(ctx, md5); diff --git a/packages/skin-database/data/IaItemModel.ts b/packages/skin-database/data/IaItemModel.ts index 54db08368..f171a4942 100644 --- a/packages/skin-database/data/IaItemModel.ts +++ b/packages/skin-database/data/IaItemModel.ts @@ -7,7 +7,6 @@ import { fetchMetadata, fetchTasks } from "../services/internetArchive"; import { ISkin } from "../api/graphql/resolvers/CommonSkinResolver"; import SkinResolver from "../api/graphql/resolvers/SkinResolver"; import { Ctx } from "../api/graphql"; -import { Query } from "../api/graphql/resolvers/QueryResolver"; const IA_URL = /^(https:\/\/)?archive.org\/details\/([^/]+)\/?/; @@ -219,11 +218,10 @@ export default class IaItemModel { * Get an archive.org item by its identifier. You can find this in the URL: * * https://archive.org/details// - * @gqlField + * @gqlQueryField */ export async function fetch_internet_archive_item_by_identifier( - _: Query, - { identifier }: { identifier: string }, + identifier: string, { ctx }: Ctx ): Promise { return IaItemModel.fromIdentifier(ctx, identifier); diff --git a/packages/skin-database/data/TweetModel.ts b/packages/skin-database/data/TweetModel.ts index 695e842fc..0835a6511 100644 --- a/packages/skin-database/data/TweetModel.ts +++ b/packages/skin-database/data/TweetModel.ts @@ -8,7 +8,6 @@ import { Int } from "grats"; import { ISkin } from "../api/graphql/resolvers/CommonSkinResolver"; import SkinResolver from "../api/graphql/resolvers/SkinResolver"; import { Ctx } from "../api/graphql"; -import { Query } from "../api/graphql/resolvers/QueryResolver"; export type TweetDebugData = { row: TweetRow; @@ -109,11 +108,10 @@ export default class TweetModel { /** * Get a tweet by its URL - * @gqlField + * @gqlQueryField */ export async function fetch_tweet_by_url( - _: Query, - { url }: { url: string }, + url: string, { ctx }: Ctx ): Promise { return TweetModel.fromAnything(ctx, url); diff --git a/packages/skin-database/package.json b/packages/skin-database/package.json index bcda4323a..45929c5ec 100644 --- a/packages/skin-database/package.json +++ b/packages/skin-database/package.json @@ -23,7 +23,7 @@ "fast-xml-parser": "^4.2.2", "graphql": "^16.8.1", "graphql-http": "^1.22.1", - "grats": "^0.0.29", + "grats": "^0.0.30", "imagemin": "^7.0.0", "imagemin-optipng": "^7.0.0", "knex": "^0.21.1", diff --git a/yarn.lock b/yarn.lock index 31c8df6f8..7fe6dcac7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15139,10 +15139,10 @@ graphql@16.8.1, graphql@^16.8.1, graphql@^16.9.0: resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.8.1.tgz#1930a965bef1170603702acdb68aedd3f3cf6f07" integrity sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw== -grats@^0.0.29: - version "0.0.29" - resolved "https://registry.yarnpkg.com/grats/-/grats-0.0.29.tgz#9efe40da41a90c35c75f7ee4617290623a4318a9" - integrity sha512-6A77DUF+FHeVEWPUr2DENA9M3iCrR7/TbGQdmJGW7mXs6a5QhnDigq8PkQQdliVzE6KIj86SokkRWS4rAljlPg== +grats@^0.0.30: + version "0.0.30" + resolved "https://registry.yarnpkg.com/grats/-/grats-0.0.30.tgz#42d048d9d651a4873d741ad38f5b41c5b399719f" + integrity sha512-F+DBYBQHyOoUVA1jH8oAzz5hQPlZSgAfGvdbfo22N5s+1Ae3EXnF5NtcSPbmHPeWhIQ6D+Lo/VHrkNWayVcJpA== dependencies: commander "^10.0.0" graphql "^16.9.0"