我正在尝试在我的 Django 项目中在 GraphQl api 上添加我现有的身份验证。 我做了以下事情:
class DRFAuthenticatedGraphQLView(GraphQLView):
@classmethod
def as_view(cls, *args, **kwargs):
view = super(DRFAuthenticatedGraphQLView, cls).as_view(*args, **kwargs)
view = permission_classes((IsAuthenticated,))(view)
view = authentication_classes((TokenAuthentication, ))(view)
view = api_view(['POST','GET'])(view)
return view
urlpatterns = [
path('graphql', csrf_exempt(DRFAuthenticatedGraphQLView.as_view(graphiql=True)))
]
这会对 GraphQl 的所有突变和查询应用身份验证检查。
我希望 1 个查询没有身份验证检查。如何跳过该查询?