driescroons / mikro-orm-graphql-example Goto Github PK
View Code? Open in Web Editor NEWA MikroORM (v4) example project for GraphQL made with Typescript using TypeGraphQL
License: MIT License
A MikroORM (v4) example project for GraphQL made with Typescript using TypeGraphQL
License: MIT License
Great example! I've just one quick question, I don't see validate
being called for any entity decorated with class-validator
. Is this somehow being validated internally that I'm missing?
Thank you!
The dev mode works well, however not the build process.
npm install
Install ok.
npm run build
Error:
src/utils/services/loadFixtures.service.ts:65:9 - error TS2740: Type 'Tag[]' is missing the following properties from type 'Collection<Tag, unknown>': snapshot, dirty, _populated, _lazyInitialized, and 42 more.
65 book.tags = [orm.em.getRepository(Tag).getReference(tags[bookIndex].id)];
~~~~~~~~~
I comment this line. Build ok.
npm run start
Error:
> cross-env NODE_PATH=./dist/src node dist/src/index.js
node_modules/globby/index.js:28
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (node_modules/@mikro-orm/core/cache/FileCacheAdapter.js:7:34)
I am trying to run you example and getting the above error:
❯ postgres --version
postgres (PostgreSQL) 13.0
❯ yarn loadFixtures
yarn run v1.22.5
$ yarn test --grep "should clear database and load fixtures"
$ cross-env NODE_DEV=true NODE_ENV=test ts-mocha ./tests/**/*.test.ts --package package.json --grep 'should clear database and load fixtures'
Sample tests
== Migration20200809143205: migrating =======
== Migration20200809143205: migrated (0.119s)
🚀 http://localhost:8080/graphql
1) should clear database and load fixtures
0 passing (2s)
1 failing
1) Sample tests
should clear database and load fixtures:
DriverException: set session_replication_role = 'replica'; - permission denied to set parameter "session_replication_role"
at PostgreSqlExceptionConverter.convertException (node_modules/@mikro-orm/core/platforms/ExceptionConverter.js:8:16)
at PostgreSqlExceptionConverter.convertException (node_modules/@mikro-orm/postgresql/PostgreSqlExceptionConverter.js:40:22)
at PostgreSqlDriver.convertException (node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:147:54)
at /Users/mandalarian/Downloads/mikro-orm-graphql-example/node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:151:24
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at SchemaGenerator.execute (node_modules/@mikro-orm/knex/schema/SchemaGenerator.js:108:13)
at SchemaGenerator.dropSchema (node_modules/@mikro-orm/knex/schema/SchemaGenerator.js:55:9)
at Object.exports.clearDatabase (src/utils/services/clearDatabase.service.ts:5:5)
at Context.<anonymous> (tests/sample.test.ts:25:9)
previous error: set session_replication_role = 'replica'; - permission denied to set parameter "session_replication_role"
at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:357:11)
at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:186:21)
at Parser.parse (node_modules/pg-protocol/src/parser.ts:101:30)
at Socket.<anonymous> (node_modules/pg-protocol/src/index.ts:7:48)
at Socket.EventEmitter.emit (domain.js:485:12)
at addChunk (_stream_readable.js:302:12)
at readableAddChunk (_stream_readable.js:278:9)
at Socket.Readable.push (_stream_readable.js:217:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Am i missing a step from the Readme?
Thank for sharing.
Was hoping to see the use of transactions here and here, and where you'd define that boundary.
As you're using ts-morph
for metadata, did you run into any problems? I figured you'd have to generate types or something. In my project I stuck with reflect-metadata
.
Glad to see you throwing up a repo :D
I believe that this line should be
book.tags.add(orm.em.getRepository(Tag).getReference(tags[bookIndex].id))
but tests are still failing..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.