Tag: astro
-
How to handle dynamic routes, non existing pages and no existing data from GraphQL request in Astro project
-2 How do I solve the following issue in my Astro project: I can request the page content data for various pages from my GraphQL endpoint. I am using Apollo Client for this. Using the following query as an example: query Page($target: String!) { page(target: $target) { id type content { …on PageOne { id…
-
Apollo Client GraphQL error is lost / undefined after second time loading the page (refreshing the browser)
0 I am using Apollo Client in my Astro project. I have the following GraphQL query: const { data, loading, errors } = await client.query({ query: GET_PAGE, variables: { url: uri, }, errorPolicy: ‘all’, }); Also I defined my errorLink, based on the Apollo docs: const errorLink = onError(({ graphQLErrors, networkError }) => { if…
-
Astro dynamic routing (SSR mode) and 404 page
0 I am using Astro and Apollo client to fetch data using GraphQL. In Astro I am using SSR only. I have set up the following Astro dynamic routing (SSR mode): // […slug].astro — import Page from ‘../components/page/Page.astro’; import Layout from ‘../layouts/Layout.astro’; — <Layout title="Test"> <Page /> </Layout> And Page.astro: // Page.astro — import PageOne…
-
Conditionally render an Astro component based on page type query
0 I am using Astro, GraphQL (Apollo Client), Typescript and React. In my dynamic route: […slug].astro file I need to conditionally render a certain Astro component. I managed to that with: {data.page.type === ‘PageOneType’ && <PageOne />} {data.page.type === ‘PageTwoType’ && <PageTwo />} Can I somehow make this more dynamic, so I don’t have to…
-
How to show Astro component based on a certain field and map the correct data and Astro component in the dynamic slug page
0 I am using Astro, GraphQL (Apollo Client), Typescript and React. For now I think don’t need React yet. I have a dynamic route: […slug].astro I have the following query: export default gql` query Page($pageTarget: String!) { page(pageTarget: $pageTarget) { type content { … on PageOne { id title } … on PageTwo { id…
-
Set up dynamic routes in Astro with GraphQL fragments query doesn’t work
0 I am trying to setup dynamic routes in Astro SSR mode. From the api I can use the following query (it contains fragments): I am using Apollo Client. const GET_PAGE = gql` query Page($target: String!) { page(target: $target) { type content { … on PageOne { url: anotherKey title: anotherTitleField id } … on…
-
Set up dynamic routes in Astro SSR mode
0 I try to create dynamic routes in astro SSR mode. I am using Apollo client. I have this grapql query from the api: const GET_PAGE = gql` query Page($target: String!) { page(target: $target) { type content { … on MyPage { id url } } } } `; So based on the target variable…