【发布时间】:2020-06-24 01:58:19
【问题描述】:
我正在尝试获取我的 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 生成为空(仅 cmets)..
【问题讨论】:
标签: angular graphql apollo-client codegen