Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import shopify from "../../shopify.app.mjs";

export default {
key: "shopify-fulfillment-cancel",
name: "Cancel Fulfillment",
description: "Cancels an existing fulfillment and reverses its effects on associated fulfillment orders. [See the documentation](https://shopify.dev/docs/api/admin-graphql/latest/mutations/fulfillmentCancel)",
version: "0.0.1",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
annotations: {
destructiveHint: true,
openWorldHint: true,
readOnlyHint: false,
},
type: "action",
props: {
shopify,
orderId: {
propDefinition: [
shopify,
"orderId",
],
optional: true,
},
fulfillmentId: {
propDefinition: [
shopify,
"fulfillmentId",
({ orderId }) => ({
orderId,
}),
],
},
},
async run({ $ }) {
const { fulfillmentCancel } = await this.shopify.cancelFulfillment({
id: this.fulfillmentId,
});

if (fulfillmentCancel.userErrors?.length) {
throw new Error(fulfillmentCancel.userErrors.map((e) => e.message).join(", "));
}

$.export("$summary", `Successfully cancelled fulfillment \`${fulfillmentCancel.fulfillment.id}\``);
return fulfillmentCancel.fulfillment;
},
};
17 changes: 17 additions & 0 deletions components/shopify/common/mutations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,22 @@ const UPDATE_ORDER = `
}
`;

const FULFILLMENT_CANCEL = `
mutation fullfillmentCancel($id: ID!){
fulfillmentCancel(id: $id) {
fulfillment {
id
status
}
userErrors {
field
message
}
}
}

`;

export default {
CREATE_WEBHOOK,
DELETE_WEBHOOK,
Expand All @@ -458,4 +474,5 @@ export default {
DELETE_PAGE,
DELETE_METAFIELD,
UPDATE_ORDER,
FULFILLMENT_CANCEL,
};
2 changes: 1 addition & 1 deletion components/shopify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/shopify",
"version": "0.9.0",
"version": "0.10.0",
"description": "Pipedream Shopify Components",
"main": "shopify.app.mjs",
"keywords": [
Expand Down
4 changes: 4 additions & 0 deletions components/shopify/shopify.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,10 @@ export default {
getFulfillment(variables) {
return this._makeGraphQlRequest(queries.GET_FULFILLMENT, variables);
},
cancelFulfillment(variables) {
return this._makeGraphQlRequest(mutations.FULFILLMENT_CANCEL, variables);

},
getFulfillmentOrder(variables) {
return this._makeGraphQlRequest(queries.GET_FULFILLMENT_ORDER, variables);
},
Expand Down