Given that aurora is set up
And the user has made some models (lets say Customer and Address)
And those models are being stored local storage in the browser
When a customer clicks "Apply to database" for the first time:
[ ] create a schema for that user in aurora
[ ] create the tables matching the models using knex (i.e something like Customer and Address)
Now the data editor has to use that database instead of local storage. What API will it use? Because we only have a Postgres database
And this would be hosted at https://api.cozemble.com/:teamId/graphql/v1.
But this would be dynamic, based on the models, not based on code generation. So if I have two teams, teamA and teamB, and teamA has models for Customer and Address, and teamB has models for Invoice and Order, when I hit this URL:
https://api.cozemble.com/teamA/graphql/v1, that GraphQL api will dynamically be about Customer and Address
And if I hit the url
https://api.cozemble.com/teamB/graphql/v1, that api will be about Invoice and Order
To implement this:
[ ] Dynamically create a GraphQL schema from cozemble models
[ ] Write one generic resolver that maps from mutations and queries, using models, to the correct INSERT, UPDATE statements
[ ] Write a node server to expose this as an endpoint
Given that aurora is set up And the user has made some models (lets say Customer and Address) And those models are being stored local storage in the browser
When a customer clicks "Apply to database" for the first time:
Now the data editor has to use that database instead of local storage. What API will it use? Because we only have a Postgres database
Option 1
Given that all data changes in the data editors are made using events, send the events to https://api.cozemble.com/:teamId/:modelId/:recordId
That endpoint can load all the models for the team, and the record, and "re-play" the events into the record, save it, and return the new record
Option 2
Make our our GraphQL endpoint that reflects the "shape" of the model. i.e if we have a Customer with a has-one Address, we can make this GraphQL api:
And this would be hosted at
https://api.cozemble.com/:teamId/graphql/v1
.But this would be dynamic, based on the models, not based on code generation. So if I have two teams, teamA and teamB, and teamA has models for Customer and Address, and teamB has models for Invoice and Order, when I hit this URL:
https://api.cozemble.com/teamA/graphql/v1
, that GraphQL api will dynamically be about Customer and AddressAnd if I hit the url
https://api.cozemble.com/teamB/graphql/v1
, that api will be about Invoice and OrderTo implement this: