def test_endpoint(app: Sanic):
    """Tests that the graphql api correctly handles file upload and processing"""
    file_name = "test.txt"

    file_content = b"Hello, there!"
    in_memory_file = BytesIO(file_content)
    in_memory_file.name = file_name

    form_data = {
        "operations": '{ "query": "mutation($file: Upload!){ fileUpload(file: $file) }", "variables": { "file": null } }',
        "map": '{ "file": ["variables.file"] }',
    }

    files = {
        "file": in_memory_file,
    }

    _, response = app.test_client.post("/graphql", data=form_data, files=files)

    assert response.json["data"]["fileUpload"] == file_name  # type: ignore
Tests that the graphql api correctly handles file upload and processing
tests/sanic/test_file_upload.py