예제 #1
0
        public StarWarsQuery()
        {
            r = new StarWarsRequest(new System.Net.Http.HttpClient());

            Name = "Query";

            Field <FilmType>(
                "film",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id", Description = "id of the film"
            }
                    ),
                resolve: context => { return(r.GetFilm(context.GetArgument <string>("id"))); } //data.GetHumanByIdAsync(context.GetArgument<string>("id"))
                );

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

            //Func<ResolveFieldContext, string, object> func = (context, id) => data.GetDroidByIdAsync(id);

            //FieldDelegate<DroidType>(
            //    "droid",
            //    arguments: new QueryArguments(
            //        new QueryArgument<NonNullGraphType<StringGraphType>> { Name = "id", Description = "id of the droid" }
            //    ),
            //    resolve: func
            //);
        }
예제 #2
0
        public FilmType()
        {
            r = new StarWarsRequest(new System.Net.Http.HttpClient());

            Name        = "Field";
            Description = "a film in the star wars franchise";

            Field(d => d.Title, nullable: true).Description("Title of the film");

            Field(d => d.EpisodeID, nullable: true).Description("Episode number in StaWars canon.");

            Field(d => d.OpeningCrawl, nullable: true).Description("opening scolling test at the beginning of the film");

            Field(d => d.Director, nullable: true).Description("Director of the film");

            Field(d => d.Producer, nullable: true).Description("Producer of the film");

            Field(d => d.ReleaseDate, nullable: true).Description("Release date of the film");

            Field <ListGraphType <PersonType> >(
                "characters",
                resolve: context => {
                return(r.GetPeople(new List <String>(context.Source.Characters)));
            }
                );
        }