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.
 
 
 

1 lines
2.6 KiB

{"ast":null,"code":"import config from \"../../../config\";\nimport fetch from \"node-fetch\";\n\nclass GQLSSRClient {\n async post(query, variables, operationName) {\n const res = await fetch(config.apiUrl(\"/graphql\"), {\n method: \"POST\",\n body: JSON.stringify({\n query,\n variables,\n operationName\n }),\n credentials: \"include\",\n headers: {\n \"Content-Type\": \"application/json\"\n }\n });\n const json = await res.json();\n\n if (json.errors) {\n throw new Error(`${json.errors[0].message} (${json.errors[0].path})`);\n }\n\n return json.data;\n }\n\n}\n\nconst gqlSsrClient = new GQLSSRClient();\nexport default gqlSsrClient;","map":{"version":3,"sources":["/home/gisle/projects/react/rpdata-frontend2/src/lib/client/graphql-ssr.ts"],"names":["config","fetch","GQLSSRClient","post","query","variables","operationName","res","apiUrl","method","body","JSON","stringify","credentials","headers","json","errors","Error","message","path","data","gqlSsrClient"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;AAEA,OAAOC,KAAP,MAAkB,YAAlB;;AAEA,MAAMC,YAAN,CAAwC;AACtC,QAAMC,IAAN,CAAWC,KAAX,EAA0BC,SAA1B,EAAyDC,aAAzD,EAAsG;AACpG,UAAMC,GAAG,GAAG,MAAMN,KAAK,CAACD,MAAM,CAACQ,MAAP,CAAc,UAAd,CAAD,EAA4B;AACjDC,MAAAA,MAAM,EAAE,MADyC;AAEjDC,MAAAA,IAAI,EAAEC,IAAI,CAACC,SAAL,CAAe;AAACR,QAAAA,KAAD;AAAQC,QAAAA,SAAR;AAAmBC,QAAAA;AAAnB,OAAf,CAF2C;AAGjDO,MAAAA,WAAW,EAAE,SAHoC;AAIjDC,MAAAA,OAAO,EAAE;AACP,wBAAgB;AADT;AAJwC,KAA5B,CAAvB;AASA,UAAMC,IAAI,GAAG,MAAMR,GAAG,CAACQ,IAAJ,EAAnB;;AACA,QAAIA,IAAI,CAACC,MAAT,EAAiB;AACf,YAAM,IAAIC,KAAJ,CAAW,GAAEF,IAAI,CAACC,MAAL,CAAY,CAAZ,EAAeE,OAAQ,KAAIH,IAAI,CAACC,MAAL,CAAY,CAAZ,EAAeG,IAAK,GAA5D,CAAN;AACD;;AAED,WAAOJ,IAAI,CAACK,IAAZ;AACD;;AAjBqC;;AAoBxC,MAAMC,YAAY,GAAG,IAAInB,YAAJ,EAArB;AACA,eAAemB,YAAf","sourcesContent":["import config from \"../../../config\";\nimport { GQLClient, GQLRespone } from \"./graphql\";\nimport fetch from \"node-fetch\";\n\nclass GQLSSRClient implements GQLClient {\n async post(query: string, variables?: {[x:string]: any}, operationName?: string): Promise<GQLRespone> {\n const res = await fetch(config.apiUrl(\"/graphql\"), {\n method: \"POST\",\n body: JSON.stringify({query, variables, operationName}),\n credentials: \"include\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n const json = await res.json();\n if (json.errors) {\n throw new Error(`${json.errors[0].message} (${json.errors[0].path})`)\n }\n\n return json.data\n }\n}\n\nconst gqlSsrClient = new GQLSSRClient();\nexport default gqlSsrClient;\n"]},"metadata":{},"sourceType":"module"}