Ejemplo n.º 1
0
        public StarWarsQuery()
        {
            var data = new StarWarsData();

            Name = "Query";

            Field<CharacterInterface>("hero", resolve: context => data.GetDroidById("3"));
            Field<HumanType>(
                "human",
                arguments: new QueryArguments(
                    new []
                    {
                        new QueryArgument { Name = "id", Type = NonNullGraphType.String}
                    }),
                resolve: context => data.GetHumanById((string)context.Arguments["id"])
            );
            Field<DroidType>(
                "droid",
                arguments: new QueryArguments(
                    new []
                    {
                        new QueryArgument { Name = "id", Type = NonNullGraphType.String}
                    }),
                resolve: context => data.GetDroidById((string)context.Arguments["id"])
            );
        }
        public Droid Droid(Id id)
        {
            var dto = _data.GetDroidById(id);

            return(dto == null ? null : new Droid(dto, _data));
        }