aboutsummaryrefslogtreecommitdiffstats
path: root/src/types/raw-data.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-11-24 20:00:08 +0100
committerArmand Philippot <git@armandphilippot.com>2023-11-27 14:47:51 +0100
commitf111685c5886f3e77edfd3621c98d8ac1b9bcce4 (patch)
tree62a541fe3afeb64bf745443706fbfb02e96c5230 /src/types/raw-data.ts
parentbee515641cb144be9a855ff2cac258d2fedab21d (diff)
refactor(services, types): reorganize GraphQL fetchers and data types
The Typescript mapped types was useful for autocompletion in fetchers but their are harder to maintain. I think it's better to keep each query close to its fetcher to have a better understanding of the fetched data. So I: * colocate queries with their own fetcher * colocate mutations with their own mutator * remove Typescript mapped types for queries and mutations * move data convertors inside graphql services * rename most of data types and fetchers
Diffstat (limited to 'src/types/raw-data.ts')
-rw-r--r--src/types/raw-data.ts111
1 files changed, 0 insertions, 111 deletions
diff --git a/src/types/raw-data.ts b/src/types/raw-data.ts
deleted file mode 100644
index 022016e..0000000
--- a/src/types/raw-data.ts
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Types for raw data coming from GraphQL API.
- */
-
-import { ContentKind } from './app';
-import { GraphQLNode, GraphQLPageInfo } from './graphql/generics';
-
-export type ACFPosts = {
- postsInThematic?: RawThematicPreview[];
- postsInTopic?: RawTopicPreview[];
-};
-
-export type ACFThematics = {
- postsInThematic: RawArticle[];
-};
-
-export type ACFTopics = {
- officialWebsite: string;
- postsInTopic: RawArticle[];
-};
-
-export type ContentParts = {
- afterMore: string;
- beforeMore: string;
-};
-
-export type Info = {
- wordsCount: number;
-};
-
-export type RawAuthor<T extends ContentKind> = {
- description?: T extends 'comment' ? never : string;
- gravatarUrl?: string;
- name: string;
- url?: string;
-};
-
-export type RawComment = {
- approved: boolean;
- author: GraphQLNode<RawAuthor<'comment'>>;
- content: string;
- databaseId: number;
- date: string;
- parentDatabaseId: number;
-};
-
-export type RawCommentsPage = {
- comments: RawComment[];
- hasNextPage: boolean;
- endCursor: string;
-};
-
-export type RawCover = {
- altText: string;
- mediaDetails: {
- width: number;
- height: number;
- };
- sourceUrl: string;
- title?: string;
-};
-
-export type RawArticle = RawPage & {
- acfPosts: ACFPosts;
- commentCount: number | null;
-};
-
-export type RawArticlePreview = Pick<
- RawArticle,
- 'databaseId' | 'date' | 'featuredImage' | 'slug' | 'title'
->;
-
-export type RawPage = {
- author?: GraphQLNode<RawAuthor<'page'>>;
- contentParts: ContentParts;
- databaseId: number;
- date: string;
- featuredImage: GraphQLNode<RawCover> | null;
- info: Info;
- modified: string;
- seo?: RawSEO;
- slug: string;
- title: string;
-};
-
-export type RawSEO = {
- metaDesc: string;
- title: string;
-};
-
-export type RawThematic = RawPage & {
- acfThematics: ACFThematics;
-};
-
-export type RawThematicPreview = Pick<
- RawThematic,
- 'databaseId' | 'featuredImage' | 'slug' | 'title'
->;
-
-export type RawTopic = RawPage & {
- acfTopics: ACFTopics;
-};
-
-export type RawTopicPreview = Pick<
- RawTopic,
- 'databaseId' | 'featuredImage' | 'slug' | 'title'
->;
-
-export type TotalItems = {
- pageInfo: Pick<GraphQLPageInfo, 'total'>;
-};