From 453b301e74e51cb9e3bfbf8a08ea7f155285f7e4 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 2 May 2022 15:48:18 -0700 Subject: [PATCH 1/2] Allow looking up articles by ID iOS needs to be able to lookup an article by its ID not its slug, because the slug can change once saved. --- packages/api/src/resolvers/article/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/api/src/resolvers/article/index.ts b/packages/api/src/resolvers/article/index.ts index d857cc31d..cc3847aaa 100644 --- a/packages/api/src/resolvers/article/index.ts +++ b/packages/api/src/resolvers/article/index.ts @@ -426,7 +426,9 @@ 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] } } From b649d583b79bae4c74be1a26269206ae8ec01520 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 2 May 2022 15:58:40 -0700 Subject: [PATCH 2/2] Linting changes --- packages/api/src/resolvers/article/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/api/src/resolvers/article/index.ts b/packages/api/src/resolvers/article/index.ts index cc3847aaa..984fc7299 100644 --- a/packages/api/src/resolvers/article/index.ts +++ b/packages/api/src/resolvers/article/index.ts @@ -427,7 +427,9 @@ export const getArticleResolver: ResolverFn< await createIntercomEvent('get-article', claims.uid) // 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 }) + const page = + (await getPageByParam({ userId: claims.uid, slug })) || + (await getPageByParam({ userId: claims.uid, _id: slug })) if (!page) { return { errorCodes: [ArticleErrorCode.NotFound] }