23 lines
562 B
TypeScript
23 lines
562 B
TypeScript
import { GraphQLClient } from "graphql-request"
|
|
|
|
import { env } from "@/env/server"
|
|
|
|
import { request as _request } from "./_request"
|
|
|
|
import type { DocumentNode } from "graphql"
|
|
|
|
import type { Data } from "@/types/request"
|
|
|
|
export async function edgeRequest<T>(
|
|
query: string | DocumentNode,
|
|
variables?: {},
|
|
params?: RequestInit
|
|
): Promise<Data<T>> {
|
|
// Creating a new client for each request to avoid conflicting parameters
|
|
const client = new GraphQLClient(env.CMS_URL, {
|
|
fetch: fetch,
|
|
})
|
|
|
|
return _request(client, query, variables, params)
|
|
}
|