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(fastify): Integrate apollo-fastify plugin #626 [WIP] #1760

Conversation

addityasingh
Copy link
Contributor

@addityasingh addityasingh commented Oct 3, 2018

Refer #626 , #1013

TODO:

  • Update CHANGELOG.md with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily


if (this.playgroundOptions && request.method === 'get') {
// perform more expensive content-type check only if necessary
const accept = parseAll(request.headers);
Copy link

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link

Choose a reason for hiding this comment

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

I don't think this is working right now, the usage is different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mcollina I need a next() method along with async/await but based on the docs

Notice: the next callback is not available when using async/await or returning a Promise. If you do invoke a next callback in this situation unexpected behavior may occur, e.g. duplicate invocation of handlers.

we can't use next() along with async/await. What would be an alternative in this case?

Choose a reason for hiding this comment

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

Why do you need it?

'Content-Length',
Buffer.byteLength(JSON.stringify(graphqlResponse), 'utf8'),
)
.send(JSON.parse(graphqlResponse));
Copy link

Choose a reason for hiding this comment

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

This is really not clear. Why are you serializing the response back-and-forth again? You are probably better off as not parsing/stringifying both the body and the request/response. This likely halves the throughput of this solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the serialization breaks most of the tests. I am assuming that the response need to be serialized.

Copy link

Choose a reason for hiding this comment

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

I mean that you are getting JSON via runHttpQuery, which I imagine it is parsed and stringified again, or maybe I'm mistaken by the API.

});

if (next && typeof next === 'function') {
next();

Choose a reason for hiding this comment

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

A question to clarify? Shouldn't this return back to the previous context if the callback is invoked, if next() is available.
E.g. I am assuming at this point that the invocation of the callback is what matters, which else wise could render undefined at some point?

if (next && typeof next === 'function') {
  next();
  return;
}

@cemremengu
Copy link

@addityasingh any updates here? I would like to help to speed things up.

@abernix
Copy link
Member

abernix commented Feb 8, 2019

@addityasingh As I mentioned in #2280, I didn't realize we had two PRs in flight that built the same integration. The names were so similar, that I just realized after I merged that PR. Furthermore, you're the actual current maintainer of the apollo-server-fastify package on npm and you've already gone to the effort of getting it, as you mention above.

You've put some effort into this integration, in both in v1 and v2, and I think you deserve commit credit, despite the fact that #1971 ended up landing. I merged this PR into #2280, preferring that branches implementation, but you'll see your commit credit.

I'll close this now, with it being superseded by #1971 and @2280, but thanks for doing this originally. I'm working on catching up on the back-log to help reduce the chance of this in the future.

We're still looking for your blessing on the apollo-server-fastify package name, but #1971 talks about that the most. Thanks again!

@abernix abernix closed this Feb 8, 2019
@addityasingh
Copy link
Contributor Author

@abernix Yeah. I opened 2 PRs (#1013 , #1760 ) to get the fastify integration in apollo, the first of which was opened on the 1st of May 2018. But none of them could be merged for so long and I couldn't keep them updated recently. But I am fine with having the PR #1971 by @rkorrelboom merged. Like I mentioned here, I have also transferred the ownership of the package to you and apollo-bot

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants