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/ts/types/comments.ts | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src/ts/types/comments.ts') diff --git a/src/ts/types/comments.ts b/src/ts/types/comments.ts index a1bb120..d5c0052 100644 --- a/src/ts/types/comments.ts +++ b/src/ts/types/comments.ts @@ -1,10 +1,14 @@ +//============================================================================== +// Comments query +//============================================================================== + export type CommentAuthor = { gravatarUrl: string; name: string; url: string; }; -export type CommentAuthorResponse = { +export type RawCommentAuthor = { node: CommentAuthor; }; @@ -19,14 +23,28 @@ export type Comment = { replies: Comment[]; }; -export type RawComment = Omit & { - author: CommentAuthorResponse; +export type RawComment = Omit & { + author: RawCommentAuthor; }; -export type CommentsResponse = { +export type CommentsNode = { nodes: RawComment[]; }; +//============================================================================== +// Comment mutations +//============================================================================== + +export type CommentData = { + author: string; + authorEmail: string; + authorUrl: string; + content: string; + parent: number; + commentOn: number; + mutationId: string; +}; + export type CreatedComment = { clientMutationId: string; success: boolean; @@ -35,16 +53,6 @@ export type CreatedComment = { }; }; -export type CreatedCommentResponse = { +export type CreateComment = { createComment: CreatedComment; }; - -export type CreatedCommentReturn = ( - author: string, - authorEmail: string, - authorUrl: string, - content: string, - parent: number, - commentOn: number, - mutationId: string -) => Promise; -- cgit v1.2.3