|
@@ -0,0 +1,116 @@
|
|
|
|
+<!DOCTYPE html>
|
|
|
|
+<html lang="en">
|
|
|
|
+
|
|
|
|
+<head>
|
|
|
|
+ <meta charset="UTF-8">
|
|
|
|
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
+ <title>Document</title>
|
|
|
|
+</head>
|
|
|
|
+
|
|
|
|
+<body>
|
|
|
|
+ <script>
|
|
|
|
+ const URLbeck = "http://shop-roles.node.ed.asmer.org.ua/graphql";
|
|
|
|
+
|
|
|
|
+ let gql = (url, query, variables = {}) =>
|
|
|
|
+ fetch(url, {
|
|
|
|
+ method: 'POST',
|
|
|
|
+ headers: {
|
|
|
|
+ Accept: 'application/json',
|
|
|
|
+ "Content-Type": 'application/json'
|
|
|
|
+ },
|
|
|
|
+ body: JSON.stringify({ query, variables })
|
|
|
|
+ }).then((res) => res.json())
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ const categoryFind = () =>
|
|
|
|
+ gql(
|
|
|
|
+ URLbeck,
|
|
|
|
+ `
|
|
|
|
+ query cadz{
|
|
|
|
+ CategoryFind(query:"[{}]") {
|
|
|
|
+ _id name
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ `
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ const categoryId = () =>
|
|
|
|
+ gql(
|
|
|
|
+ URLbeck,
|
|
|
|
+ `
|
|
|
|
+ query categotyId {
|
|
|
|
+ CategoryFind(query:"[{}]"){
|
|
|
|
+ _id name
|
|
|
|
+ goods{
|
|
|
|
+ _id name
|
|
|
|
+ price createdAt
|
|
|
|
+ description
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ `
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ const categoryIdImagesDescription = (id) =>{
|
|
|
|
+ let SearchId = `\\"_id\\":\\"${id}\\"`
|
|
|
|
+ return gql(
|
|
|
|
+ URLbeck,
|
|
|
|
+ `
|
|
|
|
+ query categoryIdImagesDescription{
|
|
|
|
+ GoodFind(query:"[{${SearchId}}]"){
|
|
|
|
+ name description
|
|
|
|
+ images{
|
|
|
|
+ _id
|
|
|
|
+ url
|
|
|
|
+ text
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ `
|
|
|
|
+
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const gqlLogin = (login, password) =>
|
|
|
|
+ gql(
|
|
|
|
+ URLbeck,
|
|
|
|
+ `
|
|
|
|
+ query login($login:String, $password: String){
|
|
|
|
+ login(login:$login, password: $password)
|
|
|
|
+ }
|
|
|
|
+ `,
|
|
|
|
+ { login, password }
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ const gqlRegistr = (login, password) =>
|
|
|
|
+ gql(
|
|
|
|
+ URLbeck,
|
|
|
|
+ `
|
|
|
|
+ mutation register($login:String, $password:String){
|
|
|
|
+ UserUpsert(user: {login:$login, password:$password}){
|
|
|
|
+ _id login createdAt
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ `,
|
|
|
|
+ { login, password }
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ console.log(categoryFind());
|
|
|
|
+ console.log(categoryId("62d403fbb74e1f5f2ec1a12a"));
|
|
|
|
+ console.log(categoryIdImagesDescription(""));
|
|
|
|
+ console.log(gqlRegistr("Billy ", "Herrington"));
|
|
|
|
+ console.log(gqlLogin("Billy ", "Herrington"));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ </script>
|
|
|
|
+
|
|
|
|
+</body>
|
|
|
|
+
|
|
|
|
+</html>
|