diff options
| author | Armand Philippot <git@armandphilippot.com> | 2021-12-20 00:15:20 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2021-12-20 00:15:20 +0100 |
| commit | fa6adedc42e9c6ec39cc30df16b54900c220b094 (patch) | |
| tree | 6bb498beadaa382245cecb86ce56931580313c6f /src/services/graphql/contact.ts | |
| parent | 2ff898626c5c0abc6b8195224067b992403e313b (diff) | |
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.
Diffstat (limited to 'src/services/graphql/contact.ts')
| -rw-r--r-- | src/services/graphql/contact.ts | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/services/graphql/contact.ts b/src/services/graphql/contact.ts deleted file mode 100644 index 4699688..0000000 --- a/src/services/graphql/contact.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { SendMailReturn, SentEmailResponse } from '@ts/types/contact'; -import { gql } from 'graphql-request'; -import { getGraphQLClient } from './client'; - -export const sendMail: SendMailReturn = async ( - subject: string, - body: string, - replyTo: string, - mutationId: string -) => { - const client = getGraphQLClient(); - const mutation = gql` - mutation SendEmail( - $subject: String! - $body: String! - $replyTo: String! - $mutationId: String! - ) { - sendEmail( - input: { - clientMutationId: $mutationId - body: $body - replyTo: $replyTo - subject: $subject - } - ) { - clientMutationId - message - sent - origin - replyTo - to - } - } - `; - - const variables = { subject, body, replyTo, mutationId }; - - try { - const response: SentEmailResponse = await client.request( - mutation, - variables - ); - return response.sendEmail; - } catch (error) { - console.error(error, undefined, 2); - process.exit(1); - } -}; |
