Failed to load schema from src/graphql/schema.ts: when I add require: ["ts-node/register"], to config #8522
-
I'd like to genereate a types to my resolver but got an error: I use Next.js with TS, prisma and nexus. D:\programming\projects\find-coal-depots-map(main -> origin)
λ yarn generate
yarn run v1.22.10
$ graphql-codegen --config codegen.ts
√ Parse Configuration
‼ Generate outputs
> Generate to ./generated/graphql.tsx
×
Failed to load schema from src/graphql/schema.ts:
Unable to load from file "D:/programmi…
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~~~~~~~~~~~~~~~
src/graphql/schema.ts:2:58 - error TS2774: This condition will always return true since this function is a…
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~~~~~~~~~~~~~
src/graphql/schema.ts:2:85 - error TS7006: Parameter 'o' implicitly has an 'any' type.
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~
src/graphql/schema.ts:2:88 - error TS7006: Parameter 'm' implicitly has an 'any' type.
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~
src/graphql/schema.ts:2:91 - error TS7006: Parameter 'k' implicitly has an 'any' type.
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~
src/graphql/schema.ts:2:94 - error TS7006: Parameter 'k2' implicitly has an 'any' type.
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~~
src/graphql/schema.ts:10:17 - error TS7006: Parameter 'o' implicitly has an 'any' type.
10 }) : (function (o, m, k, k2) {
~
src/graphql/schema.ts:10:20 - error TS7006: Parameter 'm' implicitly has an 'any' type.
10 }) : (function (o, m, k, k2) {
~
src/graphql/schema.ts:10:23 - error TS7006: Parameter 'k' implicitly has an 'any' type.
10 }) : (function (o, m, k, k2) {
~
src/graphql/schema.ts:10:26 - error TS7006: Parameter 'k2' implicitly has an 'any' type.
10 }) : (function (o, m, k, k2) {
~~
src/graphql/schema.ts:15:5 - error TS7022: '__setModuleDefault' implicitly has type 'any' because it does …
15 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
~~~~~~~~~~~~~~~~~~
src/graphql/schema.ts:15:64 - error TS2774: This condition will always return true since this function is …
15 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
~~~~~~~~~~~~~
src/graphql/schema.ts:15:91 - error TS7006: Parameter 'o' implicitly has an 'any' type.
15 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
~
src/graphql/schema.ts:15:94 - error TS7006: Parameter 'v' implicitly has an 'any' type.
15 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
~
src/graphql/schema.ts:17:16 - error TS7006: Parameter 'o' implicitly has an 'any' type.
17 }) : function (o, v) {
~
src/graphql/schema.ts:17:19 - error TS7006: Parameter 'v' implicitly has an 'any' type.
17 }) : function (o, v) {
~
src/graphql/schema.ts:20:5 - error TS7022: '__importStar' implicitly has type 'any' because it does not ha…
20 var __importStar = (this && this.__importStar) || function (mod) {
~~~~~~~~~~~~
src/graphql/schema.ts:20:61 - error TS7006: Parameter 'mod' implicitly has an 'any' type.
20 var __importStar = (this && this.__importStar) || function (mod) {
~~~
src/graphql/schema.ts:36:17 - error TS2695: Left side of comma operator is unused and has no side effects.
36 const schema = (0, nexus_1.makeSchema)({
~
src/graphql/schema.ts:39:18 - error TS2695: Left side of comma operator is unused and has no side effects.
39 module: (0, path_1.join)(process.cwd(), "./src/types/Context.ts"),
~
src/graphql/schema.ts:43:18 - error TS2695: Left side of comma operator is unused and has no side effects.
43 schema: (0, path_1.join)(process.cwd(), "./generated/schema.graphql"),
~
src/graphql/schema.ts:44:19 - error TS2695: Left side of comma operator is unused and has no side effects.
44 typegen: (0, path_1.join)(process.cwd(), "./generated/nexus-typegen.d.ts"),
~
src/graphql/schema.ts:1:1 - error TS1208: 'schema.ts' cannot be compiled under '--isolatedModules' because…
1 "use strict";
~~~~~~~~~~~~
at createTSError (D:\programming\projects\find-coal-depots-map\node_modules\ts-node\src\index.ts:859:12)
…
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~~~~~~~~~~~~~~~
src/graphql/schema.ts:2:58 - error TS2774: This condition will always return true since this function is a…
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~~~~~~~~~~~~~
src/graphql/schema.ts:2:85 - error TS7006: Parameter 'o' implicitly has an 'any' type.
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~
src/graphql/schema.ts:2:88 - error TS7006: Parameter 'm' implicitly has an 'any' type.
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~
src/graphql/schema.ts:2:91 - error TS7006: Parameter 'k' implicitly has an 'any' type.
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~
src/graphql/schema.ts:2:94 - error TS7006: Parameter 'k2' implicitly has an 'any' type.
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
~~
src/graphql/schema.ts:10:17 - error TS7006: Parameter 'o' implicitly has an 'any' type.
10 }) : (function (o, m, k, k2) {
~
src/graphql/schema.ts:10:20 - error TS7006: Parameter 'm' implicitly has an 'any' type.
10 }) : (function (o, m, k, k2) {
~
src/graphql/schema.ts:10:23 - error TS7006: Parameter 'k' implicitly has an 'any' type.
10 }) : (function (o, m, k, k2) {
~
src/graphql/schema.ts:10:26 - error TS7006: Parameter 'k2' implicitly has an 'any' type.
10 }) : (function (o, m, k, k2) {
~~
src/graphql/schema.ts:15:5 - error TS7022: '__setModuleDefault' implicitly has type 'any' because it does …
15 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
~~~~~~~~~~~~~~~~~~
src/graphql/schema.ts:15:64 - error TS2774: This condition will always return true since this function is …
15 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
~~~~~~~~~~~~~
src/graphql/schema.ts:15:91 - error TS7006: Parameter 'o' implicitly has an 'any' type.
15 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
~
src/graphql/schema.ts:15:94 - error TS7006: Parameter 'v' implicitly has an 'any' type.
15 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
~
src/graphql/schema.ts:17:16 - error TS7006: Parameter 'o' implicitly has an 'any' type.
17 }) : function (o, v) {
~
src/graphql/schema.ts:17:19 - error TS7006: Parameter 'v' implicitly has an 'any' type.
17 }) : function (o, v) {
~
src/graphql/schema.ts:20:5 - error TS7022: '__importStar' implicitly has type 'any' because it does not ha…
20 var __importStar = (this && this.__importStar) || function (mod) {
~~~~~~~~~~~~
src/graphql/schema.ts:20:61 - error TS7006: Parameter 'mod' implicitly has an 'any' type.
20 var __importStar = (this && this.__importStar) || function (mod) {
~~~
src/graphql/schema.ts:36:17 - error TS2695: Left side of comma operator is unused and has no side effects.
36 const schema = (0, nexus_1.makeSchema)({
~
src/graphql/schema.ts:39:18 - error TS2695: Left side of comma operator is unused and has no side effects.
39 module: (0, path_1.join)(process.cwd(), "./src/types/Context.ts"),
~
src/graphql/schema.ts:43:18 - error TS2695: Left side of comma operator is unused and has no side effects.
43 schema: (0, path_1.join)(process.cwd(), "./generated/schema.graphql"),
~
src/graphql/schema.ts:44:19 - error TS2695: Left side of comma operator is unused and has no side effects.
44 typegen: (0, path_1.join)(process.cwd(), "./generated/nexus-typegen.d.ts"),
~
src/graphql/schema.ts:1:1 - error TS1208: 'schema.ts' cannot be compiled under '--isolatedModules' because…
1 "use strict";
~~~~~~~~~~~~
at createTSError (D:\programming\projects\find-coal-depots-map\node_modules\ts-node\src\index.ts:859:12)
…
■ Load GraphQL documents
■ Generate
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
D:\programming\projects\find-coal-depots-map(main -> origin)
λ package.json {
"name": "find-coal-depots-map",
"version": "0.1.0",
"private": true,
"scripts": {
"predev": "yarn run generate",
"dev": "next dev",
"prebuild": "yarn run generate",
"build": "next build",
"start": "next start",
"lint": "next lint",
"generate": "graphql-codegen --config codegen.ts"
},
"dependencies": {
"@apollo/client": "^3.7.0",
"@cloudinary/react": "^1.5.0",
"@prisma/client": "^4.5.0",
"@reach/combobox": "^0.18.0",
"apollo-server-micro": "^3.10.3",
"cloudinary": "^1.32.0",
"firebase": "^9.12.1",
"firebase-admin": "^11.2.0",
"geolib": "^3.3.3",
"graphql": "^16.6.0",
"js-cookie": "^3.0.1",
"mapbox-gl": "^2.10.0",
"micro": "^9.4.1",
"micro-cors": "^0.1.1",
"next": "12.3.1",
"nexus": "^1.3.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-firebaseui": "^6.0.0",
"react-hook-form": "^6.15.4",
"react-map-gl": "^7.0.19",
"reflect-metadata": "^0.1.13",
"use-google-maps-script": "^0.1.2",
"use-places-autocomplete": "^4.0.0"
},
"devDependencies": {
"@graphql-codegen/cli": "2.13.7",
"@graphql-codegen/client-preset": "1.1.0",
"@graphql-codegen/introspection": "2.2.1",
"@graphql-codegen/typescript": "^2.8.0",
"@graphql-codegen/typescript-operations": "^2.5.5",
"@graphql-codegen/typescript-react-apollo": "^3.3.5",
"@types/js-cookie": "^3.0.2",
"@types/micro-cors": "^0.1.2",
"@types/node": "18.11.2",
"@types/react": "18.0.21",
"@types/react-dom": "18.0.6",
"@types/react-map-gl": "^6.1.3",
"apollo": "^2.34.0",
"autoprefixer": "^10.4.12",
"eslint": "8.25.0",
"eslint-config-next": "12.3.1",
"postcss": "^8.4.18",
"prisma": "^4.5.0",
"tailwindcss": "^3.2.0",
"ts-node": "^10.9.1",
"typescript": "4.8.4"
}
} codegen.ts import type { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
overwrite: true,
schema: "src/graphql/schema.ts",
require: ["ts-node/register"],
documents: "src/graphql/**/*.graphql",
generates: {
"./generated/graphql.tsx": {
plugins: [
"typescript",
"typescript-operations",
"typescript-react-apollo",
],
},
},
};
export default config; |
Beta Was this translation helpful? Give feedback.
Answered by
charlypoly
Oct 26, 2022
Replies: 1 comment
-
Hi, Could you try to remove the I suspect that the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
belkocik
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Could you try to remove the
require: ["ts-node/register"],
line?I suspect that the
schema.ts
file gets transpiled twice.