fix: exclude child comments related fields from comment edit mutation (#2391)

This commit is contained in:
soxa 2025-08-06 18:37:28 +02:00 committed by GitHub
parent 0781156305
commit e0ddba09a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 49 additions and 21 deletions

View File

@ -61,6 +61,52 @@ export const COMMENT_FIELDS = gql`
}
`
export const COMMENT_FIELDS_NO_CHILD_COMMENTS = gql`
${STREAK_FIELDS}
fragment CommentFieldsNoChildComments on Item {
id
position
parentId
createdAt
invoicePaidAt
deletedAt
text
user {
id
name
meMute
...StreakFields
}
sats
credits
meAnonSats @client
upvotes
freedFreebie
boost
meSats
meCredits
meDontLikeSats
meBookmark
meSubscription
outlawed
freebie
path
commentSats
commentCredits
mine
otsHash
imgproxyUrls
rel
apiKey
invoice {
id
actionState
confirmedAt
}
cost
}
`
export const COMMENTS_ITEM_EXT_FIELDS = gql`
${STREAK_FIELDS}
fragment CommentItemExtFields on Item {

View File

@ -1,5 +1,5 @@
import gql from 'graphql-tag'
import { COMMENTS } from './comments'
import { COMMENTS, COMMENT_FIELDS_NO_CHILD_COMMENTS } from './comments'
import { SUB_FULL_FIELDS } from './subs'
import { INVOICE_FIELDS } from './invoice'
@ -33,13 +33,13 @@ const ITEM_PAID_ACTION_FIELDS = gql`
}`
const ITEM_PAID_ACTION_FIELDS_NO_CHILD_COMMENTS = gql`
${COMMENTS}
${COMMENT_FIELDS_NO_CHILD_COMMENTS}
fragment ItemPaidActionFieldsNoChildComments on ItemPaidAction {
result {
id
deleteScheduledAt
reminderScheduledAt
...CommentFields
...CommentFieldsNoChildComments
}
}
`

View File

@ -323,24 +323,6 @@ function getClient (uri) {
}
}
},
nDirectComments: {
merge (existing, incoming, { variables, readField, toReference }) {
// if the item has new comments, don't merge the nDirectComments field
// preventing new comments not yet injected from being counted, thus causing bottomedOut
if (variables?.id && existing !== undefined) {
const item = toReference({
__typename: 'Item',
id: variables.id
})
const newComments = readField('newComments', item)
if (newComments?.length > 0) {
return existing
}
}
return incoming
}
},
newComments: {
read (newComments) {
return newComments || []