[Answered ]-How to make graphql query that can find "latest" or "min" or "max"

1👍

You can define a new Type with min and max then add it to your Query like this:

class RangeType(graphene.ObjectType):
    min = graphene.String()
    max = graphene.String()
       

class Query(graphene.ObjectType):
    temperature_statistics = graphene.Field(
       RangeType, before=graphene.String(), after=graphene.String()
    )

    def resolve_temperature_statistics(self, info, before=None, after=None):
        range_type = RangeType()
        range_type.min = # query to get min value
        range_type.max = # query to get max value
        return range_type

Calling the query should be the same.

Leave a comment