json-graphql-server icon indicating copy to clipboard operation
json-graphql-server copied to clipboard

Support many-to-many relationships

Open ivanalejandro0 opened this issue 6 years ago • 2 comments

It seems that I can't do this right now:

module.exports = {
    posts: [
        { id: 1, title: "Lorem Ipsum", views: 254, user_id: [123, 456] },
        { id: 2, title: "Sic Dolor amet", views: 65, user_id: [456, 457] },
    ],
    users: [
        { id: 123, name: "John Doe" },
        { id: 456, name: "Jane Doe" },
        { id: 457, name: "Xavier" }
    ],
    comments: [
        { id: 987, post_id: 1, body: "Consectetur adipiscing elit", date: new Date('2017-07-03') },
        { id: 995, post_id: 1, body: "Nam molestie pellentesque dui", date: new Date('2017-08-17') }
    ]
}

Is this not supported? or maybe there's a different way of doing it?

p.s.: this would be something like a combined authorship post. This is not my actual use case though, but close enough to show the problem and with a little change of the provided example.

p.s. 2: great tool, keep it up :)

ivanalejandro0 avatar Nov 20 '17 19:11 ivanalejandro0

It's not supported in json-server (the "inspiration" for this project), so I have my doubts, but it would be really wonderful :)

szkrd avatar Feb 11 '18 09:02 szkrd

There is a fork by @mrtsven for relational data that may be what you want? https://github.com/marmelab/json-graphql-server/network

mikkelking avatar Nov 25 '18 20:11 mikkelking