2.4.78 • Published 20 days ago

@pothos-examples/prisma-subscriptions v2.4.78

Weekly downloads
-
License
-
Repository
-
Last release
20 days 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!]!
}
2.4.78

20 days ago

2.4.77

2 months ago

2.4.76

3 months ago

2.4.75

4 months ago

2.4.74

5 months ago

2.4.73

5 months ago

2.4.72

5 months ago

2.4.70

5 months ago

2.4.71

5 months ago

2.4.49

10 months ago

2.4.48

10 months ago

2.4.58

8 months ago

2.4.57

9 months ago

2.4.59

8 months ago

2.4.54

9 months ago

2.4.53

9 months ago

2.4.56

9 months ago

2.4.55

9 months ago

2.4.50

10 months ago

2.4.52

10 months ago

2.4.51

10 months ago

2.4.69

7 months ago

2.4.68

7 months ago

2.4.65

8 months ago

2.4.64

8 months ago

2.4.67

8 months ago

2.4.66

8 months ago

2.4.61

8 months ago

2.4.60

8 months ago

2.4.63

8 months ago

2.4.62

8 months ago

2.4.47

11 months ago

2.4.46

12 months ago

2.4.45

12 months ago

2.4.44

1 year ago

2.4.43

1 year ago

2.4.42

1 year ago

2.4.41

1 year ago

2.4.40

1 year ago

2.4.39

1 year ago

2.4.38

1 year ago

2.4.37

1 year ago

2.4.36

1 year ago

2.4.35

1 year ago

2.4.34

1 year ago

2.4.33

1 year ago

2.4.32

1 year ago

2.4.31

1 year ago

2.4.30

1 year ago

2.4.29

1 year ago

2.4.28

1 year ago

2.4.27

1 year ago

2.4.25

1 year ago

2.4.24

1 year ago

2.4.26

1 year ago

2.4.21

1 year ago

2.4.20

1 year ago

2.4.23

1 year ago

2.4.22

1 year ago

2.4.19

1 year ago

2.4.18

1 year ago