MCPcopy Create free account
hub / github.com/alpha2phi/python-apps / Query

Class Query

hackernews/backend-python/links/schema.py:15–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13
14
15class Query(graphene.ObjectType):
16 # Add the first and skip parameters
17 links = graphene.List(
18 LinkType,
19 search=graphene.String(),
20 first=graphene.Int(),
21 skip=graphene.Int(),
22 )
23 votes = graphene.List(VoteType)
24
25 # Use them to slice the Django queryset
26 def resolve_links(self,
27 info,
28 search=None,
29 first=None,
30 skip=None,
31 **kwargs):
32 qs = Link.objects.all()
33
34 if search:
35 filter = (Q(url__icontains=search)
36 | Q(description__icontains=search))
37 qs = qs.filter(filter)
38
39 if skip:
40 qs = qs[skip:]
41
42 if first:
43 qs = qs[:first]
44
45 return qs
46
47 def resolve_votes(self, info, **kwargs):
48 return Vote.objects.all()
49
50
51class CreateLink(graphene.Mutation):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected