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

ApolloGateway: buildService() called twice for each serviceList item #3367

Closed
bwhitty opened this issue Oct 2, 2019 · 0 comments · Fixed by #3388
Closed

ApolloGateway: buildService() called twice for each serviceList item #3367

bwhitty opened this issue Oct 2, 2019 · 0 comments · Fixed by #3388
Labels
🪲 bug 🌹 has-reproduction ❤ Has a reproduction in Glitch, CodeSandbox or Git repository.

Comments

@bwhitty
Copy link

bwhitty commented Oct 2, 2019

Packages

"@apollo/federation": "^0.10.0"
"@apollo/gateway": "^0.10.5"
"apollo-server-express": "^2.9.4"

Expected behavior

When instantiating a new ApolloGateway, buildService() is called only once per serviceList item. This issue is confusing, and I am not sure if there's some underlying bug I am creating in the ApolloGateway by this happening twice?

Actual Behavior

buildService() is called twice

Reproduction

Fork of the federation-demo repo:
bwhitty/federation-demo@a424d3d#diff-ddf0120dcc313c390b98286c8b648109R12-R16

This logs out each call, and you will see every service is called twice:

$ npm run start-gateway

> federation-demo@ start-gateway /.../federation-demo
> nodemon gateway.js

[nodemon] 1.19.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node gateway.js`
accounts http://localhost:4001/graphql
reviews http://localhost:4002/graphql
products http://localhost:4003/graphql
inventory http://localhost:4004/graphql
accounts http://localhost:4001/graphql
reviews http://localhost:4002/graphql
products http://localhost:4003/graphql
inventory http://localhost:4004/graphql
🚀 Server ready at http://localhost:4000/
@trevor-scheer trevor-scheer added 🪲 bug 🌹 has-reproduction ❤ Has a reproduction in Glitch, CodeSandbox or Git repository. 👩‍🚀 federation labels Oct 8, 2019
trevor-scheer added a commit that referenced this issue Oct 9, 2019
Currently, buildService is being called twice for each service on
gateway startup. This is because we're caching the datasources,
but failing to utilize the cache.

This commit places the creation and caching of datasources in one
place, and indicates this more clearly with an updated function
name.

Fixes #3367
abernix pushed a commit to apollographql/federation that referenced this issue Sep 4, 2020
…3388)

Currently, buildService is being called twice for each service on
gateway startup. This is because we're caching the datasources,
but failing to utilize the cache.

This commit places the creation and caching of datasources in one
place, and indicates this more clearly with an updated function
name.

Fixes apollographql/apollo-server#3367
Apollo-Orig-Commit-AS: apollographql/apollo-server@edbc829
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🪲 bug 🌹 has-reproduction ❤ Has a reproduction in Glitch, CodeSandbox or Git repository.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants