Skip to content

How to share models for calling methods for different resolver? #1179

Answered by tricoder42
ptrhck asked this question in Q&A
Discussion options

You must be logged in to vote

What about different schema?

query {
  location(geo: {lat: 30, lng: 20, tmp: 2}) {
    first {
        firstMetric
    }
    second {
        secondMetric
        thirdMetric
    }
  }
}
class LocationType(graphene.ObjectType):
    first = graphene.Field(FirstField)
    second = graphene.Field(SecondField)

    def resolve_first(self, info, geo):
        # self is LocationData
        return FirstField(first_metric=self.first_metric())

    def resolve_second(self, info, geo):
        # self is LocationData
        value1 = self.second_metric()
        value2 = value1+300
        return SecondField(second_metric=value1,
                           third_metric=value2)

class Query(graphene.O…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by zbyte64
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #473 on April 14, 2021 20:18.