# ApolloGateway do not query Subgraph

**URL:** https://community.apollographql.com/t/apollogateway-do-not-query-subgraph/5360
**Category:** Other Apollo Topics
**Tags:** federation
**Created:** [January 3, 2023, 12:12pm UTC](https://community.apollographql.com/t/apollogateway-do-not-query-subgraph/5360 "2023-01-03T12:12:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cyril36](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/cyril36/32/3587_2.png) [@cyril36](https://community.apollographql.com/u/cyril36)
#### Post date: [January 3, 2023, 12:12pm UTC](https://community.apollographql.com/t/apollogateway-do-not-query-subgraph/5360/1 "2023-01-03T12:12:12Z")

</div>

Hello,

My ApolloGateway do not query my subgraph and i dont get any error from the graphql response or on my service logs so i have no clue about where this error come from.

I have a supergraph endpoint using ApolloGateway in local.  
ApolloGateway has the following configuration :

> federation\_version: 2  
> subgraphs:  
> accounts:  
> routing\_url: [http://172.17.0.1:8000](http://172.17.0.1:8000)  
> schema:  
> file: …/gruion\_subgraph\_account/src/accounts.graphql  
> organization:  
> routing\_url: [http://172.17.0.1:8001](http://172.17.0.1:8001)  
> schema:  
> file: …/gruion\_subgraph\_organization/src/organizations.graphql  
> user:  
> routing\_url: [http://172.17.0.1:8003](http://172.17.0.1:8003)  
> schema:  
> file: …/gruion\_subgraph\_user/src/users.graphql

and the code (should be standard):

> const supergraphSdl = readFileSync(‘./src/supergraph.graphql’).toString() //it is the file above  
> const gateway = new ApolloGateway({  
> supergraphSdl,  
> });  
> const {schema, executor} = await gateway.load();  
> const app = express();  
> const httpServer = http.createServer(app);
> 
> const server = new ApolloServer({  
> schema,  
> csrfPrevention: false,  
> executor,  
> });  
> await server.start();  
> app.use(  
> ‘/’,  
> json(),  
> expressMiddleware(server )  
> );
> 
> let port = 4000  
> await new Promise((resolve) =\> httpServer.listen({ port: port }, resolve));
> 
> console.log(`🚀 Server ready at http://localhost:${port}/`);

I have my subgraph that has a query define like :

> type Query {  
> getAccountName:String  
> }

And resolved like :

> getAccountName() {  
> return “MyACcountName”  
> }

when I query the above query to the subgraph server directly(accounts), the query get resolved and answers “MyACcountName” :

> curl --location --request POST ‘[http://172.17.0.1:8000](http://172.17.0.1:8000)’ --header ‘Content-Type: application/json’ --data-raw ‘{“query”:“query Query {\n getAccountName\n}”,“variables”:{}}’  
> {“data”:{“getAccountName”:“MyACcountName”}}

when I query the above query to the supergraph server, the query is not sent to the subgraph so it does not resolve it and answers null :

> curl --location --request POST ‘[http://172.17.0.1:8002](http://172.17.0.1:8002)’ --header ‘Content-Type: application/json’ --data-raw ‘{“query”:“query Query {\n getAccountName\n}”,“variables”:{}}’  
> {“data”:{“getAccountName”:null}}

Where the issue can come from?  
Is there a way to enable verbose logs on supergraph server and subgraph?  
I tried to follow different documentation to enable logs on my servers but nothing works

---

<div class="post-metadata">

### Author: ![cyril36](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/cyril36/32/3587_2.png) [@cyril36](https://community.apollographql.com/u/cyril36)
#### Post date: [January 3, 2023, 10:38pm UTC](https://community.apollographql.com/t/apollogateway-do-not-query-subgraph/5360/2 "2023-01-03T22:38:24Z")

</div>

I have found the issue. To fix this issue you have to remove :

> const {schema, executor} = await gateway.load();

so the code will be :

> const supergraphSdl = readFileSync(‘./src/supergraph.graphql’).toString() //it is the file above  
> const gateway = new ApolloGateway({  
> supergraphSdl,  
> });  
> const app = express();  
> const httpServer = http.createServer(app);
> 
> const server = new ApolloServer({  
> gateway,  
> csrfPrevention: false,  
> });  
> await server.start();  
> app.use(  
> ‘/’,  
> json(),  
> expressMiddleware(server )  
> );
> 
> let port = 4000  
> await new Promise((resolve) =\> httpServer.listen({ port: port }, resolve));
> 
> console.log(`🚀 Server ready at http://localhost:${port}/`);
