예제 #1
0
        public ZombieMutation(IZombieStore <Zombie> store, IZombieBreedTypeGenerator zombieBreedTypeGenerator)
        {
            Field <ZombieType>($"Add{nameof(Zombie)}",
                               arguments: new QueryArguments(
                                   new QueryArgument <ZombieInputType> {
                Name = "model"
            }
                                   ),
                               resolve: context =>
            {
                var zombie  = context.GetArgument <Zombie>("model");
                zombie.Type = zombieBreedTypeGenerator.Generate();

                store.Add(zombie);

                return(zombie);
            });
        }
예제 #2
0
 public ZombieQuery(IZombieStore <Zombie> store)
 {
     FieldAsync <ListGraphType <ZombieType>, IReadOnlyCollection <Zombie> >($"{nameof(Zombie)}s", resolve: context => store.GetAll().AsTask());
     Field <ListGraphType <ZombieBreedType> >($"{nameof(ZombieBreed)}s", resolve: context => Const.ZombieBreedList)
     .AuthorizeWith(Const.AuthorizedPolicy);
 }
예제 #3
0
 public ZombieSubscription(IZombieStore <Zombie> store)
 {
     FieldSubscribe <ZombieType>($"{nameof(Zombie)}sUpdated", resolve: ctx => ctx.Source, subscribe: ctx => store.Stream);
 }