wagtail-grapple icon indicating copy to clipboard operation
wagtail-grapple copied to clipboard

PageInterface swap

Open Leden opened this issue 4 years ago • 2 comments
trafficstars

This gives users the ability to swap the implementation of PageInterface.

An example use-case is to override the resolvers for the fields, for example, to allow API access to private pages based on current user's permissions, etc.

Usage:

# settings.py
GRAPPLE_PAGE_INTERFACE = "myproject.myapp.interfaces.MyPageInterface"

If not set, uses the default implementation

# myproject/myapp/interfaces.py
from grapple.types.pages import PageInterface

class MyPageInterface(PageInterface):
    def resolve_children(self, into, **kwargs):
        # alternative implementation of the `children` field resolver
        return ...

Leden avatar Feb 09 '21 11:02 Leden

Thank you for this @Leden. Could you please add some documentation and a couple of tests?

zerolab avatar Feb 12 '21 12:02 zerolab

@Leden I wanted to check in and see if you had any time or interest in finishing up this PR?

dopry avatar Aug 09 '22 22:08 dopry

@zerolab how do we want to proceed on this PR? @Leden doesn't appear to be responding. Do you think this is a valuable enough feature for one of us to take over or should we just close it as stale?

dopry avatar May 12 '23 02:05 dopry

Considering that a project that does not use Grapple can implement any custom interface, this can be a valuable enough addition to allow folk to customise things.

zerolab avatar May 12 '23 10:05 zerolab

superceded by: #325

dopry avatar May 12 '23 15:05 dopry