This repository is a boiler plate for using the prisma plugin with GraphQL Nexus. Currently, only prisma version 1 is supported. We plan on supporting prisma 2 once it hits GA.
- NodeJs - Primary language
- GraphQL - Our Networking communication specification
- Apollo Server - GraphQL server
- GraphQL Nexus - Type-first graphql implementation
- Prisma - ORM for our Postgres database
- Firebase Cloud Messaging - Used for push notifications
- PostgresSQL - Primary database
- Firebase Firestore - Secondary database (Optional)
This boilerplate has the following graphql middleware packages installed to help ease implementation.
- graphql-middleware - Hosts middleware packages for our Apollo GraphQL instance
- graphql-shield - Creates a permissions layer over your graphql queries, mutations, and return values
- graphql-upload - Adds support for file uploads through mutations and queries
- graphql-middleware-apollo-upload-server - A wrapper around graphql-upload. Automates a lot of the work around file uploads
- graphql-yup-middleware - Add yup validation on query and mutation parameters
- graphql-middleware-sentry - Add yup validation on query and mutation parameters
- Install the prisma cli
npm install -g prisma
- Build your data model in prisma/datamodel.prisma using the graphql schema definition language
type User {
id: ID! @id
email: String! @unique
token: String
name: String
username: String
description: String
photo_url: String
flagged_as_objectionable: Boolean @default(value: false)
view_objectionable_content: Boolean @default(value: true)
receive_push_notifications: Boolean @default(value: true)
oneSignalPlayerId: String
fcm_token: String
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
type Notification {
...
}
...
- Deploy your model
prisma deploy
- Customize your GraphQL server with Queries, Mutations, Subscriptions, GraphQL types, and/or computed fields
Navigate to the models directory and update the respected file(s).
const Notification = prismaObjectType({
name: 'Notification',
description: 'A separare entity to control notifications for users',
definition(t) {
t.prismaFields(['*']);
}
});
Note: This section is done using graphql-nexus. Check out the docs for more info.
There are 3 separate services that need to be deployed: A graphql server, a prisma server, and a postgres database. If using AWS, EC2 is typically used to create a graphql server, a Fargate instance for the prisma server, and an RDS instance to host the database.
- Upgrade to prisma 2
- Add examples for yup validation
- Add JWT Refresh token support/examples
- Add OneSignal Datasource
- Add middleware for push notifications
- Add examples for file upload
- Add Subscription examples