示例#1
0
 public GraphTypeBuilder <Child> Configure(GraphTypeBuilder <Child> builder)
 => builder
 .ListField(x => x.ListOfInts).Preloaded()
 .ListField(x => x.ListOfTextures).Preloaded()
 .ScalarField(x => x.ComplexThing).Preloaded()
 .ListField(x => x.MoreThings).Preloaded()
 ;
示例#2
0
        public void DefaultName()
        {
            var map       = new Internal.ScalarTypeMap();
            var cache     = new Internal.GraphTypeCache(map);
            var graphType = new GraphTypeBuilder <Model>(map).BuildGraphType(cache, new ServiceCollection());

            graphType.Name.Should().Be(nameof(Model));
        }
示例#3
0
        public void CustomName()
        {
            var graphType = new GraphTypeBuilder <Model>(new Internal.ScalarTypeMap())
                            .Named("ImmaCustomName")
                            .BuildGraphType(new Internal.GraphTypeCache(new Internal.ScalarTypeMap()), new ServiceCollection());

            graphType.Name.Should().Be("ImmaCustomName");
        }
示例#4
0
 public GraphTypeBuilder <SimpleScalarQueryModel <Child> > Configure(GraphTypeBuilder <SimpleScalarQueryModel <Child> > builder)
 {
     return(builder
            .Named("Query")
            .LooseScalarField(x => x.Child)
            .WithArgs <Args>()
            .ResolvesVia <Resolver>()
            );
 }
示例#5
0
        public void ThrowsForUnspecifiedPropSameType()
        {
            var map     = new Internal.ScalarTypeMap();
            var builder = new GraphTypeBuilder <Model>(map)
                          .ScalarField(x => x.Child1)
                          .ResolvesVia <ChildModel1.Resolver>();

            new Action(() => builder.BuildGraphType(new Internal.GraphTypeCache(map), new ServiceCollection()))
            .Should()
            .Throw <UnableToResolveException>()
            .WithMessage("Unable to resolve property Child1a on class Model");
        }
示例#6
0
        public void BuildsSchema()
        {
            var map     = new Internal.ScalarTypeMap();
            var builder = new GraphTypeBuilder <Model>(map)
                          .ScalarField(x => x.Child1)
                          .ResolvesVia <ChildModel1.Resolver>()
                          .ScalarField(x => x.Child1a)
                          .ResolvesVia <ChildModel1.Resolver>()
                          .ScalarField(x => x.Child2)
                          .ResolvesVia <ChildModel2.Resolver>();

            builder.BuildGraphType(new Internal.GraphTypeCache(map), new ServiceCollection()).Should().NotBeNull();
        }
示例#7
0
        public void OverrideToId()
        {
            var map       = new Internal.ScalarTypeMap();
            var graphType = new GraphTypeBuilder <Model>(map)
                            .ScalarField(x => x.StringVal)
                            .AsGraphType <IdGraphType>()
                            .BuildGraphType(new Internal.GraphTypeCache(map), new ServiceCollection());

            graphType.Fields
            .SingleOrDefault(x => x.Name == nameof(Model.StringVal))
            .Should()
            .BeEquivalentTo(new {
                Type = typeof(IdGraphType),
            });
        }
示例#8
0
 protected override GraphTypeBuilder <GrandchildObject> ConfigureGrandchild(GraphTypeBuilder <GrandchildObject> builder)
 {
     return(builder.ScalarField(x => x.CircularRelationship)
            .ResolvesVia <ChildFromGrandchildResolver>());
 }
示例#9
0
 protected virtual GraphTypeBuilder <GrandchildObject> ConfigureGrandchild(GraphTypeBuilder <GrandchildObject> builder)
 {
     return(builder.IgnoreProperty(x => x.CircularRelationship));
 }
示例#10
0
 private GraphTypeBuilder <ChildObject> ConfigureChildObject(GraphTypeBuilder <ChildObject> builder)
 {
     return(builder.ScalarField(x => x.Child)
            .ResolvesVia <GrandchildResolver>());
 }
示例#11
0
 internal ConnectionFieldWithArgsBuilder(GraphTypeBuilder <T> parent, Expression <Func <T, IEnumerable <TElem> > > propExpr)
 {
     _parent   = parent;
     _propExpr = propExpr;
 }
示例#12
0
 private GraphTypeBuilder <ChildObject> ConfigureChildObject(GraphTypeBuilder <ChildObject> builder)
 {
     return(builder.ScalarField(x => x.Child)
            .Preloaded());
 }
示例#13
0
 private GraphTypeBuilder <Query> ConfigureQuery(GraphTypeBuilder <Query> builder) =>
 builder
 .Nullable(x => x.Nullable);
示例#14
0
 internal ScalarFieldBuilder(GraphTypeBuilder <TModel> parentBuilder, PropertyInfo prop)
 {
     _parentBuilder = parentBuilder;
     _prop          = prop;
 }
示例#15
0
 public GraphTypeBuilder <Args> Configure(GraphTypeBuilder <Args> builder)
 => builder.IgnoreProperty(x => x.IgnoredString);
示例#16
0
 private GraphTypeBuilder <ChildObject> BuildChildObject(GraphTypeBuilder <ChildObject> builder)
 {
     return(ConfigureViaBaseType(builder)
            .IgnoreProperty(x => x.Ignored));
 }
示例#17
0
 internal LooseScalarFieldWithArgsBuilder(GraphTypeBuilder <TModel> parentBuilder, PropertyInfo prop)
 {
     _parentBuilder = parentBuilder;
     _prop          = prop;
 }
示例#18
0
 private GraphTypeBuilder <ConnectionArgs> ConfigureArgs(GraphTypeBuilder <ConnectionArgs> builder)
 {
     return(builder.ConfigureOrderBy(
                x => x.OrderBy,
                ConfigureOrderBy));
 }
示例#19
0
 internal ListFieldBuilder(GraphTypeBuilder <TModel> parentBuilder, PropertyInfo prop, ScalarTypeMap scalarTypeMap)
 {
     _parentBuilder = parentBuilder;
     _prop          = prop;
     _scalarTypeMap = scalarTypeMap;
 }
示例#20
0
 public AuthorizationBuilder(GraphTypeBuilder <TModel> parent, Expression <Func <TModel, TProp> > expr)
 {
     this._parent = parent;
     this._expr   = expr;
 }
示例#21
0
 internal LooseListFieldBuilder(GraphTypeBuilder <TModel> parentBuilder, Expression <Func <TModel, IEnumerable <TElem> > > propExpr, ScalarTypeMap scalarTypeMap)
 {
     _scalarTypeMap = scalarTypeMap;
     _parentBuilder = parentBuilder;
     _propExpr      = propExpr;
 }
示例#22
0
 internal LooseListFieldWithArgsBuilder(GraphTypeBuilder <TModel> parentBuilder, Expression <Func <TModel, IEnumerable <TElem> > > propExpr)
 {
     _parentBuilder = parentBuilder;
     _propExpr      = propExpr;
 }
示例#23
0
 private GraphTypeBuilder <T> ConfigureViaBaseType <T>(GraphTypeBuilder <T> builder) where T : class, IChildObjectBase
 {
     return(builder.IgnoreProperty(x => x.IgnoredViaBase));
 }
示例#24
0
 private GraphTypeBuilder <Args> ConfigureArgs(GraphTypeBuilder <Args> builder) =>
 builder
 .NonNullable(x => x.OrderBy)
 .Nullable(x => x.SearchText);