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

move endpoint configuration out of createServer constructor #1103

Closed
Tracked by #1358
n1ru4l opened this issue Apr 19, 2022 · 2 comments
Closed
Tracked by #1358

move endpoint configuration out of createServer constructor #1103

n1ru4l opened this issue Apr 19, 2022 · 2 comments
Milestone

Comments

@n1ru4l
Copy link
Collaborator

n1ru4l commented Apr 19, 2022

import { createServer } from "@graphql-yoga/node"
const server = createServer({
  endpoint: "/foo"
})

The endpoint config option only has an impact if the server is started via server.start(). For integrations like Next.js etc. it is not relevant and can be omitted.

It might make sense to move the endpoint option to server.start({ endpoint: "/foo" }) instead.

Instead of endpoint, the key could also be named route.

This would be a breaking change

@nikfp
Copy link

nikfp commented Jun 14, 2022

What would you think about keeping the existing implementation but also adding the a configuration option through server.start() as well? Then, build in a deprecation warning and carry both options through another major version?

The start implementation would then need to take priority if both were configured, and maybe a warning urging people to switch? Documentation on the change and log outputs would both need to be explicit to catch as many users as possible before the deprecation.

Another thought I just had is one of semantics though. Right now, createServer makes sense in the context of what you are doing, because you are creating and configuring the HTTP server to run. Having the ability to start the server with a different config could be useful, though I can't think of any reason you would configure it once just to configure it again off the top of my head. (I'm sure there are many though).

So maybe adding a second entry point would work? Something like createHandler that would essentially create a route handler without the server options that aren't needed, because frameworks like Next.js and Sveltekit are handling ports and routing to begin with. Then it becomes non-breaking and would just need to be documented to educate users.

Does this make sense, and am I anywhere near the mark of what you were thinking?

@Urigo Urigo added this to the v3 milestone Jul 6, 2022
@theguild-bot theguild-bot mentioned this issue Jul 6, 2022
@n1ru4l
Copy link
Collaborator Author

n1ru4l commented Jul 28, 2022

Kind of solved as part of v3 where you now have to use the node:http handler functionality.

@n1ru4l n1ru4l closed this as completed Jul 28, 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

No branches or pull requests

3 participants