예제 #1
0
 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
예제 #2
0
def mock_info():
    return ResolveInfo(
        None,
        None,
        None,
        None,
        schema=None,
        fragments=None,
        root_value=None,
        operation=None,
        variable_values=None,
        context=None,
    )
예제 #3
0
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,
    )
예제 #4
0
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,
    )
예제 #5
0
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,
    )
예제 #6
0
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},
    )