torchbox / wagtail-grapple

A Wagtail app that makes building GraphQL endpoints a breeze!
https://wagtail-grapple.readthedocs.io/en/latest/
Other
151 stars 57 forks source link

AttributeError: type object 'Page' has no attribute 'type' #348

Closed dejaeghered closed 11 months ago

dejaeghered commented 11 months ago

When upgrading my project to Wagtail 5 I seem to get stuck starting the application.

The stacktrace I get seems to show a conflict between Wagtail 5 and wagtail-grapple 0.20.0?

Traceback (most recent call last):
  File "/app/backend/manage.py", line 22, in <module>
    main()
  File "/app/backend/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 416, in execute
    django.setup()
  File "/usr/local/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.11/site-packages/django/apps/registry.py", line 124, in populate
    app_config.ready()
  File "/usr/local/lib/python3.11/site-packages/grapple/apps.py", line 16, in ready
    load_type_fields()
  File "/usr/local/lib/python3.11/site-packages/grapple/actions.py", line 285, in load_type_fields
    type_definition = node.type()
                      ^^^^^^^^^
AttributeError: type object 'Page' has no attribute 'type'

my packages

# framework
django==4.2.3
wagtail==5.0
wagtail-localize==1.5.1
wagtail_grapple==0.20.0
wagtail-headless-preview==0.6.0
django-taggit
django-modelcluster
whitenoise==6.5.0
django-storages[google]==1.13.2
django-cors-headers

# database
psycopg2==2.9.6

# production
gevent==23.7.0

my INSTALLED_APPS (which the stacktrace is pointing att)

INSTALLED_APPS = [
    'myapp',

    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'wagtail.contrib.forms', # new
    'wagtail.contrib.routable_page', # new
    'wagtail.contrib.settings',
    'wagtail.contrib.redirects',
    'wagtail.contrib.frontend_cache',
    'wagtail.contrib.modeladmin',
    'wagtail.embeds',
    'wagtail.sites',
    'wagtail.users',
    'wagtail.snippets',
    'wagtail.documents',
    'wagtail.images',
    'wagtail.search',
    'wagtail.admin',
    'wagtail.locales',
    'wagtail',

    'storages',
    'modelcluster',
    'taggit',

    'grapple',
    'graphene_django',
    'wagtail_headless_preview',
    'corsheaders',
]

When testing I could confirm it actually struggles with the wagtail Page object?

dejaeghered commented 11 months ago

Issue was located in one of my custom queries I load using wagtail hooks.

registry.pages[type(WagtailPage)] = Page