コード例 #1
0
        public async Task <IActionResult> Stores()
        {
            try
            {
                var stores = await _bikeStoreRepository.GetStores();

                return(Ok(stores));
            }
            catch (Exception ex)
            {
                this._logger.LogError(ex, ex.Message);
                return(new StatusCodeResult(Status500InternalServerError));
            }
        }
コード例 #2
0
        public SalesQuery(IBikeStoreRepository bikeStoreRepository)
        {
            Field <ListGraphType <StaffType> >(
                "staff",
                resolve: context =>
            {
                return(bikeStoreRepository.GetStaff());
            });

            Field <ListGraphType <StoreType> >(
                "stores",
                resolve: context =>
            {
                return(bikeStoreRepository.GetStores());
            });
        }
コード例 #3
0
ファイル: StaffType.cs プロジェクト: neilmarshall/GraphQLDemo
        public StaffType(IDataLoaderContextAccessor accessor, IBikeStoreRepository bikeStoreRepository)
        {
            Field(t => t.Active);
            Field(t => t.Email);
            Field(t => t.FirstName);
            Field(t => t.LastName);
            Field(t => t.ManagerId, nullable: true);
            Field(t => t.Phone);
            Field(t => t.StaffId);
            Field <StoreType, Store>()
            .Name("store")
            .ResolveAsync(context =>
            {
                var loader = accessor.Context.GetOrAddBatchLoader <int, Store>(
                    "StoreTypeLoader",
                    async storeIds =>
                {
                    var stores = await bikeStoreRepository.GetStores();
                    return(stores.ToDictionary(s => s.Id, s => s));
                });

                return(loader.LoadAsync(context.Source.StoreId));
            });
        }