3.1.6 • Published 8 months ago

@pothos-examples/prisma-subscriptions v3.1.6

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

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
  • @prisma/client: For querying data from a database
  • prisma: For running migrations and generating @prisma/client
  • graphql-yoga: For creating a server that executes the schema

This is a fairly basic implementation, and may not represent best practices for production, but should help demonstrate how subscriptions could be implemented.

Schema

type Comment {
  author: User!
  comment: String!
  id: ID!
  post: Post!
}

type Mutation {
  createPost(authorId: ID!, content: String!, title: String!): Post!
  createUser(firstName: String!, lastName: String!): User!
  deletePost(id: ID!): Post
  deleteUser(id: ID!): User
  updatePost(content: String, id: ID!, title: String): Post
  updateUser(firstName: String, id: ID!, lastName: String): User
}

enum MutationType {
  CREATED
  DELETED
  UPDATED
}

type Post {
  author: User!
  comments: [Comment!]!
  content: String!
  id: ID!
  title: String!
}

type Query {
  post(id: ID!): Post
  posts(skip: Int, take: Int): [Post!]!
  user(id: ID!): User
}

type Subscription {
  post(id: ID!): SubscriptionPostEvent
  posts: SubscriptionPostEvent!
  user(id: ID!): SubscriptionUserEvent
  users: SubscriptionUserEvent!
}

interface SubscriptionEvent {
  mutationType: String!
}

type SubscriptionPostEvent implements SubscriptionEvent {
  mutationType: String!
  post: Post
}

type SubscriptionUserEvent implements SubscriptionEvent {
  mutationType: String!
  user: User
}

type User {
  comments: [Comment!]!
  firstName: String!
  fullName: String!
  id: ID!
  lastName: String!
  posts: [Post!]!
}
3.1.6

8 months ago

3.1.5

8 months ago

3.1.4

8 months ago

3.1.3

9 months ago

3.0.0-next.2

12 months ago

3.0.0-next.1

12 months ago

3.0.0-next.4

12 months ago

3.0.0-next.3

12 months ago

3.0.0-next.0

12 months ago

3.0.4

12 months ago

3.0.3

12 months ago

3.0.1

12 months ago

2.4.80

1 year ago

3.0.6

11 months ago

3.0.5

12 months ago

3.0.0

12 months ago

3.1.2

11 months ago

3.1.1

11 months ago

3.1.0

11 months ago

2.4.79

1 year ago

2.4.78

1 year ago

2.4.77

1 year ago

2.4.76

1 year ago

2.4.75

1 year ago

2.4.74

2 years ago

2.4.73

2 years ago

2.4.72

2 years ago

2.4.70

2 years ago

2.4.71

2 years ago

2.4.49

2 years ago

2.4.48

2 years ago

2.4.58

2 years ago

2.4.57

2 years ago

2.4.59

2 years ago

2.4.54

2 years ago

2.4.53

2 years ago

2.4.56

2 years ago

2.4.55

2 years ago

2.4.50

2 years ago

2.4.52

2 years ago

2.4.51

2 years ago

2.4.69

2 years ago

2.4.68

2 years ago

2.4.65

2 years ago

2.4.64

2 years ago

2.4.67

2 years ago

2.4.66

2 years ago

2.4.61

2 years ago

2.4.60

2 years ago

2.4.63

2 years ago

2.4.62

2 years ago

2.4.47

2 years ago

2.4.46

2 years ago

2.4.45

2 years ago

2.4.44

2 years ago

2.4.43

2 years ago

2.4.42

2 years ago

2.4.41

2 years ago

2.4.40

2 years ago

2.4.39

2 years ago

2.4.38

2 years ago

2.4.37

2 years ago

2.4.36

2 years ago

2.4.35

2 years ago

2.4.34

2 years ago

2.4.33

2 years ago

2.4.32

2 years ago

2.4.31

2 years ago

2.4.30

2 years ago

2.4.29

2 years ago

2.4.28

2 years ago

2.4.27

2 years ago

2.4.25

2 years ago

2.4.24

2 years ago

2.4.26

2 years ago

2.4.21

2 years ago

2.4.20

2 years ago

2.4.23

2 years ago

2.4.22

2 years ago

2.4.19

2 years ago

2.4.18

2 years ago