の私はモデル内で一意の列を定義したとき、私は、sequelizeでGraphJSを使用しています:Sequelize、GraphJS:プロパティを読み取ることができません「2」ヌル
const Product = Connection.define('Product', {
label: {
type: Sequelize.STRING,
allowNull: false,
unique: true <--------------
},
description: {
type: Sequelize.TEXT,
allowNull: false
},
price: {
type: Sequelize.FLOAT(6, 3),
}
});
私はしようとすると、に秒を挿入同じラベルと行:
:const Mutations = new GraphQLObjectType({
name: 'Mutations',
description: 'All Mutations',
fields:() => {
return {
addProduct: {
type: Product,
args: {
new: {
name: 'New product',
type: ProductInput
}
},
resolve(_, args) {
return Db.models.Product.create(args.new);
}
},
};
}
});
は、私は次のエラーを得ました
TypeError: Cannot read property '2' of null
アイデア?あなたはいけない
多分挿入コードを表示? – hereandnow78
'constの変異=新しいGraphQLObjectType({ 名: '変異'、 説明: 'すべての変異'、 フィールド:()=> { リターン{ addProduct:{ タイプ:製品、 引数:{ 新しいです:{ 名: '新製品'、 タイプ:ProductInput }}、 解決(_、引数){ リターンDb.models.Product.create(args.new); }}、 }。 } }); ' –