예제 #1
0
 public StoreType(IDummyRepo repo)
 {
     Name = "Store";
     Field(o => o.ID).Name("id").Description("The store's ID.");
     Field(o => o.Country).Description("The store country.");
     Field(o => o.Name).Description("The name of the store.");
     Field(o => o.Address).Description("The store address.");
     Field(o => o.Created).Description("Store creation date.");
 }
예제 #2
0
 public PersonType(IDummyRepo repo)
 {
     Name = "Person";
     Field(o => o.ID).Name("id").Description("The person ID.");
     Field(o => o.Name, nullable: true).Description("The person's name.");
     Field(o => o.Created).Description("When the person entry was created.");
     Field <ListGraphType <TransactionType> >(
         name: "transactions",
         description: "The persons's transactions.",
         resolve: context => repo.GetTransactionsAsync(context.Source));
 }
예제 #3
0
 public TransactionType(IDummyRepo repo)
 {
     Name = "Transaction";
     Field(o => o.ID).Name("id").Description("The transaction ID.");
     Field(o => o.PersonID).Description("The ID of the person who created the transaction.");
     Field(o => o.Total).Description("The total transaction amount.");
     Field(o => o.Created).Description("When the transaction entry was created.");
     Field <ListGraphType <PurchaseType> >(
         name: "purchases",
         description: "The transaction's purchases.",
         resolve: context => repo.GetPurchasesAsync(context.Source));
 }
예제 #4
0
 public PurchaseType(IDummyRepo repo)
 {
     Name = "Purchase";
     Field(o => o.ProductID).Description("The purchase's product ID.");
     Field(o => o.TransactionID).Description("The purchase's transaction ID.");
     Field(o => o.Count).Description("Number of products purchased.");
     Field(o => o.Price).Description("Total purchase price.");
     Field(o => o.Created).Description("Purchase date.");
     Field <ProductType>(
         name: "product",
         description: "The product for this purchase.",
         resolve: context => repo.GetProductAsync(context.Source));
 }
예제 #5
0
 public ProductType(IDummyRepo repo)
 {
     Name = "Product";
     Field(o => o.ID).Name("id").Description("The product's ID.");
     Field(o => o.StoreID).Description("The product's store ID.");
     Field(o => o.Name).Description("Name of the product.");
     Field(o => o.Price).Description("Total purchase price.");
     Field(o => o.Created).Description("Product creation date.");
     Field(o => o.Description).Description("Product description.");
     Field <StoreType>(
         name: "store",
         description: "The store where this product is sold.",
         resolve: context => repo.GetStoreAsync(context.Source));
 }
예제 #6
0
 public DummyQuery(IDummyRepo repo)
 {
     Name = "TransactionsQuery";
     FieldAsync <ListGraphType <StoreType> >(name: "stores", resolve: async context => await repo.GetStoresAsync());
     FieldAsync <ListGraphType <PersonType> >(name: "people", resolve: async context => await repo.GetPeopleAsync());
     FieldAsync <ListGraphType <ProductType> >(name: "products", resolve: async context => await repo.GetProductsAsync());
     FieldAsync <ListGraphType <PurchaseType> >(name: "purchases", resolve: async context => await repo.GetPurchasesAsync());
     FieldAsync <ListGraphType <TransactionType> >(name: "transactions", resolve: async context => await repo.GetTransactionsAsync());
     FieldAsync <PersonType>(
         name: "person",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <GuidGraphType> > {
         Name = "id", Description = "The persons's ID."
     }),
         resolve: async context =>
     {
         var id = context.GetArgument <Guid>("id");
         return(await repo.GetPersonAsync(id));
     });
 }
예제 #7
0
 public DummyMutation(IDummyRepo repo)
 {
     Name = "TransactionsMutation";
     FieldAsync <PersonType>(
         name: "addPerson",
         description: "Adds a person",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <StringGraphType> > {
         Name = "name"
     }),
         resolve: async context =>
     {
         var name = context.GetArgument <string>("name");
         return(await repo.AddPersonAsync(name));
     });
     FieldAsync <PersonType>(
         name: "removePerson",
         description: "Removes a person",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <GuidGraphType> > {
         Name = "id"
     }),
         resolve: async context =>
     {
         var id = context.GetArgument <Guid>("id");
         return(await repo.RemovePersonAsync(id));
     });
     FieldAsync <StoreType>(
         name: "addStore",
         description: "Adds a store",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <StoreInputType> > {
         Name = "store"
     }),
         resolve: async context =>
     {
         var store = context.GetArgument <Store>("store");
         return(await repo.AddStoreAsync(store));
     });
     FieldAsync <StoreType>(
         name: "removeStore",
         description: "Removes a store",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <GuidGraphType> > {
         Name = "id"
     }),
         resolve: async context =>
     {
         var id = context.GetArgument <Guid>("id");
         return(await repo.RemoveStoreAsync(id));
     });
     FieldAsync <ProductType>(
         name: "addProduct",
         description: "Adds a product",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <ProductInputType> > {
         Name = "product"
     }),
         resolve: async context =>
     {
         var product = context.GetArgument <Product>("product");
         return(await repo.AddProductAsync(product));
     });
     FieldAsync <ProductType>(
         name: "removeProduct",
         description: "Removes a product",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <GuidGraphType> > {
         Name = "id"
     }),
         resolve: async context =>
     {
         var id = context.GetArgument <Guid>("id");
         return(await repo.RemoveProductAsync(id));
     });
     FieldAsync <PurchaseType>(
         name: "addPurchase",
         description: "Adds a purchase",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <PurchaseInputType> > {
         Name = "purchase"
     }),
         resolve: async context =>
     {
         var purchase = context.GetArgument <Purchase>("purchase");
         return(await repo.AddPurchaseAsync(purchase));
     });
     FieldAsync <PurchaseType>(
         name: "removePurchase",
         description: "Removes a purchase",
         arguments: new QueryArguments(
             new QueryArgument <NonNullGraphType <GuidGraphType> > {
         Name = "productID"
     },
             new QueryArgument <NonNullGraphType <GuidGraphType> > {
         Name = "transactionID"
     }),
         resolve: async context =>
     {
         var productID     = context.GetArgument <Guid>("productID");
         var transactionID = context.GetArgument <Guid>("transactionID");
         return(await repo.RemovePurchaseAsync(productID, transactionID));
     });
     FieldAsync <TransactionType>(
         name: "addTransaction",
         description: "Adds a transaction",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <TransactionInputType> > {
         Name = "transaction"
     }),
         resolve: async context =>
     {
         var transaction = context.GetArgument <Transaction>("transaction");
         return(await repo.AddTransactionAsync(transaction));
     });
     FieldAsync <TransactionType>(
         name: "removeTransaction",
         description: "Removes a transaction",
         arguments: new QueryArguments(
             new QueryArgument <NonNullGraphType <GuidGraphType> > {
         Name = "id"
     },
             new QueryArgument <NonNullGraphType <GuidGraphType> > {
         Name = "personID"
     }),
         resolve: async context =>
     {
         var id       = context.GetArgument <Guid>("id");
         var personID = context.GetArgument <Guid>("personID");
         return(await repo.RemoveTransactionAsync(id, personID));
     });
 }
예제 #8
0
 public DummyService(ILogger <DummyService> logger, IDummyRepo repo)
 {
     this.logger = logger;
     this.repo   = repo;
 }