为什么 apollo client:codegen 不生成类型?

Why apollo client:codegen is not generate types?

我正在尝试获取我的 Apollo 服务器中定义的类型

首先,有效地下载架构:

apollo client:download-schema src/code/queries/schemas/schema.json --endpoint http://localhost:4000/

该命令生成以下内容。json,出于演示目的对其进行了缩减。

{
"__schema": {
"queryType": {
  "name": "Query"
},
"mutationType": {
  "name": "Mutation"
},
"subscriptionType": null,
"types": [
  {
    "kind": "OBJECT",
    "name": "Query",
    "description": null,
    "fields": [
      {
        "name": "UserInformation",
        "description": null,
        "args": [],
        "type": {
          "kind": "OBJECT",
          "name": "User",
          "ofType": null
        },
        "isDeprecated": false,
        "deprecationReason": null
      }
    ],
    "inputFields": null,
    "interfaces": [],
    "enumValues": null,
    "possibleTypes": null
  },
  {
    "kind": "OBJECT",
    "name": "User",
    "description": null,
    "fields": [
      {
        "name": "firstName",
        "description": null,
        "args": [],
        "type": {
          "kind": "SCALAR",
          "name": "String",
          "ofType": null
        },
        "isDeprecated": false,
        "deprecationReason": null
      },
      {
        "name": "secondName",
        "description": null,
        "args": [],
        "type": {
          "kind": "SCALAR",
          "name": "String",
          "ofType": null..........

然后尝试将类型生成为打字稿但没有成功:

   apollo client:codegen --target typescript --localSchemaFile src/code/queries/schemas/schema.json  --outputFlat src/code/queries/generated

globalTypes.ts 生成为空(仅评论)..

您需要包含 --includes 选项以指示哪些文件包含要为其生成类型的实际查询。来自 docs:

--includes=includes Glob of files to search for GraphQL operations. This should be used to find queries and any client schema extensions