Hello!
I am totally new here so please forgive me for my maybe newbie question.
This is my netlify site name: https://sharp-feynman-110ca1.netlify.app.
I would like to deploy a monorepo that performs an Apollo GraphQL for the backend and a create react app for the frontend. The project is configured like this:
-- root
---- netlify.toml
---- package.json (with common scripts)
---- node_modules
---- client
-------- src
-------- package.json
-------- node_modules
-------- ts.config
---- server
-------- functions
-------- src
-------------- macro-product
-------------------- macroProduct.typedefs.ts
-------------------- index.ts
-------------- types
------------------ types.graphql.generated
-------- package.json
-------- node_modules
-------- ts.config
-------- codegen.yml
The server/codegen.yml
file generates, through graphql code generator typescript types from server/src/macroProduct.typedefs.ts
producing server/src/types/types.graphql.generated
.
What server/src/macroProduct.typedefs.ts
contains is this:
const typedefs = gql`
type MacroProduct {
id: Int!
parentPartNo: Int!
childPartNo: Int!
quantity: Int!
}
extend type Query {
macroProducts: [MacroProduct!]!
macroProduct(id: Int!): MacroProduct
}
`;
export default typedefs;
I am running the build
command inside netlify.toml
that makes run a prebuild:server
command to install all the dependencies inside the server
folder an then launches tsc
to build the server.
If I run it locally everything works while when I try to deploy it with Netlify this is the error I receive:
11:36:48 PM: src/macro-product/index.ts:2:49 - error TS2307: Cannot find module './macroProduct.typeDefs' or its corresponding type declarations.
11:36:48 PM: 2 export { default as macroProductTypeDefs } from './macroProduct.typeDefs';
This is my server/tsconfig.json
:
"compilerOptions": {
"allowJs": true,
"pretty": true,
"module": "commonjs",
"sourceMap": true,
"target": "es2019",
"outDir": "./functions/bundle",
"lib": ["ES6"],
"resolveJsonModule": true,
"types": ["node"],
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
"declaration": true,
"typeRoots": [ "./node_modules/@types", "./types", "./functions/bundle" ]
},
"include": ["src"],
"exclude": ["node_modules", "src/**/__tests__"]
}
I am really stuck at this issue. I have tried to move the generated types file in the same directory of the source file (removing the typeRoots
field in server/tsconfig.json
) but it did not work.
Could gently someone try to help me?
Thanks a lot!