Skip to content
Discussion options

You must be logged in to vote

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:

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: () => ({ …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by egoodwinx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants