blob: 6ea71acbbf2c3faebf28ceb4205fed747f98a66a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import { gql } from 'graphql-request';
import {
fetchHomePageReturn,
getHomePageReturn,
HomePage,
HomePageResponse,
} from '@ts/types/homepage';
import { getGraphQLClient } from './client';
export const fetchHomepage: fetchHomePageReturn = async () => {
const client = getGraphQLClient();
const query = gql`
query HomePage {
nodeByUri(uri: "/") {
... on Page {
id
content
}
}
}
`;
try {
const response: HomePageResponse = await client.request(query);
return response;
} catch (error) {
console.error(JSON.stringify(error, undefined, 2));
process.exit(1);
}
};
export const getHomePage: getHomePageReturn = async () => {
const rawHomePage = await fetchHomepage();
const homePage: HomePage = rawHomePage.nodeByUri;
return homePage;
};
|