Exemplo n.º 1
0
 protected override void Configure(IObjectTypeDescriptor <Cat> descriptor)
 {
     descriptor.Implements <PetType>();
     descriptor.Implements <BeingType>();
     descriptor.Implements <MammalType>();
     descriptor.Field(t => t.Name).Type <NonNullType <StringType> >();
     descriptor.Field(t => t.DoesKnowCommand(default))
        protected override void Configure(
            IObjectTypeDescriptor <SomeOtherContract> descriptor)
        {
            descriptor
            .AsNode()
            .IdField(t => t.Id)
            .NodeResolver((ctx, id) =>
            {
                return(Task.FromResult(
                           ctx.Service <ContractStorage>()
                           .Contracts
                           .OfType <SomeOtherContract>()
                           .FirstOrDefault(t => t.Id.Equals(id))));
            });

            descriptor.Implements <ContractType>();

            descriptor.Field(t => t.Id)
            .Type <NonNullType <IdType> >();

            descriptor.Field(t => t.CustomerId)
            .Type <NonNullType <IdType> >();

            descriptor.Field(t => t.ExpiryDate)
            .Type <NonNullType <DateTimeType> >();
        }
Exemplo n.º 3
0
 protected override void Configure(IObjectTypeDescriptor <Human> descriptor)
 {
     descriptor.Implements <SentientType>();
     descriptor.Implements <BeingType>();
     descriptor.Implements <IntelligentType>();
     descriptor.Field(t => t.Name).Type <NonNullType <StringType> >();
     descriptor.Field("iq")
     .Type <NonNullType <IntType> >()
     .Resolver(() => "");
     descriptor.Field("pets")
     .Type <ListType <PetType> >()
     .Resolver(() => "");
     descriptor.Field("relatives")
     .Type <ListType <HumanType> >()
     .Resolver(() => "");
 }
Exemplo n.º 4
0
        protected override void Configure(
            IObjectTypeDescriptor <LifeInsuranceContract> descriptor)
        {
            descriptor
            .AsNode()
            .IdField(t => t.Id)
            .NodeResolver((ctx, id) =>
            {
                return(Task.FromResult(
                           ctx.Service <ContractStorage>()
                           .Contracts
                           .OfType <LifeInsuranceContract>()
                           .FirstOrDefault(t => t.Id.Equals(id))));
            });

            descriptor.Implements <ContractType>();
            descriptor.Field(t => t.Id).Type <NonNullType <IdType> >();
            descriptor.Field(t => t.CustomerId).Type <NonNullType <IdType> >();
            descriptor.Field("foo")
            .Argument("bar", a => a.Type <StringType>())
            .Resolver(ctx => ctx.ArgumentValue <string>("bar"));
            descriptor.Field("error")
            .Type <StringType>()
            .Resolver(ctx => ErrorBuilder.New()
                      .SetMessage("Error_Message")
                      .SetCode("ERROR_CODE")
                      .SetPath(ctx.Path)
                      .Build());
            descriptor.Field("date_field")
            .Type <DateType>()
            .Resolver(new DateTime(2018, 5, 17));
            descriptor.Field("date_time_field")
            .Type <DateTimeType>()
            .Resolver(new DateTime(
                          2018, 5, 17, 8, 59, 0,
                          DateTimeKind.Utc));
            descriptor.Field("string_field")
            .Type <StringType>()
            .Resolver("abc");
            descriptor.Field("id_field")
            .Type <IdType>()
            .Resolver("abc_123");
            descriptor.Field("byte_field")
            .Type <ByteType>()
            .Resolver(123);
            descriptor.Field("int_field")
            .Type <IntType>()
            .Resolver(123);
            descriptor.Field("long_field")
            .Type <LongType>()
            .Resolver(123);
            descriptor.Field("float_field")
            .Type <FloatType>()
            .Argument("f", a => a.Type <FloatType>())
            .Resolve(ctx => ctx.ArgumentValue <double?>("f") ?? 123.123);
            descriptor.Field("decimal_field")
            .Type <DecimalType>()
            .Resolver(123.123);
        }
Exemplo n.º 5
0
        protected override void Configure(IObjectTypeDescriptor <Polygon> descriptor)
        {
            descriptor.BindFieldsExplicitly();

            descriptor.Implements <GeoJSONInterface>();

            descriptor.Field(x => x.Coordinates);
            descriptor.Field <GeoJSONResolvers>(x => x.GetType(default !));
Exemplo n.º 6
0
        protected override void Configure(IObjectTypeDescriptor <T> descriptor)
        {
            descriptor
            .Field(o => o.Wrapped)
            .Ignore();

            descriptor.Implements <TypeInfoType>();
        }
Exemplo n.º 7
0
 protected override void Configure(IObjectTypeDescriptor descriptor)
 {
     descriptor.Name("Tea");
     descriptor.Implements <DrinkType>();
     descriptor.Field("kind")
     .Type <NonNullType <DrinkKindType> >()
     .Resolve(() => DrinkKind.BlackTea);
     descriptor.IsOfType((c, obj) => obj.Equals("tea"));
 }
Exemplo n.º 8
0
        public NodeDescriptor(IObjectTypeDescriptor <TNode> typeDescriptor)
            : base(typeDescriptor.Extend().Context)
        {
            _typeDescriptor = typeDescriptor;

            _typeDescriptor
            .Implements <NodeType>()
            .Extend()
            .OnBeforeCreate(OnCompleteDefinition);
        }
Exemplo n.º 9
0
        protected override void Configure(IObjectTypeDescriptor <Human> descriptor)
        {
            descriptor.Implements <CharacterType>();

            descriptor.Field(t => t.Id).Type <NonNullType <IdType> >();
            descriptor.Field(f => f.Name).Type <NonNullType <StringType> >();
            descriptor.Field(t => t.AppearsIn).Type <ListType <EpisodeType> >();

            descriptor
            .Field <SharedResolvers>(r => r.GetCharacter(default, default))
Exemplo n.º 10
0
        public NodeDescriptor(IObjectTypeDescriptor descriptor, Type?nodeType = null)
            : base(descriptor.Extend().Context)
        {
            _typeDescriptor = descriptor;

            _typeDescriptor
            .Implements <NodeType>()
            .Extend()
            .OnBeforeCreate(OnCompleteDefinition);

            Definition.NodeType = nodeType;
        }
Exemplo n.º 11
0
 protected override void Configure(IObjectTypeDescriptor <Alien> descriptor)
 {
     descriptor.Implements <SentientType>();
     descriptor.Field(t => t.Name).Type <NonNullType <StringType> >();
 }
 protected override void Configure(IObjectTypeDescriptor <AudioAnswerFormat> descriptor)
 {
     descriptor.Implements <AnswerFormatType>();
 }
Exemplo n.º 13
0
 protected override void Configure(IObjectTypeDescriptor <TextQuestion> descriptor)
 {
     descriptor.Implements <QuestionInterfaceType>();
 }
Exemplo n.º 14
0
        protected override void Configure(IObjectTypeDescriptor <TextBook> descriptor)
        {
            base.Configure(descriptor);

            descriptor.Implements <BookType>();
        }
 protected override void Configure(IObjectTypeDescriptor <Concrete> descriptor)
 {
     descriptor.Name("ConcreteType");
     descriptor.Implements <BaseType>();
 }