using GraphQL.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace NewWebApi.Schema
{
    public class MySchema
    {
        public ISchema Schema { get; set; }

        public MySchema()
        {
            var schema = GraphQL.Types.Schema.For(@"
                  type Author {
                    id: ID                                
                    firstName: String
                    lastName: String                                    
                    books: [Book]                    
                  }

                  type Book {
                    id: ID
                    title: String                 
                    published: Date
                    author: Author
                  }     

                  type Query {
                      books: [Book]
                      book (id: ID): Book
                      author(id: ID): Author
                      authors: [Author]
                      }

                type Mutation {
                    addAuthor(id:ID, firstName: String, lastName:String): [Author]
                    addBook(id:ID, title: String, published:String): [Book]
                 }",
            schemaBuilder =>
            {
                schemaBuilder.Types.Include<Query>();
                schemaBuilder.Types.Include<Mutation>();
            });

            Schema = schema;
        }
    }
}
