How can I require authentication/authorization on the tier
Node field and allTiers
Connection field query below?
# schema.py
class TierNode(DjangoObjectType):
class Meta:
model = Tier
filter_fields = []
interfaces = (graphene.relay.Node,)
class Query(graphene.ObjectType):
tier = relay.Node.Field(TierNode)
all_tiers = DjangoFilterConnectionField(TierNode)
You can define a resolver for those fields with auth decorator like so:
This is just using the
login_decorator
that comes withgraphql_jwt
but it will work for your custom decorators too if you defined them.Furthermore, this also works for when you're resolving a field for
TierNode
: