Second frontend, written in Next.JS + Typescript.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

26 lines
760 B

import config from "../../../config";
import { GQLClient, GQLRespone } from "./graphql";
import fetch from "node-fetch";
class GQLSSRClient implements GQLClient {
async post(query: string, variables?: {[x:string]: any}, operationName?: string): Promise<GQLRespone> {
const res = await fetch(config.apiUrl("/graphql"), {
method: "POST",
body: JSON.stringify({query, variables, operationName}),
credentials: "include",
headers: {
"Content-Type": "application/json",
},
});
const json = await res.json();
if (json.errors) {
throw new Error(`${json.errors[0].message} (${json.errors[0].path})`)
}
return json.data
}
}
const gqlSsrClient = new GQLSSRClient();
export default gqlSsrClient;