aboutsummaryrefslogtreecommitdiffstats
path: root/src/types/graphql/queries.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-09-19 18:13:57 +0200
committerArmand Philippot <git@armandphilippot.com>2023-09-19 19:12:31 +0200
commit2faf2e34331703b3bdea3eb487cb8799c8d65377 (patch)
treededc6557ddaa8fedd42d9bdf77950f8f9168ebcb /src/types/graphql/queries.ts
parentd1fe9e2164fc5c8fd767b456eecc2a4eb929a33f (diff)
refactor(build): replace paths aliases with relative paths
Using paths aliases starting with "@" can be confusing and can lead to conflict with existings modules. I prefer to use relative paths to avoid extra configuration in tools because of these aliases.
Diffstat (limited to 'src/types/graphql/queries.ts')
-rw-r--r--src/types/graphql/queries.ts147
1 files changed, 147 insertions, 0 deletions
diff --git a/src/types/graphql/queries.ts b/src/types/graphql/queries.ts
new file mode 100644
index 0000000..fceae30
--- /dev/null
+++ b/src/types/graphql/queries.ts
@@ -0,0 +1,147 @@
+import {
+ articleBySlugQuery,
+ articlesCardQuery,
+ articlesEndCursorQuery,
+ articlesQuery,
+ articlesSlugQuery,
+ totalArticlesQuery,
+} from '../../services/graphql/articles.query';
+import { commentsQuery } from '../../services/graphql/comments.query';
+import {
+ thematicBySlugQuery,
+ thematicsListQuery,
+ thematicsSlugQuery,
+ totalThematicsQuery,
+} from '../../services/graphql/thematics.query';
+import {
+ topicBySlugQuery,
+ topicsListQuery,
+ topicsSlugQuery,
+ totalTopicsQuery,
+} from '../../services/graphql/topics.query';
+import { Slug } from '../app';
+import { RawComment } from '../raw-data';
+import {
+ GraphQLEdges,
+ GraphQLEdgesInput,
+ GraphQLNodes,
+ GraphQLPageInfo,
+} from './generics';
+
+//===========================================================================
+// Existing queries list
+//===========================================================================
+
+export type Queries =
+ | typeof articlesQuery
+ | typeof articleBySlugQuery
+ | typeof articlesCardQuery
+ | typeof articlesEndCursorQuery
+ | typeof articlesSlugQuery
+ | typeof commentsQuery
+ | typeof thematicBySlugQuery
+ | typeof thematicsListQuery
+ | typeof thematicsSlugQuery
+ | typeof topicBySlugQuery
+ | typeof topicsListQuery
+ | typeof topicsSlugQuery
+ | typeof totalArticlesQuery
+ | typeof totalThematicsQuery
+ | typeof totalTopicsQuery;
+
+//===========================================================================
+// Queries response types
+//===========================================================================
+
+export type ArticleResponse<T> = {
+ post: T;
+};
+
+export type ArticlesResponse<T> = {
+ posts: T;
+};
+
+export type CommentsResponse<T> = {
+ comments: T;
+};
+
+export type ThematicResponse<T> = {
+ thematic: T;
+};
+
+export type ThematicsResponse<T> = {
+ thematics: T;
+};
+
+export type TopicResponse<T> = {
+ topic: T;
+};
+
+export type TopicsResponse<T> = {
+ topics: T;
+};
+
+export type EdgesResponse<T> = {
+ edges: GraphQLEdges<T>[];
+ pageInfo: GraphQLPageInfo;
+};
+
+export type EndCursorResponse = {
+ pageInfo: Pick<GraphQLPageInfo, 'endCursor'>;
+};
+
+export type QueriesResponseMap<T> = {
+ [articleBySlugQuery]: ArticleResponse<T>;
+ [articlesCardQuery]: ArticlesResponse<GraphQLNodes<T>>;
+ [articlesEndCursorQuery]: ArticlesResponse<EndCursorResponse>;
+ [articlesQuery]: ArticlesResponse<EdgesResponse<T>>;
+ [articlesSlugQuery]: ArticlesResponse<EdgesResponse<T>>;
+ [commentsQuery]: CommentsResponse<EdgesResponse<T>>;
+ [thematicBySlugQuery]: ThematicResponse<T>;
+ [thematicsListQuery]: ThematicsResponse<EdgesResponse<T>>;
+ [thematicsSlugQuery]: ThematicsResponse<EdgesResponse<T>>;
+ [topicBySlugQuery]: TopicResponse<T>;
+ [topicsListQuery]: TopicsResponse<EdgesResponse<T>>;
+ [topicsSlugQuery]: TopicsResponse<EdgesResponse<T>>;
+ [totalArticlesQuery]: ArticlesResponse<T>;
+ [totalThematicsQuery]: ThematicsResponse<T>;
+ [totalTopicsQuery]: TopicsResponse<T>;
+};
+
+//===========================================================================
+// Queries input types
+//===========================================================================
+
+export type QueryEdges = Pick<GraphQLEdgesInput, 'after' | 'first'>;
+
+export type ContentId = {
+ contentId: number;
+};
+
+export type Search = {
+ search?: string;
+};
+
+export type QueriesInputMap = {
+ [articleBySlugQuery]: Slug;
+ [articlesCardQuery]: QueryEdges & Search;
+ [articlesEndCursorQuery]: QueryEdges & Search;
+ [articlesQuery]: QueryEdges & Search;
+ [articlesSlugQuery]: QueryEdges & Search;
+ [commentsQuery]: ContentId & QueryEdges;
+ [thematicBySlugQuery]: Slug;
+ [thematicsListQuery]: QueryEdges & Search;
+ [thematicsSlugQuery]: QueryEdges & Search;
+ [topicBySlugQuery]: Slug;
+ [topicsListQuery]: QueryEdges & Search;
+ [topicsSlugQuery]: QueryEdges & Search;
+ [totalArticlesQuery]: Search;
+ [totalThematicsQuery]: null;
+ [totalTopicsQuery]: null;
+};
+
+export type CommentPage = {
+ comments: RawComment[];
+ hasNextPage: boolean;
+ endCursor: string;
+};