Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendure Primary Collection Plugin #258

Merged
merged 5 commits into from
Sep 22, 2023
Merged

Conversation

dalyathan
Copy link
Member

@dalyathan dalyathan commented Sep 15, 2023

Description

Extend Vendure's shop-api by adding primaryCollection field to Product gql type. The primary collection of a product is the collection that is the highest placed collection in Vendure (Collection's are sortable in Vendure, and it's a good practice to sort by importance). To construct breadcrumbs and URL's it's useful to have a primary collection for each product, in case a product is part of multiple collections.

Breaking changes

This PR won't introduce any breaking changes

Checklist

📌 Always:

  • I have set a clear title
  • My PR is small and contains only a single feature. (Split into multiple PR's if needed)
  • I have reviewed my own PR, fixed all typo's and removed unused/commented code

⚡ Most of the time:

  • I have added or updated test cases for important functionality
  • I have updated the README if needed

📦 For publishable packages:

@dalyathan dalyathan linked an issue Sep 15, 2023 that may be closed by this pull request
@dalyathan dalyathan marked this pull request as draft September 15, 2023 14:29
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need codegen for this plugin, so we can remove this file (and add it whenever we need it)

@@ -52,6 +52,7 @@ jobs:
'vendure-plugin-stripe-subscription',
'vendure-plugin-variant-bulk-update',
'vendure-plugin-webhook',
'vendure-plugin-primary-collection',
Copy link
Member

Choose a reason for hiding this comment

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

Good one, I always forget this 👌

package.json Outdated
@@ -98,7 +98,8 @@
"modify-customer-orders",
"multiserver-db-sessioncache",
"vendure-order-client",
"all-plugins"
"all-plugins",
"vendure-plugin-primary-collection"
Copy link
Member

Choose a reason for hiding this comment

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

We can change this to primary-collection. It's used in commit scopes: E.g. git commit 'feat(primary-collection): initial commit'. And the vendure-plugin-* prefix makes it a bit tedious to do every time you commit :-)

expect(product.primaryCollection.name).toBe('Computers');
});

it("Should return 'Computers' as a primary collection for 'Cars'", async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Can we make the test data a little more intuitive for this one? 'Computer' as primary collection for a 'Car' sounds like an unexpected answer 😄. (Although these days most cars are sort of computers but...)

@@ -0,0 +1,26 @@
{
"name": "@pinelab/vendure-plugin-primary-collection",
"version": "0.0.1",
Copy link
Member

Choose a reason for hiding this comment

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

You can make this 1.0.0 if you'd like. It looks finished enough 🦾

Copy link
Member

Choose a reason for hiding this comment

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

Can you add the changelog for v1.0.0 + date? There are examples in the other plugins

Copy link
Member

@martijnvdbrug martijnvdbrug left a comment

Choose a reason for hiding this comment

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

Super clean, nothing to add but a few tiny remarks

@martijnvdbrug martijnvdbrug marked this pull request as ready for review September 16, 2023 13:39
Copy link
Member

@martijnvdbrug martijnvdbrug left a comment

Choose a reason for hiding this comment

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

Great work as always, thanks!

@martijnvdbrug martijnvdbrug merged commit 0a0cdb5 into main Sep 22, 2023
26 checks passed
@martijnvdbrug martijnvdbrug deleted the feat/primary-collection branch September 22, 2023 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New plugin: Vendure-plugin-primary-collection
2 participants