Open joneslloyd opened 1 week ago
I had the same error ("does not exist on type Resource") and the problem was that my sst-env.d.ts was not included to tsconfig, so typescript could not map Resources types..
I Had something like that:
{
"include": ["src"],
"exclude": ["node_modules", ".sst"]
}
And that was causing the error.
Try including sst.env.d.ts to tsconfig.json
Unfortunately including sst-env.d.ts
file in tsconfig.json
doesn't help (plus per the aws-monorepo
example, the root tsconfig.json
is normally empty).
Thanks for the suggestion though.
I am using a monorepo setup with Drizzle, and have encountered a peculiar problem whereby
Resource
is empty in seemingly all contexts.I have this folder structure:
My
build-schema.ts
file (to create GraphQL Schema) is in thescripts
subfolder underpackages
and looks like this:It takes a Resolver class for each of my entities (I'm trying to stick to DDD 😉), and generates the GraphQL Schema – A short snippet from
UserResolver
:This in turn uses the
UserRepository
class, which is just an abstraction layer over Drizzle (in case I ever want to replace Drizzle).The problem is that the
UserRepository
importsdb
from my Drizzle file, like so:But when I run (in the
packages/scripts/
folder):npm run sst shell ts-node ./src/build-schema.ts
(in parallel toNO_BUN=true npx sst dev
in another terminal window) I get the following error:The only way around this issue (which feels like a horrible hack) is to do:
Do you know why this is happening?
It also occurs when I try to reference
Resource
in my./infra/graphql-api.ts
file like so:(
Resource
is empty).The file in which
TestProjectDb
is defined is./infra/postgres-database.ts
and looks like this:And my
sst.config.ts
looks like this:My
sst-env.d.ts
looks like:And when I run
NO_BUN=true npx sst dev env
(or justnpx sst dev env
) I getUnexpected error occurred. Please check the logs in .sst/log/sst.log
, which itself contains nothing more than:I am using
sst
version3.1.11
as a dependency in both the mainpackage.json
and all others.Any help here would be appreciated!