@pothos-examples/prisma-smart-subscriptions-apollo
v3.1.8
Published
This example uses the following packages:
Downloads
201
Readme
A GraphQL API built with prisma with subscriptions for basic CRUD mutations
This example uses the following packages:
@pothos/core
: For building the schema@pothos/plugin-prisma
: For prisma based type definitions, and efficient queries@pothos/plugin-smart-subscriptions
: For automatically create subscription from db query@prisma/client
: For querying data from a databaseprisma
: For running migrations and generating@prisma/client
@apollo/server
: For creating a server that executes the schemaexpress
: Mandatory for Apollo v4 subscriptions
This is a fairly basic implementation, and may not represent best practices for production, but should help demonstrate how smart subscriptions could be implemented.
Schema
type Comment {
author: User!
comment: String!
id: ID!
post: Post!
}
type Mutation {
createOneUser(firstName: String!, lastName: String!): User!
}
type Post {
author: User!
comments: [Comment!]!
content: String!
id: ID!
title: String!
}
type Query {
countManyUser: Int!
}
type Subscription {
countManyUser: Int!
}
type User {
comments: [Comment!]!
firstName: String!
fullName: String!
id: ID!
lastName: String!
posts: [Post!]!
}