Skip to content
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

Pass the GraphQLResolveInfo object to the StreamField callables #356

Merged
merged 1 commit into from
Aug 30, 2023

Conversation

zerolab
Copy link
Member

@zerolab zerolab commented Aug 25, 2023

Passes the GraphQLResolveInfo object to the custom StreamField resolvers.
This is more in line with the expected GraphQL resolver definitions. This would allow using the request context (info.context) for page url resolving (page.get_url(request=info.context)) in a multi-site context

Builds on #220 and #322.

Warning

This is a breaking change and requires existing resolver signatures to be updated.

# before
def get_field(self, value=None):
   ...

def get_field(self, *, value=None):
   ...

# after
def get_field(self, info, value=None):
   ...

def get_field(self, *, info, value=None):
   ...

# or, type hinted
from graphql import GraphQLResolveInfo


def get_field(self, info: GraphQLResolveInfo, value: dict[str, Any] | None):
    ...

@zerolab zerolab requested a review from kbayliss August 25, 2023 10:16
grapple/actions.py Outdated Show resolved Hide resolved
tests/testapp/blocks.py Show resolved Hide resolved
tests/testapp/blocks.py Show resolved Hide resolved
@zerolab zerolab force-pushed the fix/streamfield-resolver-info branch from 27752fc to 20b9c1a Compare August 30, 2023 11:39
@zerolab zerolab requested a review from kbayliss August 30, 2023 11:41
Copy link
Collaborator

@kbayliss kbayliss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kbayliss
Copy link
Collaborator

Suggestion: It would be good to update the testapp with a method that uses the info - perhaps to fetch the page for request?

@zerolab zerolab force-pushed the fix/streamfield-resolver-info branch from 20b9c1a to 608b1fb Compare August 30, 2023 14:08
@zerolab zerolab merged commit 495f384 into main Aug 30, 2023
@zerolab zerolab deleted the fix/streamfield-resolver-info branch August 30, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants