Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement JSON API spec #108

Open
ghaiklor opened this issue Oct 16, 2015 · 8 comments
Open

Implement JSON API spec #108

ghaiklor opened this issue Oct 16, 2015 · 8 comments

Comments

@ghaiklor
Copy link
Owner

We can override blueprints for JSON API support.

@ghaiklor ghaiklor self-assigned this Oct 16, 2015
@ghaiklor ghaiklor added this to the v1.1.0 milestone Oct 16, 2015
@ghaiklor ghaiklor removed this from the v1.2.0 milestone Dec 27, 2015
@NikkiDreams
Copy link

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

@ghaiklor
Copy link
Owner Author

@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.

@NikkiDreams
Copy link

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.

@NikkiDreams
Copy link

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.

  • Smart handling of pluralization.
  • Add Blueprints
  • Add relationships support
  • Add links support
  • Add meta data support
  • Error Handling

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"
      }
    }
]

@ghaiklor
Copy link
Owner Author

ghaiklor commented Feb 2, 2016

@NikkiDreams do you think better to implement this in hooks ? I thought custom blueprints will be enough.

@NikkiDreams
Copy link

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.

@ghaiklor
Copy link
Owner Author

ghaiklor commented Feb 2, 2016

@NikkiDreams it would be a great step forward when you implement JSON API 👍
Yeah, responses are a little different but we can use root parameter to override default response without modifying them.

@NikkiDreams
Copy link

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

@ghaiklor ghaiklor removed their assignment Jun 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants