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

custom defined internalIds of type unlike String don't work #221

Closed qwerdenkerXD closed 1 year ago

qwerdenkerXD commented 1 year ago

Trying to set up a Zendro instance with custom primary keys with type e.g. Int don't work. Creating or updating records cause the following error:

Error: validation failed at Model.validate10 [as asyncValidate] (eval at compileSchema (/Users/f.sill/Desktop/laszlo/desc/graphql-server/node_modules/ajv/dist/compile/index.js:89:30), :3:2557) at alleleMatrix.validateForCreate (/Users/f.sill/Desktop/laszlo/desc/graphql-server/validations/alleleMatrix.js:45:45) at module.exports.validateData (/Users/f.sill/Desktop/laszlo/desc/graphql-server/utils/validatorUtil.js:52:49) at alleleMatrix.addOne (/Users/f.sill/Desktop/laszlo/desc/graphql-server/models/sql/alleleMatrix.js:237:29) at Object.addAlleleMatrix (/Users/f.sill/Desktop/laszlo/desc/graphql-server/resolvers/alleleMatrix.js:367:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async graphqlMiddleware (/Users/f.sill/Desktop/laszlo/desc/graphql-server/node_modules/express-graphql/index.js:125:26) {"message":"validation failed","name":"GraphQLError","originalError":{"message":"validation failed","errors":[{"instancePath":"/AlleleMatrix_id","schemaPath":"#/properties/AlleleMatrix_id/type","keyword":"type","params":{"type":["integer","null"]},"message":"must be integer,null"}],"validation":true,"ajv":true},"source":{"body":"mutation addAlleleMatrix($AlleleMatrix_id: ID! $expandHomozygotes: Boolean $sepPhased: String $sepUnphased: String $unknownString: String ) { addAlleleMatrix(AlleleMatrix_id: $AlleleMatrix_id expandHomozygotes: $expandHomozygotes sepPhased: $sepPhased sepUnphased: $sepUnphased unknownString: $unknownString ) { AlleleMatrix_id expandHomozygotes sepPhased sepUnphased unknownString asCursor} }","name":"GraphQL request","locationOffset":{"line":1,"column":1}},"positions":[142],"locations":[{"line":1,"column":143}],"path":["addAlleleMatrix"],"extensions":{}}

In short, the entered ID type doesn't match the expected type because it's serialized as String