Merge pull request #3284 from omnivore-app/fix/highlights-in-update-since-api
return highlights in update since api response
This commit is contained in:
@ -15,12 +15,14 @@ import {
|
||||
import { env } from '../env'
|
||||
import {
|
||||
Article,
|
||||
Highlight,
|
||||
Label,
|
||||
PageType,
|
||||
Recommendation,
|
||||
SearchItem,
|
||||
User,
|
||||
} from '../generated/graphql'
|
||||
import { findHighlightsByLibraryItemId } from '../services/highlights'
|
||||
import { findLabelsByLibraryItemId } from '../services/labels'
|
||||
import { findRecommendationsByLibraryItemId } from '../services/recommendation'
|
||||
import { findUploadFileById } from '../services/upload_file'
|
||||
@ -119,6 +121,7 @@ import {
|
||||
updateFilterResolver,
|
||||
updateHighlightResolver,
|
||||
updateLabelResolver,
|
||||
updateNewsletterEmailResolver,
|
||||
// updateLinkShareInfoResolver,
|
||||
updatePageResolver,
|
||||
// updateReminderResolver,
|
||||
@ -131,7 +134,6 @@ import {
|
||||
validateUsernameResolver,
|
||||
webhookResolver,
|
||||
webhooksResolver,
|
||||
updateNewsletterEmailResolver,
|
||||
} from './index'
|
||||
import { markEmailAsItemResolver, recentEmailsResolver } from './recent_emails'
|
||||
import { recentSearchesResolver } from './recent_searches'
|
||||
@ -435,6 +437,23 @@ export const functionResolvers = {
|
||||
return recommendations.map(recommandationDataToRecommendation)
|
||||
}
|
||||
|
||||
return []
|
||||
},
|
||||
async highlights(
|
||||
item: {
|
||||
id: string
|
||||
highlights?: Highlight[]
|
||||
highlightAnnotations?: string[] | null
|
||||
},
|
||||
_: unknown,
|
||||
ctx: WithDataSourcesContext
|
||||
) {
|
||||
if (item.highlights) return item.highlights
|
||||
|
||||
if (item.highlightAnnotations && item.highlightAnnotations.length > 0) {
|
||||
return findHighlightsByLibraryItemId(item.id, ctx.uid)
|
||||
}
|
||||
|
||||
return []
|
||||
},
|
||||
},
|
||||
|
||||
@ -1961,6 +1961,9 @@ describe('Article API', () => {
|
||||
createdAt
|
||||
updatedAt
|
||||
pageType
|
||||
highlights {
|
||||
id
|
||||
}
|
||||
}
|
||||
itemID
|
||||
updateReason
|
||||
@ -2055,6 +2058,34 @@ describe('Article API', () => {
|
||||
expect(res.body.data.updatesSince.edges.length).to.eql(5)
|
||||
})
|
||||
})
|
||||
|
||||
context('returns highlights', () => {
|
||||
let highlight: Highlight
|
||||
|
||||
before(async () => {
|
||||
highlight = await createHighlight(
|
||||
{
|
||||
user,
|
||||
shortId: 'test short id',
|
||||
quote: 'test',
|
||||
libraryItem: items[0],
|
||||
},
|
||||
items[0].id,
|
||||
user.id
|
||||
)
|
||||
})
|
||||
|
||||
it('returns highlights', async () => {
|
||||
const res = await graphqlRequest(
|
||||
updatesSinceQuery(since),
|
||||
authToken
|
||||
).expect(200)
|
||||
|
||||
expect(res.body.data.updatesSince.edges[0].node.highlights[0].id).to.eq(
|
||||
highlight.id
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('BulkAction API', () => {
|
||||
|
||||
Reference in New Issue
Block a user