示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, StarWarsDB db)
        {
            app.UseDeveloperExceptionPage();

            app.UseGraphQL <StarWarsSchema>("/graphql");

            // Create a very simple page with 2 links on it to demo the API.
            // These are not required for the API to work
            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("<html><body><a href=\"graphql?Query={ jedis { name, side } }\" > Get All</a><br /><a href=\"graphql?Query={ jedi(id: 1) { name } }\" > Get Luke</a><br /></body></html>");
                });
            });
        }
 public Jedi GetJedi(int id)
 {
     return(StarWarsDB.GetJedis().SingleOrDefault(x => x.Id == id));
 }
 public IEnumerable <Jedi> GetJedis()
 {
     return(StarWarsDB.GetJedis());
 }