Let's say I have two models in SqlAlchemy:
UserType
User
User
has a foreign key to UserType
I have properly configured flask-restless to serve these models as API endpoints:
/api/user
/api/user_type
But by default, when I visit either of these endpoints, I get the related data associated with each object in the response:
User
has the corresponding UserType
object nested in the responseUserType
has a collection of User
nested in the responseThis will definitely lead to a lot of overhead as the data grows a lot. If I just want to GET the list of UserType
that the system supports, all of the associated users will come back. Usually an API would generate a link for related resources:
/api/user/1/user_type
/api/user_type/1/users
Has anyone gotten these links out of flask-restless responses?
It looks like this is a known issue that has been active on GitHub for a long time. Not sure if the developer is planning on fixing it or not:
https://github.com/jfinkels/flask-restless/issues/168#issuecomment-69821642
I ended up going with flask-restful
and building my own endpoints.