Created
October 8, 2020 07:47
-
-
Save rob-blackbourn/a3cc1abbdd8ea04e1c15ebb3783ae9ca to your computer and use it in GitHub Desktop.
Graphene 3 example query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing | |
import graphene | |
from jetblack_tweeter import Tweeter | |
from .types import SearchResultType | |
class Query(graphene.ObjectType): | |
search_tweets = graphene.Field( | |
SearchResultType, | |
q=graphene.String(required=True), | |
count=graphene.Int(required=False) | |
) | |
@staticmethod | |
async def resolve_search_tweets( | |
_root, | |
info, | |
q: str, | |
count: typing.Optional[int] | |
) -> typing.Mapping[str, typing.Any]: | |
tweeter: Tweeter = info.context['tweeter'] | |
tweets = await tweeter.search.tweets(q, count=count) | |
return tweets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment