Merge pull request #2636 from omnivore-app/fix/web-article-fetch-error

Better handling of article fetch errors
This commit is contained in:
Jackson Harper 2023-08-10 16:52:23 +08:00 committed by GitHub
commit 1801e09884
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,11 @@
import { gql } from 'graphql-request'
import useSWRImmutable, { Cache } from 'swr'
import { gqlFetcher, makeGqlFetcher, RequestContext, ssrFetcher } from "../networkHelpers"
import {
gqlFetcher,
makeGqlFetcher,
RequestContext,
ssrFetcher,
} from '../networkHelpers'
import {
articleFragment,
ContentReader,
@ -130,14 +135,13 @@ export function useGetArticleQuery({
mutate: mutate,
articleData: resultData,
isLoading: !error && !data,
articleFetchError: resultError ? (resultError as string[]) : null,
articleFetchError: resultError ? Array(resultError) : null,
}
}
export async function articleQuery(
input: ArticleQueryInput
): Promise<ArticleAttributes | undefined> {
const result = (await gqlFetcher(query, input)) as ArticleData
if (result.article) {
return result.article.article