fix some fields not creating subfields

This commit is contained in:
DrakeTDL 2023-10-21 15:50:13 -07:00
parent f59e4d86f6
commit e9dfecdbbe
No known key found for this signature in database
5 changed files with 59 additions and 23 deletions

View File

@ -67,21 +67,21 @@ export const TextActivity = ({ operation, level }: Fields<OperationParser>) => (
},
/** The user who created the activity */
withUser(op?: { alias?: string; fn?: Fn<typeof User> }) {
operation.set({ alias: op?.alias, subField: "user", level })
operation.set({ alias: op?.alias, subField: "user", level, hasSubField: true })
if (op?.fn) op.fn(User({ operation, level: level + 1 }))
else User({ operation, level: level + 1 }).withId()
return this
},
/** The written replies to the activity */
withReplies(op?: { alias?: string; fn?: Fn<typeof ActivityReply> }) {
operation.set({ alias: op?.alias, subField: "replies", level })
operation.set({ alias: op?.alias, subField: "replies", level, hasSubField: true })
if (op?.fn) op.fn(ActivityReply({ operation, level: level + 1 }))
else ActivityReply({ operation, level: level + 1 }).withId()
return this
},
/** The users who liked the activity */
withLikes(op?: { alias?: string; fn?: Fn<typeof User> }) {
operation.set({ alias: op?.alias, subField: "likes", level })
operation.set({ alias: op?.alias, subField: "likes", level, hasSubField: true })
if (op?.fn) op.fn(User({ operation, level: level + 1 }))
else User({ operation, level: level + 1 }).withId()
return this
@ -156,28 +156,28 @@ export const ListActivity = ({ operation, level }: Fields<OperationParser>) => (
},
/** The owner of the activity */
withUser(op?: { alias?: string; fn?: Fn<typeof User> }) {
operation.set({ alias: op?.alias, subField: "user", level })
operation.set({ alias: op?.alias, subField: "user", level, hasSubField: true })
if (op?.fn) op.fn(User({ operation, level: level + 1 }))
else User({ operation, level: level + 1 }).withId()
return this
},
/** The associated media to the activity update */
withMedia(op?: { alias?: string; fn?: Fn<typeof Media> }) {
operation.set({ alias: op?.alias, subField: "media", level })
operation.set({ alias: op?.alias, subField: "media", level, hasSubField: true })
if (op?.fn) op.fn(Media({ operation, level: level + 1 }))
else Media({ operation, level: level + 1 }).withId()
return this
},
/** The written replies to the activity */
withReplies(op?: { alias?: string; fn?: Fn<typeof ActivityReply> }) {
operation.set({ alias: op?.alias, subField: "replies", level })
operation.set({ alias: op?.alias, subField: "replies", level, hasSubField: true })
if (op?.fn) op.fn(ActivityReply({ operation, level: level + 1 }))
else ActivityReply({ operation, level: level + 1 }).withId()
return this
},
/** The users who liked the activity */
withLikes(op?: { alias?: string; fn?: Fn<typeof User> }) {
operation.set({ alias: op?.alias, subField: "likes", level })
operation.set({ alias: op?.alias, subField: "likes", level, hasSubField: true })
if (op?.fn) op.fn(User({ operation, level: level + 1 }))
else User({ operation, level: level + 1 }).withId()
return this
@ -252,28 +252,28 @@ export const MessageActivity = ({ operation, level }: Fields<OperationParser>) =
},
/** The user who the activity message was sent to */
withRecipient(op?: { alias?: string; fn?: Fn<typeof User> }) {
operation.set({ alias: op?.alias, subField: "recipient", level })
operation.set({ alias: op?.alias, subField: "recipient", level, hasSubField: true })
if (op?.fn) op.fn(User({ operation, level: level + 1 }))
else User({ operation, level: level + 1 }).withId()
return this
},
/** The user who sent the activity message */
withMessenger(op?: { alias?: string; fn?: Fn<typeof User> }) {
operation.set({ alias: op?.alias, subField: "messenger", level })
operation.set({ alias: op?.alias, subField: "messenger", level, hasSubField: true })
if (op?.fn) op.fn(User({ operation, level: level + 1 }))
else User({ operation, level: level + 1 }).withId()
return this
},
/** The written replies to the activity */
withReplies(op?: { alias?: string; fn?: Fn<typeof ActivityReply> }) {
operation.set({ alias: op?.alias, subField: "replies", level })
operation.set({ alias: op?.alias, subField: "replies", level, hasSubField: true })
if (op?.fn) op.fn(ActivityReply({ operation, level: level + 1 }))
else ActivityReply({ operation, level: level + 1 }).withId()
return this
},
/** The users who liked the activity */
withLikes(op?: { alias?: string; fn?: Fn<typeof User> }) {
operation.set({ alias: op?.alias, subField: "likes", level })
operation.set({ alias: op?.alias, subField: "likes", level, hasSubField: true })
if (op?.fn) op.fn(User({ operation, level: level + 1 }))
else User({ operation, level: level + 1 }).withId()
return this

View File

@ -17,7 +17,13 @@ export const Favourites = ({ operation, level }: Fields<OperationParser>) => ({
withAnime(
op: { alias?: string; args?: AtLeastOne<FavouritesAnimeArgs>; fn: Fn<typeof MediaConnection> },
) {
operation.set({ alias: op.alias, subField: "anime", level, variables: op?.args })
operation.set({
alias: op.alias,
subField: "anime",
level,
variables: op?.args,
hasSubField: true,
})
op.fn(MediaConnection({ operation, level: level + 1 }))
return this
},
@ -25,7 +31,13 @@ export const Favourites = ({ operation, level }: Fields<OperationParser>) => ({
withManga(
op: { alias?: string; args?: AtLeastOne<FavouritesMangaArgs>; fn: Fn<typeof MediaConnection> },
) {
operation.set({ alias: op.alias, subField: "manga", level, variables: op?.args })
operation.set({
alias: op.alias,
subField: "manga",
level,
variables: op?.args,
hasSubField: true,
})
op.fn(MediaConnection({ operation, level: level + 1 }))
return this
},
@ -37,7 +49,13 @@ export const Favourites = ({ operation, level }: Fields<OperationParser>) => ({
fn: Fn<typeof CharacterConnection>
},
) {
operation.set({ alias: op.alias, subField: "characters", level, variables: op?.args })
operation.set({
alias: op.alias,
subField: "characters",
level,
variables: op?.args,
hasSubField: true,
})
op.fn(CharacterConnection({ operation, level: level + 1 }))
return this
},
@ -45,7 +63,13 @@ export const Favourites = ({ operation, level }: Fields<OperationParser>) => ({
withStaff(
op: { alias?: string; args?: AtLeastOne<FavouritesStaffArgs>; fn: Fn<typeof StaffConnection> },
) {
operation.set({ alias: op.alias, subField: "staff", level, variables: op?.args })
operation.set({
alias: op.alias,
subField: "staff",
level,
variables: op?.args,
hasSubField: true,
})
op.fn(StaffConnection({ operation, level: level + 1 }))
return this
},
@ -57,7 +81,13 @@ export const Favourites = ({ operation, level }: Fields<OperationParser>) => ({
fn: Fn<typeof StudioConnection>
},
) {
operation.set({ alias: op.alias, subField: "studios", level, variables: op?.args })
operation.set({
alias: op.alias,
subField: "studios",
level,
variables: op?.args,
hasSubField: true,
})
op.fn(StudioConnection({ operation, level: level + 1 }))
return this
},

View File

@ -44,13 +44,13 @@ export const MediaListOptions = ({ operation, level }: Fields<OperationParser>)
},
/** The user's anime list options */
withAnimeList(op: { alias?: string; fn: Fn<typeof MediaListTypeOptions> }) {
operation.set({ alias: op.alias, subField: "animeList", level })
operation.set({ alias: op.alias, subField: "animeList", level, hasSubField: true })
op.fn(MediaListTypeOptions({ operation, level: level + 1 }))
return this
},
/** The user's manga list options */
withMangaList(op: { alias?: string; fn: Fn<typeof MediaListTypeOptions> }) {
operation.set({ alias: op.alias, subField: "mangaList", level })
operation.set({ alias: op.alias, subField: "mangaList", level, hasSubField: true })
op.fn(MediaListTypeOptions({ operation, level: level + 1 }))
return this
},

View File

@ -124,7 +124,7 @@ export const Thread = ({ operation, level }: Fields<OperationParser>) => ({
},
/** The categories of the thread */
withCategories(op: { alias?: string; fn: Fn<typeof ThreadCategory> }) {
operation.set({ alias: op.alias, subField: "categories", level })
operation.set({ alias: op.alias, subField: "categories", level, hasSubField: true })
op.fn(ThreadCategory({ operation, level: level + 1 }))
return this
},

View File

@ -71,7 +71,7 @@ export const UserOptions = ({ operation, level }: Fields<OperationParser>) => ({
/** Notification options */
withNotificationOptions(op: { alias?: string; fn: Fn<typeof NotificationOption> }) {
operation.set({ alias: op.alias, subField: "notificationOptions", level })
operation.set({ alias: op.alias, subField: "notificationOptions", level, hasSubField: true })
op.fn(NotificationOption({ operation, level: level + 1 }))
return this
},
@ -170,19 +170,25 @@ export const User = ({ operation, level }: Fields<OperationParser>) => ({
},
/* The user's general options */
withOptions(op: { alias?: string; fn: Fn<typeof UserOptions> }) {
operation.set({ alias: op.alias, subField: "options", level })
operation.set({ alias: op.alias, subField: "options", level, hasSubField: true })
op.fn(UserOptions({ operation, level: level + 1 }))
return this
},
/* The user's media list options */
withMediaListOptions(op: { alias?: string; fn: Fn<typeof MediaListOptions> }) {
operation.set({ alias: op.alias, subField: "mediaListOptions", level })
operation.set({ alias: op.alias, subField: "mediaListOptions", level, hasSubField: true })
op.fn(MediaListOptions({ operation, level: level + 1 }))
return this
},
/* The users favourites */
withFavourites(op: { alias?: string; args?: UserFavouritesArgs; fn: Fn<typeof Favourites> }) {
operation.set({ alias: op.alias, subField: "favourites", level, variables: op?.args })
operation.set({
alias: op.alias,
subField: "favourites",
level,
variables: op?.args,
hasSubField: true,
})
op.fn(Favourites({ operation, level: level + 1 }))
return this
},