|
@@ -0,0 +1,26 @@
|
|
|
+async function gql(url, query, variables={}) {
|
|
|
+ try {
|
|
|
+ let response = fetch(url, {
|
|
|
+ method: 'POST',
|
|
|
+ headers: {
|
|
|
+ 'content-type': 'application/json'
|
|
|
+ },
|
|
|
+ body: JSON.stringify({query, variables})
|
|
|
+ })
|
|
|
+ let data = (await response).json()
|
|
|
+ return data
|
|
|
+ } catch(e) {
|
|
|
+ console.warn('Some error: ', e)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//в консоль
|
|
|
+(async () => {
|
|
|
+ console.log(await gql(`http://shop-roles.asmer.fs.a-level.com.ua/graphql`, `query cats{
|
|
|
+ CategoryFind(query:"[{}]"){
|
|
|
+ name goods{
|
|
|
+ name
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }`))
|
|
|
+})()
|