-
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
Feature: allow dataSources
creator function to be async
#4222
Conversation
Not sure what the test failures in |
@rintaun This feature would be awesome. Do we know if there's a reason this hasn't been approved yet? |
@jldillman no idea! probably because I put it up randomly without any discussion anywhere 😂 Personally, I'm not doing anything that would require this feature anymore, though that might change if this were merged. |
Is something holding this back? It's just a single word of behavior code change: In case anyone needs I used Click to see the
|
Practically speaking, the data sources subproject is currently unmaintained, in the sense that the current Apollo Server team members have not yet fully "on-boarded" ourselves to that subproject (which is a bunch of code almost entirely unrelated to the rest of Apollo Server) since we revived the Apollo Server project earlier this year. (For what it's worth, if/when I do find the time to onboard myself onto data sources, my first project will probably be to deprecate the top-level |
Similar to what I mentioned in my previous comment, we've removed the |
#3639 changed
initializeDataSources
to be an async function, so it is a small step to allow the supplieddataSources
creator function to also be async. This helps simplify things when the creation of thedataSources
object itself (rather than each individual entry) relies on some asynchronous process, e.g. connecting to a database or getting a connection from a pool.Right now, we are using a factory for the
dataSources
creator function that waits on the connection pool, but it would be nice to get rid of that extra step.Simplified example:
After this change, this could be represented as:
Note: the second approach also makes it possible to perform some asynchronous process on every request rather than only once at startup as in the first example.