I have 2 resources company and employees, where company can exist without employees, but not other way round.
To create company with employees, I have to fire 2 REST APIs,
POST /companies
POST /companies/:company_id/employees
Q1: Is it fine if I create employees and companies in single rest query to
POST /companies
{
"company_name": "my company",
"employees": [
{"name": "Test name 1"},
{"name": "Test name 2"}
]
}
Q2: If yes, is it mandatory that GET request to /companies should also return the same nested document?
I was planning something like this: Use above query to POST company data with employees
GET /companies - Will give me only company data
GET /companies?populate=employees - Will populate the nested resouces in this GET call
GET /companies/:company_id/employees - I still should be able to access employees in this manner