GraphQL показывает настраиваемые поля из таблицы во многих отношениях - PullRequest
0 голосов
/ 26 марта 2019

Я хотел бы показать свое настраиваемое поле "позиция" от многих ко многим.

Ковш

id | fk_language_id | код

Блок

id | код

Bucket_Block

id | fk_bucket_id | fk_block_id | положение

schema.js

# Bucket
type Bucket {
  id: Int!,
  code: String
  language(id: Int): Language
  blocks: [Block]
}

# Block
type Block {
  id: Int!,
  code: String,
  is_active: Boolean,
  position: Int
}

# query for types
type Query {
  buckets: [Bucket]
}

resolvers.js

Bucket: {
        blocks(bucket) {
            return bucket.getBlocks();
        }
    },

connectors.js

// define bucket
const BucketModel = db.define('bucket', {
    code     : {type: Sequelize.STRING},
    is_active: {type: Sequelize.BOOLEAN}
});

// define block
const BlockModel = db.define('block', {
    code     : {type: Sequelize.STRING},
    is_active: {type: Sequelize.BOOLEAN}
});

// define bucket_block
const BucketBlockModel = db.define('bucket_block', {
    position: {type: Sequelize.INTEGER}
});

BucketModel.belongsToMany(BlockModel, {
    through   : 'bucket_block',
    foreignKey: 'fk_bucket_id'
});

BlockModel.belongsToMany(BucketModel, {
    through   : 'bucket_block',
    foreignKey: 'fk_block_id'
});

Я пытался добавить сводку: Int в моей схеме, но поле не

"позиция": ноль

...