Repository navigation
Prisma dependency in the tutorial #4615
Unanswered
mindplay-dk
asked this question in
Q&A
Replies: 1 comment
|
Yes, Yoga does not depend on Prisma. It works with any data source (pg, Drizzle, Knex, REST...). The tutorial uses Prisma only because it comes from the older howtographql series. To use plain Postgres, create the client once and pass it in import { createYoga, createSchema } from 'graphql-yoga'
import pg from 'pg'
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
const yoga = createYoga({
schema: createSchema({
typeDefs: `type Link { id: ID!, url: String! } type Query { feed: [Link!]! }`,
resolvers: {
Query: {
feed: async (_, __, { db }) => (await db.query('select id, url from link')).rows,
},
},
}),
context: () => ({ db: pool }),
})Your gist would make a good PR to the docs as a "plain SQL" version of the tutorial. |
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.
To my understanding, GraphQL Yoga has no dependency on Prisma and works with any data source?
Is the Prisma dependency mostly historical? Does the tutorial use Prisma mostly because it descends from older material from before the Guild took over?
I've had Claude "translate" one of these articles to plain
postgresbecause the Prisma stuff is too distracting for me:https://gist.github.com/mindplay-dk/63aa9aacdfecae0c47eb28a7fabf1b5a
If Prisma is optional and not an intentional by-design target/requirement/recommendation, it might be nice to update the tutorial, so we can focus on learning Yoga? Everyone knows SQL, right? I don't know Prisma and don't plan on using it. 😊
All reactions