Beispiel #1
0
        static NextStepInfo getNextStepForIf(
            ISagaAction sagaAction,
            ISagaStep step,
            SagaExecutionState sagaState)
        {
            if (step.Is <ISagaStepForIf>())
            {
                IStepData currentStepData = sagaState.History.
                                            GetLatestByStepName(step.StepName);

                if (currentStepData?.ExecutionData?.ConditionResult == true)
                {
                    return(new NextStepInfo {
                        NextStep = step.ChildSteps.GetFirstStep()
                    });
                }
                else
                {
                    return(new NextStepInfo {
                        NextStep = GetNextStepElsewhere(sagaAction.ChildSteps, step)
                    });
                }
            }
            return(null);
        }
Beispiel #2
0
        static bool getResultFromPrevIfElse(
            SagaSteps childSteps,
            ISagaStep step,
            SagaExecutionState sagaState)
        {
            while (true)
            {
                ISagaStep prevStepIf = GetPrevStepSameLevel(childSteps, step.ParentStep, step);
                if (prevStepIf.Is <ISagaStepForIf>())
                {
                    IStepData stepDataIf = sagaState.History.
                                           GetLatestByStepName(prevStepIf.StepName);

                    if (stepDataIf?.ExecutionData?.ConditionResult == true)
                    {
                        return(true);
                    }

                    if (!prevStepIf.Is <ISagaStepForElse>())
                    {
                        return(false);
                    }

                    step = prevStepIf;
                }
                else
                {
                    return(false);
                }
            }
        }
        public async Task Execute(
            IServiceProvider serviceProvider,
            IExecutionContext context,
            ISagaEvent @event,
            IStepData stepData)
        {
            if (typeof(TExecuteEvent) == typeof(EmptyEvent))
            {
                return;
            }

            ISagaInternalCoordinator sagaCoordinator = serviceProvider.
                                                       GetRequiredService <ISagaCoordinator>() as ISagaInternalCoordinator;

            IExecutionContext <TSagaData> contextForAction =
                (IExecutionContext <TSagaData>)context;

            TExecuteEvent executionEvent = new TExecuteEvent();

            if (ActionDelegate != null)
            {
                await ActionDelegate(contextForAction, executionEvent);
            }

            ISaga newSaga = await sagaCoordinator.
                            Publish(executionEvent, contextForAction.ExecutionValues, contextForAction.Data.ID, new SagaRunOptions());
        }
        public async Task Execute(
            IServiceProvider serviceProvider,
            IExecutionContext context,
            ISagaEvent @event,
            IStepData stepData)
        {
            if (typeof(TExecuteEvent) == typeof(EmptyEvent))
            {
                return;
            }

            ISagaCoordinator sagaCoordinator = serviceProvider.
                                               GetRequiredService <ISagaCoordinator>();

            IExecutionContext <TSagaData> contextForAction =
                (IExecutionContext <TSagaData>)context;

            TExecuteEvent executionEvent = new TExecuteEvent();

            if (action != null)
            {
                await action(contextForAction, executionEvent);
            }

            await sagaCoordinator.
            Publish(executionEvent, contextForAction.ExecutionValues);
        }
Beispiel #5
0
 public async Task Compensate(
     IServiceProvider serviceProvider,
     IExecutionContext context,
     ISagaEvent @event,
     IStepData stepData)
 {
 }
Beispiel #6
0
 public async Task Execute(
     IServiceProvider serviceProvider,
     IExecutionContext context,
     ISagaEvent @event,
     IStepData stepData)
 {
     (context.ExecutionState as SagaExecutionState).IsBreaked = true;
 }
        /// <inheritdoc />
        public override void Unlock(IStepData data, IEnumerable <LockablePropertyData> manualUnlocked)
        {
            IEnumerable <LockablePropertyData> unlockList = PropertyReflectionHelper.ExtractLockablePropertiesFromStep(data);

            unlockList = unlockList.Union(manualUnlocked);

            foreach (LockablePropertyData lockable in unlockList)
            {
                lockable.Property.SetLocked(false);
            }
        }
 public ProductType(IStockProductData _stockProductData,
                    ICategoryData _categoryData,
                    IStepData _stepData)
 {
     Field(_ => _.Id);
     Field(_ => _.Desc);
     Field(_ => _.CategoryId);
     Field(_ => _.Type);
     Field <ListGraphType <StockProductType> >(
         "stockProduct",
         resolve: context => _stockProductData.GetStocksAsync(context.Source.Id));
     Field <CategoryType>(
         "category",
         resolve: context => _categoryData.GetAsync(context.Source.CategoryId));
 }
Beispiel #9
0
        public override Rect Draw(Rect rect, object currentValue, Action <object> changeValueCallback, GUIContent label)
        {
            if (BuildPipeline.isBuildingPlayer)
            {
                return(rect);
            }

            rect = base.Draw(rect, currentValue, changeValueCallback, label);

            Step.EntityData step = (Step.EntityData)currentValue;

            if (step.Metadata == null)
            {
                step.Metadata = new Metadata();
            }

            if (lastStep != step)
            {
                lockablePropertyTab = new LockablePropertyTab(new GUIContent("Unlocked Objects"), step);
                lastStep            = step;
            }

            GUIContent behaviorLabel = new GUIContent("Behaviors");

            if (EditorConfigurator.Instance.Validation.LastReport != null && EditorConfigurator.Instance.Validation.LastReport.GetBehaviorEntriesFor(step).Count > 0)
            {
                behaviorLabel.image = EditorGUIUtility.IconContent("Warning").image;
            }

            GUIContent transitionLabel = new GUIContent("Transitions");

            if (EditorConfigurator.Instance.Validation.LastReport != null && EditorConfigurator.Instance.Validation.LastReport.GetConditionEntriesFor(step).Count > 0)
            {
                transitionLabel.image = EditorGUIUtility.IconContent("Warning").image;
            }

            TabsGroup activeTab = new TabsGroup(
                step.Metadata,
                new DynamicTab(behaviorLabel, () => step.Behaviors, value => step.Behaviors       = (IBehaviorCollection)value),
                new DynamicTab(transitionLabel, () => step.Transitions, value => step.Transitions = (ITransitionCollection)value),
                lockablePropertyTab
                );

            Rect tabRect = new TabsGroupDrawer().Draw(new Rect(rect.x, rect.y + rect.height + 4f, rect.width, 0), activeTab, changeValueCallback, label);

            rect.height += tabRect.height;
            return(rect);
        }
Beispiel #10
0
        public static List <LockablePropertyData> ExtractLockablePropertiesFromStep(IStepData data)
        {
            List <LockablePropertyData> result = new List <LockablePropertyData>();

            if (data == null)
            {
                return(result);
            }

            foreach (ITransition transition in data.Transitions.Data.Transitions)
            {
                foreach (ICondition condition in transition.Data.Conditions)
                {
                    result.AddRange(ExtractLockablePropertiesFromConditions(condition.Data));
                }
            }

            return(result);
        }
        /// <inheritdoc />
        public override void Lock(IStepData data, IEnumerable <LockablePropertyData> manualUnlocked)
        {
            // All properties which should be locked
            IEnumerable <LockablePropertyData> lockList = PropertyReflectionHelper.ExtractLockablePropertiesFromStep(data);

            lockList = lockList.Union(manualUnlocked);

            ITransition completedTransition = data.Transitions.Data.Transitions.FirstOrDefault(transition => transition.IsCompleted);

            if (completedTransition != null)
            {
                IStepData nextStepData = GetNextStep(completedTransition);
                IEnumerable <LockablePropertyData> nextStepProperties = PropertyReflectionHelper.ExtractLockablePropertiesFromStep(nextStepData);
                if (nextStepData != null && nextStepData is ILockableStepData lockableStepData)
                {
                    IEnumerable <LockablePropertyData> toUnlock = lockableStepData.ToUnlock.Select(reference => new LockablePropertyData(reference.GetProperty()));
                    nextStepProperties = nextStepProperties.Union(toUnlock);
                }

                if (completedTransition is ILockablePropertiesProvider completedLockableTransition)
                {
                    IEnumerable <LockablePropertyData> transitionLockList = completedLockableTransition.GetLockableProperties();
                    foreach (LockablePropertyData lockable in transitionLockList)
                    {
                        lockable.Property.SetLocked(lockable.EndStepLocked && nextStepProperties.Contains(lockable) == false);
                    }

                    // Remove all lockable from completed transition
                    lockList = lockList.Except(transitionLockList);
                }
                // Remove all lockable from
                lockList = lockList.Except(nextStepProperties);
            }

            foreach (LockablePropertyData lockable in lockList)
            {
                lockable.Property.SetLocked(true);
            }
        }
        public async Task Execute(IServiceProvider serviceProvider, IExecutionContext context, ISagaEvent @event, IStepData stepData)
        {
            IExecutionContext <TSagaData> contextForAction =
                (IExecutionContext <TSagaData>)context;

            if (action != null)
            {
                bool result = await action(contextForAction);

                stepData.ExecutionData.ConditionResult = result;
            }
            else
            {
                stepData.ExecutionData.ConditionResult = false;
            }
        }
        public async Task Compensate(IServiceProvider serviceProvider, IExecutionContext context, ISagaEvent @event, IStepData stepData)
        {
            IExecutionContext <TSagaData> contextForAction =
                (IExecutionContext <TSagaData>)context;

            if (compensation != null)
            {
                await compensation(contextForAction);
            }
        }
 /// <summary>
 /// Locks all unlocked LockableProperties for the current step.
 /// </summary>
 /// <param name="data">IStepData of the current step</param>
 /// <param name="manualUnlocked">All LockableProperties which were unlocked in addition</param>
 public abstract void Lock(IStepData data, IEnumerable <LockablePropertyData> manualUnlocked);
        public async Task Execute(IServiceProvider serviceProvider, IExecutionContext context, ISagaEvent @event, IStepData stepData)
        {
            IExecutionContext <TSagaData> contextForAction =
                (IExecutionContext <TSagaData>)context;

            TEventHandler activity = (TEventHandler)ActivatorUtilities.CreateInstance(serviceProvider, typeof(TEventHandler));

            if (activity != null)
            {
                await activity.Execute(contextForAction, (TEvent)@event);
            }
        }
Beispiel #16
0
        private string CalculateNextStep(ISaga saga, ISagaAction sagaAction, ISagaStep sagaStep, IStepData stepData = null)
        {
            if (saga.ExecutionState.IsResuming)
            {
                return(sagaStep.StepName);
            }

            if (saga.ExecutionState.IsCompensating)
            {
                return(CalculateNextCompensationStep(saga));
            }

            return(sagaAction.
                   GetNextStepToExecute(sagaStep, saga.ExecutionState)?.StepName);
        }
Beispiel #17
0
 /// <inheritdoc />
 public override void Lock(IStepData data, IEnumerable <LockablePropertyData> manualUnlocked)
 {
 }
Beispiel #18
0
        public async Task Compensate(IServiceProvider serviceProvider, IExecutionContext context, ISagaEvent @event, IStepData stepData)
        {
            IExecutionContext <TSagaData> contextForAction =
                (IExecutionContext <TSagaData>)context;

            TSagaActivity activity = (TSagaActivity)ActivatorUtilities.CreateInstance(serviceProvider, typeof(TSagaActivity));

            if (activity != null)
            {
                await activity.Compensate(contextForAction);
            }
        }
Beispiel #19
0
        public async Task Execute(IServiceProvider serviceProvider, IExecutionContext context, ISagaEvent @event, IStepData stepData)
        {
            IExecutionContext <TSagaData> contextForAction =
                (IExecutionContext <TSagaData>)context;

            TSagaCondition activity = (TSagaCondition)ActivatorUtilities.CreateInstance(serviceProvider, typeof(TSagaCondition));

            if (activity != null)
            {
                bool result = await activity.Execute(contextForAction);

                stepData.ExecutionData.ConditionResult = result;
            }
            else
            {
                stepData.ExecutionData.ConditionResult = false;
            }
        }
Beispiel #20
0
        public RootQuery(IEmployeeData _employeeData,
                         IRoleData _roleData,
                         IPermissionData _permissionData,
                         ITaskData _taskData,
                         ICategoryData _categoryData,
                         IStockData _stockData,
                         IStepData _stepData,
                         IWineData _wineData,
                         IProductData _productData)
        {
//EMPLOYEES
            Field <ListGraphType <EmployeeType> >("employees", resolve: context =>
            {
                return(_employeeData.GetAllAsync());
            });

            Field <EmployeeType>("employee",
                                 arguments: new QueryArguments
            {
                new QueryArgument <IntGraphType> {
                    Name = "id"
                }
            },
                                 resolve: context =>
            {
                int id = context.GetArgument <int>("id");
                return(_employeeData.GetAsync(id));
            });

            Field <EmployeeType>("employeeEmail",
                                 arguments: new QueryArguments
            {
                new QueryArgument <StringGraphType> {
                    Name = "email"
                },
                new QueryArgument <StringGraphType> {
                    Name = "password"
                }
            },
                                 resolve: context =>
            {
                string email    = context.GetArgument <string>("email");
                string password = context.GetArgument <string>("password");
                return(_employeeData.GetByEmailPasswordAsync(email, password));
            });


//ROLES
            Field <ListGraphType <RoleType> >("roles", resolve: context =>
            {
                return(_roleData.GetAllAsync());
            });

            Field <RoleType>("role",
                             arguments: new QueryArguments
            {
                new QueryArgument <IntGraphType> {
                    Name = "id"
                }
            },
                             resolve: context =>
            {
                int id = context.GetArgument <int>("id");
                return(_roleData.GetAsync(id));
            });

//PERMISSIONS
            Field <ListGraphType <PermissionType> >("permissions", resolve: context =>
            {
                return(_permissionData.GetAllAsync());
            });

            Field <PermissionType>("permission",
                                   arguments: new QueryArguments
            {
                new QueryArgument <IntGraphType> {
                    Name = "id"
                }
            },
                                   resolve: context =>
            {
                int id = context.GetArgument <int>("id");
                return(_permissionData.GetAsync(id));
            });

// TASKS
            Field <ListGraphType <TaskType> >("tasks", resolve: context =>
            {
                return(_taskData.GetAllAsync());
            });

            Field <TaskType>("task",
                             arguments: new QueryArguments
            {
                new QueryArgument <IntGraphType> {
                    Name = "id"
                }
            },
                             resolve: context =>
            {
                int id = context.GetArgument <int>("id");
                return(_taskData.GetAsync(id));
            });

// CATEGORIES
            Field <ListGraphType <CategoryType> >("categories", resolve: context =>
            {
                return(_categoryData.GetAllAsync());
            });

            Field <CategoryType>("category",
                                 arguments: new QueryArguments
            {
                new QueryArgument <IntGraphType> {
                    Name = "id"
                }
            },
                                 resolve: context =>
            {
                int id = context.GetArgument <int>("id");
                return(_categoryData.GetAsync(id));
            });

// STOCKS
            Field <ListGraphType <StockType> >("stocks", resolve: context =>
            {
                return(_stockData.GetAllAsync());
            });

            Field <StockType>("stock",
                              arguments: new QueryArguments
            {
                new QueryArgument <IntGraphType> {
                    Name = "id"
                }
            },
                              resolve: context =>
            {
                // try{
                int id = context.GetArgument <int>("id");
                Console.WriteLine("entrou");
                return(_stockData.GetAsync(id));
                // } catch (Exception error) {
                // Console.WriteLine(error);
                // return null;
                // }
            });

// STEPS
            Field <ListGraphType <StepType> >("steps", resolve: context =>
            {
                return(_stepData.GetAllAsync());
            });

            Field <StepType>("step",
                             arguments: new QueryArguments
            {
                new QueryArgument <IntGraphType> {
                    Name = "id"
                }
            },
                             resolve: context =>
            {
                int id = context.GetArgument <int>("id");
                return(_stepData.GetAsync(id));
            });

// WINES
            Field <ListGraphType <WineType> >("wines", resolve: context =>
            {
                return(_wineData.GetAllAsync());
            });

            Field <WineType>("wine",
                             arguments: new QueryArguments
            {
                new QueryArgument <IntGraphType> {
                    Name = "id"
                }
            },
                             resolve: context =>
            {
                int id = context.GetArgument <int>("id");
                return(_wineData.GetAsync(id));
            });

// PRODUCTS
            Field <ListGraphType <ProductType> >("products", resolve: context =>
            {
                return(_productData.GetAllAsync());
            });

            Field <ProductType>("product",
                                arguments: new QueryArguments
            {
                new QueryArgument <IntGraphType> {
                    Name = "id"
                }
            },
                                resolve: context =>
            {
                int id = context.GetArgument <int>("id");
                return(_productData.GetAsync(id));
            });
        }
 public Task Execute(IServiceProvider serviceProvider, IExecutionContext context, ISagaEvent @event, IStepData stepData)
 {
     return(Task.CompletedTask);
 }
Beispiel #22
0
        // public RootMutation(IWineData wineData)
        // {
        //    Field<WineType>(
        //       "addWine",
        //       arguments: new QueryArguments
        //       {
        //          new QueryArgument<InputWineType>(){ Name = "wine"}
        //       },
        //       resolve: context =>
        //       {
        //          var wine = context.GetArgument<Wine>("wine");
        //          wineData.AddWine(wine);
        //          return null;
        //       }
        //    );
        // }

        public RootMutation(IEmployeeData employeeData,
                            IRoleData roleData,
                            IPermissionData permissionData,
                            ITaskData taskData,
                            ICategoryData categoryData,
                            IStockData stockData,
                            IStepData stepData,
                            IWineData wineData,
                            IProductData productData,
                            IStockProductData stockProductData,
                            IStockWineData stockWineData)
        {
// EMPLOYEE
            Field <EmployeeType>(
                "addEmployee",
                arguments: new QueryArguments
            {
                new QueryArgument <InputEmployeeType>()
                {
                    Name = "employee"
                }
            },
                resolve: context =>
            {
                var employee = context.GetArgument <Employee>("employee");
                return(employeeData.AddEmployee(employee));
            }
                );

            Field <EmployeeType>(
                "updateEmployee",
                arguments: new QueryArguments {
                new QueryArgument <InputEmployeeType>()
                {
                    Name = "employee"
                }
            },
                resolve: context =>
            {
                var employee = context.GetArgument <Employee>("employee");
                return(employeeData.Update(employee));
            }
                );

            Field <EmployeeType>(
                "deleteEmployee",
                arguments: new QueryArguments {
                new QueryArgument <InputEmployeeType>()
                {
                    Name = "employee"
                }
            },
                resolve: context =>
            {
                var employee = context.GetArgument <Employee>("employee");
                employeeData.Delete(employee);
                return(employee);
            }
                );


// ROLE
            Field <RoleType>(
                "addRole",
                arguments: new QueryArguments
            {
                new QueryArgument <InputRoleType>()
                {
                    Name = "role"
                }
            },
                resolve: context =>
            {
                var role = context.GetArgument <Role>("role");
                return(roleData.AddRole(role));
            }
                );

            Field <RoleType>(
                "updateRole",
                arguments: new QueryArguments {
                new QueryArgument <InputRoleType>()
                {
                    Name = "role"
                }
            },
                resolve: context =>
            {
                var role = context.GetArgument <Role>("role");
                return(roleData.Update(role));
            }
                );

            Field <RoleType>(
                "deleteRole",
                arguments: new QueryArguments {
                new QueryArgument <InputRoleType>()
                {
                    Name = "role"
                }
            },
                resolve: context =>
            {
                var role = context.GetArgument <Role>("role");
                roleData.Delete(role);
                return(role);
            }
                );

// PERMISSION
            Field <PermissionType>(
                "addPermission",
                arguments: new QueryArguments
            {
                new QueryArgument <InputPermissionType>()
                {
                    Name = "permission"
                }
            },
                resolve: context =>
            {
                var permission = context.GetArgument <Permission>("permission");
                return(permissionData.AddPermission(permission));
            }
                );

            Field <PermissionType>(
                "updatePermission",
                arguments: new QueryArguments {
                new QueryArgument <InputPermissionType>()
                {
                    Name = "permission"
                }
            },
                resolve: context =>
            {
                var permission = context.GetArgument <Permission>("permission");
                return(permissionData.Update(permission));
            }
                );

            Field <PermissionType>(
                "deletePermission",
                arguments: new QueryArguments {
                new QueryArgument <InputPermissionType>()
                {
                    Name = "permission"
                }
            },
                resolve: context =>
            {
                var permission = context.GetArgument <Permission>("permission");
                permissionData.Delete(permission);
                return(permission);
            }
                );


// TASK
            Field <TaskType>(
                "addTask",
                arguments: new QueryArguments
            {
                new QueryArgument <InputTaskType>()
                {
                    Name = "task"
                }
            },
                resolve: context =>
            {
                var task = context.GetArgument <Task>("task");
                return(taskData.AddTask(task));
            }
                );

            Field <TaskType>(
                "updateTask",
                arguments: new QueryArguments {
                new QueryArgument <InputTaskType>()
                {
                    Name = "task"
                }
            },
                resolve: context =>
            {
                var task = context.GetArgument <Task>("task");
                return(taskData.Update(task));
            }
                );

            Field <TaskType>(
                "deleteTask",
                arguments: new QueryArguments {
                new QueryArgument <InputTaskType>()
                {
                    Name = "task"
                }
            },
                resolve: context =>
            {
                var task = context.GetArgument <Task>("task");
                taskData.Delete(task);
                return(task);
            }
                );


// CATEGORY
            Field <CategoryType>(
                "addCategory",
                arguments: new QueryArguments
            {
                new QueryArgument <InputCategoryType>()
                {
                    Name = "category"
                }
            },
                resolve: context =>
            {
                var category = context.GetArgument <Category>("category");
                return(categoryData.AddCategory(category));
            }
                );

            Field <CategoryType>(
                "updateCategory",
                arguments: new QueryArguments {
                new QueryArgument <InputCategoryType>()
                {
                    Name = "category"
                }
            },
                resolve: context =>
            {
                var category = context.GetArgument <Category>("category");
                return(categoryData.Update(category));
            }
                );

            Field <CategoryType>(
                "deleteCategory",
                arguments: new QueryArguments {
                new QueryArgument <InputCategoryType>()
                {
                    Name = "category"
                }
            },
                resolve: context =>
            {
                var category = context.GetArgument <Category>("category");
                categoryData.Delete(category);
                return(category);
            }
                );

// STOCK
            Field <StockType>(
                "addStock",
                arguments: new QueryArguments
            {
                new QueryArgument <InputStockType>()
                {
                    Name = "stock"
                }
            },
                resolve: context =>
            {
                var stock = context.GetArgument <Stock>("stock");
                return(stockData.AddStock(stock));
            }
                );

            Field <StockType>(
                "updateStock",
                arguments: new QueryArguments {
                new QueryArgument <InputStockType>()
                {
                    Name = "stock"
                }
            },
                resolve: context =>
            {
                var stock = context.GetArgument <Stock>("stock");
                return(stockData.Update(stock));
            }
                );

            Field <StockType>(
                "deleteStock",
                arguments: new QueryArguments {
                new QueryArgument <InputStockType>()
                {
                    Name = "stock"
                }
            },
                resolve: context =>
            {
                var stock = context.GetArgument <Stock>("stock");
                stockData.Delete(stock);
                return(stock);
            }
                );

// STEP
            Field <StepType>(
                "addStep",
                arguments: new QueryArguments
            {
                new QueryArgument <InputStepType>()
                {
                    Name = "step"
                }
            },
                resolve: context =>
            {
                var step = context.GetArgument <Step>("step");
                return(stepData.AddStep(step));
            }
                );

            Field <StepType>(
                "updateStep",
                arguments: new QueryArguments {
                new QueryArgument <InputStepType>()
                {
                    Name = "step"
                }
            },
                resolve: context =>
            {
                var step = context.GetArgument <Step>("step");
                return(stepData.Update(step));
            }
                );

            Field <StepType>(
                "deleteStep",
                arguments: new QueryArguments {
                new QueryArgument <InputStepType>()
                {
                    Name = "step"
                }
            },
                resolve: context =>
            {
                var step = context.GetArgument <Step>("step");
                stepData.Delete(step);
                return(step);
            }
                );

// WINE

            Field <WineType>(
                "addWine",
                arguments: new QueryArguments
            {
                new QueryArgument <InputWineType>()
                {
                    Name = "wine"
                }
            },
                resolve: context =>
            {
                var wine = context.GetArgument <Wine>("wine");
                return(wineData.AddWine(wine));
            }
                );

            Field <WineType>(
                "updateWine",
                arguments: new QueryArguments {
                new QueryArgument <InputWineType>()
                {
                    Name = "wine"
                }
            },
                resolve: context =>
            {
                var wine = context.GetArgument <Wine>("wine");
                return(wineData.Update(wine));
            }
                );

            Field <WineType>(
                "deleteWine",
                arguments: new QueryArguments {
                new QueryArgument <InputWineType>()
                {
                    Name = "wine"
                }
            },
                resolve: context =>
            {
                var wine = context.GetArgument <Wine>("wine");
                wineData.Delete(wine);
                return(wine);
            }
                );

// PRODUCT
            Field <ProductType>(
                "addProduct",
                arguments: new QueryArguments
            {
                new QueryArgument <InputProductType>()
                {
                    Name = "product"
                }
            },
                resolve: context =>
            {
                var product = context.GetArgument <Product>("product");
                return(productData.AddProduct(product));
            }
                );

            Field <ProductType>(
                "updateProduct",
                arguments: new QueryArguments {
                new QueryArgument <InputProductType>()
                {
                    Name = "product"
                }
            },
                resolve: context =>
            {
                var product = context.GetArgument <Product>("product");
                return(productData.Update(product));
            }
                );

            Field <ProductType>(
                "deleteProduct",
                arguments: new QueryArguments {
                new QueryArgument <InputProductType>()
                {
                    Name = "product"
                }
            },
                resolve: context =>
            {
                var product = context.GetArgument <Product>("product");
                productData.Delete(product);
                return(product);
            }
                );

// StockProduct
            Field <StockProductType>(
                "addStockProduct",
                arguments: new QueryArguments
            {
                new QueryArgument <InputStockProductType>()
                {
                    Name = "stockProduct"
                }
            },
                resolve: context =>
            {
                var stockProduct = context.GetArgument <StockProduct>("stockProduct");
                return(stockProductData.AddStockProduct(stockProduct));
            }
                );

            Field <StockProductType>(
                "updateStockProduct",
                arguments: new QueryArguments {
                new QueryArgument <InputStockProductType>()
                {
                    Name = "stockProduct"
                }
            },
                resolve: context =>
            {
                var stockProduct = context.GetArgument <StockProduct>("stockProduct");
                return(stockProductData.Update(stockProduct));
            }
                );

            Field <StockProductType>(
                "deleteStockProduct",
                arguments: new QueryArguments {
                new QueryArgument <InputStockProductType>()
                {
                    Name = "stockProduct"
                }
            },
                resolve: context =>
            {
                var stockProduct = context.GetArgument <StockProduct>("stockProduct");
                stockProductData.Delete(stockProduct);
                return(stockProduct);
            }
                );

// StockWine
            Field <StockWineType>(
                "addStockWine",
                arguments: new QueryArguments
            {
                new QueryArgument <InputStockWineType>()
                {
                    Name = "stockWine"
                }
            },
                resolve: context =>
            {
                var stockWine = context.GetArgument <StockWine>("stockWine");
                return(stockWineData.AddStockWine(stockWine));
            }
                );

            Field <StockWineType>(
                "updateStockWine",
                arguments: new QueryArguments {
                new QueryArgument <InputStockWineType>()
                {
                    Name = "stockWine"
                }
            },
                resolve: context =>
            {
                var stockWine = context.GetArgument <StockWine>("stockWine");
                return(stockWineData.Update(stockWine));
            }
                );

            Field <StockWineType>(
                "deleteStockWine",
                arguments: new QueryArguments {
                new QueryArgument <InputStockWineType>()
                {
                    Name = "stockWine"
                }
            },
                resolve: context =>
            {
                var stockWine = context.GetArgument <StockWine>("stockWine");
                stockWineData.Delete(stockWine);
                return(stockWine);
            }
                );
        }