这里有一个可重现的例子 https://github.com/stonecold123/typegraphql-test. Run app.js
并在操场上导航http://localhost:4000/graphql http://localhost:4000/graphql
您可以运行如下查询:
query RecipeQuery{
recipe(title:"Recipe 2"){
description
}
}
Problem:
我需要来自的调试信息extensions
响应数据中的字段。我正在谈论这个extensions
field:
"data":{....},
"extensions": {
"tracing": {}
"cacheControl":{}
}
但实际上,我只获取数据字段:
"data":{....}
我已经启用了tracing
and cacheControl
在阿波罗服务器配置中,但是extensions
字段仍被排除在响应数据中。我怎样才能得到extensions
数据回来?
以下是阿波罗引擎的启动方式:
const expressApp = express();
const server = new ApolloServer({
schema,
tracing: true,
cacheControl: true,
engine: false, // we will provide our own ApolloEngine
});
server.applyMiddleware({ app: expressApp });
const engine = new ApolloEngine({
apiKey: "YOUR_ID",
});
engine.listen(
{
port,
expressApp,
graphqlPaths: [graphqlEndpointPath],
},
() => console.log(`Server with Apollo Engine is running on http://localhost:${port}`),
);
依赖关系
"dependencies": {
"apollo-cache-control": "^0.1.1",
"apollo-engine": "^1.1.2",
"apollo-server-express": "^2.2.2",
"graphql-depth-limit": "^1.1.0",
"graphql-yoga": "^1.16.7",
"type-graphql": "^0.15.0"
}