Zendro-dev / graphql-server-model-codegen

Command line utility to auto-generate the structure files for a graphql server
MIT License
1 stars 2 forks source link

SPA's detail view generates an error for empty "Int" type foreign key array associations #176

Closed asishallab closed 3 years ago

asishallab commented 3 years ago

Consider the following two example data models:

Material has a many-to-many association using Zendro's foreign key array method:

   // material.json
 "associations": {
   "assays": {                           
      "type": "to_many",   
      "targetStorageType": "sql",
      "target": "assay",         
      "targetKey": "material_ids",   
      "sourceKey": "assay_ids",   
      "keyIn": "material",                  
      "reverseAssociationType": "to_many",
      "label": "measurement"              
    }
 // ...

In the material detail view the resulting (generated) SPA shows one error for each association matching the above example. The error message is

[
     {
          "message": "Error: with_errors",
          "locations": [
               {
                    "association": "assays",
                    "method": "getData()",
                    "request": "api.material.getAssays"
               }
          ],
          "path": [
               "detail",
               "material_id:1",
               "assays"
          ],
          "extensions": {
               "graphqlResponse": {
                    "data": {
                         "readOneMaterial": {
                              "assaysConnection": null
                         }
                    },
                    "errors": [
                         {
                              "query": "readOneMaterial",
                              "errors": [
                                   {
                                        "message": "invalid input syntax for integer: \"\"",
                                        "locations": [
                                             {
                                                  "line": 3,
                                                  "column": 17
                                             }
                                        ],
                                        "path": [
                                             "readOneMaterial",
                                             "assaysConnection"
                                        ]
                                   }
                              ]
                         }
                    ]
               }
          }
     }
]