ariadne ver 0.22 and cannot import name 'PLAYGROUND_HTML' from 'ariadne.constants'

·

1 min read

Are you following the GraphQL with Python guide?

Or are you doing something along the line of creating Flask x GraphQL API and running in to the error

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

Long story short, 0.22 does not have PLAYGROUND_HTML and the answers you found on stack overflow to downgrade graphql-core is incorrect.

You can find the solution actually in ariadne documentation of playground @ https://ariadnegraphql.org/docs/flask-integration

from ariadne.constants import PLAYGROUND_HTML
## above is replaced with 
from ariadne.explorer import ExplorerGraphiQL
## you can use the following to return an playground HTML
ExplorerGraphiQL().html(None)

Now onward to next step!