async def resolve_token(self, info: ResolveInfo, token: str): await Authentication.expire_tokens() config = Config() token_data = config[TOKENS].get(token) if token_data: user = config[USERS][token_data['user']] info.context['current_user'] = user info.context['current_token'] = token return token
def mock_info(): return ResolveInfo( None, None, None, None, schema=None, fragments=None, root_value=None, operation=None, variable_values=None, context=None, )
def admin_info(admin_request): """Mock for GraphQL resolve info embedding authenticated django request as context.""" return ResolveInfo( None, None, None, None, schema=None, fragments=None, root_value=None, operation=None, variable_values=None, context=admin_request, )
def info(anonymous_request): """Mock for GraphQL resolve info embedding django request as context.""" return ResolveInfo( None, None, None, None, schema=None, fragments=None, root_value=None, operation=None, variable_values=None, context=anonymous_request, )
def admin_info(admin_request): """Mock for GraphQL resolve info embedding authenticated django request as context.""" return ResolveInfo( None, None, None, None, None, None, None, None, None, None, context=admin_request, # TODO: see if this has an influence on execution, might need parametrization is_awaitable=lambda x: False, )
def mock_info(): class Mutation(ObjectType): create_my_model = CreateMyModelMutation.Field() update_my_model = UpdateMyModelMutation.Field() return ResolveInfo( None, None, None, None, schema=Schema(query=None, mutation=Mutation, types=[MyFakeModelType]), fragments=None, root_value=None, operation=None, variable_values=None, context={"request": None}, )