Search code examples
androidamazon-web-servicesgraphqlapollo-android

graphql is not compiling in android if a list type is added in mutation query


I am trying to build a mutation query with the input having a list and other data and while compiling it is throwing an error.

Here ItemData is a list type and if I remove it the code is compiling properly.

The query is validating inside the AWS Screenchot of Query in AWS

My schema.graphql looks like below

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
 }
}

and some part of my schema.json looks like below

{
              "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
        }

Any help is appreciable,

Thanks in advance


Solution

  • I got it working

    The kind of ItemData is List so we need to put the data in [] so that it can be listed as a list input

    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
     }
    }