diff --git a/fragments/comments.js b/fragments/comments.js index 43658c6a..3cbc7cc9 100644 --- a/fragments/comments.js +++ b/fragments/comments.js @@ -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 { diff --git a/fragments/paidAction.js b/fragments/paidAction.js index f5ccdea3..94c319fc 100644 --- a/fragments/paidAction.js +++ b/fragments/paidAction.js @@ -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 } } ` diff --git a/lib/apollo.js b/lib/apollo.js index 7cc81f6a..14d06f5e 100644 --- a/lib/apollo.js +++ b/lib/apollo.js @@ -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 || []