K
K
Kirill Gavrilov2019-07-18 12:11:56
Node.js
Kirill Gavrilov, 2019-07-18 12:11:56

How to make a layered Graphql model?

Dear colleagues!
I am studying graphql and here is such a question, I have already learned how to do operations with simple collections, but how to get data from a multilevel collection, now I have such a document in mongodb:
5d3036cae146a448887546.png
how do I write a model, something like this does not work)

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const componentNavbarSchema = new Schema({
    name: String,
    menu_items: {
        id: String,
        name: String,
        child: String
    }
});

module.exports = mongoose.model('componentNavbar', componentsNavbarSchema);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question