public MafiaQuery(MafiaData data)
        {
            Name = "Query";

            Field <BossType>("boss", resolve: context => data.GetFamilyBoss());
            Field <UnderBossType>("underboss", resolve: context => data.GetUnderBoss());

            Field <CapoType>(
                "capo",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id", Description = "id of the capo"
            }
                    ),
                resolve: context => data.GetCapoById(context.GetArgument <string>("id"))
                );

            Field <SoldierType>(
                "soldier",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> >
            {
                Name = "id", Description = "id of the soldier"
            }
                    ),
                resolve: context => data.GetSoldierById(context.GetArgument <string>("id"))
                );

            Field <ListGraphType <CapoType> >(
                "capos",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> >
            {
                Name = "id", Description = "id of the underboss"
            }
                    ),
                resolve: context => data.GetCapos(new UnderBoss()
            {
                Id = context.GetArgument <string>("id")
            }));

            Field <ListGraphType <SoldierType> >(
                "soldiers",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> >
            {
                Name = "id", Description = "id of the capo"
            }
                    ),
                resolve: context => data.GetCapoSoldiers(new Capo()
            {
                Id = context.GetArgument <string>("id")
            }));
        }
Beispiel #2
0
        public MafiaMutation(MafiaData data)
        {
            Name = "Mutation";

            Field <SoldierType>(
                "createSoldier",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <SoldierInputType> > {
                Name = "soldier"
            },
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id", Description = "id of the capo"
            }
                    ),
                resolve: context =>
            {
                var soldier = context.GetArgument <Soldier>("soldier");
                var id      = context.GetArgument <string>("id");
                return(data.AddSoldierToCapo(id, soldier));
            });
        }