laravel-json-api / laravel

JSON:API for Laravel applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about extendability

theimerj opened this issue · comments

Hello @lindyhopchris, first of all I would like to thank you for all the work you've put into this project, it is brilliant and nicely written.

I am currently building an API layer for a headless ecommerce store which consists of multiple packages all dealing with separate concerns. The initial thought was that there will be a core and then additional modules which add specific functionality.

There are at least 3 levels:

  • Core API package
  • Multiple other packages building on top of that
  • User application adding functionality on top of that

However, some of them need to extend already existing schemas, resources and so on. I spent long hours code diving, trying to figure out a way how to extend the base classes and ended up with writing singleton manifests in order to at least be able to compose the array return value of Schema public methods in order to make them extendable.

To make it less abstract, here is some code:

Current solution works, but it does not feel clean and it is somewhat inconvenient to have to call ...parrent::someMethod() in every single extendable schema plus there is no way to enforce it with a contract and so on.

If possible, could you please suggest a better approach to address this issue?
Thank you very much.