Beispiel #1
0
        public BookType(BookReviewsRepository bookReviewsRepository)
        {
            Field(t => t.ISBN);
            Field(t => t.Title);
            Field(t => t.Authors);
            Field(t => t.PublishDate);
            Field <GenreEnumType>("genre", "Genre of book");

            Field <ListGraphType <BookReviewType> >(
                "reviews",
                resolve: context => bookReviewsRepository.GetBookReviews(context.Source.ISBN)
                );
        }
Beispiel #2
0
        public BookType(
            BookReviewsRepository bookReviewsRepository)
        //IDataLoaderContextAccessor dataLoaderContextAccessor)
        {
            Field(t => t.ISBN).Description("Unique identifier for a book");
            Field(t => t.Title);
            Field(t => t.Authors);
            Field(t => t.PublishDate);
            Field <GenreEnumType>("genre", "Genre of book");

            Field <ListGraphType <BookReviewType> >(
                "reviews",
                resolve: context => bookReviewsRepository.GetBookReviews(context.Source.ISBN));

            //resolve: context =>
            //{
            //    var loader = dataLoaderContextAccessor.Context.GetOrAddCollectionBatchLoader<string, BookReview>(
            //        "GetBookReviewByBookISBNs", (isbns) => bookReviewsRepository.GetBookReviewsByMultipleISBNs(isbns));

            //    return loader.LoadAsync(context.Source.ISBN);
            //}
        }