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

Prepare for fastify v5 #129

Merged
merged 4 commits into from
Oct 12, 2024
Merged

Conversation

jonnydgreen
Copy link
Collaborator

This includes the following changes

  • Updated package.json to prepare for Fastify v5
  • Reworked the error handling to ensure errors are passed through correctly
  • Updated tests to account for deduplication of federated request entities

app.graphql.addHook('preExecution', filterGraphQLSchemaHook.bind(app))
if (!err) {
app.graphql.addHook('preExecution', filterGraphQLSchemaHook.bind(app))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure about this? Isn't it swallowing the error?

Copy link
Collaborator Author

@jonnydgreen jonnydgreen Sep 17, 2024

Choose a reason for hiding this comment

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

Yeah I thought the same and it's related to the issue I was coming up against! If I leave as it, app.ready() rejects with the expected error but then the error is thrown again within this callback and causes unhandled rejection issues.

Even though we're swallowing the error here, it's still being thrown and eventually surfaced, as shown and caught in this test here: https://github.com/mercurius-js/auth/blob/main/test/introspection-filter.js#L359

wdyt? Reckon it's worth looking for a better solution?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey @mcollina ! Hope the Fastify release went okay this week! Just wondered what your thoughts were on my response to your comment? :)

Copy link
Collaborator Author

@jonnydgreen jonnydgreen Sep 29, 2024

Choose a reason for hiding this comment

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

I've actually refactored it to use the fastify onReady hook instead, lemme know what you think!

Edit: Just double checking when this hook actually runs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, it should be okay from what I've read and the tests cover it and all run absolutely fine: https://github.com/mercurius-js/auth/blob/main/test/introspection-filter.js#L104

The only things I can think of with changing to use the onReady hook:

  • It does fire slightly earlier that waiting until the app.ready callback to fire but crucially, it still ensures that it fires the filter schema hook after all the auth context hooks are called.
  • If another onReady hook was registered after the plugin registration, this this would run after (rather than before with the original implementation) but I would argue that in this case, this introduces dependencies and you could get around it by registering the onReady before the plugin registration

wdyt?

cc. @Eomm for visibility as I think you did the original implementation of this :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Need to check - I don't remember ATM

package.json Outdated Show resolved Hide resolved
Co-authored-by: Manuel Spigolon <behemoth89@gmail.com>
Copy link
Contributor

@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

@mcollina
Copy link
Contributor

mcollina commented Oct 2, 2024

@jonnydgreen can you bump the minimum Node.js version in CI to 20+?

@jonnydgreen
Copy link
Collaborator Author

Yep, will do!

@jonnydgreen jonnydgreen merged commit d890603 into mercurius-js:main Oct 12, 2024
7 checks passed
@jonnydgreen jonnydgreen deleted the prepare-fasify-v5 branch October 12, 2024 09:25
@jonnydgreen
Copy link
Collaborator Author

Releasing a semver major version bump now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants