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
3.8 KiB

{"ast":null,"code":"import _regeneratorRuntime from \"@babel/runtime/regenerator\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport config from \"../../config\";\nimport fetch from \"node-fetch\";\n\nvar GQLSSRClient = /*#__PURE__*/function () {\n function GQLSSRClient() {\n _classCallCheck(this, GQLSSRClient);\n }\n\n _createClass(GQLSSRClient, [{\n key: \"post\",\n value: function post(query, variables, operationName) {\n var res, json;\n return _regeneratorRuntime.async(function post$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return _regeneratorRuntime.awrap(fetch(config.apiUrl(\"/graphql\"), {\n method: \"POST\",\n body: JSON.stringify({\n query: query,\n variables: variables,\n operationName: operationName\n }),\n credentials: \"include\",\n headers: {\n \"Content-Type\": \"application/json\"\n }\n }));\n\n case 2:\n res = _context.sent;\n _context.next = 5;\n return _regeneratorRuntime.awrap(res.json());\n\n case 5:\n json = _context.sent;\n\n if (!json.errors) {\n _context.next = 8;\n break;\n }\n\n throw new Error(\"\".concat(json.errors[0].message, \" (\").concat(json.errors[0].path, \")\"));\n\n case 8:\n return _context.abrupt(\"return\", json.data);\n\n case 9:\n case \"end\":\n return _context.stop();\n }\n }\n }, null, null, null, Promise);\n }\n }]);\n\n return GQLSSRClient;\n}();\n\nvar gqlSsrClient = new GQLSSRClient();\nexport default gqlSsrClient;","map":{"version":3,"sources":["/data/projects/react/rpdata-frontend2/lib/client/graphql-ssr.ts"],"names":["config","fetch","GQLSSRClient","query","variables","operationName","apiUrl","method","body","JSON","stringify","credentials","headers","res","json","errors","Error","message","path","data","gqlSsrClient"],"mappings":";;;AAAA,OAAOA,MAAP,MAAmB,cAAnB;AAEA,OAAOC,KAAP,MAAkB,YAAlB;;IAEMC,Y;;;;;;;yBACOC,K,EAAeC,S,EAA+BC,a;;;;;;;+CACrCJ,KAAK,CAACD,MAAM,CAACM,MAAP,CAAc,UAAd,CAAD,EAA4B;AACjDC,gBAAAA,MAAM,EAAE,MADyC;AAEjDC,gBAAAA,IAAI,EAAEC,IAAI,CAACC,SAAL,CAAe;AAACP,kBAAAA,KAAK,EAALA,KAAD;AAAQC,kBAAAA,SAAS,EAATA,SAAR;AAAmBC,kBAAAA,aAAa,EAAbA;AAAnB,iBAAf,CAF2C;AAGjDM,gBAAAA,WAAW,EAAE,SAHoC;AAIjDC,gBAAAA,OAAO,EAAE;AACP,kCAAgB;AADT;AAJwC,eAA5B,C;;;AAAjBC,cAAAA,G;;+CASaA,GAAG,CAACC,IAAJ,E;;;AAAbA,cAAAA,I;;mBACFA,IAAI,CAACC,M;;;;;oBACD,IAAIC,KAAJ,WAAaF,IAAI,CAACC,MAAL,CAAY,CAAZ,EAAeE,OAA5B,eAAwCH,IAAI,CAACC,MAAL,CAAY,CAAZ,EAAeG,IAAvD,O;;;+CAGDJ,IAAI,CAACK,I;;;;;;;;;;;;;;AAIhB,IAAMC,YAAY,GAAG,IAAIlB,YAAJ,EAArB;AACA,eAAekB,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;"]},"metadata":{},"sourceType":"module"}