add a function_resolver to return originalArticleUrl from article.url (#317)

* add a function_resolver to return originalArticleUrl from article.url

* add a test
This commit is contained in:
Hongbo Wu
2022-03-25 11:25:30 +08:00
committed by GitHub
parent 134264940f
commit e7203bebb5
2 changed files with 15 additions and 1 deletions

View File

@ -306,6 +306,9 @@ export const functionResolvers = {
}
return article.url
},
async originalArticleUrl(article: { url: string }) {
return article.url
},
async savedByViewer(
article: { id: string; savedByViewer?: boolean },
__: unknown,

View File

@ -104,6 +104,7 @@ const articlesQuery = (after = '', order = 'ASCENDING') => {
id
url
linkId
originalArticleUrl
labels {
id
name
@ -360,6 +361,8 @@ describe('Article API', () => {
})
describe('GetArticles', () => {
const url = 'https://blog.omnivore.app/p/getting-started-with-omnivore'
let query = ''
let after = ''
let pages: Page[] = []
@ -380,7 +383,7 @@ describe('Article API', () => {
updatedAt: new Date(),
readingProgressPercent: 100,
readingProgressAnchorIndex: 0,
url: 'https://blog.omnivore.app/p/getting-started-with-omnivore',
url: url,
savedAt: new Date(),
} as Page
const pageId = await createPage(page, ctx)
@ -406,6 +409,14 @@ describe('Article API', () => {
query = articlesQuery(after)
})
it('should return originalArticleUrl', async () => {
const res = await graphqlRequest(query, authToken).expect(200)
expect(res.body.data.articles.edges[0].node.originalArticleUrl).to.eql(
url
)
})
context('when there are pages with labels', () => {
before(() => {
// get the last page