Merge pull request #529 from omnivore-app/feature/lookup-article-by-id

Allow looking up articles by ID
This commit is contained in:
Jackson Harper 2022-05-02 20:59:09 -07:00 committed by GitHub
commit daa60d55ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -426,7 +426,11 @@ export const getArticleResolver: ResolverFn<
})
await createIntercomEvent('get-article', claims.uid)
const page = await getPageByParam({ userId: claims.uid, slug })
// We allow the backend to use the ID instead of a slug to fetch the article
const page =
(await getPageByParam({ userId: claims.uid, slug })) ||
(await getPageByParam({ userId: claims.uid, _id: slug }))
if (!page) {
return { errorCodes: [ArticleErrorCode.NotFound] }
}