Skip to content

Commit

Permalink
Merge pull request #6 from fabrix-app/v1.1
Browse files Browse the repository at this point in the history
[feat] throw error if misconfigured resolver
  • Loading branch information
scott-wyatt authored Jul 31, 2018
2 parents 46486d9 + 913a0f6 commit bdb25aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lib/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as Sequelize from 'sequelize'
import { FabrixApp } from '@fabrix/fabrix'
import { FabrixModel } from '@fabrix/fabrix/dist/common'
import { pickBy, isString, startsWith } from 'lodash'
import { SequelizeResolver } from './SequelizeResolver'

export const Transformer = {
BreakException: {},
Expand Down Expand Up @@ -182,6 +183,13 @@ export const Transformer = {
const options = Transformer.getModelOptions(app, model)
const schema = Transformer.getModelSchema(app, model)

if (!model.resolver || !model.resolver.connect) {
throw new Error(`${modelName} was set to use Sequelize but the resolver is missing "connect"`)
}
if (!(model.resolver instanceof SequelizeResolver)) {
throw new Error(`${modelName} is not a Sequelize Resolver`)
}

model.store = store
model.migrate = migrate
model.resolver.connection = connection
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fabrix/spool-sequelize",
"version": "1.1.2",
"version": "1.1.3",
"description": "Spool - Datastore Spool for Sequelize.js http://sequelizejs.com",
"scripts": {
"build": "tsc -p ./lib/tsconfig.release.json",
Expand Down

0 comments on commit bdb25aa

Please sign in to comment.