示例#1
0
        public EasyStoreQuery(IImperialStarDestroyerRepository ImperialStarDestroyerRepository, ITieFighterRepository TieFighterRepository)
        {
            Field <ImperialStarDestroyerType>(
                "spaceship",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id", Description = "ImperialStarDestroyer id"
            }
                    ),
                resolve: context => ImperialStarDestroyerRepository.GetImperialStarDestroyerAsync(context.GetArgument <int>("id")).Result
                );

            Field <ListGraphType <ImperialStarDestroyerType> >(
                "spaceships",
                resolve: context => ImperialStarDestroyerRepository.GetImperialStarDestroyersAsync());

            Field <TieFighterType>(
                "tiefighter",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id", Description = "TieFighter id"
            }
                    ),
                resolve: context => TieFighterRepository.GetTieFighterAsync(context.GetArgument <int>("id")).Result
                );
        }
示例#2
0
        public TieFighterType(IImperialStarDestroyerRepository ImperialStarDestroyerRepository)
        {
            Field(x => x.Id).Description("TieFighter id.");
            Field(x => x.Name).Description("TieFighter name.");
            Field(x => x.Description, nullable: true).Description("TieFighter description.");
            Field(x => x.Price).Description("TieFighter price.");

            Field <ImperialStarDestroyerType>(
                "ImperialStarDestroyer",
                resolve: context => ImperialStarDestroyerRepository.GetImperialStarDestroyerAsync(context.Source.ImperialStarDestroyerId).Result
                );
        }