Are you able to use a separate ORM layer if you wish? #1315
Unanswered
miloofcroton
asked this question in
Q&A
Replies: 1 comment
-
Absolutely. You don't have to "opt-out" of anything. @ObjectType()
class FooGraphql {
@Field(() => ID)
public id!: string
@Field(() => String)
public name!: string
}
@DBEntity()
class FooDb // use whatever flavour of ORM you want here
@Resolver(() => FooGraphql)
class FooResolver {
@Query(() => FooGraphql)
getFoo() {
const foodb = this.myOrm.findOne()
// you'll probably want to abstract this through any kind of DTO implementation you wish
const gqlFoo = new FooGraphql()
gqlFoo.id = foodb.id
gqlFoo.name = foodb.name
return gql
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
You define the DB and GraphQL types in one TypeGraphQL model. Is there a way to opt out of this, using a custom ORM solution, without totally messing up your resolver types (derived from the DB/GraphQL types normally).
Beta Was this translation helpful? Give feedback.
All reactions