-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Refactor runHttpQuery and runQuery #1468
Conversation
Thanks, this is a great start! I think there is more we can do however. Features like persisted queries and cache control are still tied to One thorny issue is batching, which really complicates the logic of More generally, I think breaking up the pipeline into We may want to move to a model where transport-specific entry points call smaller functions that are reusable across transports, instead of handing over control to I think your suggestion of using a class to encapsulate parts of the request pipeline is worth investigating. There is a proliferation of config and options types ( I tried to clean some of the code up, but resolving options and initializing the context is still pretty confusing. I think this is mostly because when we designed the API we were still thinking in terms of middleware handlers. And even when So the main flow is through the handlers, which pass an array of handler arguments to Cleaning up the main request flow should probably have priority though. My hope is that we can break features up even more, so they are encapsulated and can be reused across transports. We may be able to move most of the cache control code from Let me know how you would like us to work on this. It may make sense to start with a design doc for some of this work. I'm happy to contribute as well. And we could always set up a meeting next week to talk or pair if that is helpful. |
closed in favor of request pipeline https://github.com/apollographql/apollo-server/tree/new-request-pipeline |
This PR breaks up runHttpQuery and runQuery into separate functions for each of the distinct steps. These steps include: creation of the query string, parse, validate and execute.
Additionally, this PR changes the error on a non-query for a GET request to a validation error.
A learning out of this refactor is that there's a fair amount of state that is passed deeply, namely
debug
andformatter
. We could make runQuery into a class that is constructed on each request(similar to the extensions stack) and keeps this state.