Repository navigation
Prisma dependency in the tutorial #4615
|
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 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. 😊 |
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. |
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
context: