Ariadne Python : ModuleNotFoundError: No module named 'graphql.type'

717 views Asked by At

I am getting following error when using latest ariadne 0.16.1 with graphql-core 3.2.3 and Python 3.10. It's a FastAPI app.

from fastapi import FastAPI from ariadne.asgi import GraphQL

Second line throws the error

from graphql.type import GraphQLEnumType, GraphQLNamedType, GraphQLSchema ModuleNotFoundError: No module named 'graphql.type'

I tried changing libraries versions both upgrading and downgrading but no luck.

Thanks

UPDATE

issue is resolved. There was a graphql directory in the project. renaming it fixed the issue. Thanks.

1

There are 1 answers

0
Grey On

If the code is in a graphql/ directory then Python is confused about the modules and tries to find graphql/types.py in your directory instead of the package one.

If that's the case then rename your graphql/ directory to something else, e.g. graphql_api/.