-
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
[apollo-datasource-rest] - Reuse classes outside of Apollo Server context #2561
Comments
Actually relates to this #2240 Calling initialize() function with empty object fixed my problem. this.authenticationAPI = new AuthenticationAPI()
this.authenticationAPI.initialize({})
const token = await this.authenticationAPI.login(credentials) |
i have the same issue |
As mentioned above, data sources are automatically initialized by Apollo Server with the context, so you'll need to do this manually when using them separately. |
@martijnwalraven do you plan having a clean support for using datasources in subscriptions? |
@quentinus95 Yes, but not until Apollo Server 3 unfortunately. Subscriptions are currently implemented as a completely separate server that doesn't share the request pipeline with the regular server. |
I had the same problem with You can see my comments about it here |
I'm using the package apollo-datasource-rest alongside Apollo Server to manage external REST requests and its working fine.
I would like to call those same class methods on server init before actually launching the Apollo Server. Naively I tried to instanciate the class with new and then call methods on the instance but at the moment I'm getting this error when class is instantiated outside the apollo server "context".
Is there a way to archieve this or will I have to duplicate same fetching methods?
The text was updated successfully, but these errors were encountered: