Ariadne-GraphQL - ModuleNotFoundError: No module named 'graphql.pyutils.undefined'

635 Views Asked by At

I am trying to import several libraries:

from ariadne import load_schema_from_path, make_executable_schema, \
    graphql_sync, snake_case_fallback_resolvers, ObjectType

But when running this I get this Error:

ModuleNotFoundError: No module named 'graphql.pyutils.undefined'

Before that I downgraded to a lower graphql-core version by using pip install "graphql-core<3.1"because I got this ImportError:

ImportError: cannot import name 'PLAYGROUND_HTML' from 'ariadne.constants'

What can I do to solve this?

2

There are 2 best solutions below

0
On

Checking the source code of Ariadne v. 0.19.1, the PLAYGROUND_HTML seems to be supposed to be used via an ExplorerPlayground class.

Try something like this:

from ariadne.explorer import ExplorerPlayground

PLAYGROUND_HTML = ExplorerPlayground(title="Cool API").html(None)

@app.route("/graphql", methods=["GET"])
def graphql_playground():
    return PLAYGROUND_HTML, 200
0
On

Got the same issue here.

I noticed ariadne 0.18 was not compatible with graphql-core<3.1.

Then I downgraded ariadne to 0.17.

This way my server (I'm using Flask) runs on http://127.0.0.1:5000/ and the playground is accesible on http://127.0.0.1:5000/graphql.

Not ideal but it worked out for me.