simonw / datasette-graphql

Datasette plugin providing an automatic GraphQL API for your SQLite databases
https://datasette-graphql-demo.datasette.io/
Apache License 2.0
101 stars 6 forks source link

Upgrade to Graphene 3.0 #81

Closed simonw closed 3 years ago

simonw commented 3 years ago

Refs #80

simonw commented 3 years ago
    from graphql.execution.executors.asyncio import AsyncioExecutor
36
E   ModuleNotFoundError: No module named 'graphql.execution.executors'
simonw commented 3 years ago

Looks like Schema has a new async def execute_async method.

simonw commented 3 years ago

Failing tests are:

=================================== FAILURES ===================================
_________________________ test_graphql_examples[path1] _________________________

ds = <datasette.app.Datasette object at 0x7ff46d943b10>
path = PosixPath('/home/runner/work/datasette-graphql/datasette-graphql/examples/sort_desc.md')

    @pytest.mark.asyncio
    @pytest.mark.parametrize(
        "path", (pathlib.Path(__file__).parent.parent / "examples").glob("*.md")
    )
    async def test_graphql_examples(ds, path):
        content = path.read_text()
        query = graphql_re.search(content)[1]
        try:
            variables = variables_re.search(content)[1]
        except TypeError:
            variables = "{}"
        expected = json.loads(json_re.search(content)[1])
        response = await ds.client.post(
            "/graphql",
            json={
                "query": query,
                "variables": json.loads(variables),
            },
        )
>       assert response.status_code == 200, response.json()
E       AssertionError: {'data': {'users': None}, 'errors': [{'locations': [{'column': 5, 'line': 3}], 'message': "<usersSortDesc.points: 'points'>", 'path': ['users']}]}
E       assert 500 == 200
E        +  where 500 = <Response [500 Internal Server Error]>.status_code

tests/test_graphql.py:143: AssertionError
________________________ test_graphql_examples[path13] _________________________

ds = <datasette.app.Datasette object at 0x7ff46d943b10>
path = PosixPath('/home/runner/work/datasette-graphql/datasette-graphql/examples/related.md')

    @pytest.mark.asyncio
    @pytest.mark.parametrize(
        "path", (pathlib.Path(__file__).parent.parent / "examples").glob("*.md")
    )
    async def test_graphql_examples(ds, path):
        content = path.read_text()
        query = graphql_re.search(content)[1]
        try:
            variables = variables_re.search(content)[1]
        except TypeError:
            variables = "{}"
        expected = json.loads(json_re.search(content)[1])
        response = await ds.client.post(
            "/graphql",
            json={
                "query": query,
                "variables": json.loads(variables),
            },
        )
>       assert response.status_code == 200, response.json()
E       AssertionError: {'data': {'licenses_with_repos': {'nodes': [{'name': 'Apache 2', 'repos_list': {'nodes': [...]}}, {'name': 'MIT', 'rep...n': 13, 'line': 25}], 'message': "<reposSort.id: 'id'>", 'path': ['users_with_dogspotter', 'nodes', 1, 'repos_list']}]}
E       assert 500 == 200
E        +  where 500 = <Response [500 Internal Server Error]>.status_code

tests/test_graphql.py:143: AssertionError
________________________ test_graphql_examples[path14] _________________________

ds = <datasette.app.Datasette object at 0x7ff46d943b10>
path = PosixPath('/home/runner/work/datasette-graphql/datasette-graphql/examples/sort.md')

    @pytest.mark.asyncio
    @pytest.mark.parametrize(
        "path", (pathlib.Path(__file__).parent.parent / "examples").glob("*.md")
    )
    async def test_graphql_examples(ds, path):
        content = path.read_text()
        query = graphql_re.search(content)[1]
        try:
            variables = variables_re.search(content)[1]
        except TypeError:
            variables = "{}"
        expected = json.loads(json_re.search(content)[1])
        response = await ds.client.post(
            "/graphql",
            json={
                "query": query,
                "variables": json.loads(variables),
            },
        )
>       assert response.status_code == 200, response.json()
E       AssertionError: {'data': {'users': None, 'users_sort_by_dog_award': None}, 'errors': [{'locations': [{'column': 5, 'line': 3}], 'messa...s': [{'column': 5, 'line': 9}], 'message': "<usersSort.dog_award: 'dog_award'>", 'path': ['users_sort_by_dog_award']}]}
E       assert 500 == 200
E        +  where 500 = <Response [500 Internal Server Error]>.status_code

tests/test_graphql.py:143: AssertionError
=========================== short test summary info ============================
FAILED tests/test_graphql.py::test_graphql_examples[path1] - AssertionError: ...
FAILED tests/test_graphql.py::test_graphql_examples[path13] - AssertionError:...
FAILED tests/test_graphql.py::test_graphql_examples[path14] - AssertionError:...
=================== 3 failed, 63 passed, 1 skipped in 4.16s ====================
simonw commented 3 years ago

For this one:

https://github.com/simonw/datasette-graphql/blob/6724518e57fb4963d42ac24a26fefe113a1d9a89/examples/sort_desc.md#L1-L32

Error is:

E AssertionError: {'data': {'users': None}, 'errors': [{'locations': [{'column': 5, 'line': 3}], 'message': "<usersSortDesc.points: 'points'>", 'path': ['users']}]}

simonw commented 3 years ago

usersSortDesc.points is an enum, and enums changed according to the release notes here: https://github.com/graphql-python/graphene/wiki/v3-release-notes

These release notes are more detailed but less useful: https://github.com/graphql-python/graphene/releases/tag/v3.0.0

simonw commented 3 years ago

I think I'm hitting this bug: