2021-02-18 09:00:08 +00:00
|
|
|
class Collections {
|
|
|
|
getCollection(collectionId, channelSlug) {
|
|
|
|
const operationName = "Collection";
|
|
|
|
const variables = {
|
|
|
|
attributes: {},
|
|
|
|
priceGte: null,
|
|
|
|
priceLte: null,
|
|
|
|
sortBy: null,
|
|
|
|
channel: channelSlug,
|
|
|
|
id: collectionId,
|
|
|
|
pageSize: 6
|
|
|
|
};
|
|
|
|
const query =
|
|
|
|
"query Collection($id: ID!, $channel: String!) {\n collection(id: $id, channel: $channel) {\n id\n slug\n name\n seoDescription\n seoTitle\n backgroundImage {\n url\n __typename\n }\n __typename\n }\n attributes(filter: {channel: $channel, inCollection: $id, filterableInStorefront: true}, first: 100) {\n edges {\n node {\n id\n name\n slug\n values {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n";
|
|
|
|
return cy.sendFrontShopRequest(operationName, query, variables);
|
|
|
|
}
|
2021-02-19 11:08:10 +00:00
|
|
|
getCollections(search) {
|
|
|
|
const filter = search
|
|
|
|
? `, filter:{
|
|
|
|
search:""
|
|
|
|
}`
|
|
|
|
: "";
|
|
|
|
const query = `query{
|
|
|
|
collections(first:100 ${filter}){
|
|
|
|
edges{
|
|
|
|
node{
|
|
|
|
id
|
2021-02-19 12:41:40 +00:00
|
|
|
name
|
2021-02-19 11:08:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-02-19 12:41:40 +00:00
|
|
|
return cy
|
|
|
|
.sendRequestWithQuery(query)
|
|
|
|
.then(resp => resp.body.data.collections.edges);
|
2021-02-19 11:08:10 +00:00
|
|
|
}
|
|
|
|
deleteCollection(collectionId) {
|
|
|
|
const mutation = `mutation{
|
|
|
|
collectionDelete(id:"${collectionId}"){
|
|
|
|
collection{
|
|
|
|
id
|
|
|
|
}
|
|
|
|
collectionErrors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
|
|
|
return cy.sendRequestWithQuery(mutation);
|
|
|
|
}
|
2021-02-18 09:00:08 +00:00
|
|
|
}
|
|
|
|
export default Collections;
|