This commit is contained in:
23
models/graphql/resolvers.ts
Normal file
23
models/graphql/resolvers.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
export const resolvers = {
|
||||
Query: {
|
||||
_empty: (): null => null,
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
addTorrent: async (_: any, { input }: any, context: any) => {
|
||||
const { broker } = context;
|
||||
if (!broker) throw new Error("Broker not available in context");
|
||||
|
||||
return broker.call("qbittorrent.addTorrent", {
|
||||
torrentToDownload: input.torrentToDownload,
|
||||
comicObjectId: input.comicObjectId,
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
JSON: {
|
||||
__parseValue: (value: any) => value,
|
||||
__serialize: (value: any) => value,
|
||||
__parseLiteral: (ast: any) => ast.value,
|
||||
},
|
||||
};
|
||||
25
models/graphql/typedef.ts
Normal file
25
models/graphql/typedef.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { gql } from "graphql-tag";
|
||||
|
||||
export const typeDefs = gql`
|
||||
scalar JSON
|
||||
|
||||
input AddTorrentInput {
|
||||
torrentToDownload: String!
|
||||
comicObjectId: ID!
|
||||
}
|
||||
|
||||
type AddTorrentResult {
|
||||
result: JSON
|
||||
}
|
||||
|
||||
type Query {
|
||||
_empty: String
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
"""
|
||||
Add a torrent to qBittorrent
|
||||
"""
|
||||
addTorrent(input: AddTorrentInput!): AddTorrentResult
|
||||
}
|
||||
`;
|
||||
Reference in New Issue
Block a user