2021-03-12 12:14:18 +00:00
|
|
|
export function createCategory(name, slug = name) {
|
|
|
|
const mutation = `mutation{
|
2021-03-12 14:57:02 +00:00
|
|
|
categoryCreate(input:{name:"${name}", slug: "${slug}"}){
|
|
|
|
productErrors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
category{
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy.sendRequestWithQuery(mutation);
|
|
|
|
}
|
|
|
|
export function getCategories(first, search) {
|
|
|
|
const mutation = `query{
|
2021-03-12 14:57:02 +00:00
|
|
|
categories(first:${first}, filter:{
|
|
|
|
search:"${search}"
|
|
|
|
}){
|
|
|
|
edges{
|
|
|
|
node{
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy
|
|
|
|
.sendRequestWithQuery(mutation)
|
|
|
|
.then(resp => resp.body.data.categories.edges);
|
|
|
|
}
|
|
|
|
export function deleteCategory(categoryId) {
|
|
|
|
const mutation = `mutation{
|
2021-03-12 14:57:02 +00:00
|
|
|
categoryDelete(id:"${categoryId}"){
|
|
|
|
productErrors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy.sendRequestWithQuery(mutation);
|
2021-02-02 11:34:10 +00:00
|
|
|
}
|