title: javascript difference between function constructor object and an object inside object
body: <p>I am trying to comprehend/understand GraphQL schema instructor have used. </p>
  
  <p>So first he did something like this </p>
  
  <pre><code>const BookType = new GraphQLObjectType({  
      name: 'Book', 
  
      fields: () =&gt; ({
          id: { type: GraphQLString},
          name: { type: GraphQLString},
          genre: { type: GraphQLString }
      })
  })
  </code></pre>
  
  <p>Here, he mentioned that reason <em>fields needs to be a function is because later when we have multiple type and they have reference to one another. then unless we wrap it in function, one type won't know what other types (more later)</em></p>
  
  <p>And afterwards when he was making <strong>RootQuery</strong> he did something like this </p>
  
  <pre><code>const RootQuery = new GraphQLObjectType({
      name: "RootQueryType",
      fields: {
          book: {
            type: BookType, 
            args: { id: { type: GraphQLString }},
            resolve(parent, args){
             args.id
              }
           }
        }
  })
  </code></pre>
  
  <p>Here, he did   <code>fields: {</code> instead of  <code>fields: () =&gt; ({</code> for which he gave following reason </p>
  
  <p><em>We don't need to wrap it like the field above because we don't need to worry about the order so much inside root Query</em></p>
  
  <p><strong>[Question:]</strong> I am unable to understand his explanation so I was looking for someone to explain me why he did <code>fields: {</code> instead of  <code>fields: () =&gt; ({</code> this?  </p>