Document `CustomQuery` example for `register_schema_query` hook
Morsey187 opened this issue · 3 comments
I'm on a project where we've found ourselves having to use a custom query via the register_schema_query
hook for a snippet model, we're no longer querying via snippets because of this and I've had to resolve a RichtextField myself, for example:
class AlertObjectType(graphene.ObjectType):
title = graphene.String(required=True)
richtext = graphene.String(required=True)
def resolve_message(self, info, **kwargs):
if grapple_settings.RICHTEXT_FORMAT == "html":
return render_to_string(
"wagtailcore/richtext.html",
{"html": expand_db_html(self.richtext)},
)
return self.richtext
We could either document an example of a CustomQuery
class with a wagtail field on this page to hightlight this issue, or create a fix and document a cleaner solution.
Improving docs is a always a good thing.
Alternatively, we could perhaps create a new GraphQLRichText
model that does all of this for devs?
I'd be in favour of adding a new GraphQLRichText field type. I'm on holiday for 2 weeks now but definitely keen to pick this one up myself if no one gets to it before then.
This is now fixed by #266
Docs - https://wagtail-grapple.readthedocs.io/en/latest/general-usage/model-types.html#grapple.models.GraphQLRichText