[go: up one dir, main page]

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

feat: Allow preExecution hook to modify variables #921

Merged
merged 3 commits into from
Dec 3, 2022

Conversation

curtiswilkinson
Copy link
Contributor

I saw discussions about this on #876, which mainly talked about accessing variables, but there is a comment that also mentions updating them.

I require this use-case, where hooks can modify the incoming variables based on logic or contacting external systems. See the test included with the PR for an example.

This could have be achieved by putting the logic in a plugin earlier in the chain than Mercurius, but preventing double query parsing would be difficult, as the hooks need to be query-aware.

I'll admit I don't have a complete understanding of this codebase so forgive me if there are any things I've missed here, it's mainly to frame the requirement I have and start a discussion.

If there is any modifications you'd like here, let me know and I'd be happy to contribute; I can update any documentation as necessary, but wanted to wait until this feature was discussed.

@curtiswilkinson curtiswilkinson changed the title Allow preExecution hook to modify variables feat: Allow preExecution hook to modify variables Nov 25, 2022
@mcollina mcollina requested review from codeflyer and jonnydgreen and removed request for codeflyer November 25, 2022 11:07
Copy link
Collaborator
@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Can you document this new behavior?

@curtiswilkinson curtiswilkinson requested review from mcollina and removed request for jonnydgreen and codeflyer November 25, 2022 11:23
@curtiswilkinson
Copy link
Contributor Author

Apologies @mcollina, I didn't expect the "re-review" button to drop the reviewers you requested, but apparently it does for some reason

Copy link
Collaborator
@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor
@jonnydgreen jonnydgreen left a comment

Choose a reason for hiding this comment

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

Functionally all good - just a small comment to add these changes to the typings :)

docs/hooks.md Show resolved Hide resolved
Copy link
Contributor
@jonnydgreen jonnydgreen left a comment

Choose a reason for hiding this comment

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

LGTM!

@mcollina mcollina merged commit e18a889 into mercurius-js:master Dec 3, 2022
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.

3 participants