3.1.18 • Published 10 months ago

@pothos-examples/prisma-subscriptions v3.1.18

Weekly downloads
-
License
-
Repository
-
Last release
10 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.7

1 year ago

3.1.12

12 months ago

3.1.11

12 months ago

3.1.14

11 months ago

3.1.13

11 months ago

3.1.16

11 months ago

3.1.15

11 months ago

3.1.18

10 months ago

3.1.17

10 months ago

3.1.10

1 year ago

3.1.9

1 year ago

3.1.8

1 year ago

3.1.6

1 year ago

3.1.5

1 year ago

3.1.4

1 year ago

3.1.3

1 year ago

3.0.0-next.2

2 years ago

3.0.0-next.1

2 years ago

3.0.0-next.4

2 years ago

3.0.0-next.3

2 years ago

3.0.0-next.0

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.1

2 years ago

2.4.80

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.0

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

2.4.79

2 years ago

2.4.78

2 years ago

2.4.77

2 years ago

2.4.76

2 years ago

2.4.75

2 years 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

3 years ago

2.4.48

3 years ago

2.4.58

3 years ago

2.4.57

3 years ago

2.4.59

3 years ago

2.4.54

3 years ago

2.4.53

3 years ago

2.4.56

3 years ago

2.4.55

3 years ago

2.4.50

3 years ago

2.4.52

3 years ago

2.4.51

3 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

3 years ago

2.4.60

3 years ago

2.4.63

3 years ago

2.4.62

3 years ago

2.4.47

3 years ago

2.4.46

3 years ago

2.4.45

3 years ago

2.4.44

3 years ago

2.4.43

3 years ago

2.4.42

3 years ago

2.4.41

3 years ago

2.4.40

3 years ago

2.4.39

3 years ago

2.4.38

3 years ago

2.4.37

3 years ago

2.4.36

3 years ago

2.4.35

3 years ago

2.4.34

3 years ago

2.4.33

3 years ago

2.4.32

3 years ago

2.4.31

3 years ago

2.4.30

3 years ago

2.4.29

3 years ago

2.4.28

3 years ago

2.4.27

3 years ago

2.4.25

3 years ago

2.4.24

3 years ago

2.4.26

3 years ago

2.4.21

3 years ago

2.4.20

3 years ago

2.4.23

3 years ago

2.4.22

3 years ago

2.4.19

3 years ago

2.4.18

3 years ago