Open ghaiklor opened 9 years ago
We have a common goal here. I may be able to help. I NEED a JSONAPI blueprint in a bad way. The entire Ember 2.X community does in fact. I am working with another developer who may be writing the serializer for this to work in Sails. I just turned his company on to your project. Cross your fingers. We may actually get this done. I will let you know. Have you already started on something or is this still in the, "not sure don't have time category"?
Cheers, Nichole
@NikkiDreams thanks for help. We can integrate your JSON-spec compatible blueprints alongside with our current blueprints and allow to users choose which one they want to use. When you will be ready to create PR for this I'll be glad to do other stuff related to generator itself.
I am starting to put stuff together. My project is stuck until JSON API support in Sails is available. Not sure if you have seen this https://github.com/IanVS/sails-hook-jsonapi I'm evaluating what was done at the moment.
Ok. I know this is not ideal but it is a start. I forked the original sails-hook-jsonapi. My fork is basically working. There are many things that need/should get fixed though. This is only basics so far.
Model and Collection relationships are pre loaded as you can see from my sample data queried from my users table.
"data": [
{
"type": "users",
"id": "1",
"attributes": {
"employer": [],
"companies": [
{
"id": 1,
"name": "Nikki's Magic Garden",
"adminId": null,
"industry": "Urban Farming",
"address": "N Awesome St.",
"addressSecondary": null,
"city": "Portland",
"state": "OR",
"province": null,
"postalCode": null,
"countryCode": null,
"details": {},
"createdAt": "2016-02-01T23:49:15.000Z",
"updatedAt": "2016-02-01T23:49:16.000Z"
},
{
"id": 2,
"name": "5Movez",
"adminId": null,
"industry": "Business Growth",
"address": "SE Awesome St.",
"addressSecondary": null,
"city": "Portland",
"state": "OR",
"province": null,
"postalCode": null,
"countryCode": null,
"details": {},
"createdAt": "2016-02-01T23:49:15.000Z",
"updatedAt": "2016-02-01T23:49:16.000Z"
}
],
"is-growth-champion": [],
"growth-teams": [],
"trios": [
{
"id": 1,
"name": "Trio A",
"team": 1,
"workout": 1,
"growthTeam": null,
"growthChampion": null,
"company": 1,
"createdAt": "2016-02-01T23:49:15.000Z",
"updatedAt": "2016-02-01T23:49:15.000Z"
},
{
"id": 2,
"name": "Trio A",
"team": 1,
"workout": 1,
"growthTeam": null,
"growthChampion": null,
"company": 1,
"createdAt": "2016-02-01T23:49:18.000Z",
"updatedAt": "2016-02-01T23:49:18.000Z"
},
{
"id": 3,
"name": "Trio A",
"team": 1,
"workout": 1,
"growthTeam": null,
"growthChampion": null,
"company": 1,
"createdAt": "2016-02-01T23:49:35.000Z",
"updatedAt": "2016-02-01T23:49:35.000Z"
},
{
"id": 4,
"name": "Trio A",
"team": 1,
"workout": 1,
"growthTeam": null,
"growthChampion": null,
"company": 1,
"createdAt": "2016-02-01T23:49:44.000Z",
"updatedAt": "2016-02-01T23:49:44.000Z"
}
],
"workouts": [
{
"id": 1,
"type": "access",
"results": null,
"complete": false,
"active": true,
"details": {},
"createdAt": "2016-02-01T23:49:15.000Z",
"updatedAt": "2016-02-01T23:49:16.000Z",
"growthChampion": null,
"growthteam": null,
"company": 1,
"worksheets": null
},
{
"id": 2,
"type": "access",
"results": null,
"complete": false,
"active": true,
"details": {},
"createdAt": "2016-02-01T23:49:18.000Z",
"updatedAt": "2016-02-01T23:49:19.000Z",
"growthChampion": null,
"growthteam": null,
"company": 1,
"worksheets": null
},
{
"id": 3,
"type": "access",
"results": null,
"complete": false,
"active": true,
"details": {},
"createdAt": "2016-02-01T23:49:35.000Z",
"updatedAt": "2016-02-01T23:49:36.000Z",
"growthChampion": null,
"growthteam": null,
"company": 1,
"worksheets": null
},
{
"id": 4,
"type": "access",
"results": null,
"complete": false,
"active": true,
"details": {},
"createdAt": "2016-02-01T23:49:44.000Z",
"updatedAt": "2016-02-01T23:49:45.000Z",
"growthChampion": null,
"growthteam": null,
"company": 1,
"worksheets": null
}
],
"username": "TheMaster",
"email": "booboo@5movez.com",
"first-name": "",
"last-name": "",
"photo": "",
"phone": null,
"postal-code": null,
"details": {},
"active": true,
"admin-id": null,
"created-at": "2016-02-01T23:49:16.000Z",
"updated-at": "2016-02-01T23:49:16.000Z"
}
}
]
@NikkiDreams do you think better to implement this in hooks ? I thought custom blueprints will be enough.
Both have advantages. But I would prefer blueprints. In fact I think a combination may be useful. Since hooks was already 50% done I just edited it to get a start. My next stab at this will be blueprints and pulling the processin out of the OK response file. The OK response file is not the right way to call the serializer as it does now. But it's a start.
@NikkiDreams it would be a great step forward when you implement JSON API :+1:
Yeah, responses are a little different but we can use root
parameter to override default response without modifying them.
I just started the Blueprints part of this endeavor. I'm getting way to old to be pulling these all nighters. But someone's gotta do it right? This will hopefully be very flexible and probably everything you could possibly need when I get the jsonapi-serializer hooked up to the blueprint service. I have quite a lot to do here but I expect to have basic things working by end of the week. https://github.com/NikkiDreams/sails-generate-jsonapi-blueprints
sails-hook-jsonapi is now working. As a hook its super basic and not very flexible. But it does the job, mostly. It is a very basic, no frills alternative. https://github.com/NikkiDreams/sails-hook-jsonapi
Cheers
We can override blueprints for JSON API support.