我有一个 graphQL 查询,想将它转换为 GraphQL Transformer v1 到 v2
I have a graphQL query and wanted to convert it GraphQL Transformer v1 to v2
我正在使用 GraphQl 进行放大处理现有项目 API。
查询将@Key 的问题显示为 Your GraphQL Schema is using "@key" directive from an older version of the GraphQL Transformer
。由于我是 graphQL 的新手,我应该改变什么才能让它工作?
谢谢
错误:
✖ An error occurred when pushing the resources to the cloud
An error occurred during the push operation: Your GraphQL Schema is using "@key" directive from an older version of the GraphQL Transformer. Visit https://docs.amplify.aws/cli/migration/transformer-migration/ to learn how to migrate your GraphQL schema.
查询:
type KeyValuePair {
key: String!
value: String
}
type Template
@model
@auth(rules: [ {allow: owner } ]) {
id: ID!
name: String!
description: String
provision_style: String!
status: String!
params: [KeyValuePair]
resources: [KeyValuePair]
}
type Asset
@model
@auth(rules: [ {allow: owner } ])
@key(name: "categoryTypeIndex", fields: ["category", "type"], queryField: "assetsByCategoryAndType")
@key(name: "categoryNameIndex", fields: ["category", "name"], queryField: "assetsByCategoryAndName")
@key(name: "categoryStatusIndex", fields: ["category", "status"], queryField: "assetsByCategoryAndStatus") {
id: ID!
parent: ID
category: String!
type: String!
name: String!
description: String
status: String
template: String
details: [KeyValuePair]
}
type Contract
@model
@auth(rules: [ {allow: owner } ])
@key(name: "tenantAssetIndex", fields: ["tenantId", "assetId"], queryField: "contractsByTenantAndAsset")
@key(name: "tenantNameIndex", fields: ["tenantId", "name"], queryField: "contractsByTenantAndName")
@key(name: "tenantStatusIndex", fields: ["tenantId", "status"], queryField: "contractsByTenantAndStatus") {
id: ID!
type: String!
tenantId: String!
assetId: String!
name: String!
description: String
status: String
details: [KeyValuePair]
resources: [KeyValuePair]
}
type PlatformEvent
@model
@auth(rules: [ {allow: owner } ])
@key(name: "contractTypeIndex", fields: ["contractId", "type"], queryField: "eventsByContractAndType")
@key(name: "contractSourceIndex", fields: ["contractId", "sourceId"], queryField: "eventsByContractAndSource")
@key(name: "sourceTypeIndex", fields: ["sourceId", "type"], queryField: "eventsBySourceAndType") {
id: ID!
type: String!
contractId: String!
sourceId: String!
content: String!
details: [KeyValuePair]
}
This 应该会让您的生活变得轻松。
AWS 提供了一个迁移指南:https://docs.amplify.aws/cli/migration/transformer-migration/ 但遗憾的是他们没有具体说明如何实际设置您的 API 以使用 new/old 版本。
如果您查看 amplify
文件夹,您会找到一个 cli.json
文件,要将您的后端设置为使用 GraphQLTransformer 版本 1,您只需编辑该文件并设置以下两个属性:
"features": {
"graphqltransformer": {
...
"useexperimentalpipelinedtransformer": false,
"transformerversion": 1,
...
},
从那里您只需 amplify push
并假设您已满足迁移指南描述的所有更改,它将正确更新您的端点。
编辑:对于那些希望升级到 V2 而不是降级到 V1 的用户,您需要按如下方式设置属性:
"features": {
"graphqltransformer": {
...
"useexperimentalpipelinedtransformer": true,
"transformerversion": 2,
...
},
我正在使用 GraphQl 进行放大处理现有项目 API。
查询将@Key 的问题显示为 Your GraphQL Schema is using "@key" directive from an older version of the GraphQL Transformer
。由于我是 graphQL 的新手,我应该改变什么才能让它工作?
谢谢
错误:
✖ An error occurred when pushing the resources to the cloud
An error occurred during the push operation: Your GraphQL Schema is using "@key" directive from an older version of the GraphQL Transformer. Visit https://docs.amplify.aws/cli/migration/transformer-migration/ to learn how to migrate your GraphQL schema.
查询:
type KeyValuePair {
key: String!
value: String
}
type Template
@model
@auth(rules: [ {allow: owner } ]) {
id: ID!
name: String!
description: String
provision_style: String!
status: String!
params: [KeyValuePair]
resources: [KeyValuePair]
}
type Asset
@model
@auth(rules: [ {allow: owner } ])
@key(name: "categoryTypeIndex", fields: ["category", "type"], queryField: "assetsByCategoryAndType")
@key(name: "categoryNameIndex", fields: ["category", "name"], queryField: "assetsByCategoryAndName")
@key(name: "categoryStatusIndex", fields: ["category", "status"], queryField: "assetsByCategoryAndStatus") {
id: ID!
parent: ID
category: String!
type: String!
name: String!
description: String
status: String
template: String
details: [KeyValuePair]
}
type Contract
@model
@auth(rules: [ {allow: owner } ])
@key(name: "tenantAssetIndex", fields: ["tenantId", "assetId"], queryField: "contractsByTenantAndAsset")
@key(name: "tenantNameIndex", fields: ["tenantId", "name"], queryField: "contractsByTenantAndName")
@key(name: "tenantStatusIndex", fields: ["tenantId", "status"], queryField: "contractsByTenantAndStatus") {
id: ID!
type: String!
tenantId: String!
assetId: String!
name: String!
description: String
status: String
details: [KeyValuePair]
resources: [KeyValuePair]
}
type PlatformEvent
@model
@auth(rules: [ {allow: owner } ])
@key(name: "contractTypeIndex", fields: ["contractId", "type"], queryField: "eventsByContractAndType")
@key(name: "contractSourceIndex", fields: ["contractId", "sourceId"], queryField: "eventsByContractAndSource")
@key(name: "sourceTypeIndex", fields: ["sourceId", "type"], queryField: "eventsBySourceAndType") {
id: ID!
type: String!
contractId: String!
sourceId: String!
content: String!
details: [KeyValuePair]
}
This 应该会让您的生活变得轻松。
AWS 提供了一个迁移指南:https://docs.amplify.aws/cli/migration/transformer-migration/ 但遗憾的是他们没有具体说明如何实际设置您的 API 以使用 new/old 版本。
如果您查看 amplify
文件夹,您会找到一个 cli.json
文件,要将您的后端设置为使用 GraphQLTransformer 版本 1,您只需编辑该文件并设置以下两个属性:
"features": {
"graphqltransformer": {
...
"useexperimentalpipelinedtransformer": false,
"transformerversion": 1,
...
},
从那里您只需 amplify push
并假设您已满足迁移指南描述的所有更改,它将正确更新您的端点。
编辑:对于那些希望升级到 V2 而不是降级到 V1 的用户,您需要按如下方式设置属性:
"features": {
"graphqltransformer": {
...
"useexperimentalpipelinedtransformer": true,
"transformerversion": 2,
...
},