Vincit/objection-graphql

How to handle jsonSchema relations?

Closed this issue · 0 comments

Given a many to many scenario of tags/posts, what is the right approach to complete the jsonSchema for properties tags and posts without causing circular references or unnecessary repetition:

// tag.js
class Tag extends Model {
    static get jsonSchema () {
        return {
            type: 'object',
            properties: {
                id: { type: 'integer' },
                name: { type: 'string' },
                posts: {
                    // what goes here???
                }
            },
        };
    }
}

// post.js
class Post extends Model {
    static getjsonSchema () {
        return {
            type: 'object',
            properties: {
                id: { type: 'integer' },
                title: { type: 'string' },
                tags: {
                    // what goes here???
                }
            },
        };
    }
}