public LibrarySubscription(LibraryMessageService messageService)
 {
     Name = "Subscription";
     AddField(new EventStreamFieldType
     {
         Name       = "bookAdded",
         Type       = typeof(BookAddedMessageType),
         Resolver   = new FuncFieldResolver <BookAddedMessage>(c => c.Source as BookAddedMessage),
         Subscriber = new EventStreamResolver <BookAddedMessage>(c => messageService.GetMessages())
     });
 }
Ejemplo n.º 2
0
 public LibraryMutation(ILibraryService libraryService, LibraryMessageService messageService)
 {
     FieldAsync <BookType>(
         name: "createBook",
         description: "",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <BookInputType> > {
         Name = "book"
     }),
         resolve: async context =>
     {
         var book      = context.GetArgument <BookDto>("book");
         var addedBook = await libraryService.AddBookAsync(book);
         messageService.AddBookAddedMessage(addedBook);
         return(addedBook);
     });
 }