summaryrefslogtreecommitdiffstats
path: root/src/services/graphql/contact.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-08-20 21:39:51 +0200
committerArmand Philippot <git@armandphilippot.com>2022-08-20 21:39:51 +0200
commita0d00743cbbdb77b27c1a3d5711407ffed5befac (patch)
treef4caab160daf6b93c74d60ab93edd265c8edb158 /src/services/graphql/contact.ts
parent46b158bf9d2f7fa9cc253915151e0b53c052a444 (diff)
refactor(types): move and rename GraphQL types
The api file in services was not really readable. So I move the types and I also rewrite a little the fetch function. I also rename most of the type to avoid conflict with preexisting types (like Node) and to keep consistency.
Diffstat (limited to 'src/services/graphql/contact.ts')
-rw-r--r--src/services/graphql/contact.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/services/graphql/contact.ts b/src/services/graphql/contact.ts
index 00c6ca2..de078b9 100644
--- a/src/services/graphql/contact.ts
+++ b/src/services/graphql/contact.ts
@@ -1,4 +1,5 @@
-import { fetchAPI, getAPIUrl, SendMailVars } from './api';
+import { SendMailInput } from '@ts/types/graphql/mutations';
+import { fetchAPI } from './api';
import { sendMailMutation } from './contact.mutation';
export type SentEmail = {
@@ -12,12 +13,11 @@ export type SentEmail = {
/**
* Send an email using GraphQL API.
*
- * @param {sendMailVars} data - The mail data.
+ * @param {SendMailInput} data - The mail data.
* @returns {Promise<SentEmail>} The mutation response.
*/
-export const sendMail = async (data: SendMailVars): Promise<SentEmail> => {
+export const sendMail = async (data: SendMailInput): Promise<SentEmail> => {
const response = await fetchAPI<SentEmail, typeof sendMailMutation>({
- api: getAPIUrl(),
query: sendMailMutation,
variables: { ...data },
});