Added item_listing query

+ items can be searched or all items can be returned
+ Added missing migration
doc_update
Joey Hines 2020-08-22 13:39:25 -05:00
parent 2f846de921
commit 9eabf09fc0
1 changed files with 13 additions and 1 deletions

View File

@ -35,6 +35,10 @@ class ItemListingType(DjangoObjectType):
fields = ("item_name", "price", "amount", "date_restocked", "normalized_price", "id")
normalized_price = graphene.Float()
shop = graphene.Field("GeoffreyApp.api.schema.ShopType")
def resolve_shop(self, info):
return self.shop
class ResourceType(DjangoObjectType):
@ -146,6 +150,7 @@ class Query(graphene.ObjectType):
bases = graphene.List(BaseType, id=graphene.Argument(graphene.Int, required=False), name=graphene.Argument(graphene.String, required=False))
attractions = graphene.List(AttractionType, id=graphene.Argument(graphene.Int, required=False), name=graphene.Argument(graphene.String, required=False))
points_of_interest = graphene.List(PointOfInterestType, id=graphene.Argument(graphene.Int, required=False), name=graphene.Argument(graphene.String, required=False))
item_listing = graphene.List(ItemListingType, item=graphene.Argument(graphene.String, required=False))
@ProtectedAPI.protected_api()
def resolve_player(root, info, id=None, name=None, discord_uuid=None, mc_uuid=None):
@ -161,7 +166,6 @@ class Query(graphene.ObjectType):
return query.get()
@ProtectedAPI.protected_api()
def resolve_locations(root, info, id=None, name=None):
return get_location(root, info, id=id, name=name, location_type=Location)
@ -190,6 +194,14 @@ class Query(graphene.ObjectType):
def resolved_points_of_interest(root, info, id=None, name=None):
return get_location(root, info, id=id, name=name, location_type=PointOfInterest)
@ProtectedAPI.protected_api()
def resolve_item_listing(root, info, item=None):
query = ItemListing.objects
if item is not None:
query = query.filter(item_name=item)
return query.all()
def get_location(root, info, id=None, name=None, location_type=Location):
if id is not None: