protected override void Configure(IObjectTypeDescriptor <Message> descriptor)
        {
            descriptor.Field(t => t.Id).Type <NonNullType <IdType> >();
            descriptor.Field(t => t.Text).Type <NonNullType <StringType> >();
            descriptor.Field("createdBy").Type <NonNullType <UserType> >().Resolver(ctx =>
            {
                UserRepository repository = ctx.Service <UserRepository>();

                IDataLoader <ObjectId, User> dataLoader = ctx.BatchDataLoader <ObjectId, User>(
                    "UserById",
                    repository.GetUsersAsync);

                return(dataLoader.LoadAsync(ctx.Parent <Message>().UserId));
            });
            descriptor.Field("replyTo").Type <MessageType>().Resolver(async ctx =>
            {
                ObjectId?replyToId = ctx.Parent <Message>().ReplyToId;
                if (replyToId.HasValue)
                {
                    MessageRepository repository = ctx.Service <MessageRepository>();

                    IDataLoader <ObjectId, Message> dataLoader = ctx.CacheDataLoader <ObjectId, Message>(
                        "MessageById",
                        repository.GetMessageById);

                    return(await dataLoader.LoadAsync(ctx.Parent <Message>().ReplyToId.Value));
                }
                return(null);
            });
            descriptor.Ignore(t => t.UserId);
            descriptor.Ignore(t => t.ReplyToId);
        }
        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);
        }
예제 #3
0
        protected override void Configure(IObjectTypeDescriptor <Book> descriptor)
        {
            descriptor.Field(t => t.Id)
            .Type <NonNullType <IdType> >();
            descriptor.Field(t => t.Name)
            .Type <NonNullType <StringType> >()
            .Description("The name of the book");
            descriptor.Field(t => t.ImageUrl)
            .Type <StringType>();
            descriptor.Field(t => t.Description)
            .Type <StringType>();

            descriptor.Ignore(t => t.AuthorId);

            descriptor.Field(t => t.Reviews)
            .Type <NonNullType <ListType <BookReviewType> > >()
            .Argument("skip", arg => arg.Type <IntType>())
            .Argument("first", arg => arg.Type <IntType>())
            .Resolver(ctx =>
            {
                var repository = ctx.Service <IBookReviewRepository>();
                var book       = ctx.Parent <Book>();
                var skip       = ctx.Argument <int?>("skip") ?? 0;
                var first      = ctx.Argument <int?>("first") ?? 100;

                return(repository.FindAll()
                       .Where(x => x.BookId == book.Id)
                       .OrderByDescending(x => x.CreatedAt)
                       .Skip(skip)
                       .Take(first));
            });

            descriptor.Include <BookResolvers>();
        }
예제 #4
0
        /// <inheritdoc/>
        protected override void ConcreteConfigure(IObjectTypeDescriptor <ItemAttribute> descriptor)
        {
            descriptor.Description("Item attributes define particular aspects of items, e.g. \"usable in battle\" or \"consumable\".");
            descriptor.UseNamedApiResourceCollectionField <ItemAttribute, Item, ItemType>(x => x.Items);

            // TODO add missing field
            descriptor.Ignore(x => x.Descriptions);
        }
예제 #5
0
        protected override void Configure(IObjectTypeDescriptor <MediaThumbnail> descriptor)
        {
            descriptor.Ignore(x => x.Data);

            descriptor
            .Field("dataUrl")
            .Type(typeof(string))
            .ResolveWith <ThumbnailResolvers>(x => x.GetDataUrl(default !, default !));
예제 #6
0
        protected override void Configure(IObjectTypeDescriptor <Product> descriptor)
        {
            descriptor
            .Field(p => p.ID)
            .Name("id");

            descriptor
            .Ignore(p => p.ModifiedOn);
        }
예제 #7
0
        protected override void Configure(IObjectTypeDescriptor <Media> descriptor)
        {
            descriptor.Ignore(x => x.Thumbnails);

            descriptor.Field("thumbnail")
            .Argument("size", a => a
                      .DefaultValue(ThumbnailSizeName.M)
                      .Type(typeof(ThumbnailSizeName)))
            .ResolveWith <ThumbnailResolvers>(x => x
                                              .GetThumbnailAsync(default !, default !, default !, default !));
예제 #8
0
        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);
        }
예제 #9
0
 /// <inheritdoc/>
 protected override void ConcreteConfigure(IObjectTypeDescriptor <Characteristic> descriptor)
 {
     descriptor.Description(@"Characteristics indicate which stat contains a Pokémon's highest IV.
         A Pokémon's Characteristic is determined by the remainder of its highest IV divided by 5 (gene_modulo).");
     descriptor.Field(x => x.GeneModulo)
     .Description("The remainder of the highest stat/IV divided by 5.");
     descriptor.Field(x => x.PossibleValues)
     .Description("The possible values of the highest stat that would result in a pokémon recieving this characteristic when divided by 5.")
     .Type <ListType <IntType> >();
     descriptor.UseNamedApiResourceField <Characteristic, Stat, StatType>(x => x.HighestStat);
     descriptor.Ignore(x => x.Descriptions);
 }
예제 #10
0
 /// <inheritdoc/>
 protected override void ConcreteConfigure(IObjectTypeDescriptor <GrowthRate> descriptor)
 {
     descriptor.Description("Growth rates are the speed with which pokémon gain levels through experience.");
     descriptor.Ignore(x => x.Descriptions);
     descriptor.Field(x => x.Formula)
     .Description("The formula used to calculate the rate at which the pokémon species gains level.")
     .Type <NonNullType <StringType> >();
     descriptor.Field(x => x.Levels)
     .Description("A list of levels and the amount of experienced needed to atain them based on this growth rate.")
     .Type <ListType <GrowthRateExperienceLevelType> >();
     descriptor.UseNamedApiResourceCollectionField <GrowthRate, PokemonSpecies, PokemonSpeciesType>(x => x.PokemonSpecies);
 }
예제 #11
0
 protected override void Configure(IObjectTypeDescriptor <T> descriptor)
 {
     descriptor.Name(GetNameFromException());
     descriptor.Ignore(x => x.Data);
     descriptor.Ignore(x => x.Source);
     descriptor.Ignore(x => x.HelpLink);
     descriptor.Ignore(x => x.HResult);
     descriptor.Ignore(x => x.InnerException);
     descriptor.Ignore(x => x.StackTrace);
     descriptor.Ignore(x => x.TargetSite);
     descriptor.Ignore(x => x.GetBaseException());
     descriptor.Field(x => x.Message).Type <NonNullType <StringType> >();
     descriptor.Extend().Definition.ContextData.MarkAsError();
 }
예제 #12
0
 protected override void Configure(IObjectTypeDescriptor <Message> descriptor)
 {
     descriptor.Field(t => t.Id).Type <NonNullType <IdType> >();
     descriptor.Field(t => t.Text).Type <NonNullType <StringType> >();
     descriptor.Field("createdBy").Type <NonNullType <UserType> >().Resolver(ctx =>
     {
         UserRepository repository = ctx.Service <UserRepository>();
         return(repository.GetUserAsync(ctx.Parent <Message>().UserId, ctx.RequestAborted));
     });
     descriptor.Field("replyTo").Type <MessageType>().Resolver(async ctx =>
     {
         ObjectId?replyToId = ctx.Parent <Message>().ReplyToId;
         if (replyToId.HasValue)
         {
             MessageRepository repository = ctx.Service <MessageRepository>();
             return(await repository.GetMessageById(replyToId.Value));
         }
         return(null);
     });
     descriptor.Ignore(t => t.UserId);
     descriptor.Ignore(t => t.ReplyToId);
 }
예제 #13
0
 /// <inheritdoc/>
 protected override void ConcreteConfigure(IObjectTypeDescriptor <PokemonForm> descriptor)
 {
     descriptor.Description(@"Some pokémon have the ability to take on different forms. 
         At times, these differences are purely cosmetic and have no bearing on the difference in the Pokémon's stats from another; 
         however, several Pokémon differ in stats (other than HP), type, and Ability depending on their form.");
     descriptor.Ignore(x => x.FormNames);
     descriptor.Ignore(x => x.Sprites);
     descriptor.Field(x => x.Order)
     .Description(@"The order in which forms should be sorted within all forms. 
             Multiple forms may have equal order, in which case they should fall back on sorting by name.");
     descriptor.Field(x => x.FormOrder)
     .Description("The order in which forms should be sorted within a species' forms.");
     descriptor.Field(x => x.IsDefault)
     .Description("True for exactly one form used as the default for each pokémon.");
     descriptor.Field(x => x.IsBattleOnly)
     .Description("Whether or not this form can only happen during battle.");
     descriptor.Field(x => x.IsMega)
     .Description("Whether or not this form requires mega evolution.");
     descriptor.Field(x => x.FormName)
     .Description("The name of this form.");
     descriptor.UseNamedApiResourceField <PokemonForm, Pokemon, PokemonType>(x => x.Pokemon);
     descriptor.UseNamedApiResourceField <PokemonForm, VersionGroup, VersionGroupType>(x => x.VersionGroup);
 }
예제 #14
0
        protected override void Configure(IObjectTypeDescriptor <BookReview> descriptor)
        {
            descriptor.Field(t => t.Id)
            .Type <NonNullType <IdType> >();
            descriptor.Field(t => t.Name)
            .Type <NonNullType <StringType> >()
            .Description("The name of the reviewer");
            descriptor.Field(t => t.Title)
            .Type <NonNullType <StringType> >();
            descriptor.Field(t => t.Content)
            .Type <NonNullType <StringType> >();

            descriptor.Ignore(t => t.BookId);
        }
예제 #15
0
        protected override void Configure(IObjectTypeDescriptor <AvEquipment> descriptor)
        {
            base.Configure(descriptor);
            descriptor.Field("tags")
            .Type <ListType <AvTagType> >()
            .Resolver(async ctx =>
            {
                var repository = ctx.Service <EquipmentRepository>();

                IDataLoader <int, AvTags[]> dataLoader = ctx.GroupDataLoader <int, AvTags>(
                    "TagsById",
                    repository.GetEquipmentAsync);
                return(await dataLoader.LoadAsync(ctx.Parent <AvEquipment>().Id));
            });
            descriptor.Ignore(f => f.AvTagsAssociatedGear);
        }
예제 #16
0
        protected override void Configure(IObjectTypeDescriptor <Message> descriptor)
        {
            descriptor.Field(t => t.Id).Type <NonNullType <IdType> >();
            descriptor.Field(t => t.Text).Type <NonNullType <StringType> >();
            descriptor.Field("createdBy").Type <NonNullType <UserType> >().Resolver(ctx =>
            {
                UserRepository repository = ctx.Service <UserRepository>();

                IDataLoader <ObjectId, User> dataLoader = ctx.DataLoader <ObjectId, User>(
                    "UserById",
                    keys => repository.GetUsersAsync(keys, ctx.RequestAborted));

                return(dataLoader.LoadAsync(ctx.Parent <Message>().UserId));
            });
            descriptor.Ignore(t => t.UserId);
        }
예제 #17
0
        /// <inheritdoc/>
        protected override void ConcreteConfigure(IObjectTypeDescriptor <Pokedex> descriptor)
        {
            descriptor.Description(@"A Pokédex is a handheld electronic encyclopedia device; one which is capable of recording 
            and retaining information of the various Pokémon in a given region with the exception of the national dex
            and some smaller dexes related to portions of a region.");
            descriptor.Field(x => x.IsMainSeries)
            .Description("Whether or not this pokédex originated in the main series of the video games.");
            descriptor.Field(x => x.PokemonEntries)
            .Description("A list of pokémon catalogued in this pokédex  and their indexes.")
            .Type <ListType <PokemonEntryType> >();
            descriptor.UseNamedApiResourceField <Pokedex, Region, RegionType>(x => x.Region);
            descriptor.UseNamedApiResourceCollectionField <Pokedex, VersionGroup, VersionGroupType>(x => x.VersionGroups);

            // TODO: implement ignored field
            descriptor.Ignore(x => x.Descriptions);
        }
예제 #18
0
 /// <inheritdoc/>
 protected override void ConcreteConfigure(IObjectTypeDescriptor <PokemonSpecies> descriptor)
 {
     descriptor.Description(@"A Pokémon Species forms the basis for at least one pokémon. 
         Attributes of a Pokémon species are shared across all varieties of pokémon within the species. 
         A good example is Wormadam; Wormadam is the species which can be found in three different varieties, Wormadam-Trash, Wormadam-Sandy and Wormadam-Plant.");
     descriptor.Ignore(x => x.FormDescriptions);
     descriptor.Field(x => x.Order)
     .Description(@"The order in which species should be sorted.
             Based on National Dex order, except families are grouped together and sorted by stage.");
     descriptor.Field(x => x.GenderRate)
     .Description("The chance of this Pokémon being female, in eighths; or -1 for genderless.");
     descriptor.Field(x => x.CaptureRate)
     .Description("The base capture rate; up to 255. The higher the number, the easier the catch.");
     descriptor.Field(x => x.BaseHappiness)
     .Description("The happiness when caught by a normal pokéball; up to 255. The higher the number, the happier the pokémon.");
     descriptor.Field(x => x.IsBaby)
     .Description("Whether or not this is a baby pokémon.");
     descriptor.Field(x => x.HatchCounter)
     .Description("Initial hatch counter: one must walk 255 × (hatch_counter + 1) steps before this Pokémon's egg hatches, unless utilizing bonuses like Flame Body's.");
     descriptor.Field(x => x.HasGenderDifferences)
     .Description("Whether or not this pokémon can have different genders.");
     descriptor.Field(x => x.FormsSwitchable)
     .Description("Whether or not this pokémon has multiple forms and can switch between them.");
     descriptor.UseNamedApiResourceField <PokemonSpecies, GrowthRate, GrowthRateType>(x => x.GrowthRate);
     descriptor.Field(x => x.PokedexNumbers)
     .Description("A list of pokedexes and the indexes reserved within them for this pokémon species.")
     .Type <ListType <PokemonSpeciesDexEntryType> >();
     descriptor.UseNamedApiResourceCollectionField <PokemonSpecies, EggGroup, EggGroupType>(x => x.EggGroups);
     descriptor.UseNamedApiResourceField <PokemonSpecies, PokemonColor, PokemonColorType>(x => x.Color);
     descriptor.UseNamedApiResourceField <PokemonSpecies, PokemonShape, PokemonShapeType>(x => x.Shape);
     descriptor.UseNullableNamedApiResourceField <PokemonSpecies, PokemonSpecies, PokemonSpeciesType>(x => x.EvolvesFromSpecies);
     descriptor.UseApiResourceField <PokemonSpecies, EvolutionChain, EvolutionChainType>(x => x.EvolutionChain);
     descriptor.UseNamedApiResourceField <PokemonSpecies, PokemonHabitat, PokemonHabitatType>(x => x.Habitat);
     descriptor.UseNamedApiResourceField <PokemonSpecies, Generation, GenerationType>(x => x.Generation);
     descriptor.Field(x => x.PalParkEncounters)
     .Description("A list of encounters that can be had with this pokémon species in pal park.")
     .Type <ListType <PalParkEncounterAreaType> >();
     descriptor.Field(x => x.Genera)
     .Description("The genus of this pokémon species listed in multiple languages.")
     .Type <ListType <GenusType> >();
     descriptor.Field(x => x.Varieties)
     .Description("A list of the pokémon that exist within this pokémon species.")
     .Type <ListType <PokemonSpeciesVarietyType> >();
     descriptor.Field(x => x.FlavorTextEntries)
     .Type <ListType <PokemonSpeciesFlavorTextsType> >();
 }
예제 #19
0
 /// <inheritdoc/>
 protected override void ConcreteConfigure(IObjectTypeDescriptor <Move> descriptor)
 {
     descriptor.Description(@"Moves are the skills of pokémon in battle. 
         In battle, a Pokémon uses one move each turn. 
         Some moves (including those learned by Hidden Machine) can be used outside 
         of battle as well, usually for the purpose of removing obstacles or exploring new areas.");
     descriptor.Ignore(x => x.FlavorTextEntries);
     descriptor.Field(x => x.Accuracy)
     .Description("The percent value of how likely this move is to be successful.");
     descriptor.Field(x => x.EffectChance)
     .Description("The percent value of how likely it is this moves effect will happen.");
     descriptor.Field(x => x.Pp)
     .Description("Power points. The number of times this move can be used.");
     descriptor.Field(x => x.Priority)
     .Description("A value between -8 and 8. Sets the order in which moves are executed during battle.");
     descriptor.Field(x => x.Power)
     .Description("The base power of this move with a value of 0 if it does not have a base power");
     descriptor.Field(x => x.ContestCombos)
     .Description("A detail of normal and super contest combos that require this move.")
     .Type <ContestComboSetsType>();
     descriptor.UseNamedApiResourceField <Move, ContestType, ContestTypeType>(x => x.ContestType);
     descriptor.UseApiResourceField <Move, ContestEffect, ContestEffectType>(x => x.ContestEffect);
     descriptor.UseNamedApiResourceField <Move, MoveDamageClass, MoveDamageClassType>(x => x.DamageClass);
     descriptor.Field(x => x.EffectEntries)
     .Description("The effect of this move listed in different languages.")
     .Type <ListType <VerboseEffectType> >();
     descriptor.Field(x => x.EffectChanges)
     .Description("The list of previous effects this move has had across version groups of the games.")
     .Type <ListType <AbilityEffectChangeType> >();
     descriptor.UseNamedApiResourceField <Move, Generation, GenerationType>(x => x.Generation);
     descriptor.Field(x => x.Meta)
     .Description("Meta data about this move.")
     .Type <MoveMetaDataType>();
     descriptor.Field(x => x.PastValues)
     .Description("A list of move resource value changes across ersion groups of the game.")
     .Type <ListType <PastMoveStatValuesType> >();
     descriptor.Field(x => x.StatChanges)
     .Description("A list of stats this moves effects and how much it effects them.")
     .Type <ListType <MoveStatChangeType> >();
     descriptor.UseApiResourceField <Move, SuperContestEffect, SuperContestEffectType>(x => x.SuperContestEffect);
     descriptor.UseNamedApiResourceField <Move, MoveTarget, MoveTargetType>(x => x.Target);
     descriptor.UseNamedApiResourceField <Move, Type, TypePropertyType>(x => x.Type);
     descriptor.Field(x => x.Machines)
     .Type <ListType <MachineVersionDetailType> >();
 }
        protected override void Configure(IObjectTypeDescriptor <CompanyReport> descriptor)
        {
            descriptor.Ignore(t => t.FsItems);

            descriptor.Field("fsItems")
            .Type <ListType <ObjectType <FsItem2> > >()
            .Resolver(ctx =>
            {
                return(new List <FsItem2>
                {
                    new FsItem2
                    {
                        Key = "Key",
                        Value = 100
                    }
                });
            });
        }
예제 #21
0
        protected override void Configure(IObjectTypeDescriptor <CatalogProductDto> descriptor)
        {
            descriptor.Field(t => t.Id).Type <NonNullType <UuidType> >();

            descriptor.Field(t => t.Category).Type <NonNullType <CategoryType> >();

            descriptor.Field("store").Type <NonNullType <InventoryType> >().Resolver(async ctx =>
            {
                var inventoryGateway = ctx.Service <IStoreGateway>();

                var dataLoader = ctx.BatchDataLoader <Guid, Protobuf.Inventory.V1.StoreDto>(
                    "StoreById",
                    inventoryGateway.GetStoresAsync);

                return(await dataLoader.LoadAsync(ctx.Parent <CatalogProductDto>().StoreId.ConvertTo <Guid>()));
            });

            // ignore fields
            base.Configure(descriptor);
            descriptor.Ignore(t => t.StoreId);
        }
예제 #22
0
 /// <inheritdoc/>
 protected override void ConcreteConfigure(IObjectTypeDescriptor <Pokemon> descriptor)
 {
     descriptor.Description(@"Pokémon are the creatures that inhabit the world of the pokemon games. 
         They can be caught using pokéballs and trained by battling with other pokémon.");
     descriptor.Ignore(x => x.Sprites);
     descriptor.Field(x => x.BaseExperience)
     .Description("The base experience gained for defeating this pokémon.");
     descriptor.Field(x => x.Height)
     .Description("The height of this pokémon.");
     descriptor.Field(x => x.IsDefault)
     .Description("Set for exactly one pokémon used as the default for each species.");
     descriptor.Field(x => x.Order)
     .Description("Order for sorting. Almost national order, except families are grouped together.");
     descriptor.Field(x => x.Weight)
     .Description("The mass of this pokémon.");
     descriptor.Field(x => x.Abilities)
     .Description("A list of abilities this pokémon could potentially have.")
     .Type <ListType <PokemonAbilityType> >();
     descriptor.UseNamedApiResourceCollectionField <Pokemon, PokemonForm, PokemonFormType>(x => x.Forms);
     descriptor.UseNamedApiResourceField <Pokemon, PokemonSpecies, PokemonSpeciesType>(x => x.Species);
     descriptor.Field(x => x.Types)
     .Description("A list of details showing types this pokémon has.")
     .Type <ListType <PokemonTypeMapType> >();
     descriptor.Field(x => x.HeldItems)
     .Description("A list of items this pokémon may be holding when encountered.")
     .Type <ListType <PokemonHeldItemType> >();
     descriptor.Field(x => x.Moves)
     .Description("A list of moves along with learn methods and level details pertaining to specific version groups.")
     .Type <ListType <PokemonMoveType> >();
     descriptor.Field(x => x.Stats)
     .Description("A list of base stat values for this pokémon.")
     .Type <ListType <PokemonStatType> >();
     descriptor.Field(x => x.GameIndicies)
     .Description("A list of game indices relevent to pokémon item by generation.")
     .Type <ListType <VersionGameIndexType> >();
     descriptor.Field(x => x.LocationAreaEncounters)
     .Description("A list of location areas as well as encounter details pertaining to specific versions.")
     .Type <ListType <LocationAreaEncounterType> >()
     .Resolver((ctx, token) => ctx.Service <UrlResolver>().GetAsync <LocationAreaEncounter[]>(ctx.Parent <Pokemon>().LocationAreaEncounters));
 }
예제 #23
0
 /// <inheritdoc/>
 protected override void ConcreteConfigure(IObjectTypeDescriptor <MoveDamageClass> descriptor)
 {
     descriptor.Description("Damage classes moves can have, e.g. physical, special, or status (non-damaging).");
     descriptor.Ignore(x => x.Descriptions);
     descriptor.UseNamedApiResourceCollectionField <MoveDamageClass, Move, MoveType>(x => x.Moves);
 }
예제 #24
0
 /// <inheritdoc/>
 protected override void ConcreteConfigure(IObjectTypeDescriptor <MoveCategory> descriptor)
 {
     descriptor.Description("Very general categories that loosely group move effects.");
     descriptor.Ignore(x => x.Descriptions);
     descriptor.UseNamedApiResourceCollectionField <MoveCategory, Move, MoveType>(x => x.Moves);
 }
예제 #25
0
 /// <inheritdoc/>
 protected override void ConcreteConfigure(IObjectTypeDescriptor <MoveTarget> descriptor)
 {
     descriptor.Description("Targets moves can be directed at during battle. Targets can be pokémon, environments or even other moves.");
     descriptor.Ignore(x => x.Descriptions);
     descriptor.UseNamedApiResourceCollectionField <MoveTarget, Move, MoveType>(x => x.Moves);
 }
예제 #26
0
 /// <inheritdoc/>
 protected override void ConcreteConfigure(IObjectTypeDescriptor <MoveLearnMethod> descriptor)
 {
     descriptor.Description("Methods by which pokémon can learn moves.");
     descriptor.Ignore(x => x.Descriptions);
     descriptor.UseNamedApiResourceCollectionField <MoveLearnMethod, VersionGroup, VersionGroupType>(x => x.VersionGroups);
 }