add more examples
This commit is contained in:
parent
e396f024a5
commit
319be15c31
|
@ -0,0 +1,24 @@
|
|||
import { Client } from "../mod.ts"
|
||||
import { MediaType } from "../src/types/generated/graphql.ts"
|
||||
|
||||
const query = Client().query.Media({ type: MediaType.Anime, search: "Kamisama Ni Natta Hi" })
|
||||
|
||||
console.log(query.raw.get())
|
||||
/*
|
||||
query {
|
||||
Media(type: ANIME, search: "Kamisama Ni Natta Hi") {
|
||||
id
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
console.log(await query.fetch())
|
||||
/*
|
||||
{
|
||||
data: {
|
||||
Media: {
|
||||
id: 118419,
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,15 @@
|
|||
import { Client } from "../mod.ts"
|
||||
|
||||
const page = Client().query.Page(
|
||||
{ perPage: 1 },
|
||||
(page) =>
|
||||
page.withMedia(
|
||||
{ search: "Kamisama Ni Natta" },
|
||||
(media) =>
|
||||
media.withTitle(
|
||||
(title) => title.userPreferred(),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
console.log(await page.fetch())
|
|
@ -0,0 +1,44 @@
|
|||
import { Client } from "../mod.ts"
|
||||
import { MediaType } from "../src/types/generated/graphql.ts"
|
||||
|
||||
const query = Client().query.Page(
|
||||
{ perPage: 1 },
|
||||
(page) =>
|
||||
page.withMedia(
|
||||
{ type: MediaType.Anime },
|
||||
(media) =>
|
||||
media.withTitle(
|
||||
(title) => title.userPreferred(),
|
||||
).withId().withDescription(),
|
||||
),
|
||||
)
|
||||
|
||||
console.log(query.raw.get()) /*
|
||||
query {
|
||||
Page(perPage: 1) {
|
||||
media(type: ANIME) {
|
||||
title {
|
||||
userPreferred
|
||||
},
|
||||
id,
|
||||
description
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
const data = await query.fetch()
|
||||
|
||||
console.log(data)
|
||||
/*
|
||||
{
|
||||
media: [
|
||||
{
|
||||
title: { romaji: 'Cowboy Bebop' },
|
||||
id: 1,
|
||||
description: 'Enter a world in the distant future, where Bounty Hunters roam the solar system. Spike and Jet, bounty hunting partners, set out on journeys in an ever struggling effort to win bounty rewards to survive.<br><br>\n' +
|
||||
'While traveling, they meet up with other very interesting people. Could Faye, the beautiful and ridiculously poor gambler, Edward, the computer genius, and Ein, the engineered dog be a good addition to the group?'
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
Loading…
Reference in New Issue