Esempio n. 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);
            });
        }
Esempio n. 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);
 }
 public ZombieSubscription(IZombieStore <Zombie> store)
 {
     FieldSubscribe <ZombieType>($"{nameof(Zombie)}sUpdated", resolve: ctx => ctx.Source, subscribe: ctx => store.Stream);
 }