Skip to content

Commit df3dc80

Browse files
committed
baseapp-auth[graphql]: add avatar field to UserObjectType
1 parent c31fd86 commit df3dc80

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

baseapp-auth/baseapp_auth/graphql/object_types.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import graphene
2-
from baseapp_core.graphql import DjangoObjectType
2+
from avatar.templatetags.avatar_tags import avatar_url
3+
from baseapp_core.graphql import DjangoObjectType, File
34
from django.apps import apps
45
from django.contrib.auth import get_user_model
56
from graphene import relay
@@ -28,6 +29,8 @@ class AbstractUserObjectType(object):
2829
full_name = graphene.String()
2930
short_name = graphene.String()
3031

32+
avatar = graphene.Field(File, width=graphene.Int(), height=graphene.Int())
33+
3134
# Make them not required
3235
email = graphene.String()
3336
phone_number = graphene.String()
@@ -65,6 +68,9 @@ class Meta:
6568
interfaces = interfaces
6669
filterset_class = UsersFilter
6770

71+
def resolve_avatar(self, info, width, height):
72+
return File(url=avatar_url(self, width, height))
73+
6874
def resolve_metadata(self, info):
6975
return MetadataObjectType(
7076
meta_title=self.get_full_name(),

baseapp-auth/setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = baseapp_auth
3-
version = 0.2.8
3+
version = 0.2.9
44
description = BaseApp Auth
55
long_description = file: README.md
66
url = https://github.com/silverlogic/baseapp-backend

0 commit comments

Comments
 (0)