paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
681 stars 55 forks source link

Unknown type "Decimal". #194

Closed omar-dulaimi closed 3 years ago

omar-dulaimi commented 3 years ago

Hello, I'm recieving a lot of errors in the terminal saying:

Unknown type "Decimal".

and also:

    at assertValidSDL (/home/GraphQL-API-Prisma2-SDL/node_modules/graphql/validation/validate.js:107:11)
    at Object.buildASTSchema (/home/GraphQL-API-Prisma2-SDL/node_modules/graphql/utilities/buildASTSchema.js:45:34)
    at buildSchemaFromTypeDefinitions (/home/GraphQL-API-Prisma2-SDL/node_modules/graphql-tools/dist/schema/src/buildSchemaFromTypeDefinitions.js:9:18)
    at Object.makeExecutableSchema (/home/GraphQL-API-Prisma2-SDL/node_modules/graphql-tools/dist/schema/src/makeExecutableSchema.js:64:18)
    at Object.<anonymous> (/home/GraphQL-API-Prisma2-SDL/src/server.ts:10:14)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Module._compile (/home/GraphQL-API-Prisma2-SDL/node_modules/source-map-support/source-map-support.js:547:25)
    at Module.m._compile (/tmp/ts-node-dev-hook-1092971041551758.js:69:33)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at require.extensions.<computed> (/tmp/ts-node-dev-hook-1092971041551758.js:71:20)
[ERROR] 20:46:37 Error: Unknown type "Decimal".
AhmedElywa commented 3 years ago

Yes, you face this issue with the last version of prisma because they added the Decimal type. I must convert it to Float to work with Graphql

omar-dulaimi commented 3 years ago

I saw in the past PRS this one https://github.com/paljs/prisma-tools/pull/176 Isn't it supposed to fix this issue?

I'm not sure really about conversion from Decimal to Float, wouldn't that introduce data loss/other issues?

AhmedElywa commented 3 years ago

I'm not sure really about conversion from Decimal to Float, wouldn't that introduce data loss/other issues?

No, it just changes the type name.

176 fix this issue for nexus generator not SDL generator

AhmedElywa commented 3 years ago

For SDL first generator, you need to add Decimal scalar manually in your resolvers

omar-dulaimi commented 3 years ago

Aha okay. Is there anything I can do to speed this ticket resolution?

omar-dulaimi commented 3 years ago

@AhmedElywa Hello again. Could you please elaborate on how to manually do this?

For SDL first generator, you need to add Decimal scalar manually in your resolvers

I'm blocked at this issue since yesterday, and I couldn't find mentions of "Decimal" besides in typeDefs and resolversTypes files. We really need to get going with Pal.js

omar-dulaimi commented 3 years ago

@AhmedElywa Also, how can I change the names of some fields; like "take" I want to change it to "first"

AhmedElywa commented 3 years ago

for adding a custom scalar, look to this example https://www.graphql-tools.com/docs/scalars/#custom-scalar-examples