From 8b2189a6cae68f2df043c46bf16243f7afbd25a2 Mon Sep 17 00:00:00 2001 From: anshk Date: Fri, 13 Mar 2026 19:54:09 +0530 Subject: [PATCH] feat: add shared GraphQL note queries module --- app/graphql/noteQueries.js | 69 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 app/graphql/noteQueries.js diff --git a/app/graphql/noteQueries.js b/app/graphql/noteQueries.js new file mode 100644 index 0000000..8a6d7e0 --- /dev/null +++ b/app/graphql/noteQueries.js @@ -0,0 +1,69 @@ +export const CREATE_NOTE = `#graphql + mutation CreateNote($ownerId: ID!, $value: String!) { + metafieldsSet( + metafields: [{ + ownerId: $ownerId, + namespace: "custom", + key: "note", + type: "single_line_text_field", + value: $value + }] + ) { + metafields { + id + key + value + } + } + } +`; + +export const UPDATE_NOTE = `#graphql + mutation UpdateNote($ownerId: ID!, $value: String!) { + metafieldsSet( + metafields: [{ + ownerId: $ownerId, + namespace: "custom", + key: "note", + type: "single_line_text_field", + value: $value + }] + ) { + metafields { + id + value + } + } + } +`; + +export const DELETE_NOTE = `#graphql + mutation DeleteNote($id: ID!) { + metafieldsDelete(metafields: [{ id: $id }]) { + deletedMetafields { + id + } + userErrors { + field + message + } + } + } +`; + +export const READ_NOTES = `#graphql + query ReadNotes { + products(first: 20) { + edges { + node { + id + title + metafield(namespace: "custom", key: "note") { + id + value + } + } + } + } + } +`;