1

我正在尝试使用具有列表和其他数据的输入来构建突变查询,并且在编译时会引发错误。

这里的ItemData是一个列表类型,如果我删除它,代码就会正确编译。

该查询正在 AWS 查询的 AWS Screenchot 中进行验证

我的schema.graphql如下所示

mutation AddAdHoc($doc_no: String!, $bag: Int!,  $cartons: Int!, $destination: String!, $pallets: Int!, $reason: String! ,$source: String!, $type: String!, $version: String, $itemData: ItemData){
addAdHocDetails(input: {doc_no: $doc_no, bag: $bag, cartons: $cartons, destination: $destination, pallets: $pallets, reason: $reason ,source: $source, type: $type, version: $version, itemData: $itemData})
  {
    id
 }
}

我的schema.json的某些部分如下所示

{
              "name": "addAdHocDetails",
              "description": null,
              "args": [
                {
                  "name": "input",
                  "description": null,
                  "type": {
                    "kind": "NON_NULL",
                    "name": null,
                    "ofType": {
                      "kind": "INPUT_OBJECT",
                      "name": "addAdHocInput",
                      "ofType": null
                    }
                  },
                  "defaultValue": null
                }
              ],
              "type": {
                "kind": "OBJECT",
                "name": "TBLAdHoc",
                "ofType": null
              },
              "isDeprecated": false,
              "deprecationReason": null
            }
{
          "kind": "INPUT_OBJECT",
          "name": "addAdHocInput",
          "description": null,
          "fields": null,
          "inputFields": [
            {
              "name": "doc_no",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "String",
                  "ofType": null
                }
              },
              "defaultValue": null
            },
            {
              "name": "bag",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "Int",
                  "ofType": null
                }
              },
              "defaultValue": null
            },
            {
              "name": "cartons",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "Int",
                  "ofType": null
                }
              },
              "defaultValue": null
            },
            {
              "name": "destination",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "String",
                  "ofType": null
                }
              },
              "defaultValue": null
            },
            {
              "name": "pallets",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "Int",
                  "ofType": null
                }
              },
              "defaultValue": null
            },
            {
              "name": "reason",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "String",
                  "ofType": null
                }
              },
              "defaultValue": null
            },
            {
              "name": "source",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "String",
                  "ofType": null
                }
              },
              "defaultValue": null
            },
            {
              "name": "type",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "String",
                  "ofType": null
                }
              },
              "defaultValue": null
            },
            {
              "name": "version",
              "description": null,
              "type": {
                "kind": "SCALAR",
                "name": "String",
                "ofType": null
              },
              "defaultValue": null
            },
            {
              "name": "itemData",
              "description": null,
              "type": {
                "kind": "LIST",
                "name": null,
                "ofType": {
                  "kind": "INPUT_OBJECT",
                  "name": "ItemData",
                  "ofType": null
                }
              },
              "defaultValue": null
            }
          ],
          "interfaces": null,
          "enumValues": null,
          "possibleTypes": null
        },
{
          "kind": "INPUT_OBJECT",
          "name": "ItemData",
          "description": null,
          "fields": null,
          "inputFields": [
            {
              "name": "item_id",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "Int",
                  "ofType": null
                }
              },
              "defaultValue": null
            },
            {
              "name": "uom",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "String",
                  "ofType": null
                }
              },
              "defaultValue": null
            },
            {
              "name": "qty",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "Int",
                  "ofType": null
                }
              },
              "defaultValue": null
            },
            {
              "name": "collectd",
              "description": null,
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "Int",
                  "ofType": null
                }
              },
              "defaultValue": null
            }
          ],
          "interfaces": null,
          "enumValues": null,
          "possibleTypes": null
        }

任何帮助都是可观的,

提前致谢

4

1 回答 1

0

我让它工作了

ItemData的种类List所以我们需要把数据放进去,[]这样它就可以被列为列表输入

mutation AddAdHoc($doc_no: String!, $bag: Int!,  $cartons: Int!, $destination: String!, $pallets: Int!, $reason: String! ,$source: String!, $type: String!, $version: String, $itemData: [ItemData]){
addAdHocDetails(input: {doc_no: $doc_no, bag: $bag, cartons: $cartons, destination: $destination, pallets: $pallets, reason: $reason ,source: $source, type: $type, version: $version, itemData: $itemData})
  {
    id
 }
}
于 2018-07-05T04:39:52.080 回答