Closed indirectlylit closed 4 years ago
Hey @ indirectlylit,
Thank you for the detailed bug report! The fix for line 59 is indeed the correct one. get_parent()
returns the parent node (a Wagtail Page
object).
on, the root page parent issue -- needs something like
from graphql.error.located_error import GraphQLLocatedError
#...
def resolve_parent(self, info, **kwargs):
"""
Resolves the parent node of current page node.
Docs: https://docs.wagtail.io/en/stable/reference/pages/model_reference.html#wagtail.core.models.Page.get_parent
"""
try:
return resolve_queryset(self.get_parent().specific, info, **kwargs)
except GraphQLLocatedError:
return WagtailPage.objects.none()
and a test for getting the parent. Would you be able to sumbmit a PR?
Thanks @zerolab - Grapple is a great tool and a big improvement over manually creating graphql schemas. Nice work!
I'm currently in a quick evaluation & prototyping phase so unfortunately don't have time to submit PRs at the moment. Would be happy to contribute in the future if we end up using the package though.
Thank you. All credit goes to @NathHorrigan for the package.
Hope to get some time to sort this out today. Good luck with the prototyping!
I have a couple
Page
subclasses,BlogPage
andBlogIndexPage
as described in the tutorial.Cannot get parent
A query like this returns correctly a
BlogPage
:However attempting to get the parent does not work:
This code is giving the error:
https://github.com/torchbox/wagtail-grapple/blob/d39ba1bd39f7079bdb8a41fab2ae823df7f694c6/grapple/types/pages.py#L54-L59
Updating line 59 seems to remove the error:
Accessing parent of a root page
An unhandled exception is thrown if
parent
is accessed on a root page. For example, this query:gives this error: