add Markdown query

closes #25
This commit is contained in:
DrakeTDL 2023-10-08 18:11:12 -07:00
parent 7829d95722
commit 66acfcc940
No known key found for this signature in database
1 changed files with 24 additions and 2 deletions

View File

@ -371,6 +371,13 @@ const UserAvatar = (query: ReturnType<typeof updateOperation>[], level: number)
return this
},
})
const Markdown = ({ query, level }: Fields<typeof updateOperation>) => ({
/** The parsed markdown as html */
withHtml() {
query[0] = query[0].set({ subField: "html", level })
return this
},
})
const AniChartUser = ({ query, level }: Fields<typeof updateOperation>) => ({
withUser(fn: Fn<typeof User>) {
query[0] = query[0].set({ subField: "user", level })
@ -2984,8 +2991,23 @@ export const Client = function (auth?: { token: string }) {
return this
},
/** Provide AniList markdown to be converted to html (Requires auth) */
Markdown() {
throw "To be Implemented"
Markdown(
args: {
/** The markdown to be parsed to html */
markdown: string
},
fn: (fields: ReturnType<typeof Markdown>) => void,
) {
operation = operation.set({
subField: "Markdown",
hasSubField: true,
variables: args,
level: 1,
})
let tmpQuery
fn(Markdown({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
return this
},
AniChartUser(fn: (fields: ReturnType<typeof AniChartUser>) => void) {
operation = operation.set({ subField: "AniChartUser", hasSubField: true, level: 1 })