manifest icon indicating copy to clipboard operation
manifest copied to clipboard

Unable to hide implicit id field and restrict related-entity fields via relations query in API response

Open waqar-ahmed opened this issue 8 months ago • 0 comments

I’m using Manifest to create two entities, ServiceCategory and Service, with a many-to-one relationship:

  ServiceCategory:
    properties:
      - { name: id,        hidden: true }
      - name
      - { name: order, type: number , default: 999 }
      - { name: isActive, type: boolean, hidden: true, default: true }
      - {
        name: photo,
        type: image,
        options:
          { sizes: { small: { height: 90, width: 90 }, large: { width: 200 } } }
      }
    policies:
          read:
            - { access: restricted, allow: User }

  Service:
    properties:
      - { name: id,        hidden: true }
      - name
      - { name: order, type: number, default: 999}
      - { name: isActive, type: boolean, hidden: true, default: true }
      - {
        name: photo,
        type: image,
        options:
          { sizes: { small: { height: 90, width: 90 }, large: { width: 200 } } }
      }
    belongsTo:
      - ServiceCategory
    policies:
          read:
            - { access: restricted, allow: User }

I ran into two issues:

Hiding the id field I added a hidden: true flag to the id property in my backend.yml, but the auto-generated id is still showing up in every API response.

Limiting fields on related entities When I request /api/collections/services?relations=serviceCategory,serviceCategory.name, I still get all fields of my ServiceCategory objects. I expect to get like:

{
            "id": 2,
            "name": "A",
            "order": 0,
            "photo": null,
            "serviceCategory": {
                "name": "B",
         }
}

Please let me know if I am doing it wrong. Many thanks.

waqar-ahmed avatar Apr 28 '25 18:04 waqar-ahmed