What’s new in Orion v4 and how to upgrade your project
lodash
, you must replace it with lodash-es
for ESM compatibility.experimentalDecorators
in your tsconfig.json
"type": "module"
to your package.jsonreflect-metadata
.@TypedSchema()
@Prop()
now always need a type option.typedi
anymore, we created our own dependency injection system, very similar to typedi
. So:
@orion-js/schema
was rewritten to be much more powerful.
Schema
and all of the places it’s used, like resolvers
, are now type safe.
Infer
a typescript type from a Schema
definition.
type
property, you must use typeof Enum.__tsFieldType
to get the type.
@TypedSchema()
and Model
Model
and TypedSchema()
will still work. If you have any TS error, you can set as any
to fix it until you migrate to Schema
.
AsModel.initItem
was deprecated in v3 and removed in v4, soCollections
now can’t accept amodel
option, only aschema
option.
TypedSchema()
now always needs a type option, it became less appealing. We always aim to only write code once.
Usage of TypedSchema()
and Model
is not recommended anymore and it’s marked as deprecated.
schemaWithName()
but you won’t be able to use them in GraphQL.
createEventJob
and createRecurrentJob
instead of defineJob
.scheduleJob
.runEvery
in createRecurrentJob
now accepts ms
string.createEchoEvent
and createEchoRequest
instead of echo
.createQuery
and createMutation
instead createResolver
.schemaWithName
is preferred over Model
and TypedSchema()
.Schema
to params and returns because GraphQL
needs a name.canSubscribe
option to check permissions instead of checkPermission
.bodyParams
to clean and validate body params.queryParams
to clean and validate query params.returns
to clean the return value.model
param in model was removed, and objects are never “initialized” anymore. This pattern was deprecated in v3 and removed in v4.collection.startConnection
.typedId
from the schema and use it to create prefixed ids.@orion-js/core
)tsx
to run the app. You must install tsx
in your project.
pnpm orion dev
to start in dev mode, it will watch for changes and automatically restart the server.pnpm orion prod
to start in prod mode, it will compile the code and then run it.You must have installed@orion-js/core
in your project, you can’t running usingnpx
orpnpx
.
tsconfig.json
to use modern settings:
@orion-js/mailing
@orion-js/cache
@orion-js/cache
it’s not longer going to be maintained. We are not using it in any package.
If you need a cache system, we recommend using lru-cache
.
getCacheKey
and cacheProvider
were removed from the options of createResolver
and createModelResolver
.
checkPermission
and permissionsOptions
were removed from the options of createResolver
and createModelResolver
.
If you need to check permissions, you can do it in the resolve
function or in a middleware.