Skip to content

Commit

Permalink
fix(typegraphql): migrate to newer deps (#4773)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolg42 authored Apr 4, 2024
1 parent a843588 commit 180ce6e
Show file tree
Hide file tree
Showing 7 changed files with 296 additions and 235 deletions.
11 changes: 11 additions & 0 deletions community-generators/typegraphql-prisma/context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

export interface Context {
prisma: PrismaClient
}

export const context: Context = {
prisma: prisma,
}
19 changes: 6 additions & 13 deletions community-generators/typegraphql-prisma/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { resolvers } from './generated/typegraphql-prisma'
import { buildSchema, Field, ObjectType, Query, Resolver } from 'type-graphql'

import { PrismaClient, Prisma } from '@prisma/client'
import { Context, context } from './context'

import { ApolloServer } from 'apollo-server'

interface Context {
prisma: PrismaClient
}
import { ApolloServer } from '@apollo/server'
import { startStandaloneServer } from '@apollo/server/standalone'

@ObjectType()
class VersionObject {
Expand All @@ -30,14 +28,9 @@ async function main() {
validate: false,
})

const prisma = new PrismaClient()

const server = new ApolloServer({
schema,
context: (): Context => ({ prisma }),
})
const { port } = await server.listen(4000)
console.log(`GraphQL is listening on ${port}!`)
const server = new ApolloServer<Context>({ schema })
const { url } = await startStandaloneServer(server, { context: async () => context })
console.log(`Server is running at ${url}`)
}

main()
4 changes: 2 additions & 2 deletions community-generators/typegraphql-prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"@prisma/client": "5.13.0-dev.12",
"@apollo/server": "4.0.0",
"class-validator": "0.14.1",
"graphql": "15.8.0",
"graphql": "16.8.1",
"graphql-fields": "2.0.3",
"graphql-scalars": "1.23.0",
"graphql-type-json": "0.3.2",
"reflect-metadata": "0.2.2",
"tslib": "2.6.2",
"type-graphql": "1.1.1"
"type-graphql": "2.0.0-beta.6"
},
"scripts": {
"start": "ts-node index.ts"
Expand Down
Loading

0 comments on commit 180ce6e

Please sign in to comment.