improve graphql error handling
This commit is contained in:
@ -51,12 +51,14 @@ export async function generateStaticParams() {
|
|||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
const { data, error } = await getClient().query(allGenericSlugsQuery, {});
|
const { data, error } = await getClient().query(allGenericSlugsQuery, {});
|
||||||
|
if (error) {
|
||||||
if (data === undefined || error) {
|
throw new Error(error.message);
|
||||||
throw new Error("failed to generate static params");
|
}
|
||||||
|
if (!data?.pages) {
|
||||||
|
throw new Error("Failed to generate static params for generic subpages");
|
||||||
}
|
}
|
||||||
|
|
||||||
return data?.pages.map((page: any) => {
|
return data.pages.map((page: any) => {
|
||||||
// wagtail-grapple prepends the home page slug to the full path on multisite setups
|
// wagtail-grapple prepends the home page slug to the full path on multisite setups
|
||||||
// we also strip the trailing slash
|
// we also strip the trailing slash
|
||||||
const urlPath: string[] = page.urlPath
|
const urlPath: string[] = page.urlPath
|
||||||
@ -79,12 +81,14 @@ export async function generateMetadata(
|
|||||||
urlPath: urlPath,
|
urlPath: urlPath,
|
||||||
});
|
});
|
||||||
|
|
||||||
const page = (data?.page ?? []) as GenericFragment;
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
if (!page) {
|
}
|
||||||
|
if (!data?.page) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const page = data.page as GenericFragment;
|
||||||
const metadata = await getSeoMetadata(page, parent);
|
const metadata = await getSeoMetadata(page, parent);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
@ -95,13 +99,16 @@ export default async function Page({ params }: { params: { url: string[] } }) {
|
|||||||
const { data, error } = await getClient().query(genericPageByUrlPathQuery, {
|
const { data, error } = await getClient().query(genericPageByUrlPathQuery, {
|
||||||
urlPath: urlPath,
|
urlPath: urlPath,
|
||||||
});
|
});
|
||||||
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
|
||||||
const page = (data?.page ?? []) as GenericFragment;
|
if (!data?.page) {
|
||||||
|
|
||||||
if (!page) {
|
|
||||||
return notFound();
|
return notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const page = data?.page as GenericFragment;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
|
@ -30,11 +30,16 @@ export async function generateStaticParams() {
|
|||||||
`);
|
`);
|
||||||
const { data, error } = await getClient().query(allNewsSlugsQuery, {});
|
const { data, error } = await getClient().query(allNewsSlugsQuery, {});
|
||||||
|
|
||||||
if (data === undefined || error) {
|
if (error) {
|
||||||
throw new Error("failed to generate static params");
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.pages) {
|
||||||
|
throw new Error(
|
||||||
|
"Failed to generate static params for subpages of /aktuelt"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data?.pages.map((page: any) => ({
|
return data.pages.map((page: any) => ({
|
||||||
slug: page.slug,
|
slug: page.slug,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -46,12 +51,13 @@ export async function generateMetadata(
|
|||||||
const { data, error } = await getClient().query(newsBySlugQuery, {
|
const { data, error } = await getClient().query(newsBySlugQuery, {
|
||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
const news = (data?.news ?? []) as NewsFragment[];
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
if (!news) {
|
}
|
||||||
|
if (!data?.news) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const news = data.news as NewsFragment;
|
||||||
const metadata = await getSeoMetadata(news, parent);
|
const metadata = await getSeoMetadata(news, parent);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
@ -61,13 +67,15 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data?.news === null || error) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.news) {
|
||||||
return notFound();
|
return notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
const news = (data?.news ?? {}) as NewsFragment;
|
const news = data?.news as NewsFragment;
|
||||||
const featuredImage: any = news.featuredImage;
|
const featuredImage: any = news.featuredImage;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
<section className="news-header">
|
<section className="news-header">
|
||||||
|
@ -10,20 +10,25 @@ export async function generateMetadata(
|
|||||||
parent: ResolvingMetadata
|
parent: ResolvingMetadata
|
||||||
): Promise<Metadata | null> {
|
): Promise<Metadata | null> {
|
||||||
const { data, error } = await getClient().query(newsQuery, {});
|
const { data, error } = await getClient().query(newsQuery, {});
|
||||||
const index = (data?.index ?? []) as NewsIndexFragment;
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
if (!index) {
|
}
|
||||||
|
if (!data?.index) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const index = data.index as NewsIndexFragment;
|
||||||
const metadata = await getSeoMetadata(index, parent);
|
const metadata = await getSeoMetadata(index, parent);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const { data, error } = await getClient().query(newsQuery, {});
|
const { data, error } = await getClient().query(newsQuery, {});
|
||||||
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
const news = (data?.news ?? []) as NewsFragment[];
|
const news = (data?.news ?? []) as NewsFragment[];
|
||||||
const index = (data?.index ?? []) as NewsIndexFragment;
|
const index = data?.index as NewsIndexFragment;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
|
@ -31,11 +31,16 @@ export async function generateStaticParams() {
|
|||||||
`);
|
`);
|
||||||
const { data, error } = await getClient().query(allEventSlugsQuery, {});
|
const { data, error } = await getClient().query(allEventSlugsQuery, {});
|
||||||
|
|
||||||
if (data === undefined || error) {
|
if (error) {
|
||||||
throw new Error("failed to generate static params");
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.pages) {
|
||||||
|
throw new Error(
|
||||||
|
"Failed to generate static params for subpages of /arrangementer"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data?.pages.map((page: any) => ({
|
return data.pages.map((page: any) => ({
|
||||||
slug: page.slug,
|
slug: page.slug,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -47,12 +52,15 @@ export async function generateMetadata(
|
|||||||
const { data, error } = await getClient().query(eventBySlugQuery, {
|
const { data, error } = await getClient().query(eventBySlugQuery, {
|
||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
const event = (data?.event ?? []) as EventFragment[];
|
|
||||||
|
|
||||||
if (!event) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.event) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const event = data.event as EventFragment;
|
||||||
const metadata = await getSeoMetadata(event, parent);
|
const metadata = await getSeoMetadata(event, parent);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
@ -62,11 +70,14 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data?.event === null || error) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.event) {
|
||||||
return notFound();
|
return notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
const event = (data?.event ?? {}) as EventFragment;
|
const event = data.event as EventFragment;
|
||||||
const eventPig = getEventPig(event);
|
const eventPig = getEventPig(event);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -18,19 +18,35 @@ export async function generateMetadata(
|
|||||||
parent: ResolvingMetadata
|
parent: ResolvingMetadata
|
||||||
): Promise<Metadata | null> {
|
): Promise<Metadata | null> {
|
||||||
const { data, error } = await getClient().query(eventIndexMetadataQuery, {});
|
const { data, error } = await getClient().query(eventIndexMetadataQuery, {});
|
||||||
const index = (data?.index ?? []) as EventIndexFragment;
|
|
||||||
|
|
||||||
if (!index) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.index) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const index = data.index as EventIndexFragment;
|
||||||
const metadata = await getSeoMetadata(index, parent);
|
const metadata = await getSeoMetadata(index, parent);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const { data, error } = await getClient().query(eventsOverviewQuery, {});
|
const { data, error } = await getClient().query(eventsOverviewQuery, {});
|
||||||
const index = (data?.index ?? []) as EventIndexFragment;
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
!data?.index ||
|
||||||
|
!data?.events?.futureEvents ||
|
||||||
|
!data?.eventCategories ||
|
||||||
|
!data?.eventOrganizers ||
|
||||||
|
!data?.venues
|
||||||
|
) {
|
||||||
|
throw new Error("Failed to render /arrangementer");
|
||||||
|
}
|
||||||
|
|
||||||
|
const index = data?.index as EventIndexFragment;
|
||||||
const events = (data?.events?.futureEvents ?? []) as EventFragment[];
|
const events = (data?.events?.futureEvents ?? []) as EventFragment[];
|
||||||
const eventCategories = (data?.eventCategories ?? []) as EventCategory[];
|
const eventCategories = (data?.eventCategories ?? []) as EventCategory[];
|
||||||
const eventOrganizers = (data?.eventOrganizers ?? []) as EventOrganizer[];
|
const eventOrganizers = (data?.eventOrganizers ?? []) as EventOrganizer[];
|
||||||
|
@ -27,12 +27,15 @@ export async function generateMetadata(
|
|||||||
const { data, error } = await getClient().query(associationBySlugQuery, {
|
const { data, error } = await getClient().query(associationBySlugQuery, {
|
||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
const association = (data?.association ?? []) as AssociationFragment[];
|
|
||||||
|
|
||||||
if (!association) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.association) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const association = data.association as AssociationFragment;
|
||||||
const metadata = await getSeoMetadata(association, parent);
|
const metadata = await getSeoMetadata(association, parent);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
@ -48,11 +51,16 @@ export async function generateStaticParams() {
|
|||||||
`);
|
`);
|
||||||
const { data, error } = await getClient().query(allAssociationSlugsQuery, {});
|
const { data, error } = await getClient().query(allAssociationSlugsQuery, {});
|
||||||
|
|
||||||
if (data === undefined || error) {
|
if (error) {
|
||||||
throw new Error("failed to generate static params");
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.pages) {
|
||||||
|
throw new Error(
|
||||||
|
"Failed to generate static params for subpages of /foreninger"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data?.pages.map((page: any) => ({
|
return data.pages.map((page: any) => ({
|
||||||
slug: page.slug,
|
slug: page.slug,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -62,11 +70,14 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data?.association === null || error) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.association) {
|
||||||
return notFound();
|
return notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
const association = (data?.association ?? {}) as AssociationFragment;
|
const association = data.association as AssociationFragment;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
|
@ -30,12 +30,15 @@ export async function generateMetadata(
|
|||||||
parent: ResolvingMetadata
|
parent: ResolvingMetadata
|
||||||
): Promise<Metadata | null> {
|
): Promise<Metadata | null> {
|
||||||
const { data, error } = await getClient().query(allAssociationsQuery, {});
|
const { data, error } = await getClient().query(allAssociationsQuery, {});
|
||||||
const index = (data?.index ?? []) as AssociationIndexFragment;
|
|
||||||
|
|
||||||
if (!index) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.index) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const index = data.index as AssociationIndexFragment;
|
||||||
const metadata = await getSeoMetadata(index, parent);
|
const metadata = await getSeoMetadata(index, parent);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
@ -79,8 +82,16 @@ const AssociationFragmentDefinition = graphql(`
|
|||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const { data, error } = await getClient().query(allAssociationsQuery, {});
|
const { data, error } = await getClient().query(allAssociationsQuery, {});
|
||||||
const associations = (data?.associations ?? []) as AssociationFragment[];
|
|
||||||
const index = (data?.index ?? []) as AssociationIndexFragment;
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.associations || !data.index) {
|
||||||
|
throw new Error("Failed to render /foreninger");
|
||||||
|
}
|
||||||
|
|
||||||
|
const associations = data.associations as AssociationFragment[];
|
||||||
|
const index = data.index as AssociationIndexFragment;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Metadata, ResolvingMetadata } from "next";
|
import { Metadata, ResolvingMetadata } from "next";
|
||||||
|
import { notFound } from "next/navigation";
|
||||||
import { graphql } from "@/gql";
|
import { graphql } from "@/gql";
|
||||||
import { ContactIndexFragment } from "@/gql/graphql";
|
import { ContactIndexFragment } from "@/gql/graphql";
|
||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
@ -36,19 +37,30 @@ export async function generateMetadata(
|
|||||||
parent: ResolvingMetadata
|
parent: ResolvingMetadata
|
||||||
): Promise<Metadata | null> {
|
): Promise<Metadata | null> {
|
||||||
const { data, error } = await getClient().query(contactQuery, {});
|
const { data, error } = await getClient().query(contactQuery, {});
|
||||||
const index = (data?.index ?? []) as ContactIndexFragment;
|
|
||||||
|
|
||||||
if (!index) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.index) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const index = data.index as ContactIndexFragment;
|
||||||
const metadata = await getSeoMetadata(index, parent);
|
const metadata = await getSeoMetadata(index, parent);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const { data, error } = await getClient().query(contactQuery, {});
|
const { data, error } = await getClient().query(contactQuery, {});
|
||||||
const index = (data?.index ?? []) as ContactIndexFragment;
|
|
||||||
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.index) {
|
||||||
|
return notFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
const index = data.index as ContactIndexFragment;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
|
@ -27,12 +27,15 @@ export async function generateMetadata(
|
|||||||
const { data, error } = await getClient().query(venueBySlugQuery, {
|
const { data, error } = await getClient().query(venueBySlugQuery, {
|
||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
const venue = (data?.venue ?? []) as VenueFragment[];
|
|
||||||
|
|
||||||
if (!venue) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.venue) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const venue = data.venue as VenueFragment;
|
||||||
const metadata = await getSeoMetadata(venue, parent);
|
const metadata = await getSeoMetadata(venue, parent);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
@ -48,11 +51,16 @@ export async function generateStaticParams() {
|
|||||||
`);
|
`);
|
||||||
const { data, error } = await getClient().query(allVenueSlugsQuery, {});
|
const { data, error } = await getClient().query(allVenueSlugsQuery, {});
|
||||||
|
|
||||||
if (data === undefined || error) {
|
if (error) {
|
||||||
throw new Error("failed to generate static params");
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.pages) {
|
||||||
|
throw new Error(
|
||||||
|
"Failed to generate static params for subpages of /lokaler"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data?.pages.map((page: any) => ({
|
return data.pages.map((page: any) => ({
|
||||||
slug: page.slug,
|
slug: page.slug,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -62,11 +70,14 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data?.venue === null || error) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.venue) {
|
||||||
return notFound();
|
return notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
const venue = (data?.venue ?? {}) as VenueFragment;
|
const venue = data.venue as VenueFragment;
|
||||||
const featuredImage: any = venue.featuredImage;
|
const featuredImage: any = venue.featuredImage;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -74,19 +74,30 @@ export async function generateMetadata(
|
|||||||
parent: ResolvingMetadata
|
parent: ResolvingMetadata
|
||||||
): Promise<Metadata | null> {
|
): Promise<Metadata | null> {
|
||||||
const { data, error } = await getClient().query(venueIndexQuery, {});
|
const { data, error } = await getClient().query(venueIndexQuery, {});
|
||||||
const index = (data?.index ?? []) as VenueIndexFragment;
|
|
||||||
|
|
||||||
if (!index) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.index) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const index = (data?.index ?? []) as VenueIndexFragment;
|
||||||
const metadata = await getSeoMetadata(index, parent);
|
const metadata = await getSeoMetadata(index, parent);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const { data, error } = await getClient().query(venueIndexQuery, {});
|
const { data, error } = await getClient().query(venueIndexQuery, {});
|
||||||
const index = (data?.index ?? []) as VenueIndexFragment;
|
|
||||||
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.index || !data?.venues) {
|
||||||
|
throw new Error("Failed to render /lokaler");
|
||||||
|
}
|
||||||
|
|
||||||
|
const index = data.index as VenueIndexFragment;
|
||||||
const venues = (data?.venues ?? []) as VenueFragment[];
|
const venues = (data?.venues ?? []) as VenueFragment[];
|
||||||
const visibleVenues = venues.filter((x) => x.showInOverview);
|
const visibleVenues = venues.filter((x) => x.showInOverview);
|
||||||
|
|
||||||
|
@ -42,19 +42,30 @@ export async function generateMetadata(
|
|||||||
parent: ResolvingMetadata
|
parent: ResolvingMetadata
|
||||||
): Promise<Metadata | null> {
|
): Promise<Metadata | null> {
|
||||||
const { data, error } = await getClient().query(venueRentalIndexQuery, {});
|
const { data, error } = await getClient().query(venueRentalIndexQuery, {});
|
||||||
const index = (data?.index ?? []) as VenueRentalIndexFragment;
|
|
||||||
|
|
||||||
if (!index) {
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.index) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const index = data.index as VenueRentalIndexFragment;
|
||||||
const metadata = await getSeoMetadata(index, parent);
|
const metadata = await getSeoMetadata(index, parent);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const { data, error } = await getClient().query(venueRentalIndexQuery, {});
|
const { data, error } = await getClient().query(venueRentalIndexQuery, {});
|
||||||
const index = (data?.index ?? []) as VenueRentalIndexFragment;
|
|
||||||
|
if (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
if (!data?.index || !data?.venues) {
|
||||||
|
throw new Error("Failed to render /utleie");
|
||||||
|
}
|
||||||
|
|
||||||
|
const index = data.index as VenueRentalIndexFragment;
|
||||||
const venues = (data?.venues ?? []) as VenueFragment[];
|
const venues = (data?.venues ?? []) as VenueFragment[];
|
||||||
const bookableVenues = venues.filter((venue) => venue.showAsBookable);
|
const bookableVenues = venues.filter((venue) => venue.showAsBookable);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user