Skip to content

Document response handling on Admin validation #2185

@rvanlaak

Description

@rvanlaak

https://api-platform.com/docs/admin/validation/ currently states some details on how client and server side validation can be added.

In situations where we are not using React Admin but do want to leverage the @api-platform/admin functionality to handle hydra / jsonld HTTP 422 validation responses, things become more complex.

tldr; the response gets expanded, and documentation would be helpful 1) for what reason, and 2) how to cope with expanded responses in userland.

Context

Our application has an additional React application that's living next to the React Admin application, and leverages helpful utilities like the fetchJsonld and authentication. When trying to handle validation errors on a form, the thrown http 422 error content does look different from the actual response payload as internally the structure gets expanded using the API Platform jsonld documentation.

Response payload

Image

Response error object (in debugger)
Image

Related issues api-platform/admin#548 api-platform/admin#553 api-platform/admin#528 https://github.com/api-platform/admin/pull/352/files

Questions to answer

  1. How to cope with jsonld response objects that are expanded according to the API Platform's docs?
  2. As can be seen on the jsonld lib, the compact method could be used. Might require fetchHydra's documentLoader, so how to compac the error response again?
  3. Maybe add features to allow userland to
    1. add functionality to fetchHydra to not expand the response (e.g. in case of non http 20x responses)
    2. export the documentLoader in API Platform's fetchHydra so that one can be reused

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions