Migrating to Vendure v2.0 #1991
Replies: 7 comments 6 replies
-
Do you have an ETA for the stable release of 2.0. If we are new to vandure do you recommend starting on the prerelease of version 2 or on the last stable release of v1. If we start on the prerelease version and some major changes do occur will you have any guides on how to migrate. Thanks a lot. |
Beta Was this translation helpful? Give feedback.
-
This might save some people headaches:
|
Beta Was this translation helpful? Give feedback.
-
The docs don't mention OrderItemPriceCalculationStrategy being changed - although as the name suggests, this is an OrderItem strategy. Has this changed at all in V2? |
Beta Was this translation helpful? Give feedback.
-
If you are using |
Beta Was this translation helpful? Give feedback.
-
This isnt quite correct @michaelbromley - Just tried it out for the Remix Storefornt in the YAML config like this: config:
scalars:
Money: number Which successfully generates the new types, see the diff here 👍 |
Beta Was this translation helpful? Give feedback.
-
Might be a bit late, but, related to the breaking Shop-API export const SET_SHIPPING_METHOD = gql`
mutation SetShippingMethod($id: [ID!]!) {
- setOrderShippingMethod(shippingMethodId: $id) {
+ setOrderShippingMethod(shippingMethodIds: $id) {
... on Order {
# ...
}
}
}
`; |
Beta Was this translation helpful? Give feedback.
-
Upgrading from Jest to VitestIf you are using Jest in your projects, and upgrade to Vendure version 2, you will probably run into some errors related to ESM. You could configure Jest to work with ES Modules, but I found it easier to install Vitest (which is also what Vendure Core is using to run tests). Migrating from Jest to Vitest is pretty easy:
- "types": ["node", "jest"]
+ "types": ["node"]
If you are using
|
Beta Was this translation helpful? Give feedback.
-
Vendure v2 is now in beta and is available using the
@next
npm tag or by specifying a specific beta version like2.0.0-beta.0
This is a living document that will be updated throughout the beta phase as user feedback is gathered. When the final v2 release occurs, this information will be used as the basis of the official migration guide that will be featured in the Vendure docs.
If you run into issues not covered here, or have other feedback, please leave a comment below!
Migration consists of 2 main parts:
@vendure/migrate-v2
tool - start with that to get your database schema migrated.Dependency updates
Updates to Vendure's underlying dependencies may require changes in your code:
TypeScript
ts-node
, update it to the latest versionES2022
orESNEXT
in yourtsconfig.json
, you'll need to set"useDefineForClassFields": false
. See this issue for more context.Apollo Server
If you have any custom ApolloServerPlugins, the plugin methods must now return a Promise. Example
TypeORM
TypeORM 0.3.x introduced a large number of breaking changes. For a complete guide, see the TypeORM v0.3.0 release notes.
Here are the main API changes you'll likely need to make:
null
, you need to use the newIsNull()
helper:findOne()
method returnsnull
rather thanundefined
if a record is not found.findOne() method no longer accepts an id argument. Lookup based on id must be done with a
where` clause:findByIds()
method has been deprecated. Use the newIn
helper instead:Vendure TypeScript API Changes
Custom Order / Fulfillment / Payment processes
In v2, the hard-coded states & transition logic for the Order, Fulfillment and Payment state machines has been extracted from the core services and instead resides in a default OrdertProcess, FulfillmentProcess and PaymentProcess object. This allows you to really customize these flows without having to work around the assumptions & logic implemented by the default processes.
What this means is that if you are defining a custom process, you'll now need to explicitly add the default process to the array.
Also note that
shippingOptions.customFulfillmentProcess
andpaymentOptions.customPaymentProcess
are both now renamed toprocess
. The old names are still usable but are deprecated.OrderItem no longer exists
As a result of #1981, the
OrderItem
entity no longer exists. The function and data ofOrderItem
is now transferred toOrderLine
. As a result, the following APIs which previously used OrderItem arguments have now changed:FulfillmentHandler
ChangedPriceHandlingStrategy
PromotionItemAction
TaxLineCalculationStrategy
ProductVariant stock changes
With #1545 we have changed the way we model stock levels in order to support multiple stock locations. This means that the
ProductVariant.stockOnHand
andProductVariant.stockAllocated
properties no longer exist on theProductVariant
entity in TypeScript.Instead, this information is now located at
ProductVariant.stockLevels
, which is an array of StockLevel entities.Other breaking API changes
ChannelService.findAll()
now returns aPaginatedList<Channel>
instead ofChannel[]
.vdr-product-selector
has been renamed tovdr-product-variant-selector
to more accurately represent what it does. If you are usingvdr-product-selector
if any ui extensions code, update it to use the new selector.ErrorResult
classes now take a single object argument rather than multiple args.Money
scalar type. If you use graphql-code-generator, you'll want to tell it to treat this scalar as a number:Region
entity has been introduced, which is a base class forCountry
and the newProvince
entity. TheZone.members
property is now an array ofRegion
rather thanCountry
, since Zones may now be composed of both countries and provinces. If you have defined any custom fields onCountry
, you'll need to change it toRegion
in your custom fields config.Shop API Changes
setOrderShippingMethod
mutation now takes an array of IDs rather than a single ID (to support multi-vendor orders with split shipping)Beta Was this translation helpful? Give feedback.
All reactions