Example #1
0
 protected override void Configure(IObjectTypeDescriptor <User> descriptor)
 {
     base.Configure(descriptor);
     descriptor.AsNode()
     .IdField(u => u.Id)
     .NodeResolver(ResolveUser);
 }
        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> >();
        }
Example #3
0
 protected override void Configure(IObjectTypeDescriptor <Client> descriptor)
 {
     descriptor.AsNode()
     .IdField(t => t.Id)
     .NodeResolver((context, id) =>
                   context.DataLoader <ClientByIdDataLoader>().LoadAsync(id, context.RequestAborted));
 }
Example #4
0
 protected override void Configure(IObjectTypeDescriptor <Demand> descriptor)
 {
     base.Configure(descriptor);
     descriptor.AsNode()
     .IdField(d => d.Id)
     .NodeResolver(ResolveDemand);
 }
Example #5
0
 protected override void Configure(IObjectTypeDescriptor <Product> descriptor)
 {
     base.Configure(descriptor);
     descriptor.AsNode()
     .IdField(p => p.Id)
     .NodeResolver(ResolveProduct);
 }
Example #6
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.Interface <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);
        }
Example #7
0
 protected override void Configure(
     IObjectTypeDescriptor <Entity> descriptor)
 {
     descriptor.AsNode <Entity, string>(
         (ctx, id) => Task.FromResult(new Entity {
         Name = id
     }));
     descriptor.Field(t => t.Id).Type <NonNullType <IdType> >();
 }
        protected override void Configure(IObjectTypeDescriptor <SchemaVersion> descriptor)
        {
            descriptor.AsNode()
            .IdField(t => t.Id)
            .NodeResolver((context, id) =>
                          context.DataLoader <SchemaVersionByIdDataLoader>()
                          .LoadAsync(id, context.RequestAborted));

            descriptor.Ignore(t => t.SchemaId);
        }
Example #9
0
        protected override void Configure(IObjectTypeDescriptor <Session> descriptor)
        {
            descriptor
            .AsNode()
            .IdField(t => t.Id)
            .NodeResolver((ctx, id) => ctx.DataLoader <SessionByIdDataLoader>().LoadAsync(id, ctx.RequestAborted));

            descriptor
            .Field(t => t.SessionSpeakers)
            .ResolveWith <SessionResolvers>(t => t.GetSpeakersAsync(default !, default !, default !, default))
Example #10
0
 protected override void Configure(
     IObjectTypeDescriptor <Entity> descriptor)
 {
     descriptor.AsNode()
     .IdField(t => t.Id)
     .NodeResolver((ctx, id) =>
                   Task.FromResult(new Entity {
         Name = id
     }));
 }
Example #11
0
 protected override void Configure(IObjectTypeDescriptor descriptor)
 {
     descriptor.Name("_DummyNodeType")
     .Description("Dummy type to enable Relay support with only default types. Do not use this type.")
     .Field("id")
     .Deprecated("Do not use this type.")
     .Resolver("__dummy")
     .Type <IdType>();
     descriptor.AsNode()
     .NodeResolver <string>((ctx, id) => Task.FromResult(new object()));
 }
Example #12
0
        protected override void Configure(IObjectTypeDescriptor <IGame> descriptor)
        {
            descriptor.ExtendGame();
            descriptor.Interface <NodeType>();
            descriptor.Field("id")
            .Type <IdType>()
            .Resolver(ctx => ctx.Parent <IGame>().Record.RecordID);

            descriptor.AsNode()
            .NodeResolver <Guid>(async(ctx, id) => await ctx.SnowflakeService <IGameLibrary>().GetGameAsync(id));
        }
        protected override void Configure(IObjectTypeDescriptor <SchemaPublishReport> descriptor)
        {
            descriptor.AsNode()
            .IdField(t => t.Id)
            .NodeResolver((ctx, id) =>
                          ctx.DataLoader <SchemaPublishReportByIdDataLoader>().LoadAsync(
                              id, ctx.RequestAborted));

            descriptor.Ignore(t => t.SchemaVersionId);
            descriptor.Ignore(t => t.EnvironmentId);
        }
Example #14
0
        protected override void Configure(IObjectTypeDescriptor <Player> descriptor)
        {
            descriptor.AsNode()
            .IdField(t => t.Id)
            .NodeResolver((ctx, id) => ctx.Service <PlayerRepository>().GetPlayerByIdAsync(id));

            descriptor.Field(t => t.Name)
            .Type <NonNullType <StringType> >();

            descriptor.Field(t => t.Avatar)
            .Type <NonNullType <StringType> >();
        }
Example #15
0
        protected override void Configure(IObjectTypeDescriptor <Team> descriptor)
        {
            descriptor.AsNode()
            .IdField(t => t.Id)
            .NodeResolver((ctx, id) => ctx.Service <PlayerRepository>().GetTeamByIdAsync(id));

            descriptor.Field(t => t.PlayerA)
            .Type <NonNullType <PlayerType> >();

            descriptor.Field(t => t.PlayerB)
            .Type <NonNullType <PlayerType> >();
        }
        protected override void Configure(IObjectTypeDescriptor <IPlatformInfo> descriptor)
        {
            descriptor.Name("PlatformInfo");
            descriptor.Interface <NodeType>();
            descriptor.Field("id")
            .Type <IdType>()
            .Resolver(ctx => ctx.Parent <IPlatformInfo>().PlatformID);

            descriptor.AsNode()
            .NodeResolver <PlatformId>((ctx, id) => Task.FromResult(
                                           ctx.SnowflakeService <IStoneProvider>().Platforms.TryGetValue(id, out var value) ? value : null));
        }
Example #17
0
        protected override void Configure(IObjectTypeDescriptor <IInputDevice> descriptor)
        {
            descriptor.Name("InputDevice");
            descriptor.Interface <NodeType>();
            descriptor.Field("id")
            .Type <IdType>()
            .Resolver(ctx => ctx.Parent <IInputDevice>().InstanceGuid);

            descriptor.AsNode()
            .NodeResolver <Guid>((ctx, id) =>
                                 Task.FromResult(
                                     ctx.SnowflakeService <IDeviceEnumerator>().QueryConnectedDevices().FirstOrDefault(i => i.InstanceGuid == id)));
        }
Example #18
0
        protected override void Configure(IObjectTypeDescriptor <ArticleDto> descriptor)
        {
            descriptor
            .AsNode()
            .IdField(a => a.Id)
            .NodeResolver(async(ctx, id) =>
            {
                // Attempt same way as in ArticleQueryTypeExtensions, fails
                var articleType = ctx.Schema.Types.Single(t => t.Name.Value == "Article");
                var fields      = ctx.CollectFields(articleType as ObjectType);

                // Attempt way I'd ideally want to work
                // (so I can do this from a base class that can resolve its sub types in one way)
                fields = ctx.CollectFields(this);

                return(await Task.FromResult(new ArticleDto(id, fields)));
            });
        }
Example #19
0
        protected override void Configure(
            IObjectTypeDescriptor <Customer> descriptor)
        {
            descriptor
            .AsNode()
            .IdField(t => t.Id)
            .NodeResolver((ctx, id) =>
            {
                return(Task.FromResult(
                           ctx.Service <CustomerRepository>()
                           .Customers.FirstOrDefault(t => t.Id.Equals(id))));
            });

            descriptor.Field(t => t.Name).Type <NonNullType <StringType> >();
            descriptor.Field(t => t.Street).Type <NonNullType <StringType> >();
            descriptor.Field(t => t.ConsultantId).Ignore();

            descriptor.Field <CustomerResolver>(
                t => t.GetConsultant(default, default))
Example #20
0
        protected override void Configure(
            IObjectTypeDescriptor <Consultant> descriptor)
        {
            descriptor
            .AsNode()
            .IdField(t => t.Id)
            .NodeResolver((ctx, id) =>
            {
                return(Task.FromResult(
                           ctx.Service <CustomerRepository>()
                           .Consultants.FirstOrDefault(t => t.Id.Equals(id))));
            });

            descriptor.Field(t => t.Name).Type <NonNullType <StringType> >();
            descriptor.Field("customers")
            .UsePaging <CustomerType>()
            .Resolve(ctx =>
            {
                Consultant consultant = ctx.Parent <Consultant>();
                return(ctx.Service <CustomerRepository>().Customers
                       .Where(t => t.ConsultantId == consultant.Id));
            });
        }
Example #21
0
 protected override void Configure(IObjectTypeDescriptor <Match> descriptor)
 {
     descriptor.AsNode()
     .IdField(t => t.Id)
     .NodeResolver((ctx, id) => ctx.Service <MatchRepository>().GetMatchByIdAsync(id));
 }