From 9eabf09fc0bbb92b9afb12af1dc26977894bca92 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Sat, 22 Aug 2020 13:39:25 -0500 Subject: [PATCH] Added item_listing query + items can be searched or all items can be returned + Added missing migration --- GeoffreyApp/api/schema.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/GeoffreyApp/api/schema.py b/GeoffreyApp/api/schema.py index a8fa165..be7fc38 100644 --- a/GeoffreyApp/api/schema.py +++ b/GeoffreyApp/api/schema.py @@ -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: