Required Relation Field

hi @hunter

can you just help me to how to implement this service in my case beacuse i’m facing same issue for required true

i have no custom controller & no custom service till now
then how would i integrate this service

My files Code ::
service/project.js

'use strict';

/**
 * project service
 */

const { createCoreService } = require('@strapi/strapi').factories;

module.exports = createCoreService('api::project.project');

controller/project.js

'use strict';

/**
 * project controller
 */

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::project.project');

and the last one schema.json

{
  "kind": "collectionType",
  "collectionName": "projects",
  "info": {
    "singularName": "project",
    "pluralName": "projects",
    "displayName": "Project",
    "description": ""
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "title": {
      "type": "string",
      "required": true
    },
    "description": {
      "type": "richtext",
      "required": true
    },
    "projectMediumCategory": {
      "type": "relation",
      "relation": "oneToOne",
      "target": "api::medium-category.medium-category",
      "required": true
    },
    "projectSubjectMatterCategories": {
      "type": "relation",
      "relation": "oneToMany",
      "target": "api::subject-matter-category.subject-matter-category",
      "required": true
    }
  }
}

This issue only occurred for oneToMany relation keep in Mind Guy’s

Please help me ! @hunter

1 Like