ent icon indicating copy to clipboard operation
ent copied to clipboard

friendlier error message when missing dependencies when types that have custom scalars are used

Open lolopinto opened this issue 3 years ago • 1 comments

there's dependencies we use for graphql scalars but it's not expressed anywhere and we need a better way of indicating this

  • JSONType or JSONBType: graphql-type-json
  • BinaryTextType or ByteaType: graphql-scalars
/usr/lib/node_modules/ts-node/src/index.ts:692
    return new TSError(diagnosticText, diagnosticCodes);
           ^
TSError: ⨯ Unable to compile TypeScript:
src/graphql/resolvers/generated/task_type.ts:7:27 - error TS2307: Cannot find module 'graphql-type-json' or its corresponding type declarations.

7 import {GraphQLJSON} from "graphql-type-json";
                            ~~~~~~~~~~~~~~~~~~~

    at createTSError (/usr/lib/node_modules/ts-node/src/index.ts:692:12)
    at reportTSError (/usr/lib/node_modules/ts-node/src/index.ts:696:19)
    at getOutput (/usr/lib/node_modules/ts-node/src/index.ts:883:36)
    at Object.compile (/usr/lib/node_modules/ts-node/src/index.ts:1185:30)
    at Module.m._compile (/usr/lib/node_modules/ts-node/src/index.ts:1309:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .ts] (/usr/lib/node_modules/ts-node/src/index.ts:1313:12)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  diagnosticText: "\x1B[96msrc/graphql/resolvers/generated/task_type.ts\x1B[0m:\x1B[93m7\x1B[0m:\x1B[93m27\x1B[0m - \x1B[91merror\x1B[0m\x1B[90m TS2307: \x1B[0mCannot find module 'graphql-type-json' or its corresponding type declarations.\n" +
    '\n' +
    '\x1B[7m7\x1B[0m import {GraphQLJSON} from "graphql-type-json";\n' +
    '\x1B[7m \x1B[0m \x1B[91m                          ~~~~~~~~~~~~~~~~~~~\x1B[0m\n',
  diagnosticCodes: [ 2307 ]
}

relevants: https://github.com/lolopinto/ent/commits/main/internal/codegen/prompts.go

lolopinto avatar Sep 28 '21 18:09 lolopinto

also graphql-scalars from https://github.com/lolopinto/ent/pull/1654

lolopinto avatar Sep 14 '23 21:09 lolopinto