const actionCatById = (_id) =>
    actionPromise('catById', gql(`query catById($q: String){
        CategoryFindOne(query: $q){
            _id name goods {
                _id name price images {
                    url
                }
            }
        }
    }`, {q: JSON.stringify([{_id}])}))


const actionRootCats = () =>
    actionPromise('rootCats', gql(`query {
        CategoryFind(query: "[{\\"parent\\":null}]"){
            _id name
        }
    }`))


const actionGoodFind = () =>
    actionPromise('goods', gql(`query {
        GoodFind(query:"[{}]"){
            _id name price
            categories{
                _id name 
            }
        }
    }`))


const actionLogin = (login, password) =>
    actionPromise('goods', gql(`query ($login:String, $password: String){
    login(login: $login, password: $password)
    }`, {login: JSON.stringify([{login}]), password: JSON.stringify([{password}])}))


const actionGoodById = (_id) =>
    actionPromise('goodById', gql(`query goodById($q: String){
    GoodFindOne(query: $q){
            _id name description price images{
              url
            }
        }
    }`, {q: JSON.stringify([{_id}])}))