import { useQuery } from "urql"; import { GetFeedsDocument } from "../graphql/generated/graphql"; import { FeedItem } from "./FeedItem"; interface Props { onFeedUnsubscribed?: () => void; } const urqlContextFeed = { additionalTypenames: ["Feed"] }; export function FeedList({ onFeedUnsubscribed }: Props) { const [{ data, fetching, error }] = useQuery({ query: GetFeedsDocument, context: urqlContextFeed, }); if (fetching) { return
Loading feeds...
; } if (error) { return
Error: {error.message}
; } if (!data?.feeds || data.feeds.length === 0) { return
No feeds added yet.
; } return (
{data.feeds.map((feed) => ( ))}
); }