public ProjectsSpecification(ProjectCommonController projects) { var safe = new Safe(_log); var options = new GraphQlQueryOptions <ProjectCommonController, ProjectModel, Project>(projects); Name = "Projects"; Field <ProjectSpecification>( "byId", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "id", Description = "id of the project" } ), resolve: safe.Wrap(context => projects.GetById(context.GetArgument <string>("id"))) ).RequirePermission(Activity.ReadProject); Field <ListGraphType <ProjectSpecification> >( "all", Description = "all projects", resolve: safe.Wrap(context => projects.Query(queryable => queryable)) ).RequirePermission(Activity.ReadProject); Field <ListGraphType <ProjectSpecification> >( "recent", Description = "recent modified projects", new QueryArguments( new QueryArgument <IntGraphType> { Name = "first", Description = "id of the project" } ), safe.Wrap(context => projects .Query(queryable => queryable .OrderByDescending(x => x.UpdateDate) .Take(context.HasArgument("first") ? context.GetArgument <int>("first") : 100) )) ).RequirePermission(Activity.ReadProject); Field <QueryResultSpecification>( "query", Description = "query the projects projects", options.GetArguments(), safe.Wrap(context => options.Query(context)) ).RequirePermission(Activity.ReadProject); }
public Task <ProjectModel> GetById(string id) { return(_projectCommonController.GetById(id)); }