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

Add included objects to serialized JSON #22

Open
mklocek opened this issue Dec 30, 2015 · 2 comments
Open

Add included objects to serialized JSON #22

mklocek opened this issue Dec 30, 2015 · 2 comments

Comments

@mklocek
Copy link
Contributor

mklocek commented Dec 30, 2015

In one of my apps using jsonapi-datastore I needed a way to include to result of serialize method an array of complete relationship objects, just like in jsonapi specification. For my purposes, I created this: mklocek/jsonapi-datastore@a955efec9ecaba87a0dde0598232d1822022df3a. Including is optional here and looks like that:

var projectAttributes = {
    attributes: ['title'],
    relationships: ['clients', 'managers'],
    included: {
        clients: {
            attributes: ['name']
        },
        managers: {
            attributes: ['name']
        }
    }
};

project.serialize(projectAttributes);
=> # jsonapi json containing 'included' array

Have you thought about such feature?

@beauby
Copy link
Owner

beauby commented Dec 30, 2015

Hi @mklocek. jsonapi-datastore was intended as a client-side library. Hence, creating payloads with an included property was not in the requirements, as (AFAIK) only a server would have to generate those. Would you mind elaborating on your use-case?

@mklocek
Copy link
Contributor Author

mklocek commented Dec 31, 2015

Hi @beauby! I needed a way to create nested_form-like api requests. That's not the way things are made in jsonapi specification, just my use-case, so I didn't make PR. Just wondering if it could be a good feature for you.

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