2021-04-12 15:22:12 +00:00
|
|
|
export function createCollection(name, slug = name) {
|
|
|
|
const mutation = `mutation {
|
|
|
|
collectionCreate(input:{
|
|
|
|
name:"${name}",
|
|
|
|
slug:"${name}"
|
|
|
|
}){
|
|
|
|
collectionErrors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
collection{
|
|
|
|
name
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
|
|
|
return cy
|
|
|
|
.sendRequestWithQuery(mutation)
|
|
|
|
.its("body.data.collectionCreate.collection");
|
|
|
|
}
|
2021-03-12 12:14:18 +00:00
|
|
|
export function getCollections(search) {
|
|
|
|
const filter = search
|
|
|
|
? `, filter:{
|
2021-02-24 13:21:19 +00:00
|
|
|
search:""
|
|
|
|
}`
|
2021-03-12 12:14:18 +00:00
|
|
|
: "";
|
|
|
|
const query = `query{
|
2021-03-12 14:57:02 +00:00
|
|
|
collections(first:100 ${filter}){
|
|
|
|
edges{
|
|
|
|
node{
|
|
|
|
id
|
|
|
|
name
|
2021-02-24 13:21:19 +00:00
|
|
|
}
|
2021-03-12 14:57:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy
|
|
|
|
.sendRequestWithQuery(query)
|
|
|
|
.then(resp => resp.body.data.collections.edges);
|
|
|
|
}
|
|
|
|
export function deleteCollection(collectionId) {
|
|
|
|
const mutation = `mutation{
|
2021-03-12 14:57:02 +00:00
|
|
|
collectionDelete(id:"${collectionId}"){
|
|
|
|
collection{
|
|
|
|
id
|
|
|
|
}
|
|
|
|
collectionErrors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy.sendRequestWithQuery(mutation);
|
2021-02-24 13:21:19 +00:00
|
|
|
}
|