Skip to content
Merged
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
6 changes: 6 additions & 0 deletions imports/collections/schemas/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ export const CartItem = new SimpleSchema({
type: String,
optional: true
},
"productTagIds": {
label: "Product Tags",
type: Array,
optional: true
},
"productTagIds.$": String,
"productVendor": {
label: "Product Vendor",
type: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { encodeCartItemOpaqueId } from "@reactioncommerce/reaction-graphql-xforms/cart";
import { resolveShopFromShopId } from "@reactioncommerce/reaction-graphql-utils";
import productTags from "./productTags";

export default {
_id: (node) => encodeCartItemOpaqueId(node._id),
productTags,
shop: resolveShopFromShopId
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { getPaginatedResponse } from "@reactioncommerce/reaction-graphql-utils";
import { xformArrayToConnection } from "@reactioncommerce/reaction-graphql-xforms/connection";

/**
* @name "CartItems.productTags"
* @method
* @memberof Catalog/GraphQL
* @summary Returns the tags for a CartItem
* @param {Object} product - CartItem from parent resolver
* @param {TagConnectionArgs} args - arguments sent by the client {@link ConnectionArgs|See default connection arguments}
* @param {Object} context - an object containing the per-request state
* @return {Promise<Object[]>} Promise that resolves with array of Tag objects
*/
export default async function tags(cartItem, connectionArgs, context) {
const { productTagIds } = cartItem;
if (!productTagIds || productTagIds.length === 0) return xformArrayToConnection(connectionArgs, []);

const query = await context.queries.tagsByIds(context, productTagIds, connectionArgs);

return getPaginatedResponse(query, connectionArgs);
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ type CartItem implements Node {
"The type of product, used to display cart items differently"
productType: String

"The list of tags that have been applied to this product"
productTags(after: ConnectionCursor, before: ConnectionCursor, first: ConnectionLimitInt, last: ConnectionLimitInt, sortOrder: SortOrder = asc, sortBy: TagSortByField = _id): TagConnection

"The product vendor"
productVendor: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export default async function addCartItems(collections, currentItems, inputItems
productSlug: catalogProduct.slug,
productVendor: catalogProduct.vendor,
productType: catalogProduct.type,
productTagIds: catalogProduct.tagIds,
quantity,
shopId: catalogProduct.shopId,
taxCode: chosenVariant.taxCode,
Expand Down
4 changes: 2 additions & 2 deletions imports/plugins/core/core/server/startup/startNodeApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default async function startNodeApp() {

// Log to inform that the server is running
WebApp.httpServer.on("listening", () => {
Logger.info(`GraphQL listening at ${ROOT_URL}graphql-alpha`);
Logger.info(`GraphiQL UI: ${ROOT_URL}graphiql`);
Logger.info(`GraphQL listening at ${ROOT_URL}/graphql-alpha`);
Logger.info(`GraphiQL UI: ${ROOT_URL}/graphiql`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

});
}