import graphene from graphql import GraphQLError from vbv_lernwelt.course.graphql.types import CourseType from vbv_lernwelt.course.models import Course from vbv_lernwelt.course.permissions import has_course_access class CourseQuery: course = graphene.Field(CourseType, id=graphene.Int()) def resolve_course(root, info, id): course = Course.objects.get(pk=id) if has_course_access(info.context.user, course): return course return GraphQLError("You do not have access to this course")