public StaticMutation(UbigiaData data)
        {
            Name = "Mutation";

            Field <HumanType>(
                name: "createHuman",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <HumanInputType> > {
                Name = "human"
            }),
                resolve: context =>
            {
                var human = context.GetArgument <Human>("human");
                return(data.AddHuman(human));
            });
        }
Beispiel #2
0
        public StaticQuery(UbigiaData data)
        {
            Name = "Query";

            Field <CharacterInterface>(
                name: "hero",
                resolve: context => data.GetDroidByIdAsync("3"));
            Field <HumanType>(
                name: "human",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id", Description = "id of the human"
            }),
                resolve: context => data.GetHumanByIdAsync(context.GetArgument <string>("id"))
                );

            FieldDelegate <DroidType>(
                name: "droid",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id", Description = "id of the droid"
            }),
                resolve: new Func <ResolveFieldContext, string, object>((context, id) => data.GetDroidByIdAsync(id))
                );
        }