コード例 #1
0
ファイル: CatType.cs プロジェクト: anadale/hotchocolate
 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))
コード例 #2
0
        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> >();
        }
コード例 #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(() => "");
 }
コード例 #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);
        }
コード例 #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 !));
コード例 #6
0
        protected override void Configure(IObjectTypeDescriptor <T> descriptor)
        {
            descriptor
            .Field(o => o.Wrapped)
            .Ignore();

            descriptor.Implements <TypeInfoType>();
        }
コード例 #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"));
 }
コード例 #8
0
        public NodeDescriptor(IObjectTypeDescriptor <TNode> typeDescriptor)
            : base(typeDescriptor.Extend().Context)
        {
            _typeDescriptor = typeDescriptor;

            _typeDescriptor
            .Implements <NodeType>()
            .Extend()
            .OnBeforeCreate(OnCompleteDefinition);
        }
コード例 #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))
コード例 #10
0
        public NodeDescriptor(IObjectTypeDescriptor descriptor, Type?nodeType = null)
            : base(descriptor.Extend().Context)
        {
            _typeDescriptor = descriptor;

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

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

            descriptor.Implements <BookType>();
        }
コード例 #15
0
 protected override void Configure(IObjectTypeDescriptor <Concrete> descriptor)
 {
     descriptor.Name("ConcreteType");
     descriptor.Implements <BaseType>();
 }