From fa6adedc42e9c6ec39cc30df16b54900c220b094 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 20 Dec 2021 00:15:20 +0100 Subject: refactor: rewrite types and services I was repeating myself a lot in services. So I rewrited the different functions to improve readability and I extracted some formatting functions to put them in utils. I also rewrited/reorganized some types to keep consistent names. --- src/services/graphql/homepage.ts | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 src/services/graphql/homepage.ts (limited to 'src/services/graphql/homepage.ts') diff --git a/src/services/graphql/homepage.ts b/src/services/graphql/homepage.ts deleted file mode 100644 index 6ea71ac..0000000 --- a/src/services/graphql/homepage.ts +++ /dev/null @@ -1,36 +0,0 @@ -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; -}; -- cgit v1.2.3