All things Shopify and commerce
Could you please provide insights on how to utilize customer segment APIs with REST APIs and their implementation in Node.js? Additionally, it would be helpful to know how to integrate GraphQL APIs for customer segments on the React side. Thank you.
Hello @Abhishek2941
Recently, I've created customer segment usign the GRAPHQL API. Here is code to create a customer segment.
# Define the GraphQL mutation query
mutation_query = <<~QUERY
mutation segmentCreate($name: String!, $query: String!) {
segmentCreate(name: $name, query: $query) {
segment {
name
}
userErrors {
field
message
}
}
}
QUERY
# Define the variables for the mutation
variables = {
"name": "DISCOUNT_APPLIED_SEGMENT",
"query": "customer_tags NOT CONTAINS 'vip'"
}
# Execute the mutation query
response = shop.with_shopify_session do
Shopify::Graphql::Connector.client.query(query: mutation_query, variables: variables)
end
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025