iamshaunjp / graphql-playlist

All course files for the GraphQL tutorial playlist on The Net Ninja YouTube channel.
755 stars 625 forks source link

Any reason `books` is not part of the Author model? #17

Open dgtlmonk opened 5 years ago

dgtlmonk commented 5 years ago

Hey! Awesome tutorial and loving this.

Just a question and probably a suggestion.

https://github.com/iamshaunjp/graphql-playlist/blob/7a11b2b4fcf3c3766098bf3da1aa2b12e5cac77a/server/models/author.js#L4-L7

For clarity purpose, any reason books is not part of Author model? Since, books can be part of the graphql query.

e.g.

const authorSchema = new Schema({
    name: String,
    age: Number, 
    books: Array
});

GQL query

{
  author(id: "cdf0506f8f561f87c1d8d140") {
    name
    books {
      name
    }
  }
}
dgtlmonk commented 5 years ago

Let me know if this is reasonable and i'll send PR :)