-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wagtail 4.1.1+ compatibility for Snippets #307
Comments
Any chance you could add a minimal reproducible code snippet (or snippets)? I don't have a good answer for this yet as we are always at the mercy of app interdependency. |
I would be something along the lines of settings.py INSTALLED_APPS = [
# graphql to make it all headless
"graphene_django",
"grapple",
"myapp",
# core wagtail stuff
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.embeds",
"wagtail.sites",
"wagtail.users",
"wagtail.snippets",
"wagtail.documents",
"wagtail.images",
"wagtail.search",
"wagtail.admin",
"wagtail", app.py @register_snippet
class PageCategory(Model):
name = CharField(max_length=255)
slug = CharField(max_length=255, unique=True)
panels = [ FieldPanel("name"), FieldPanel("slug") ]
def __str__(self):
return self.name
graphql_fields = [ GraphQLString("name"), GraphQLString("slug"), ]
class MySnippetBlock(StructBlock):
categories = ListBlock(SnippetChooserBlock("myapp.Category", required=False))
class MyPage(Page):
body = StreamField([MySnippetBlock])
class MyApp(AppConfig):
name = "MyApp"
def ready(self):
class MySnippetType:
from grapple.types.snippets import SnippetTypes
snippet_relationship = graphene.List(SnippetTypes.get_object_type()) The gist is I can work on a more formal test setup next week if it's necessary, but I'm launching a new property this week. This was just something I ran into trying to get on latest wagtail before launch, but isn't critical. |
@zerolab this hit me again today as I was trying to upgrade my wagtail instance. I figured I should get on 5 before 6 gets releases. I don't want to be too far behind the current. ultimately what I had to do to resolve this was move my grapple implementation to it's own app and move grapple and my graphql app to after wagtail core... I ended up with INSTALLED_APPS = [
# graphql to make it all headless
"graphene_django",
"myapp",
# core wagtail stuff
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.embeds",
"wagtail.sites",
"wagtail.users",
"wagtail.snippets",
"wagtail.documents",
"wagtail.images",
"wagtail.search",
"wagtail.admin",
"wagtail",
"grapple",
"myapp_grapple" if the setup documentation isn't explicit about making the grapple integration it's own app and grapple's location in installed apps relative to wagtail that seems like it might be something worth doing to help other users avoid the headache I just went through working that out. |
I was revisting my wagtail 5.x updates and I've ran into this again... It seems like snippets are hunting for hooks
and I have
Where I have
I'm getting a keyError because registry.models isn't populated yet. So now whether I put my grapple app before or after wagtail/snippets it's not launching. I've got a circular dependency here where grapple needs snippets to be registered to generate snippet types... but snippets are calling hooks that need grapple types to be registered.... Mostly documenting this here... don't have much time to debug it just now... I'll poke at it over the next few days. |
I just ran into an issue with wagtail/wagtail#9605
I have a field definition like
My graphql interface started spitting out the error
I don't import my grapple type definitions until my app.ready(), but I guess that is running before snippets.app.ready
because get_object type() now returns None since snippets are not registered yet.
I am able to make it work by moving graphene_django, grapple, and my app after wagtail.snippets... This obviously isn't very ideal since now the template priority favors wagtail over my apps... :(
The text was updated successfully, but these errors were encountered: