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: numberWhich 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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Vendure v2 is now in beta and is available using the
@nextnpm tag or by specifying a specific beta version like2.0.0-beta.0This 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-v2tool - 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 versionES2022orESNEXTin 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 returnsnullrather thanundefinedif a record is not found.findOne() method no longer accepts an id argument. Lookup based on id must be done with awhere` clause:findByIds()method has been deprecated. Use the newInhelper 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.customFulfillmentProcessandpaymentOptions.customPaymentProcessare both now renamed toprocess. The old names are still usable but are deprecated.OrderItem no longer exists
As a result of #1981, the
OrderItementity no longer exists. The function and data ofOrderItemis now transferred toOrderLine. As a result, the following APIs which previously used OrderItem arguments have now changed:FulfillmentHandlerChangedPriceHandlingStrategyPromotionItemActionTaxLineCalculationStrategyProductVariant 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.stockOnHandandProductVariant.stockAllocatedproperties no longer exist on theProductVariantentity 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-selectorhas been renamed tovdr-product-variant-selectorto more accurately represent what it does. If you are usingvdr-product-selectorif any ui extensions code, update it to use the new selector.ErrorResultclasses now take a single object argument rather than multiple args.Moneyscalar type. If you use graphql-code-generator, you'll want to tell it to treat this scalar as a number:Regionentity has been introduced, which is a base class forCountryand the newProvinceentity. TheZone.membersproperty is now an array ofRegionrather 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 toRegionin your custom fields config.Shop API Changes
setOrderShippingMethodmutation 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