diff --git a/src/utils/graphql/index.jsx b/src/utils/graphql/index.jsx new file mode 100644 index 0000000..978d228 --- /dev/null +++ b/src/utils/graphql/index.jsx @@ -0,0 +1,25 @@ + +export default async function graphql(query = '', variables = {}, token = '',) { + + const response = await fetch(`https://api.adhorizonintl.com/graphql`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` + }, + body: JSON.stringify({ + query, + variables, + }), + cache:"no-store" + }); + + const json = await response.json(); + + if (json.errors) { + console.error(json.errors); + throw new Error('Failed to fetch GraphQL data'); + } + + return json.data ; +}