Пример #1
0
        public DroidQuery(DroidService service)
        {
            Field <DroidType>(
                "droid", "Get one droid by id",
                arguments: new QueryArguments()
            {
                new QueryArgument <IntGraphType> {
                    Name        = "id",
                    Description = "Command to list droids"
                }
            },
                resolve: context => {
                var userConterxt = context.UserContext as DroidUserContext;
                var id           = context.GetArgument <int>("id");

                return(service.Get(id));
            }
                );

            Field <ListGraphType <DroidType> >(
                "droids", "Get lists droid by param",
                arguments: new QueryArguments()
            {
                new QueryArgument <ListInputType> {
                    Name         = "param",
                    DefaultValue = new FindDroidCmd(),
                    Description  = "Command to list doids"
                },
                new QueryArgument <ListGraphType <IntGraphType> > {
                    Name        = "id",
                    Description = "Command to list doids"
                },
                new QueryArgument <StringGraphType> {
                    Name        = "keyworks",
                    Description = "Command to list doids"
                }
            },
                resolve: context => {
                var userConterxt = context.UserContext as DroidUserContext;
                var param        = context.GetArgument <FindDroidCmd>("param");
                var keyworks     = context.GetArgument <string>("keyworks");
                var doid         = context.GetArgument <int[]>("id");

                param.Keyworks = keyworks ?? param.Keyworks;
                param.Droid    = doid ?? param.Droid;

                return(service.Find(param));
            }
                );
        }
Пример #2
0
        public DroidMutation(DroidService service)
        {
            Field <DroidType>(
                "createDroid", "Creating new droid",
                arguments: new QueryArguments()
            {
                new QueryArgument <CreateInputType> {
                    Name         = "command",
                    Description  = "Command to create droids",
                    DefaultValue = new CreateDroidCmd(),
                }
            },
                resolve: context => {
                var userConterxt = context.UserContext as DroidUserContext;
                var command      = context.GetArgument <CreateDroidCmd>("command");

                return(service.Create(command));
            }
                );

            Field <DroidType>(
                "updateDroid", "Update droid by id",
                arguments: new QueryArguments()
            {
                new QueryArgument <UpdateInputType> {
                    Name         = "command",
                    Description  = "Command to update droids",
                    DefaultValue = new UpdateDroidCmd(),
                }
            },
                resolve: context => {
                var userConterxt = context.UserContext as DroidUserContext;
                var command      = context.GetArgument <UpdateDroidCmd>("command");

                return(service.Update(command));
            }
                );
        }