
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 ;
}
