Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 0d161d3

Browse files
authored
GraphQL: Add sendEmailToFriend mutation (#5368)
* checkpoint * add navigation * small updates * update example * convert paragraph to note * update opening sentence
1 parent 7f529a7 commit 0d161d3

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

_data/toc/graphql.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ pages:
184184
- label: revokeCustomerToken mutation
185185
url: /graphql/mutations/revoke-customer-token.html
186186

187+
- label: sendEmailToFriend mutation
188+
url: /graphql/mutations/send-email-to-friend.html
189+
187190
- label: setBillingAddressesOnCart mutation
188191
url: /graphql/mutations/set-billing-address.html
189192

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
group: graphql
3+
title: sendEmailToFriend mutation
4+
---
5+
6+
Use the `sendEmailToFriend` mutation to allow Magento to send a message on behalf of a customer to the specified email addresses.
7+
8+
{:.bs-callout-info}
9+
The **Stores** > **Configuration** > **Catalog** > **Email to a friend** > **Enabled** field must be set to **Yes** to implement this mutation.
10+
11+
## Syntax
12+
13+
`mutation: {sendEmailToFriend(input: SendEmailToFriendInput): {SendEmailToFriendOutput}}`
14+
15+
## Example usage
16+
17+
The following example sends a message to two friends.
18+
19+
**Request**
20+
21+
```graphql
22+
mutation {
23+
sendEmailToFriend(
24+
input: {
25+
product_id: 10
26+
sender: {
27+
name: "Veronica Cost"
28+
29+
message: "Sarah needs this! http://luma.example.com/savvy-shoulder-tote.html"
30+
}
31+
recipients: [
32+
{ name: "Amie Franklin", email: "[email protected]" }
33+
{ name: "Tomoko", email: "[email protected]" }
34+
]
35+
}
36+
) {
37+
sender {
38+
name
39+
email
40+
}
41+
recipients {
42+
name
43+
email
44+
}
45+
}
46+
}
47+
```
48+
49+
**Response**
50+
51+
```json
52+
{
53+
"data": {
54+
"sendEmailToFriend": {
55+
"sender": {
56+
"name": "Veronica Cost",
57+
"email": "[email protected]",
58+
},
59+
"recipients": [
60+
{
61+
"name": "Amie Franklin",
62+
"email": "[email protected]"
63+
},
64+
{
65+
"name": "Tomoko",
66+
"email": "[email protected]"
67+
}
68+
]
69+
}
70+
}
71+
}
72+
```
73+
74+
## Input attributes
75+
76+
The `SendEmailToFriendInput` object contains the following attributes:
77+
78+
Attribute | Data Type | Description
79+
--- | --- | ---
80+
`product_id` | Int! | The ID of the product that the customer is referencing
81+
`recipients` | [SendEmailToFriendRecipientInput]! | An array containing information about each recipient
82+
`sender` | SendEmailToFriendSenderInput! | Information about the customer and the content of the message
83+
84+
### SendEmailToFriendRecipientInput object {#SendEmailToFriendRecipientInput}
85+
86+
The `SendEmailToFriendRecipientInput` object must contain the following attributes:
87+
88+
Attribute | Data Type | Description
89+
--- | --- | ---
90+
`email` | String! | The email address of the recipient
91+
`name` | String! | The name of the recipient
92+
93+
### SendEmailToFriendSenderInput object {#SendEmailToFriendSenderInput}
94+
95+
The `SendEmailToFriendSenderInput` object must contain the following attributes:
96+
97+
Attribute | Data Type | Description
98+
--- | --- | ---
99+
`email` | String! | The email address of the sender
100+
`message` | String! | The text of the message to be sent
101+
`name` | String! | The name of the sender
102+
103+
## Output attributes
104+
105+
The `SendEmailToFriendOutput` object contains the following attributes:
106+
107+
Attribute | Data Type | Description
108+
--- | --- | ---
109+
`recipients` | [SendEmailToFriendRecipient] | An array containing information about each recipient
110+
`sender` | SendEmailToFriendSender | Information about the customer and the content of the message
111+
112+
### SendEmailToFriendRecipient object
113+
114+
The `SendEmailToFriendRecipientInput` object can contain the following attributes:
115+
116+
Attribute | Data Type | Description
117+
--- | --- | ---
118+
`email` | String | The email address of the recipient
119+
`name` | String | The name of the recipient
120+
121+
### SendEmailToFriendSender object
122+
123+
The `SendEmailToFriendSender` object can contain the following attributes:
124+
125+
Attribute | Data Type | Description
126+
--- | --- | ---
127+
`email` | String | The email address of the sender
128+
`message` | String | The text of the message
129+
`name` | String | The name of the sender

0 commit comments

Comments
 (0)