**What** There is actually an issue with using the `fields` query params with the way the repositories are using our custom query strategy. This pr aims to fix this issue by reworking the strategy. What we had to do was to rework the way the selects are built for each subquery in order to follow the aliasing convention and to be taken into consideration. Alongside these changes, the join used to always select everything, this needed to be changed so that if there are any selects provided for a join, the join should not select everything and let the query select the fields that are requested. Another notable change is that all the repositories are now using the repository util in order to centralize the customization and to have a single place to update when this kind of issue arises. This means that the eager relations when using the query builder are not necessarily taken into account. For that reason, I have removed the `shipping_option` eager option in favor of explicitly asking for the relations like we started to do it in some places. FIXES CORE-1413
SendGrid
Handle sending emails to customers related to orders, restock notifications, users, or custom events.
SendGrid Plugin Documentation | Medusa Website | Medusa Repository
Features
- Send emails when an event related to orders, restock notifications, or users is triggered.
- Use dynamic templates in SendGrid to build the emails to be sent.
- Send emails with SendGrid for custom events.
Prerequisites
How to Install
1. Run the following command in the directory of the Medusa backend:
npm install medusa-plugin-sendgrid
2. Set the following environment variable in .env:
SENDGRID_API_KEY=<API_KEY>
SENDGRID_FROM=<SEND_FROM_EMAIL>
# IDs for different email templates
SENDGRID_ORDER_PLACED_ID=<ORDER_PLACED_TEMPLATE_ID> # example
3. In medusa-config.js add the following at the end of the plugins array:
const plugins = [
// ...,
{
resolve: `medusa-plugin-sendgrid`,
options: {
api_key: process.env.SENDGRID_API_KEY,
from: process.env.SENDGRID_FROM,
order_placed_template:
process.env.SENDGRID_ORDER_PLACED_ID,
localization: {
"de-DE": { // locale key
order_placed_template:
process.env.SENDGRID_ORDER_PLACED_ID_LOCALIZED,
},
},
},
},
]
Test the Plugin
1. Run the following command in the directory of the Medusa backend to run the backend:
npm run start
2. Place an order using a storefront or the Store APIs. You should receive a confirmation email.