123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <!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>
|