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.1 KiB

{"ast":null,"code":"import compress from \"gql-compress\";\n\nclass GQLBrowserClient {\n async post(query, variables, operationName) {\n const res = await fetch(`/api/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 console.log(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\nexport function gql(a) {\n return compress(a.join(\"\"));\n}\nconst gqlBrowserClient = new GQLBrowserClient();\nexport default gqlBrowserClient;","map":{"version":3,"sources":["/data/projects/react/rpdata-frontend2/lib/client/graphql.ts"],"names":["compress","GQLBrowserClient","post","query","variables","operationName","res","fetch","method","body","JSON","stringify","credentials","headers","json","console","log","errors","Error","message","path","data","gql","a","join","gqlBrowserClient"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,cAArB;;AAEA,MAAMC,gBAAN,CAA4C;AAC1C,QAAMC,IAAN,CAAWC,KAAX,EAA0BC,SAA1B,EAAyDC,aAAzD,EAAsG;AACpG,UAAMC,GAAG,GAAG,MAAMC,KAAK,CAAE,cAAF,EAAiB;AACtCC,MAAAA,MAAM,EAAE,MAD8B;AAEtCC,MAAAA,IAAI,EAAEC,IAAI,CAACC,SAAL,CAAe;AAACR,QAAAA,KAAD;AAAQC,QAAAA,SAAR;AAAmBC,QAAAA;AAAnB,OAAf,CAFgC;AAGtCO,MAAAA,WAAW,EAAE,SAHyB;AAItCC,MAAAA,OAAO,EAAE;AACP,wBAAgB;AADT;AAJ6B,KAAjB,CAAvB;AASA,UAAMC,IAAI,GAAG,MAAMR,GAAG,CAACQ,IAAJ,EAAnB;AACAC,IAAAA,OAAO,CAACC,GAAR,CAAYF,IAAZ;;AACA,QAAIA,IAAI,CAACG,MAAT,EAAiB;AACf,YAAM,IAAIC,KAAJ,CAAW,GAAEJ,IAAI,CAACG,MAAL,CAAY,CAAZ,EAAeE,OAAQ,KAAIL,IAAI,CAACG,MAAL,CAAY,CAAZ,EAAeG,IAAK,GAA5D,CAAN;AACD;;AAGD,WAAON,IAAI,CAACO,IAAZ;AACD;;AAnByC;;AAiC5C,OAAO,SAASC,GAAT,CAAaC,CAAb,EAA8C;AACnD,SAAOvB,QAAQ,CAACuB,CAAC,CAACC,IAAF,CAAO,EAAP,CAAD,CAAf;AACD;AAED,MAAMC,gBAAgB,GAAG,IAAIxB,gBAAJ,EAAzB;AACA,eAAewB,gBAAf","sourcesContent":["import compress from \"gql-compress\";\n\nclass GQLBrowserClient implements GQLClient {\n async post(query: string, variables?: {[x:string]: any}, operationName?: string): Promise<GQLRespone> {\n const res = await fetch(`/api/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 console.log(json)\n if (json.errors) {\n throw new Error(`${json.errors[0].message} (${json.errors[0].path})`)\n }\n\n\n return json.data\n }\n}\n\nexport interface GQLClient {\n post(query: string, variables?: {[x:string]: any}, operationName?: string): Promise<GQLRespone>\n}\n\nexport interface GQLRespone {[x:string]: any}\n\nexport interface GQLError {\n message: string\n path: string[]\n}\n\nexport function gql(a: TemplateStringsArray): string {\n return compress(a.join(\"\")) as string;\n}\n\nconst gqlBrowserClient = new GQLBrowserClient();\nexport default gqlBrowserClient;"]},"metadata":{},"sourceType":"module"}