Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 55 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. using EatMore.API.Models.GraphQL;
  2. using GraphQL.Types;
  3. using Microsoft.EntityFrameworkCore;
  4. using System;
  5. using System.Linq;
  6.  
  7. namespace EatMore.API.Query
  8. {
  9.     public class EatMoreQuery : ObjectGraphType
  10.     {
  11.         public EatMoreQuery(AppContext db)
  12.         {
  13.             Field<RestaurantType>(
  14.                 "restaurant",
  15.                 arguments: new QueryArguments(
  16.                     new QueryArgument<IdGraphType> { Name = "id", Description = "The ID of the restaurant." }),
  17.                 resolve: context =>
  18.                 {
  19.                     var id = context.GetArgument<Guid?>("id");
  20.                     var restaurant = db
  21.                         .Restaurants
  22.                         .Include("Menus.MenuItems")
  23.                         .FirstOrDefault(i => i.Id == id);
  24.                     return restaurant;
  25.                 });
  26.  
  27.             Field<ListGraphType<RestaurantType>>(
  28.                 "restaurants",
  29.                 resolve: context =>
  30.                 {
  31.                     var restaurants = db.Restaurants.Include("Menus.MenuItems");
  32.                     return restaurants;
  33.                 });
  34.         }
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top