Skip to content

Instantly share code, notes, and snippets.

@rob-blackbourn
Created October 8, 2020 07:47
Show Gist options
  • Save rob-blackbourn/a3cc1abbdd8ea04e1c15ebb3783ae9ca to your computer and use it in GitHub Desktop.
Save rob-blackbourn/a3cc1abbdd8ea04e1c15ebb3783ae9ca to your computer and use it in GitHub Desktop.
Graphene 3 example query
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