public static ObjectGraphType AddStyleQueries(this ObjectGraphType objectGraphType, IRepository <Style> styleRepository) { objectGraphType.Field <ListGraphType <StyleType> >() .Name("styles") .Argument <IntGraphType>("amount", "The number of styles returned") .Argument <StringGraphType>("searchString", "The string to search") .Resolve(context => { var builder = new SpecificationBuilder <Style>(); var searchString = context.GetArgument <string>("searchString"); if (!string.IsNullOrWhiteSpace(searchString)) { builder.WithExpression(x => x.Name.Contains(searchString, System.StringComparison.InvariantCultureIgnoreCase)); } var amount = context.GetArgument <int?>("amount"); if (amount.HasValue && amount.Value > 0) { builder.WithAmount(amount.Value); } return(styleRepository.Get(builder.Build())); }); objectGraphType.Field <StyleType>() .Name("style") .Argument <IdGraphType>("id", "The id of the style") .Resolve(context => { var styleId = context.GetArgument <int>("id"); return(styleRepository.GetSingle(x => x.Id == styleId)); }); return(objectGraphType); }