torchbox / wagtail-grapple

A Wagtail app that makes building GraphQL endpoints a breeze!

Home Page:https://wagtail-grapple.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting `GRAPPLE_EXPOSE_GRAPHIQL` prevents the server from starting

kbayliss opened this issue · comments

The GRAPPLE_EXPOSE_GRAPHIQL var is deprecated and replaced by the EXPOSE_GRAPHIQL setting, though if the GRAPPLE_EXPOSE_GRAPHIQL variable is used, then it's not possible to run the Django server.

We still have an env variable named GRAPPLE_EXPOSE_GRAPHIQL that we use to control the EXPOSE_GRAPHIQL variable (i.e. maintaining current env variables while supporting the new approach) - and this works fine.

However, if we also set GRAPPLE_EXPOSE_GRAPHIQL=True (to avoid all developers adding the env var to their .env), the server will fail to start.

A deprecated variable should not break things.

Steps to reproduce:

  1. Add GRAPPLE_EXPOSE_GRAPHIQL=True to your settings file

Could use a traceback for this

11:49:24 web.1  | The 'GRAPPLE_EXPOSE_GRAPHIQL' setting is deprecated and will be removed in the next release, use GRAPPLE['EXPOSE_GRAPHIQL'] instead.
11:49:24 web.1  | Exception in thread django-main-thread:
11:49:24 web.1  | Traceback (most recent call last):
11:49:24 web.1  |   File "/usr/local/lib/python3.9/threading.py", line 980, in _bootstrap_inner
11:49:24 web.1  |     self.run()
11:49:24 web.1  |   File "/usr/local/lib/python3.9/threading.py", line 917, in run
11:49:24 web.1  |     self._target(*self._args, **self._kwargs)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
11:49:24 web.1  |     fn(*args, **kwargs)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/channels/management/commands/runserver.py", line 107, in inner_run
11:49:24 web.1  |     application=self.get_application(options),
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/channels/management/commands/runserver.py", line 134, in get_application
11:49:24 web.1  |     return get_default_application()
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/channels/routing.py", line 28, in get_default_application
11:49:24 web.1  |     module = importlib.import_module(path)
11:49:24 web.1  |   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
11:49:24 web.1  |     return _bootstrap._gcd_import(name[level:], package, level)
11:49:24 web.1  |   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
11:49:24 web.1  |   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
11:49:24 web.1  |   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
11:49:24 web.1  |   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
11:49:24 web.1  |   File "<frozen importlib._bootstrap_external>", line 850, in exec_module
11:49:24 web.1  |   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphql_ws/django/routing.py", line 7, in <module>
11:49:24 web.1  |     from .consumers import GraphQLSubscriptionConsumer
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphql_ws/django/consumers.py", line 6, in <module>
11:49:24 web.1  |     from .subscriptions import subscription_server
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphql_ws/django/subscriptions.py", line 39, in <module>
11:49:24 web.1  |     subscription_server = ChannelsSubscriptionServer(schema=graphene_settings.SCHEMA)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphene_django/settings.py", line 127, in __getattr__
11:49:24 web.1  |     val = perform_import(val, attr)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphene_django/settings.py", line 66, in perform_import
11:49:24 web.1  |     return import_from_string(val, setting_name)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphene_django/settings.py", line 80, in import_from_string
11:49:24 web.1  |     module = importlib.import_module(module_path)
11:49:24 web.1  |   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
11:49:24 web.1  |     return _bootstrap._gcd_import(name[level:], package, level)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/grapple/schema.py", line 88, in <module>
11:49:24 web.1  |     schema = create_schema()
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/grapple/schema.py", line 79, in create_schema
11:49:24 web.1  |     return graphene.Schema(
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphene/types/schema.py", line 78, in __init__
11:49:24 web.1  |     self.build_typemap()
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphene/types/schema.py", line 167, in build_typemap
11:49:24 web.1  |     self._type_map = TypeMap(
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphene/types/typemap.py", line 80, in __init__
11:49:24 web.1  |     super(TypeMap, self).__init__(types)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphql/type/typemap.py", line 31, in __init__
11:49:24 web.1  |     self.update(reduce(self.reducer, types, OrderedDict()))  # type: ignore
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphene/types/typemap.py", line 88, in reducer
11:49:24 web.1  |     return self.graphene_reducer(map, type)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphene/types/typemap.py", line 117, in graphene_reducer
11:49:24 web.1  |     return GraphQLTypeMap.reducer(map, internal_type)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphql/type/typemap.py", line 109, in reducer
11:49:24 web.1  |     field_map = type_.fields
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphql/pyutils/cached_property.py", line 22, in __get__
11:49:24 web.1  |     value = obj.__dict__[self.func.__name__] = self.func(obj)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphql/type/definition.py", line 198, in fields
11:49:24 web.1  |     return define_field_map(self, self._fields)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphql/type/definition.py", line 212, in define_field_map
11:49:24 web.1  |     field_map = field_map()
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphene/types/typemap.py", line 275, in construct_fields_for_type
11:49:24 web.1  |     map = self.reducer(map, field.type)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphene/types/field.py", line 119, in type
11:49:24 web.1  |     return get_type(self._type)
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/graphene/types/utils.py", line 45, in get_type
11:49:24 web.1  |     return _type()
11:49:24 web.1  |   File "/venv/lib/python3.9/site-packages/grapple/helpers.py", line 69, in <lambda>
11:49:24 web.1  |     field_type = lambda: registry.models[cls]  # noqa: E731
11:49:24 web.1  | KeyError: <class 'path.to.a.page.model'>

Note: replaced the path to the page model referenced in KeyError with path.to.a.page.model.

found the issue. will fix

You hero.