diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index c9fc0c2cdcb2..000000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,79 +0,0 @@ -version: 2 -jobs: - meta: - docker: - - image: circleci/node - steps: - - checkout - - run: cd .github/tests && yarn && yarn test - - node: - docker: - - image: circleci/node - steps: - - checkout - - run: sudo yarn global add prisma - - run: cd node/cli-app && yarn && prisma generate - - run: cd node/graphql && yarn && prisma generate - - run: cd node/graphql-auth && yarn && prisma generate - - run: cd node/graphql-subscriptions && yarn && prisma generate - - run: cd node/rest-express && yarn && prisma generate - - run: cd node/script && yarn && prisma generate - - run: cd node/docker-mongodb && yarn && prisma generate - - run: cd node/docker-mysql && yarn && prisma generate - - run: cd node/docker-postgres && yarn && prisma generate - - run: cd node/grpc && yarn && prisma generate - - typescript: - docker: - - image: circleci/node - steps: - - checkout - - run: sudo yarn global add prisma - # - run: cd typescript/circleci && yarn && yarn tsc - - run: cd typescript/cli-app && yarn && prisma generate && yarn tsc - - run: cd typescript/graphql && yarn && prisma generate && npx nexus-prisma-generate --client "./src/generated/prisma-client" --output "./src/generated/nexus-prisma" && yarn tsc - - run: cd typescript/graphql-auth && yarn && prisma generate && npx nexus-prisma-generate --client "./src/generated/prisma-client" --output "./src/generated/nexus-prisma" && yarn tsc - - run: cd typescript/graphql-subscriptions && yarn && prisma generate && yarn generate && yarn tsc - - run: cd typescript/rest-express && yarn && prisma generate && yarn tsc - - run: cd typescript/script && yarn && prisma generate && yarn tsc - - run: cd typescript/docker-mongodb && yarn && prisma generate - - run: cd typescript/docker-mysql && yarn && prisma generate - - run: cd typescript/docker-postgres && yarn && prisma generate - - run: cd typescript/grpc && yarn && prisma generate && yarn tsc - - flow: - docker: - - image: circleci/node - steps: - - checkout - - run: sudo yarn global add prisma - - run: cd flow/graphql && yarn && prisma generate && yarn generate && yarn flow check - # - run: cd flow/script && yarn && prisma generate && yarn flow check # typechecking is broken: https://github.com/prisma/prisma-examples/issues/373 - - run: cd flow/script && yarn && prisma generate - - go: - docker: - - image: circleci/golang - working_directory: /go/src/github.com/prisma/prisma-examples - steps: - - checkout - - run: curl https://s3-eu-west-1.amazonaws.com/curl-linux/prisma-1.27.0.tar.gz | tar xvz && sudo mv prisma /usr/local/bin # TODO (see https://github.com/prisma/prisma/issues/3620) - - run: cd go/cli-app && prisma generate && dep ensure && go build - - run: cd go/graphql && prisma generate && dep ensure && go run ./scripts/gqlgen.go && cd server && go build - - run: cd go/http-mux && prisma generate && dep ensure && go build - - run: cd go/rest-gin && prisma generate && dep ensure && go build - - run: cd go/script && prisma generate && dep ensure && go build - - run: cd go/docker-mongodb && prisma generate && dep ensure && go build - - run: cd go/docker-mysql && prisma generate && dep ensure && go build - - run: cd go/docker-postgres && prisma generate && dep ensure && go build - -workflows: - version: 2 - build: - jobs: - - meta - - node - - typescript - - flow - - go diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 000000000000..e39330b6b209 --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,23 @@ +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json +# yaml template to refer to https://docs.coderabbit.ai/reference/yaml-template#enterprise +language: 'en-US' +reviews: + collapse_walkthrough: false + profile: 'chill' + high_level_summary: true + request_changes_workflow: true + poem: false + in_progress_fortune: false + sequence_diagrams: true + suggested_labels: false + suggested_reviewers: false + auto_review: + enabled: true + drafts: false + finishing_touches: + docstrings: + enabled: false + unit_tests: + enabled: false +chat: + art: false diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000000..9d08a1a828a3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.github/prisma-configs/flow/seed.js b/.github/get-ppg-dev/.gitignore similarity index 100% rename from .github/prisma-configs/flow/seed.js rename to .github/get-ppg-dev/.gitignore diff --git a/.github/get-ppg-dev/index.js b/.github/get-ppg-dev/index.js new file mode 100644 index 000000000000..855592cdc5c7 --- /dev/null +++ b/.github/get-ppg-dev/index.js @@ -0,0 +1,26 @@ +import { unstable_startServer } from '@prisma/dev' + +async function main() { + const server = await unstable_startServer({ + persistenceMode: 'stateless', + }) + + // Emit only the Prisma-compatible URL for CI shell script to capture + console.log(server.ppg.url) + + // Wait for shutdown signal + process.once('SIGTERM', async () => { + await server.close() + process.exit(0) + }) + + process.once('SIGINT', async () => { + await server.close() + process.exit(0) + }) +} + +main().catch((err) => { + console.error('❌ Failed to start dev server:', err) + process.exit(1) +}) diff --git a/.github/get-ppg-dev/package.json b/.github/get-ppg-dev/package.json new file mode 100644 index 000000000000..0ab72036898e --- /dev/null +++ b/.github/get-ppg-dev/package.json @@ -0,0 +1,15 @@ +{ + "name": "get-ppg-dev", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "type": "module", + "author": "", + "license": "ISC", + "dependencies": { + "@prisma/dev": "latest" + } +} diff --git a/.github/prisma-configs/configure.sh b/.github/prisma-configs/configure.sh deleted file mode 100644 index c441b7b38a12..000000000000 --- a/.github/prisma-configs/configure.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash - -# Node -cp ./node/prisma.yml ../../node/cli-app/prisma -cp ./node/prisma.yml ../../node/graphql/prisma -cp ./node/prisma.yml ../../node/graphql-auth/prisma -cp ./node/prisma.yml ../../node/graphql-subscriptions/prisma -cp ./node/prisma.yml ../../node/rest-express/prisma -cp ./node/prisma.yml ../../node/script/prisma -cp ./node/mongo/prisma.yml ../../node/docker-mongodb/prisma -cp ./node/mysql-and-postgres/prisma.yml ../../node/docker-mysql/prisma -cp ./node/mysql-and-postgres/prisma.yml ../../node/docker-postgres/prisma -cp ./node/grpc/prisma.yml ../../node/grpc/prisma - -# Node (seeding) -cp ./node/seed.js ../../node/graphql/prisma -cp ./node/graphql-auth/seed.js ../../node/graphql-auth/prisma -cp ./node/graphql-subscriptions/seed.js ../../node/graphql-subscriptions/prisma -cp ./node/seed.js ../../node/rest-express/prisma -cp ./node/seed.js ../../node/script/prisma -cp ./node/grpc/seed.js ../../node/grpc/prisma -cp ./node/cli-app/seed.js ../../node/cli-app/prisma -cp ./node/mongo/seed.js ../../node/docker-mongodb/prisma -cp ./node/mysql-and-postgres/seed.js ../../node/docker-mysql/prisma -cp ./node/mysql-and-postgres/seed.js ../../node/docker-postgres/prisma - -# TypeScript (prisma.yml) -cp ./typescript/prisma.yml ../../typescript/cli-app/prisma -cp ./typescript/graphql/prisma.yml ../../typescript/graphql/prisma -cp ./typescript/graphql/prisma.yml ../../typescript/graphql-crud/prisma -cp ./typescript/graphql-auth/prisma.yml ../../typescript/graphql-auth/prisma -cp ./typescript/prisma.yml ../../typescript/graphql-subscriptions/prisma -cp ./typescript/prisma.yml ../../typescript/script/prisma -cp ./typescript/mongo/prisma.yml ../../typescript/docker-mongodb/prisma -cp ./typescript/mysql-and-postgres/prisma.yml ../../typescript/docker-mysql/prisma -cp ./typescript/mysql-and-postgres/prisma.yml ../../typescript/docker-postgres/prisma -cp ./typescript/grpc/prisma.yml ../../typescript/grpc/prisma - -# TypeScript (seeding) -cp ./typescript/seed.ts ../../typescript/graphql/prisma -cp ./typescript/seed.ts ../../typescript/graphql-crud/prisma -cp ./typescript/graphql-auth/seed.ts ../../typescript/graphql-auth/prisma -cp ./typescript/graphql-subscriptions/seed.ts ../../typescript/graphql-subscriptions/prisma -cp ./typescript/seed.ts ../../typescript/rest-express/prisma -cp ./typescript/seed.ts ../../typescript/script/prisma -cp ./typescript/grpc/seed.ts ../../typescript/grpc/prisma -cp ./typescript/cli-app/seed.ts ../../typescript/cli-app/prisma -cp ./typescript/mongo/seed.ts ../../typescript/docker-mongodb/prisma -cp ./typescript/mysql-and-postgres/seed.ts ../../typescript/docker-mysql/prisma -cp ./typescript/mysql-and-postgres/seed.ts ../../typescript/docker-postgres/prisma - -# TypeScript (tsconfig.json) -cp ./typescript/tsconfig.json ../../typescript/cli-app -cp ./typescript/tsconfig-graphql.json ../../typescript/graphql -mv ../../typescript/graphql/tsconfig-graphql.json ../../typescript/graphql/tsconfig.json -cp ./typescript/tsconfig-graphql.json ../../typescript/graphql-crud -mv ../../typescript/graphql-crud/tsconfig-graphql.json ../../typescript/graphql-crud/tsconfig.json -cp ./typescript/tsconfig-graphql.json ../../typescript/graphql-auth -mv ../../typescript/graphql-auth/tsconfig-graphql.json ../../typescript/graphql-auth/tsconfig.json -cp ./typescript/tsconfig-graphql.json ../../typescript/graphql-subscriptions -mv ../../typescript/graphql-subscriptions/tsconfig-graphql.json ../../typescript/graphql-subscriptions/tsconfig.json -cp ./typescript/tsconfig.json ../../typescript/script -cp ./typescript/tsconfig.json ../../typescript/docker-mongodb -cp ./typescript/tsconfig.json ../../typescript/docker-mysql -cp ./typescript/tsconfig.json ../../typescript/docker-postgres -cp ./typescript/tsconfig.json ../../typescript/grpc - -# TypeScript (graphqlgen) -cp ./typescript/graphqlgen.yml ../../typescript/graphql-subscriptions - -# Flow (prisma.yml) -cp ./flow/prisma.yml ../../flow/graphql/prisma -cp ./flow/prisma.yml ../../flow/script/prisma - -# Flow (.flowconfig) -cp ./flow/.flowconfig ../../flow/graphql -cp ./flow/.flowconfig ../../flow/script - -# Go -cp ./go/prisma.yml ../../go/cli-app/prisma -cp ./go/prisma.yml ../../go/graphql/prisma -cp ./go/prisma.yml ../../go/http-mux/prisma -cp ./go/prisma.yml ../../go/rest-gin/prisma -cp ./go/prisma.yml ../../go/script/prisma -cp ./go/mongo/prisma.yml ../../go/docker-mongodb/prisma -cp ./go/mysql-and-postgres/prisma.yml ../../go/docker-mysql/prisma -cp ./go/mysql-and-postgres/prisma.yml ../../go/docker-postgres/prisma - -# Go (seeding) -cp ./go/graphql/seed.go ../../go/graphql/prisma -cp ./go/http-mux/seed.go ../../go/http-mux/prisma -cp ./go/rest-gin/seed.go ../../go/rest-gin/prisma -cp ./go/script/seed.go ../../go/script/prisma -cp ./go/cli-app/seed.go ../../go/cli-app/prisma diff --git a/.github/prisma-configs/flow/.flowconfig b/.github/prisma-configs/flow/.flowconfig deleted file mode 100644 index 1454726c4c08..000000000000 --- a/.github/prisma-configs/flow/.flowconfig +++ /dev/null @@ -1,13 +0,0 @@ -[ignore] -# this is required until this issue gets fixed: https://github.com/prisma/prisma/issues/3617 -.*/node_modules/graphql/jsutils/keyValMap.js.flow - -[include] - -[libs] - -[lints] - -[options] - -[strict] diff --git a/.github/prisma-configs/flow/prisma.yml b/.github/prisma-configs/flow/prisma.yml deleted file mode 100644 index f58d63fc5490..000000000000 --- a/.github/prisma-configs/flow/prisma.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: '' - -# Defines your models, each model is mapped to the database as a table. -datamodel: datamodel.prisma - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: flow-client - output: ../src/generated/prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - import: seed.graphql \ No newline at end of file diff --git a/.github/prisma-configs/go/cli-app/seed.go b/.github/prisma-configs/go/cli-app/seed.go deleted file mode 100644 index dcff7537e003..000000000000 --- a/.github/prisma-configs/go/cli-app/seed.go +++ /dev/null @@ -1,24 +0,0 @@ -package main - -import ( - "context" - - prisma "github.com/prisma/prisma-examples/go/cli-app/prisma-client" -) - -func main() { - - client := prisma.New(nil) - ctx := context.Background() - - text1 := "Join us for GraphQL Conf 2019 in Berlin" - text2 := "Subscribe to GraphQL Weekly for community news" - - client.CreateTodo(prisma.TodoCreateInput{ - Text: text1, - }).Exec(ctx) - - client.CreateTodo(prisma.TodoCreateInput{ - Text: text2, - }).Exec(ctx) -} diff --git a/.github/prisma-configs/go/graphql/seed.go b/.github/prisma-configs/go/graphql/seed.go deleted file mode 100644 index eaefcb729d48..000000000000 --- a/.github/prisma-configs/go/graphql/seed.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "context" - - prisma "github.com/prisma/prisma-examples/go/graphql/prisma-client" -) - -func main() { - - client := prisma.New(nil) - ctx := context.Background() - - published := true - - email1 := "alice@prisma.io" - name1 := "Alice" - title1 := "Join us for GraphQL Conf 2019 in Berlin" - content1 := "https://www.graphqlconf.org/" - client.CreateUser(prisma.UserCreateInput{ - Name: &name1, - Email: email1, - Posts: &prisma.PostCreateManyWithoutAuthorInput{ - Create: []prisma.PostCreateWithoutAuthorInput{ - prisma.PostCreateWithoutAuthorInput{ - Title: title1, - Content: &content1, - Published: &published, - }, - }, - }, - }).Exec(ctx) - - email2 := "bob@prisma.io" - name2 := "Bob" - title2 := "Subscribe to GraphQL Weekly for community news" - content2 := "https://graphqlweekly.com/" - title3 := "Follow Prisma on Twitter" - content3 := "https://twitter.com/prisma/" - client.CreateUser(prisma.UserCreateInput{ - Name: &name2, - Email: email2, - Posts: &prisma.PostCreateManyWithoutAuthorInput{ - Create: []prisma.PostCreateWithoutAuthorInput{ - prisma.PostCreateWithoutAuthorInput{ - Title: title2, - Content: &content2, - Published: &published, - }, - prisma.PostCreateWithoutAuthorInput{ - Title: title3, - Content: &content3, - }, - }, - }, - }).Exec(ctx) -} diff --git a/.github/prisma-configs/go/http-mux/seed.go b/.github/prisma-configs/go/http-mux/seed.go deleted file mode 100644 index ab3e918a9410..000000000000 --- a/.github/prisma-configs/go/http-mux/seed.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "context" - - prisma "github.com/prisma/prisma-examples/go/http-mux/prisma-client" -) - -func main() { - - client := prisma.New(nil) - ctx := context.Background() - - published := true - - email1 := "alice@prisma.io" - name1 := "Alice" - title1 := "Join us for GraphQL Conf 2019 in Berlin" - content1 := "https://www.graphqlconf.org/" - client.CreateUser(prisma.UserCreateInput{ - Name: &name1, - Email: email1, - Posts: &prisma.PostCreateManyWithoutAuthorInput{ - Create: []prisma.PostCreateWithoutAuthorInput{ - prisma.PostCreateWithoutAuthorInput{ - Title: title1, - Content: &content1, - Published: &published, - }, - }, - }, - }).Exec(ctx) - - email2 := "bob@prisma.io" - name2 := "Bob" - title2 := "Subscribe to GraphQL Weekly for community news" - content2 := "https://graphqlweekly.com/" - title3 := "Follow Prisma on Twitter" - content3 := "https://twitter.com/prisma/" - client.CreateUser(prisma.UserCreateInput{ - Name: &name2, - Email: email2, - Posts: &prisma.PostCreateManyWithoutAuthorInput{ - Create: []prisma.PostCreateWithoutAuthorInput{ - prisma.PostCreateWithoutAuthorInput{ - Title: title2, - Content: &content2, - Published: &published, - }, - prisma.PostCreateWithoutAuthorInput{ - Title: title3, - Content: &content3, - }, - }, - }, - }).Exec(ctx) -} diff --git a/.github/prisma-configs/go/mongo/prisma.yml b/.github/prisma-configs/go/mongo/prisma.yml deleted file mode 100644 index bd95197b12a2..000000000000 --- a/.github/prisma-configs/go/mongo/prisma.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: http://localhost:4466 - -# Defines your models, each model is mapped to the database as a collection. -datamodel: datamodel.prisma - -# Indicates that this Prisma server is based on MongoDB. -databaseType: document - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: go-client - output: ../prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - import: seed.graphql \ No newline at end of file diff --git a/.github/prisma-configs/go/mysql-and-postgres/prisma.yml b/.github/prisma-configs/go/mysql-and-postgres/prisma.yml deleted file mode 100644 index 3fae5e4875f0..000000000000 --- a/.github/prisma-configs/go/mysql-and-postgres/prisma.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: http://localhost:4466 - -# Defines your models, each model is mapped to the database as a collection. -datamodel: datamodel.prisma - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: go-client - output: ../prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - import: seed.graphql \ No newline at end of file diff --git a/.github/prisma-configs/go/prisma.yml b/.github/prisma-configs/go/prisma.yml deleted file mode 100644 index d06f4e6330f9..000000000000 --- a/.github/prisma-configs/go/prisma.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: '' - -# Defines your models, each model is mapped to the database as a table. -datamodel: datamodel.prisma - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: go-client - output: ../prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - run: go run ./prisma/seed.go \ No newline at end of file diff --git a/.github/prisma-configs/go/rest-gin/seed.go b/.github/prisma-configs/go/rest-gin/seed.go deleted file mode 100644 index e24c6a65a0b9..000000000000 --- a/.github/prisma-configs/go/rest-gin/seed.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "context" - - prisma "github.com/prisma/prisma-examples/go/rest-gin/prisma-client" -) - -func main() { - - client := prisma.New(nil) - ctx := context.Background() - - published := true - - email1 := "alice@prisma.io" - name1 := "Alice" - title1 := "Join us for GraphQL Conf 2019 in Berlin" - content1 := "https://www.graphqlconf.org/" - client.CreateUser(prisma.UserCreateInput{ - Name: &name1, - Email: email1, - Posts: &prisma.PostCreateManyWithoutAuthorInput{ - Create: []prisma.PostCreateWithoutAuthorInput{ - prisma.PostCreateWithoutAuthorInput{ - Title: title1, - Content: &content1, - Published: &published, - }, - }, - }, - }).Exec(ctx) - - email2 := "bob@prisma.io" - name2 := "Bob" - title2 := "Subscribe to GraphQL Weekly for community news" - content2 := "https://graphqlweekly.com/" - title3 := "Follow Prisma on Twitter" - content3 := "https://twitter.com/prisma/" - client.CreateUser(prisma.UserCreateInput{ - Name: &name2, - Email: email2, - Posts: &prisma.PostCreateManyWithoutAuthorInput{ - Create: []prisma.PostCreateWithoutAuthorInput{ - prisma.PostCreateWithoutAuthorInput{ - Title: title2, - Content: &content2, - Published: &published, - }, - prisma.PostCreateWithoutAuthorInput{ - Title: title3, - Content: &content3, - }, - }, - }, - }).Exec(ctx) -} diff --git a/.github/prisma-configs/go/script/seed.go b/.github/prisma-configs/go/script/seed.go deleted file mode 100644 index a9d1da6fa255..000000000000 --- a/.github/prisma-configs/go/script/seed.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "context" - - prisma "github.com/prisma/prisma-examples/go/script/prisma-client" -) - -func main() { - - client := prisma.New(nil) - ctx := context.Background() - - published := true - - email1 := "alice@prisma.io" - name1 := "Alice" - title1 := "Join us for GraphQL Conf 2019 in Berlin" - content1 := "https://www.graphqlconf.org/" - client.CreateUser(prisma.UserCreateInput{ - Name: &name1, - Email: email1, - Posts: &prisma.PostCreateManyWithoutAuthorInput{ - Create: []prisma.PostCreateWithoutAuthorInput{ - prisma.PostCreateWithoutAuthorInput{ - Title: title1, - Content: &content1, - Published: &published, - }, - }, - }, - }).Exec(ctx) - - email2 := "bob@prisma.io" - name2 := "Bob" - title2 := "Subscribe to GraphQL Weekly for community news" - content2 := "https://graphqlweekly.com/" - title3 := "Follow Prisma on Twitter" - content3 := "https://twitter.com/prisma/" - client.CreateUser(prisma.UserCreateInput{ - Name: &name2, - Email: email2, - Posts: &prisma.PostCreateManyWithoutAuthorInput{ - Create: []prisma.PostCreateWithoutAuthorInput{ - prisma.PostCreateWithoutAuthorInput{ - Title: title2, - Content: &content2, - Published: &published, - }, - prisma.PostCreateWithoutAuthorInput{ - Title: title3, - Content: &content3, - }, - }, - }, - }).Exec(ctx) -} diff --git a/.github/prisma-configs/node/cli-app/seed.js b/.github/prisma-configs/node/cli-app/seed.js deleted file mode 100644 index 603c7fec5cbd..000000000000 --- a/.github/prisma-configs/node/cli-app/seed.js +++ /dev/null @@ -1,8 +0,0 @@ -const { prisma } = require('../src/generated/prisma-client') - -async function main() { - await prisma.createTodo({ title: 'Subscribe to GraphQL Weekly' }) - await prisma.createTodo({ title: 'Join GraphQL Conf 2019' }) -} - -main() \ No newline at end of file diff --git a/.github/prisma-configs/node/graphql-auth/seed.js b/.github/prisma-configs/node/graphql-auth/seed.js deleted file mode 100644 index 121b8665fc75..000000000000 --- a/.github/prisma-configs/node/graphql-auth/seed.js +++ /dev/null @@ -1,33 +0,0 @@ -const { prisma } = require('../src/generated/prisma-client') - -async function main() { - await prisma.createUser({ - email: "alice@prisma.io", - name: "Alice", - password: "$2b$10$dqyYw5XovLjpmkYNiRDEWuwKaRAvLaG45fnXE5b3KTccKZcRPka2m", // "secret42" - posts: { - create: { - title: "Join us for GraphQL Conf 2019 in Berlin", - content: "https://www.graphqlconf.org/", - published: true - } - } - }) - await prisma.createUser({ - email: "bob@prisma.io", - name: "Bob", - password: "$2b$10$o6KioO.taArzboM44Ig85O3ZFZYZpR3XD7mI8T29eP4znU/.xyJbW", // "secret43" - posts: { - create: [{ - title: "Subscribe to GraphQL Weekly for community news", - content: "https://graphqlweekly.com/", - published: true - }, { - title: "Follow Prisma on Twitter", - content: "https://twitter.com/prisma", - }] - } - }) -} - -main() diff --git a/.github/prisma-configs/node/graphql-subscriptions/seed.js b/.github/prisma-configs/node/graphql-subscriptions/seed.js deleted file mode 100644 index 3bf48612690b..000000000000 --- a/.github/prisma-configs/node/graphql-subscriptions/seed.js +++ /dev/null @@ -1,20 +0,0 @@ -const { prisma } = require('../src/generated/prisma-client') - -async function main() { - await prisma.createPost({ - title: 'Join us for GraphQL Conf 2019 in Berlin', - content: 'https://www.graphqlconf.org/', - published: true, - }) - await prisma.createPost({ - title: 'Subscribe to GraphQL Weekly for community news', - content: 'https://graphqlweekly.com/', - published: true, - }) - await prisma.createPost({ - title: 'Follow Prisma on Twitter', - content: 'https://twitter.com/prisma', - }) -} - -main().catch(e => console.error(e)) diff --git a/.github/prisma-configs/node/grpc/prisma.yml b/.github/prisma-configs/node/grpc/prisma.yml deleted file mode 100644 index d5110c94c819..000000000000 --- a/.github/prisma-configs/node/grpc/prisma.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: '' - -# Defines your models, each model is mapped to the database as a table. -datamodel: datamodel.prisma - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: javascript-client - output: ../server/generated/prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - run: node ./prisma/seed.js \ No newline at end of file diff --git a/.github/prisma-configs/node/grpc/seed.js b/.github/prisma-configs/node/grpc/seed.js deleted file mode 100644 index 2ee2fcc87ff5..000000000000 --- a/.github/prisma-configs/node/grpc/seed.js +++ /dev/null @@ -1,31 +0,0 @@ -const { prisma } = require('../server/generated/prisma-client') - -async function main() { - await prisma.createUser({ - email: "alice@prisma.io", - name: "Alice", - posts: { - create: { - title: "Join us for GraphQL Conf 2019 in Berlin", - content: "https://www.graphqlconf.org/", - published: true - } - } - }) - await prisma.createUser({ - email: "bob@prisma.io", - name: "Bob", - posts: { - create: [{ - title: "Subscribe to GraphQL Weekly for community news", - content: "https://graphqlweekly.com/", - published: true - }, { - title: "Follow Prisma on Twitter", - content: "https://twitter.com/prisma", - }] - } - }) -} - -main().catch(e => console.error(e)) diff --git a/.github/prisma-configs/node/mongo/prisma.yml b/.github/prisma-configs/node/mongo/prisma.yml deleted file mode 100644 index 25929a7cb713..000000000000 --- a/.github/prisma-configs/node/mongo/prisma.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: http://localhost:4466 - -# Defines your models, each model is mapped to the database as a collection. -datamodel: datamodel.prisma - -# Indicates that this Prisma server is based on MongoDB. -databaseType: document - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: javascript-client - output: ../src/generated/prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - run: node ./prisma/seed.js \ No newline at end of file diff --git a/.github/prisma-configs/node/mongo/seed.js b/.github/prisma-configs/node/mongo/seed.js deleted file mode 100644 index 9508af2c5987..000000000000 --- a/.github/prisma-configs/node/mongo/seed.js +++ /dev/null @@ -1,44 +0,0 @@ -const { prisma } = require('../src/generated/prisma-client') - -async function main() { - await prisma.createUser({ - name: 'Alice', - email: 'alice@prisma.io', - posts: { - create: [ - { - title: 'Join us for GraphQL Conf 2019 in Berlin', - content: 'https://www.graphqlconf.org/', - published: true - }, - ], - }, - }) - - await prisma.createUser({ - name: 'Bob', - email: 'bob@prisma.io', - posts: { - create: [ - { - title: 'Subscribe to GraphQL Weekly for community news', - content: 'https://graphqlweekly.com/', - published: true, - comments: { - create: [{ - text: "Can recommend 💯", - writtenBy: { - connect: { email: "alice@prisma.io" } - } - }] - } - }, { - title: "Follow Prisma on Twitter", - content: "https://twitter.com/prisma" - } - ], - }, - }) -} - -main() \ No newline at end of file diff --git a/.github/prisma-configs/node/mysql-and-postgres/prisma.yml b/.github/prisma-configs/node/mysql-and-postgres/prisma.yml deleted file mode 100644 index 1acc1ee774a0..000000000000 --- a/.github/prisma-configs/node/mysql-and-postgres/prisma.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: http://localhost:4466 - -# Defines your models, each model is mapped to the database as a collection. -datamodel: datamodel.prisma - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: javascript-client - output: ../src/generated/prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - run: node ./prisma/seed.js \ No newline at end of file diff --git a/.github/prisma-configs/node/mysql-and-postgres/seed.js b/.github/prisma-configs/node/mysql-and-postgres/seed.js deleted file mode 100644 index 9508af2c5987..000000000000 --- a/.github/prisma-configs/node/mysql-and-postgres/seed.js +++ /dev/null @@ -1,44 +0,0 @@ -const { prisma } = require('../src/generated/prisma-client') - -async function main() { - await prisma.createUser({ - name: 'Alice', - email: 'alice@prisma.io', - posts: { - create: [ - { - title: 'Join us for GraphQL Conf 2019 in Berlin', - content: 'https://www.graphqlconf.org/', - published: true - }, - ], - }, - }) - - await prisma.createUser({ - name: 'Bob', - email: 'bob@prisma.io', - posts: { - create: [ - { - title: 'Subscribe to GraphQL Weekly for community news', - content: 'https://graphqlweekly.com/', - published: true, - comments: { - create: [{ - text: "Can recommend 💯", - writtenBy: { - connect: { email: "alice@prisma.io" } - } - }] - } - }, { - title: "Follow Prisma on Twitter", - content: "https://twitter.com/prisma" - } - ], - }, - }) -} - -main() \ No newline at end of file diff --git a/.github/prisma-configs/node/prisma.yml b/.github/prisma-configs/node/prisma.yml deleted file mode 100644 index b32ebf8f6008..000000000000 --- a/.github/prisma-configs/node/prisma.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: '' - -# Defines your models, each model is mapped to the database as a table. -datamodel: datamodel.prisma - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: javascript-client - output: ../src/generated/prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - run: node ./prisma/seed.js \ No newline at end of file diff --git a/.github/prisma-configs/node/seed.js b/.github/prisma-configs/node/seed.js deleted file mode 100644 index fb509606798b..000000000000 --- a/.github/prisma-configs/node/seed.js +++ /dev/null @@ -1,31 +0,0 @@ -const { prisma } = require('../src/generated/prisma-client') - -async function main() { - await prisma.createUser({ - email: "alice@prisma.io", - name: "Alice", - posts: { - create: { - title: "Join us for GraphQL Conf 2019 in Berlin", - content: "https://www.graphqlconf.org/", - published: true - } - } - }) - await prisma.createUser({ - email: "bob@prisma.io", - name: "Bob", - posts: { - create: [{ - title: "Subscribe to GraphQL Weekly for community news", - content: "https://graphqlweekly.com/", - published: true - }, { - title: "Follow Prisma on Twitter", - content: "https://twitter.com/prisma", - }] - } - }) -} - -main().catch(e => console.error(e)) diff --git a/.github/prisma-configs/typescript/cli-app/seed.ts b/.github/prisma-configs/typescript/cli-app/seed.ts deleted file mode 100644 index 3485da19430d..000000000000 --- a/.github/prisma-configs/typescript/cli-app/seed.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { prisma } from '../src/generated/prisma-client' - -async function main() { - await prisma.createTodo({ title: 'Subscribe to GraphQL Weekly' }) - await prisma.createTodo({ title: 'Join GraphQL Conf 2019' }) -} - -main() \ No newline at end of file diff --git a/.github/prisma-configs/typescript/graphql-auth/prisma.yml b/.github/prisma-configs/typescript/graphql-auth/prisma.yml deleted file mode 100644 index d5b2a6aae33e..000000000000 --- a/.github/prisma-configs/typescript/graphql-auth/prisma.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: '' - -# Defines your models, each model is mapped to the database as a table. -datamodel: datamodel.prisma - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: typescript-client - output: ../src/generated/prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - - npx nexus-prisma-generate --client ./src/generated/prisma-client --output ./src/generated/nexus-prisma # Runs the codegen tool from nexus-prisma. - -# Seeds initial data into the database by running a script. -seed: - run: yarn ts-node ./prisma/seed.ts \ No newline at end of file diff --git a/.github/prisma-configs/typescript/graphql-auth/seed.ts b/.github/prisma-configs/typescript/graphql-auth/seed.ts deleted file mode 100644 index 5d2e520e419d..000000000000 --- a/.github/prisma-configs/typescript/graphql-auth/seed.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { prisma } from '../src/generated/prisma-client' - -async function main() { - await prisma.createUser({ - email: "alice@prisma.io", - name: "Alice", - password: "$2b$10$dqyYw5XovLjpmkYNiRDEWuwKaRAvLaG45fnXE5b3KTccKZcRPka2m", // "secret42" - posts: { - create: { - title: "Join us for GraphQL Conf 2019 in Berlin", - content: "https://www.graphqlconf.org/", - published: true - } - } - }) - await prisma.createUser({ - email: "bob@prisma.io", - name: "Bob", - password: "$2b$10$o6KioO.taArzboM44Ig85O3ZFZYZpR3XD7mI8T29eP4znU/.xyJbW", // "secret43" - posts: { - create: [{ - title: "Subscribe to GraphQL Weekly for community news", - content: "https://graphqlweekly.com/", - published: true - }, { - title: "Follow Prisma on Twitter", - content: "https://twitter.com/prisma", - }] - } - }) -} - -main() diff --git a/.github/prisma-configs/typescript/graphql-subscriptions/seed.ts b/.github/prisma-configs/typescript/graphql-subscriptions/seed.ts deleted file mode 100644 index 72e2e29495ef..000000000000 --- a/.github/prisma-configs/typescript/graphql-subscriptions/seed.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { prisma } from '../src/generated/prisma-client' - -async function main() { - await prisma.createPost({ - title: 'Join us for GraphQL Conf 2019 in Berlin', - content: 'https://www.graphqlconf.org/', - published: true, - }) - await prisma.createPost({ - title: 'Subscribe to GraphQL Weekly for community news', - content: 'https://graphqlweekly.com/', - published: true, - }) - await prisma.createPost({ - title: 'Follow Prisma on Twitter', - content: 'https://twitter.com/prisma', - }) -} - -main().catch(e => console.error(e)) diff --git a/.github/prisma-configs/typescript/graphql/prisma.yml b/.github/prisma-configs/typescript/graphql/prisma.yml deleted file mode 100644 index d5b2a6aae33e..000000000000 --- a/.github/prisma-configs/typescript/graphql/prisma.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: '' - -# Defines your models, each model is mapped to the database as a table. -datamodel: datamodel.prisma - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: typescript-client - output: ../src/generated/prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - - npx nexus-prisma-generate --client ./src/generated/prisma-client --output ./src/generated/nexus-prisma # Runs the codegen tool from nexus-prisma. - -# Seeds initial data into the database by running a script. -seed: - run: yarn ts-node ./prisma/seed.ts \ No newline at end of file diff --git a/.github/prisma-configs/typescript/graphqlgen.yml b/.github/prisma-configs/typescript/graphqlgen.yml deleted file mode 100644 index 9f462336625c..000000000000 --- a/.github/prisma-configs/typescript/graphqlgen.yml +++ /dev/null @@ -1,23 +0,0 @@ -# The target programming language for the generated code. -language: typescript - -# The file path pointing to your GraphQL schema. -schema: ./src/schema.graphql - -# Type definition for the resolver context object. -context: ./src/types.ts:Context - -# Map SDL types from the GraphQL schema to TS models. -models: - files: - - ./src/generated/prisma-client - - ./src/types.ts - -# Generated typings for resolvers and default resolver implementations -# DO NOT EDIT THIS FILE but just _import_ from it into your own source files. -output: ./src/generated/graphqlgen.ts - -# Temporary scaffolded resolvers to copy and paste into your own source files. -resolver-scaffolding: - output: ./src/generated/tmp-resolvers/ - layout: file-per-type diff --git a/.github/prisma-configs/typescript/grpc/prisma.yml b/.github/prisma-configs/typescript/grpc/prisma.yml deleted file mode 100644 index 8a65f858990e..000000000000 --- a/.github/prisma-configs/typescript/grpc/prisma.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: '' - -# Defines your models, each model is mapped to the database as a table. -datamodel: datamodel.prisma - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: typescript-client - output: ../server/generated/prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - run: yarn ts-node ./prisma/seed.ts \ No newline at end of file diff --git a/.github/prisma-configs/typescript/grpc/seed.ts b/.github/prisma-configs/typescript/grpc/seed.ts deleted file mode 100644 index fb9d77c6a2b9..000000000000 --- a/.github/prisma-configs/typescript/grpc/seed.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { prisma } from '../server/generated/prisma-client' - -async function main() { - await prisma.createUser({ - email: "alice@prisma.io", - name: "Alice", - posts: { - create: { - title: "Join us for GraphQL Conf 2019 in Berlin", - content: "https://www.graphqlconf.org/", - published: true - } - } - }) - await prisma.createUser({ - email: "bob@prisma.io", - name: "Bob", - posts: { - create: [{ - title: "Subscribe to GraphQL Weekly for community news", - content: "https://graphqlweekly.com/", - published: true - }, { - title: "Follow Prisma on Twitter", - content: "https://twitter.com/prisma", - }] - } - }) -} - -main().catch(e => console.error(e)) diff --git a/.github/prisma-configs/typescript/mongo/prisma.yml b/.github/prisma-configs/typescript/mongo/prisma.yml deleted file mode 100644 index e5bbd8d69b35..000000000000 --- a/.github/prisma-configs/typescript/mongo/prisma.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: http://localhost:4466 - -# Defines your models, each model is mapped to the database as a collection. -datamodel: datamodel.prisma - -# Indicates that this Prisma server is based on MongoDB. -databaseType: document - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: typescript-client - output: ../src/generated/prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - run: yarn ts-node ./prisma/seed.ts \ No newline at end of file diff --git a/.github/prisma-configs/typescript/mongo/seed.ts b/.github/prisma-configs/typescript/mongo/seed.ts deleted file mode 100644 index c6aa9e6fb98e..000000000000 --- a/.github/prisma-configs/typescript/mongo/seed.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { prisma } from '../src/generated/prisma-client' - -async function main() { - await prisma.createUser({ - name: 'Alice', - email: 'alice@prisma.io', - posts: { - create: [ - { - title: 'Join us for GraphQL Conf 2019 in Berlin', - content: 'https://www.graphqlconf.org/', - published: true - }, - ], - }, - }) - - await prisma.createUser({ - name: 'Bob', - email: 'bob@prisma.io', - posts: { - create: [ - { - title: 'Subscribe to GraphQL Weekly for community news', - content: 'https://graphqlweekly.com/', - published: true, - comments: { - create: [{ - text: "Can recommend 💯", - writtenBy: { - connect: { email: "alice@prisma.io" } - } - }] - } - }, { - title: "Follow Prisma on Twitter", - content: "https://twitter.com/prisma" - } - ], - }, - }) -} - -main() \ No newline at end of file diff --git a/.github/prisma-configs/typescript/mysql-and-postgres/prisma.yml b/.github/prisma-configs/typescript/mysql-and-postgres/prisma.yml deleted file mode 100644 index 00aaafdb7bee..000000000000 --- a/.github/prisma-configs/typescript/mysql-and-postgres/prisma.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: http://localhost:4466 - -# Defines your models, each model is mapped to the database as a collection. -datamodel: datamodel.prisma - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: typescript-client - output: ../src/generated/prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - run: yarn ts-node ./prisma/seed.ts \ No newline at end of file diff --git a/.github/prisma-configs/typescript/mysql-and-postgres/seed.ts b/.github/prisma-configs/typescript/mysql-and-postgres/seed.ts deleted file mode 100644 index c6aa9e6fb98e..000000000000 --- a/.github/prisma-configs/typescript/mysql-and-postgres/seed.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { prisma } from '../src/generated/prisma-client' - -async function main() { - await prisma.createUser({ - name: 'Alice', - email: 'alice@prisma.io', - posts: { - create: [ - { - title: 'Join us for GraphQL Conf 2019 in Berlin', - content: 'https://www.graphqlconf.org/', - published: true - }, - ], - }, - }) - - await prisma.createUser({ - name: 'Bob', - email: 'bob@prisma.io', - posts: { - create: [ - { - title: 'Subscribe to GraphQL Weekly for community news', - content: 'https://graphqlweekly.com/', - published: true, - comments: { - create: [{ - text: "Can recommend 💯", - writtenBy: { - connect: { email: "alice@prisma.io" } - } - }] - } - }, { - title: "Follow Prisma on Twitter", - content: "https://twitter.com/prisma" - } - ], - }, - }) -} - -main() \ No newline at end of file diff --git a/.github/prisma-configs/typescript/prisma.yml b/.github/prisma-configs/typescript/prisma.yml deleted file mode 100644 index 0627df6eb77d..000000000000 --- a/.github/prisma-configs/typescript/prisma.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Specifies the HTTP endpoint of your Prisma API. -endpoint: '' - -# Defines your models, each model is mapped to the database as a table. -datamodel: datamodel.prisma - -# Specifies the language and directory for the generated Prisma client. -generate: - - generator: typescript-client - output: ../src/generated/prisma-client/ - -# Ensures Prisma client is re-generated after a datamodel change. -hooks: - post-deploy: - - prisma generate - -# Seeds initial data into the database by running a script. -seed: - run: yarn ts-node ./prisma/seed.ts \ No newline at end of file diff --git a/.github/prisma-configs/typescript/seed.ts b/.github/prisma-configs/typescript/seed.ts deleted file mode 100644 index 00c2b7dc5833..000000000000 --- a/.github/prisma-configs/typescript/seed.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { prisma } from '../src/generated/prisma-client' - - -async function main() { - await prisma.createUser({ - email: "alice@prisma.io", - name: "Alice", - posts: { - create: { - title: "Join us for GraphQL Conf 2019 in Berlin", - content: "https://www.graphqlconf.org/", - published: true - } - } - }) - await prisma.createUser({ - email: "bob@prisma.io", - name: "Bob", - posts: { - create: [{ - title: "Subscribe to GraphQL Weekly for community news", - content: "https://graphqlweekly.com/", - published: true - }, { - title: "Follow Prisma on Twitter", - content: "https://twitter.com/prisma", - }] - } - }) -} - -main().catch(e => console.error(e)) diff --git a/.github/prisma-configs/typescript/tsconfig-graphql.json b/.github/prisma-configs/typescript/tsconfig-graphql.json deleted file mode 100644 index 0064ec16f4e6..000000000000 --- a/.github/prisma-configs/typescript/tsconfig-graphql.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "sourceMap": true, - "outDir": "dist", - "lib": ["esnext", "dom"], - // "strict": true, // `strict` is commented because of this issue: https://github.com/prisma/prisma/issues/3774; all its options except `strictNullChecks` & `strictPropertyInitialization` are explicitly set below. - "noImplicitAny": true, - "noImplicitThis": true, - "alwaysStrict": true, - "strictBindCallApply": true, - "strictFunctionTypes": true, - "skipLibCheck": true // `skipLibCheck` is enabled until this is issue is fixed: https://github.com/prisma/nexus-prisma/issues/82 - } -} \ No newline at end of file diff --git a/.github/prisma-configs/typescript/tsconfig.json b/.github/prisma-configs/typescript/tsconfig.json deleted file mode 100644 index 669f46efc390..000000000000 --- a/.github/prisma-configs/typescript/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "compilerOptions": { - "sourceMap": true, - "outDir": "dist", - "strict": true, - "lib": ["esnext", "dom"] - } -} \ No newline at end of file diff --git a/.github/readmes/_using-the-graphql-api-auth.md b/.github/readmes/_using-the-graphql-api-auth.md deleted file mode 100644 index f213b6f26c18..000000000000 --- a/.github/readmes/_using-the-graphql-api-auth.md +++ /dev/null @@ -1,173 +0,0 @@ -### 5. Using the GraphQL API - -The schema that specifies the API operations of your GraphQL server is defined in [`./src/schema.graphql`](./src/schema.graphql). Below are a number of operations that you can send to the API using the GraphQL Playground. - -Feel free to adjust any operation by adding or removing fields. The GraphQL Playground helps you with its auto-completion and query validation features. - -#### Retrieve all published posts and their authors - -```graphql -query { - feed { - id - title - content - published - author { - id - name - email - } - } -} -``` - -
See more API operations - -#### Register a new user - -You can send the following mutation in the Playground to sign up a new user and retrieve an authentication token for them: - -```graphql -mutation { - signup(name: "Alice", email: "alice@prisma.io", password: "graphql") { - token - } -} -``` - -#### Log in an existing user - -This mutation will log in an existing user by requesting a new authentication token for them: - -```graphql -mutation { - login(email: "alice@prisma.io", password: "graphql") { - token - } -} -``` - -#### Check whether a user is currently logged in with the `me` query - -For this query, you need to make sure a valid authentication token is sent along with the `Bearer`-prefix in the `Authorization` header of the request: - -```json -{ - "Authorization": "Bearer __YOUR_TOKEN__" -} -``` - -With a real token, this looks similar to this: - -```json -{ - "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjanAydHJyczFmczE1MGEwM3kxaWl6c285IiwiaWF0IjoxNTQzNTA5NjY1fQ.Vx6ad6DuXA0FSQVyaIngOHYVzjKwbwq45flQslnqX04" -} -``` - -Inside the Playground, you can set HTTP headers in the bottom-left corner: - -![](https://imgur.com/ToRcCTj.png) - -Once you've set the header, you can send the following query to check whether the token is valid: - -```graphql -{ - me { - id - name - email - } -} -``` - -#### Create a new draft - -You need to be logged in for this query to work, i.e. an authentication token that was retrieved through a `signup` or `login` mutation needs to be added to the `Authorization` header in the GraphQL Playground. - -```graphql -mutation { - createDraft( - title: "Join the Prisma Slack" - content: "https://slack.prisma.io/" - authorEmail: "alice@prisma.io" - ) { - id - published - } -} -``` - -#### Publish an existing draft - -You need to be logged in for this query to work, i.e. an authentication token that was retrieved through a `signup` or `login` mutation needs to be added to the `Authorization` header in the GraphQL Playground. The authentication token must belong to the user who created the post. - -```graphql -mutation { - publish(id: "__POST_ID__") { - id - published - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `filterPosts`-query. - -#### Search for posts with a specific title or content - -You need to be logged in for this query to work, i.e. an authentication token that was retrieved through a `signup` or `login` mutation needs to be added to the `Authorization` header in the GraphQL Playground. - -```graphql -{ - filterPosts(searchString: "graphql") { - id - title - content - published - author { - id - name - email - } - } -} -``` - -#### Retrieve a single post - -You need to be logged in for this query to work, i.e. an authentication token that was retrieved through a `signup` or `login` mutation needs to be added to the `Authorization` header in the GraphQL Playground. - -```graphql -{ - posts(id: "__POST_ID__") { - id - title - content - published - author { - id - name - email - } - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `filterPosts`-query. - -#### Delete a post - -You need to be logged in for this query to work, i.e. an authentication token that was retrieved through a `signup` or `login` mutation needs to be added to the `Authorization` header in the GraphQL Playground. The authentication token must belong to the user who created the post. - -```graphql -mutation { - deletePost(id: "__POST_ID__") { - id - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `filterPosts`-query. - -
\ No newline at end of file diff --git a/.github/readmes/_using-the-graphql-api-crud.md b/.github/readmes/_using-the-graphql-api-crud.md deleted file mode 100644 index f4ddcb5158d0..000000000000 --- a/.github/readmes/_using-the-graphql-api-crud.md +++ /dev/null @@ -1,133 +0,0 @@ -### 5. Using the CRUD GraphQL API - -The schema that specifies the API operations of your GraphQL server is defined in [`./src/schema.graphql`](./src/schema.graphql). Below are a number of operations that you can send to the API using the GraphQL Playground. - -Feel free to adjust any operation by adding or removing fields. The GraphQL Playground helps you with its auto-completion and query validation features. - -#### Retrieve all posts and their authors - -```graphql -query { - posts { - id - title - content - published - author { - id - name - email - } - } -} -``` - -
See more API operations - -#### Create a new user - -```graphql -mutation { - createUser(data: { - name: "Sarah" - email: "sarah@prisma.io" - }) { - id - } -} -``` - -#### Create a new post - -```graphql -mutation { - createPost(data: { - title: "Join the Prisma Slack" - content: "https://slack.prisma.io/" - author: { - connect: { email: "alice@prisma.io" } - } - }) { - id - published - author { - id - name - } - } -} -``` - -#### Update an existing draft - -```graphql -mutation { - updatePost( - where: { id: "__POST_ID__" } - data: { published: true } - ) { - id - published - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `posts`-query. - -#### Search for posts with a specific title or content - -```graphql -{ - posts(where: { - OR: [{ - title_contains: "graphql" - }, { - content_contains: "graphql" - }] - }) { - id - title - content - published - author { - id - name - email - } - } -} -``` - -#### Retrieve a single post - -```graphql -{ - post(where: { id: "__POST_ID__"}) { - id - title - content - published - author { - id - name - email - } - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `posts`-query. - -#### Delete a post - -```graphql -mutation { - deletePost(where: { id: "__POST_ID__"}) { - id - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `posts`-query. - -
\ No newline at end of file diff --git a/.github/readmes/_using-the-graphql-api-subs.md b/.github/readmes/_using-the-graphql-api-subs.md deleted file mode 100644 index 755f67b3ba36..000000000000 --- a/.github/readmes/_using-the-graphql-api-subs.md +++ /dev/null @@ -1,194 +0,0 @@ -### 5. Using the GraphQL API - -The schema that specifies the API operations of your GraphQL server is defined in [`./src/schema.graphql`](./src/schema.graphql). Below are a number of operations that you can send to the API using the GraphQL Playground. - -Feel free to adjust any operation by adding or removing fields. The GraphQL Playground helps you with its auto-completion and query validation features. - -#### Retrieve all published posts and their authors - -```graphql -query { - feed { - id - title - content - published - author { - id - name - email - } - } -} -``` - -
See more API operations - -#### Register a new user - -You can send the following mutation in the Playground to sign up a new user and retrieve an authentication token for them: - -```graphql -mutation { - signup(name: "Alice", email: "alice@prisma.io", password: "graphql") { - token - } -} -``` - -#### Log in an existing user - -This mutation will log in an existing user by requesting a new authentication token for them: - -```graphql -mutation { - login(email: "alice@prisma.io", password: "graphql") { - token - } -} -``` - -#### Check whether a user is currently logged in with the `me` query - -For this query, you need to make sure a valid authentication token is sent along with the `Bearer`-prefix in the `Authorization` header of the request. Inside the Playground, you can set HTTP headers in the bottom-left corner: - -![](https://imgur.com/bEGUtO0.png) - -Once you've set the header, you can send the following query to check whether the token is valid: - -```graphql -{ - me { - id - name - email - } -} -``` - -#### Create a new draft - -You need to be logged in for this query to work, i.e. an authentication token that was retrieved through a `signup` or `login` mutation needs to be added to the `Authorization` header in the GraphQL Playground. - -```graphql -mutation { - createDraft( - title: "Join the Prisma Slack" - content: "https://slack.prisma.io/" - authorEmail: "alice@prisma.io" - ) { - id - published - } -} -``` - -#### Publish an existing draft - -You need to be logged in for this query to work, i.e. an authentication token that was retrieved through a `signup` or `login` mutation needs to be added to the `Authorization` header in the GraphQL Playground. The authentication token must belong to the user who created the post. - -```graphql -mutation { - publish(id: "__POST_ID__") { - id - published - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `filterPosts`-query. - -#### Search for posts with a specific title or content - -You need to be logged in for this query to work, i.e. an authentication token that was retrieved through a `signup` or `login` mutation needs to be added to the `Authorization` header in the GraphQL Playground. - -```graphql -{ - filterPosts(searchString: "graphql") { - id - title - content - published - author { - id - name - email - } - } -} -``` - -#### Retrieve a single post - -You need to be logged in for this query to work, i.e. an authentication token that was retrieved through a `signup` or `login` mutation needs to be added to the `Authorization` header in the GraphQL Playground. - -```graphql -{ - posts(id: "__POST_ID__") { - id - title - content - published - author { - id - name - email - } - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `filterPosts`-query. - -#### Delete a post - -You need to be logged in for this query to work, i.e. an authentication token that was retrieved through a `signup` or `login` mutation needs to be added to the `Authorization` header in the GraphQL Playground. The authentication token must belong to the user who created the post. - -```graphql -mutation { - deletePost(id: "__POST_ID__") { - id - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `filterPosts`-query. - -
- -### 6. Testing GraphQL subscriptions in the Playground - -To test the `post` subscription, you need to send a subscription query in the Playground, e.g.: - -```graphql -subscription { - posts { - id - createdAt - title - content - published - } -} -``` - -When hitting the _Play_-button, you won't see an immediate response. Instead there's a loading indicator in the response pane of the Playground: - -![](https://imgur.com/l4WObKG.png) - -Now, whenever a post is created (or updated), e.g. with this mutation (you can run it in another tab): - -```graphql -mutation { - createDraft( - title: "Join the Prisma community on Slack" - content: "https://slack.prisma.io/" - ) { - id - } -} -``` - -You will see the results appear in the tab where the subscription is running: - -![](https://imgur.com/HRWDPsE.png) \ No newline at end of file diff --git a/.github/readmes/_using-the-graphql-api.md b/.github/readmes/_using-the-graphql-api.md deleted file mode 100644 index 90fd72242b21..000000000000 --- a/.github/readmes/_using-the-graphql-api.md +++ /dev/null @@ -1,118 +0,0 @@ -### 5. Using the GraphQL API - -The schema that specifies the API operations of your GraphQL server is defined in [`./src/schema.graphql`](./src/schema.graphql). Below are a number of operations that you can send to the API using the GraphQL Playground. - -Feel free to adjust any operation by adding or removing fields. The GraphQL Playground helps you with its auto-completion and query validation features. - -#### Retrieve all published posts and their authors - -```graphql -query { - feed { - id - title - content - published - author { - id - name - email - } - } -} -``` - -
See more API operations - -#### Create a new user - -```graphql -mutation { - signupUser( - name: "Sarah" - email: "sarah@prisma.io" - ) { - id - } -} -``` - -#### Create a new draft - -```graphql -mutation { - createDraft( - title: "Join the Prisma Slack" - content: "https://slack.prisma.io/" - authorEmail: "alice@prisma.io" - ) { - id - published - } -} -``` - -#### Publish an existing draft - -```graphql -mutation { - publish(id: "__POST_ID__") { - id - published - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `filterPosts`-query. - -#### Search for posts with a specific title or content - -```graphql -{ - filterPosts(searchString: "graphql") { - id - title - content - published - author { - id - name - email - } - } -} -``` - -#### Retrieve a single post - -```graphql -{ - post(id: "__POST_ID__") { - id - title - content - published - author { - id - name - email - } - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `filterPosts`-query. - -#### Delete a post - -```graphql -mutation { - deletePost(id: "__POST_ID__") { - id - } -} -``` - -> **Note**: You need to replace the `__POST_ID__`-placeholder with an actual `id` from a `Post` item. You can find one e.g. using the `filterPosts`-query. - -
\ No newline at end of file diff --git a/.github/readmes/_using-the-rest-api.md b/.github/readmes/_using-the-rest-api.md deleted file mode 100644 index 42b7923380b4..000000000000 --- a/.github/readmes/_using-the-rest-api.md +++ /dev/null @@ -1,27 +0,0 @@ -### 5. Using the REST API - -#### `GET` - -- `/post/:id`: Fetch a single post by its `id` -- `/feed`: Fetch all _published_ posts -- `/filterPosts?searchString={searchString}`: Filter posts by `title` or `content` - -#### `POST` - -- `/post`: Create a new post - - Body: - - `title: String` (required): The title of the post - - `content: String` (optional): The content of the post - - `authorEmail: String` (required): The email of the user that creates the post -- `/user`: Create a new user - - Body: - - `email: String` (required): The email address of the user - - `name: String` (optional): The name of the user - -#### `PUT` - -- `/publish/:id`: Publish a post by its `id` - -#### `DELETE` - -- `/post/:id`: Delete a post by its `id` \ No newline at end of file diff --git a/.github/readmes/flow/_next-steps.md b/.github/readmes/flow/_next-steps.md deleted file mode 100644 index 75839deb0901..000000000000 --- a/.github/readmes/flow/_next-steps.md +++ /dev/null @@ -1,5 +0,0 @@ -## Next steps - -- [Use Prisma with an existing database](https://www.prisma.io/docs/-f003/) -- [Explore the Prisma client API](https://www.prisma.io/client/client-flow) -- [Learn more about the GraphQL schema](https://www.prisma.io/blog/graphql-server-basics-the-schema-ac5e2950214e/) \ No newline at end of file diff --git a/.github/readmes/flow/_setup-1.md b/.github/readmes/flow/_setup-1.md deleted file mode 100644 index f5fcb69916cb..000000000000 --- a/.github/readmes/flow/_setup-1.md +++ /dev/null @@ -1,13 +0,0 @@ -## How to use - -### 1. Download example & install dependencies - -Clone the repository: - -``` -git clone git@github.com:prisma/prisma-examples.git -``` - -Install Node dependencies: - -``` \ No newline at end of file diff --git a/.github/readmes/flow/_setup-2.md b/.github/readmes/flow/_setup-2.md deleted file mode 100644 index d05c2a47bc45..000000000000 --- a/.github/readmes/flow/_setup-2.md +++ /dev/null @@ -1,64 +0,0 @@ -npm install -``` - -### 2. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -npm install -g prisma -``` - -### 3. Set up database & deploy Prisma datamodel - -For this example, you'll use a free _demo database_ (AWS Aurora) hosted in Prisma Cloud. To set up your database, run: - -``` -prisma deploy -``` - -Then, follow these steps in the interactive CLI wizard: - -1. Select **Demo server** -1. **Authenticate** with Prisma Cloud in your browser (if necessary) -1. Back in your terminal, **confirm all suggested values** - -
- Alternative: Run Prisma locally via Docker - -1. Ensure you have Docker installed on your machine. If not, you can get it from [here](https://store.docker.com/search?offering=community&type=edition). -1. Create `docker-compose.yml` for MySQL (see [here](https://www.prisma.io/docs/prisma-server/database-connector-POSTGRES-jgfr/) for Postgres): - ```yml - version: '3' - services: - prisma: - image: prismagraphql/prisma:1.27 - restart: always - ports: - - "4466:4466" - environment: - PRISMA_CONFIG: | - port: 4466 - databases: - default: - connector: mysql - host: mysql - port: 3306 - user: root - password: prisma - migrations: true - mysql: - image: mysql:5.7 - restart: always - environment: - MYSQL_ROOT_PASSWORD: prisma - volumes: - - mysql:/var/lib/mysql - volumes: - mysql: - ``` -1. Run `docker-compose up -d` -1. Set the `endpoint` in `prisma.yml` to `http://localhost:4466` -1. Run `prisma deploy` - -
\ No newline at end of file diff --git a/.github/readmes/flow/_start-graphql-server.md b/.github/readmes/flow/_start-graphql-server.md deleted file mode 100644 index de3531c94450..000000000000 --- a/.github/readmes/flow/_start-graphql-server.md +++ /dev/null @@ -1,9 +0,0 @@ -### 4. Start the GraphQL server - -Launch your GraphQL server with this command: - -``` -npm run start -``` - -Navigate to [http://localhost:4000](http://localhost:4000) in your browser to explore the API of your GraphQL server in a [GraphQL Playground](https://github.com/prisma/graphql-playground). \ No newline at end of file diff --git a/.github/readmes/flow/graphql/README.md b/.github/readmes/flow/graphql/README.md deleted file mode 100644 index 420fafaa0e23..000000000000 --- a/.github/readmes/flow/graphql/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# GraphQL Server Example - -This example shows how to implement a **GraphQL server with Flow** based on Prisma & [graphql-yoga](https://github.com/prisma/graphql-yoga). - -__INLINE(../_setup-1.md)__ -cd prisma-examples/flow/graphql -__INLINE(../_setup-2.md)__ - -__INLINE(../_start-graphql-server.md)__ - -__INLINE(../../_using-the-graphql-api-subs.md)__ - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/flow/script/README.md b/.github/readmes/flow/script/README.md deleted file mode 100644 index 5cf34a42e2d3..000000000000 --- a/.github/readmes/flow/script/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Simple Flow Script Example - -This example shows how to use the Prisma client in a **simple Flow script** to read and write data in a database. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/flow/script -__INLINE(../_setup-2.md)__ - -### 4. Run the script - -Execute the script with this command: - -``` -npm run start -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/go/_next-steps.md b/.github/readmes/go/_next-steps.md deleted file mode 100644 index 9426bab67422..000000000000 --- a/.github/readmes/go/_next-steps.md +++ /dev/null @@ -1,5 +0,0 @@ -## Next steps - -- [Use Prisma with an existing database](https://www.prisma.io/docs/-g003/) -- [Explore the Prisma client API](https://www.prisma.io/client/client-go) -- [Learn more about the GraphQL schema](https://www.prisma.io/blog/graphql-server-basics-the-schema-ac5e2950214e/) \ No newline at end of file diff --git a/.github/readmes/go/_setup-1.md b/.github/readmes/go/_setup-1.md deleted file mode 100644 index 8ba8009853de..000000000000 --- a/.github/readmes/go/_setup-1.md +++ /dev/null @@ -1,13 +0,0 @@ -## How to use - -### 1. Download example & install dependencies - -Clone the repository: - -``` -git clone git@github.com:prisma/prisma-examples.git -``` - -Ensure dependencies are available and up-to-date: - -``` \ No newline at end of file diff --git a/.github/readmes/go/_setup-2.md b/.github/readmes/go/_setup-2.md deleted file mode 100644 index 4f72d492bba9..000000000000 --- a/.github/readmes/go/_setup-2.md +++ /dev/null @@ -1,65 +0,0 @@ -dep ensure -update -``` - -### 2. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via Homebrew or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -brew install prisma -brew tap -``` - -### 3. Set up database & deploy Prisma datamodel - -For this example, you'll use a free _demo database_ (AWS Aurora) hosted in Prisma Cloud. To set up your database, run: - -``` -prisma deploy -``` - -Then, follow these steps in the interactive CLI wizard: - -1. Select **Demo server** -1. **Authenticate** with Prisma Cloud in your browser (if necessary) -1. Back in your terminal, **confirm all suggested values** - -
- Alternative: Run Prisma locally via Docker - -1. Ensure you have Docker installed on your machine. If not, you can get it from [here](https://store.docker.com/search?offering=community&type=edition). -1. Create `docker-compose.yml` for MySQL (see [here](https://www.prisma.io/docs/prisma-server/database-connector-POSTGRES-jgfr/) for Postgres): - ```yml - version: '3' - services: - prisma: - image: prismagraphql/prisma:1.27 - restart: always - ports: - - "4466:4466" - environment: - PRISMA_CONFIG: | - port: 4466 - databases: - default: - connector: mysql - host: mysql - port: 3306 - user: root - password: prisma - migrations: true - mysql: - image: mysql:5.7 - restart: always - environment: - MYSQL_ROOT_PASSWORD: prisma - volumes: - - mysql:/var/lib/mysql - volumes: - mysql: - ``` -1. Run `docker-compose up -d` -1. Set the `endpoint` in `prisma.yml` to `http://localhost:4466` -1. Run `prisma deploy` - -
\ No newline at end of file diff --git a/.github/readmes/go/cli-app/README.md b/.github/readmes/go/cli-app/README.md deleted file mode 100644 index db3685a4c3b7..000000000000 --- a/.github/readmes/go/cli-app/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Simple TODO-App Example (CLI) - -This example shows how to implement a **TODO-app as a CLI tool** with Golang and Prisma. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/go/cli-app -__INLINE(../_setup-2.md)__ - -### 4. Use the CLI app - -``` -go run main.go -``` - -#### Add a `Todo` item - -``` -go run main.go create Groceries -``` - -#### List all `Todo` items - -``` -go run main.go list -``` - -#### Delete a `Todo` item - -``` -go run main.go delete Groceries -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/go/docker-mongodb/README.md b/.github/readmes/go/docker-mongodb/README.md deleted file mode 100644 index 806365613a1c..000000000000 --- a/.github/readmes/go/docker-mongodb/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# MongoDB with Docker Example - -This example shows how to **set up Prisma using Docker and MongoDB** locally on your machine. It then uses the Prisma client in a simple Go script to read and write data in the database. - -> When using MongoDB with Prisma, you use a [new datamodel format](https://www.prisma.io/docs/-b6a7/). Learn more in the [docs](https://www.prisma.io/docs/-b6o5/). - -__INLINE(../_setup-1.md)__ -cd prisma-examples/go/docker-mongodb -dep ensure -update -``` - -### 2. Launch Prisma with Docker - -This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): - -``` -docker-compose up -d -``` - -### 3. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via Homebrew or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -brew install prisma -brew tap -``` - -### 4. Set up database & deploy Prisma datamodel - -To deploy the datamodel for this example, run the following command: - -``` -prisma deploy -``` - -### 5. Run the script - -Execute the script with this command: - -``` -go run main.go -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/go/docker-mysql/README.md b/.github/readmes/go/docker-mysql/README.md deleted file mode 100644 index 30b9bccb678b..000000000000 --- a/.github/readmes/go/docker-mysql/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# MySQL with Docker Example - -This example shows how to **set up Prisma using Docker and MySQL** locally on your machine. It then uses the Prisma client in a simple Go script to read and write data in the database. - -> This example uses a new and empty database. **Learn how to connect Prisma to your existing database [here](https://www.prisma.io/docs/-g003/)**. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/go/docker-mysql -dep ensure -update -``` - -### 2. Launch Prisma with Docker - -This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): - -``` -docker-compose up -d -``` - -### 3. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via Homebrew or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -brew install prisma -brew tap -``` - -### 4. Set up database & deploy Prisma datamodel - -To deploy the datamodel for this example, run the following command: - -``` -prisma deploy -``` - -### 5. Run the script - -Execute the script with this command: - -``` -go run main.go -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/go/docker-postgres/README.md b/.github/readmes/go/docker-postgres/README.md deleted file mode 100644 index 960d3600d586..000000000000 --- a/.github/readmes/go/docker-postgres/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# PostgreSQL with Docker Example - -This example shows how to **set up Prisma using Docker and PostgreSQL** locally on your machine. It then uses the Prisma client in a simple Go script to read and write data in the database. - -> This example uses a new and empty database. **Learn how to connect Prisma to your existing database [here](https://www.prisma.io/docs/-g003/)**. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/go/docker-postgres -dep ensure -update -``` - -### 2. Launch Prisma with Docker - -This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): - -``` -docker-compose up -d -``` - -### 3. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via Homebrew or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -brew install prisma -brew tap -``` - -### 4. Set up database & deploy Prisma datamodel - -To deploy the datamodel for this example, run the following command: - -``` -prisma deploy -``` - -### 5. Run the script - -Execute the script with this command: - -``` -go run main.go -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/go/graphql/README.md b/.github/readmes/go/graphql/README.md deleted file mode 100644 index 1e3c4693bca5..000000000000 --- a/.github/readmes/go/graphql/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# GraphQL Server Example - -This example shows how to implement a **GraphQL server with Golang** based on Prisma & [gqlgen](https://github.com/99designs/gqlgen). - -__INLINE(../_setup-1.md)__ -cd prisma-examples/go/graphql -__INLINE(../_setup-2.md)__ - -### 4. Start the GraphQL server - -``` -go run ./server -``` - -Navigate to [http://localhost:4000](http://localhost:4000) in your browser to explore the API of your GraphQL server in a [GraphQL Playground](https://github.com/prisma/graphql-playground). - -__INLINE(../../_using-the-graphql-api.md)__ - -### 6. Changing the GraphQL schema - -After you made changes to `schema.graphql`, you need to update the generated types in `./server/generated.go` and potentially also adjust the resolver implementations in `./server/resolver.go`: - -``` -go run sripts/gqlgen.go -``` - -This updates `./server/generated.go` to incorporate the schema changes in your Go type definitions. It also generates scaffolded resolvers in `tmp/resolver.go` that you might need to copy and paste into `./server/resolver.go`. - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/go/http-mux/README.md b/.github/readmes/go/http-mux/README.md deleted file mode 100644 index 034d5e7d21bf..000000000000 --- a/.github/readmes/go/http-mux/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# REST API Example - -This example shows how to implement a **REST (HTTP) API** using [gorilla/mux](http://www.gorillatoolkit.org/pkg/mux) and Prisma. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/go/http-mux -__INLINE(../_setup-2.md)__ - -### 4. Start the REST API server - -``` -go run main.go -``` - -The server is now running on `http://localhost:8080`. You can send the API requests implemented in `main.go`, e.g. [`http://localhost:8080/feed`](http://localhost:8080/feed). - -__INLINE(../../_using-the-rest-api.md)__ - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/go/rest-gin/README.md b/.github/readmes/go/rest-gin/README.md deleted file mode 100644 index 873aa212c0d1..000000000000 --- a/.github/readmes/go/rest-gin/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# REST API Example - -This example shows how to implement a **REST (HTTP) API** using the [Gin Web Framework](https://github.com/gin-gonic/gin) and Prisma. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/go/rest-gin -__INLINE(../_setup-2.md)__ - -### 4. Start the REST API server - -``` -go run main.go -``` - -The server is now running on `http://localhost:8080`. You can send the API requests implemented in `main.go`, e.g. [`http://localhost:8080/feed`](http://localhost:8080/feed). - -__INLINE(../../_using-the-rest-api.md)__ - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/go/script/README.md b/.github/readmes/go/script/README.md deleted file mode 100644 index 98b8d1c28fb6..000000000000 --- a/.github/readmes/go/script/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Simple Golang Script Example - -This example shows how to use the Prisma client in a **simple Golang script** to read and write data in a database. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/go/script -__INLINE(../_setup-2.md)__ - -### 4. Run the script - -Execute the script with this command: - -``` -go run main.go -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/node/_next-steps.md b/.github/readmes/node/_next-steps.md deleted file mode 100644 index 8b6bd7f82a95..000000000000 --- a/.github/readmes/node/_next-steps.md +++ /dev/null @@ -1,5 +0,0 @@ -## Next steps - -- [Use Prisma with an existing database](https://www.prisma.io/docs/-a003/) -- [Explore the Prisma client API](https://www.prisma.io/client/client-javascript) -- [Learn more about the GraphQL schema](https://www.prisma.io/blog/graphql-server-basics-the-schema-ac5e2950214e/) \ No newline at end of file diff --git a/.github/readmes/node/_setup-1.md b/.github/readmes/node/_setup-1.md deleted file mode 100644 index f5fcb69916cb..000000000000 --- a/.github/readmes/node/_setup-1.md +++ /dev/null @@ -1,13 +0,0 @@ -## How to use - -### 1. Download example & install dependencies - -Clone the repository: - -``` -git clone git@github.com:prisma/prisma-examples.git -``` - -Install Node dependencies: - -``` \ No newline at end of file diff --git a/.github/readmes/node/_setup-2.md b/.github/readmes/node/_setup-2.md deleted file mode 100644 index d05c2a47bc45..000000000000 --- a/.github/readmes/node/_setup-2.md +++ /dev/null @@ -1,64 +0,0 @@ -npm install -``` - -### 2. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -npm install -g prisma -``` - -### 3. Set up database & deploy Prisma datamodel - -For this example, you'll use a free _demo database_ (AWS Aurora) hosted in Prisma Cloud. To set up your database, run: - -``` -prisma deploy -``` - -Then, follow these steps in the interactive CLI wizard: - -1. Select **Demo server** -1. **Authenticate** with Prisma Cloud in your browser (if necessary) -1. Back in your terminal, **confirm all suggested values** - -
- Alternative: Run Prisma locally via Docker - -1. Ensure you have Docker installed on your machine. If not, you can get it from [here](https://store.docker.com/search?offering=community&type=edition). -1. Create `docker-compose.yml` for MySQL (see [here](https://www.prisma.io/docs/prisma-server/database-connector-POSTGRES-jgfr/) for Postgres): - ```yml - version: '3' - services: - prisma: - image: prismagraphql/prisma:1.27 - restart: always - ports: - - "4466:4466" - environment: - PRISMA_CONFIG: | - port: 4466 - databases: - default: - connector: mysql - host: mysql - port: 3306 - user: root - password: prisma - migrations: true - mysql: - image: mysql:5.7 - restart: always - environment: - MYSQL_ROOT_PASSWORD: prisma - volumes: - - mysql:/var/lib/mysql - volumes: - mysql: - ``` -1. Run `docker-compose up -d` -1. Set the `endpoint` in `prisma.yml` to `http://localhost:4466` -1. Run `prisma deploy` - -
\ No newline at end of file diff --git a/.github/readmes/node/_start-graphql-server.md b/.github/readmes/node/_start-graphql-server.md deleted file mode 100644 index de3531c94450..000000000000 --- a/.github/readmes/node/_start-graphql-server.md +++ /dev/null @@ -1,9 +0,0 @@ -### 4. Start the GraphQL server - -Launch your GraphQL server with this command: - -``` -npm run start -``` - -Navigate to [http://localhost:4000](http://localhost:4000) in your browser to explore the API of your GraphQL server in a [GraphQL Playground](https://github.com/prisma/graphql-playground). \ No newline at end of file diff --git a/.github/readmes/node/cli-app/README.md b/.github/readmes/node/cli-app/README.md deleted file mode 100644 index 5fa3a64335c4..000000000000 --- a/.github/readmes/node/cli-app/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Simple TODO-App Example (CLI) - -This example shows how to implement a **TODO-app as a CLI tool** with Node.js and Prisma. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/node/cli-app -__INLINE(../_setup-2.md)__ - -### 4. Use the CLI app - -``` -npm run cli -``` - -#### Add a `Todo` item - -``` -npm run cli add Groceries -``` - -#### List all `Todo` items - -``` -npm run cli list -``` - -#### Delete a `Todo` item - -``` -npm run cli delete Groceries -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/node/docker-mongodb/README.md b/.github/readmes/node/docker-mongodb/README.md deleted file mode 100644 index a41c4a721dd3..000000000000 --- a/.github/readmes/node/docker-mongodb/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# MongoDB with Docker Example - -This example shows how to **set up Prisma using Docker and MongoDB** locally on your machine. It then uses the Prisma client in a simple Node script to read and write data in the database. - -> When using MongoDB with Prisma, you use a [new datamodel format](https://www.prisma.io/docs/-b6a7/). Learn more in the [docs](https://www.prisma.io/docs/-b6o5/). - -__INLINE(../_setup-1.md)__ -cd prisma-examples/node/docker-mongodb -npm install -``` - -### 2. Launch Prisma with Docker - -This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): - -``` -docker-compose up -d -``` - -### 3. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -npm install -g prisma -``` - -### 4. Set up database & deploy Prisma datamodel - -To deploy the datamodel for this example, run the following command: - -``` -prisma deploy -``` - -### 5. Run the script - -Execute the script with this command: - -``` -npm run start -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/node/docker-mysql/README.md b/.github/readmes/node/docker-mysql/README.md deleted file mode 100644 index a3c48649e4ed..000000000000 --- a/.github/readmes/node/docker-mysql/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# MySQL with Docker Example - -This example shows how to **set up Prisma using Docker and MySQL** locally on your machine. It then uses the Prisma client in a simple Node script to read and write data in the database. - -> This example uses a new and empty database. **Learn how to connect Prisma to your existing database [here](https://www.prisma.io/docs/-a003/)**. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/node/docker-mysql -npm install -``` - -### 2. Launch Prisma with Docker - -This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): - -``` -docker-compose up -d -``` - -### 3. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -npm install -g prisma -``` - -### 4. Set up database & deploy Prisma datamodel - -To deploy the datamodel for this example, run the following command: - -``` -prisma deploy -``` - -### 5. Run the script - -Execute the script with this command: - -``` -npm run start -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/node/docker-postgres/README.md b/.github/readmes/node/docker-postgres/README.md deleted file mode 100644 index ccb3646a4d1e..000000000000 --- a/.github/readmes/node/docker-postgres/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# PostgreSQL with Docker Example - -This example shows how to **set up Prisma using Docker and PostgreSQL** locally on your machine. It then uses the Prisma client in a simple Node script to read and write data in the database. - -> This example uses a new and empty database. **Learn how to connect Prisma to your existing database [here](https://www.prisma.io/docs/-a003/)**. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/node/docker-postgres -npm install -``` - -### 2. Launch Prisma with Docker - -This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): - -``` -docker-compose up -d -``` - -### 3. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -npm install -g prisma -``` - -### 4. Set up database & deploy Prisma datamodel - -To deploy the datamodel for this example, run the following command: - -``` -prisma deploy -``` - -### 5. Run the script - -Execute the script with this command: - -``` -npm run start -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/node/graphql-auth/README.md b/.github/readmes/node/graphql-auth/README.md deleted file mode 100644 index ecd7d1ae712b..000000000000 --- a/.github/readmes/node/graphql-auth/README.md +++ /dev/null @@ -1,223 +0,0 @@ -# GraphQL Server with Authentication & Permissions - -This example shows how to implement a **GraphQL server with an email-password-based authentication workflow and authentication rules** based on Prisma, [graphql-yoga](https://github.com/prisma/graphql-yoga) & [graphql-shield](https://github.com/maticzav/graphql-shield). - -__INLINE(../_setup-1.md)__ -cd prisma-examples/node/graphql-auth -__INLINE(../_setup-2.md)__ - -__INLINE(../_start-graphql-server.md)__ - -__INLINE(../../_using-the-graphql-api-auth.md)__ - -### 6. Evolving the example - -If you want to change the GraphQL API, you need to adjust the GraphQL schema in [`./src/schema.graphql`](./src/schema.graphql) and the respective resolver functions. - -
Adding an operation without updating the datamodel - -To add new operation that can be based on the current [datamodel](./prisma/datamodel.prisma), you first need to add the operation to the GraphQL schema's `Query` or `Mutation` type and then add the corresponding resolver function. - -For example, to add a new mutation that updates a user's name, you can extend the `Mutation` type as follows: - -```diff -type Mutation { - signupUser(email: String!, name: String): User! - createDraft(title: String!, content: String, authorEmail: String!): Post! - deletePost(id: ID!): Post - publish(id: ID!): Post -+ updateUserName(id: ID!, newName: String!): User -} -``` - -Then add the new resolver to the `Mutation` object in [`./src/resolvers/Mutation.js`](./src/resolvers/Mutation.js): - -```diff -const Mutation = { - // ... -+ updateUserName(parent, { id, newName }, context) { -+ return context.prisma.updateUser({ -+ where: { -+ id -+ }, -+ data: { -+ name: newName -+ } -+ }) -+ } -} -``` - -You can now send the following mutation to your GraphQL API: - -```graphql -mutation { - updateUserName( - id: "__USER_ID__" - newName: "John") - ) { - id - name - } -} -``` - -
- -
Adding an operation and updating the datamodel - -Some new API features can't be covered with the existing datamodel. For example, you might want to add _comment_ feature to the API, so that users can leave comments on posts. - -For that, you first need to adjust the Prisma datamodel in [`./prisma/datamodel.prisma`](./prisma/datamodel.prisma): - -```diff -type User { - id: ID! @unique - email: String! @unique - name: String - posts: [Post!]! -+ comments: [Comment!]! -} - -type Post { - id: ID! @unique - createdAt: DateTime! - updatedAt: DateTime! - published: Boolean! @default(value: "false") - title: String! - content: String - author: User! -+ comments: [Comment!]! -} - -+ type Comment { -+ id: ID! @unique -+ text: String! -+ writtenBy: User! -+ post: Post! -+ } -``` - -After having updated the datamodel, you need to deploy the changes: - -``` -prisma deploy -``` - -Note that this also invokes `prisma generate` (because of the `post-deploy` hook in [`prisma.yml`](./prisma/prisma.yml)) which regenerates the Prisma client in [`./src/generated/prisma-client`](./src/generated/prisma-client). - -To now enable users to add comments to posts, you need to add the `Comment` type as well as the corresponding operation to the GraphQL schema in [`./src/schema.graphql`](./src/schema.graphql): - -```diff -type Query { - # ... as before -} - -type Mutation { - signupUser(email: String!, name: String): User! - createDraft(title: String!, content: String, authorEmail: String!): Post! - deletePost(id: ID!): Post - publish(id: ID!): Post - updateUserName(id: ID!, newName: String!): User -+ writeComment(text: String!, postId: ID!): Comment -} - -type User { - id: ID! - email: String! - name: String - posts: [Post!]! -+ comments: [Comment!]! -} - -type Post { - id: ID! - createdAt: DateTime! - updatedAt: DateTime! - published: Boolean! - title: String! - content: String - author: User! -+ comments: [Comment!]! -} - -+ type Comment { -+ id: ID! -+ text: String! -+ writtenBy: User! -+ post: Post! -+ } -``` - -Next, you need to implement the resolver for the new operation in [`./src/resolvers/Mutation.js`](./src/resolvers/Mutation.js): - -```diff -const resolvers = { - // ... - Mutation: { - // ... -+ writeComment(parent, { postId, userId }, context) { -+ const userId = getUserId(context) -+ return context.prisma.createComment({ -+ text, -+ post: { -+ connect: { id: postId } -+ }, -+ writtenBy: { -+ connect: { id: userId } -+ } -+ }) -+ } - } -} -``` - -Finally, because `Comment` has a relation to `Post` and `User`, you need to update the type resolvers as well so that the relation can be properly resolved (learn more about why this is necessary in [this](https://www.prisma.io/blog/graphql-server-basics-the-schema-ac5e2950214e/) blog article): - -```diff -const resolvers = { - // ... - User: { - // ... -+ comments: ({ id }, args, context) { -+ return context.prisma.user({ id }).comments() -+ } - }, - Post: { - // ... -+ comments: ({ id }, args, context) { -+ return context.prisma.post({ id }).comments() -+ } - }, -+ Comment: { -+ writtenBy: ({ id }, args, context) { -+ return context.prisma.comment({ id }).writtenBy() -+ }, -+ post: ({ id }, args, context) { -+ return context.prisma.comment({ id }).post() -+ }, -+ } -} -``` - -You can now send the following mutation to your GraphQL API. Note that this mutation only works if you're authenticated through a valid token in the `Authorization` header. - -```graphql -mutation { - writeComment( - postId: "__POST_ID__" - text: "I like turtles 🐢" - ) { - id - name - } -} -``` - -
- -__INLINE(../_next-steps.md)__ - -## The idea behind the example - -The Prisma client is used as a replacement for a traditional ORM in this example. It bridges the gap between your GraphQL resolvers and your database by providing a powerful CRUD API for the types that are defined in your Prisma datamodel. diff --git a/.github/readmes/node/graphql-subscriptions/README.md b/.github/readmes/node/graphql-subscriptions/README.md deleted file mode 100644 index b398a9abcf08..000000000000 --- a/.github/readmes/node/graphql-subscriptions/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# GraphQL Server with Realtime Subscriptions Example - -This example shows how to implement **GraphQL server with realtime subscriptions** based on Prisma & [graphql-yoga](https://github.com/prisma/graphql-yoga). - -> To learn more about implementing GraphQL subscriptions with Prisma, visit [this](https://www.prisma.io/tutorials/build-a-realtime-graphql-server-with-subscriptions-ct11/) tutorial. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/node/graphql-subscriptions -__INLINE(../_setup-2.md)__ - -__INLINE(../_start-graphql-server.md)__ - -__INLINE(../../_using-the-graphql-api-subs.md)__ - -__INLINE(../_next-steps.md)__ diff --git a/.github/readmes/node/graphql/README.md b/.github/readmes/node/graphql/README.md deleted file mode 100644 index b059da96cda6..000000000000 --- a/.github/readmes/node/graphql/README.md +++ /dev/null @@ -1,226 +0,0 @@ -# GraphQL Server Example - -This example shows how to implement a **GraphQL server with Node.js** based on Prisma & [graphql-yoga](https://github.com/prisma/graphql-yoga). - -__INLINE(../_setup-1.md)__ -cd prisma-examples/node/graphql -__INLINE(../_setup-2.md)__ - -__INLINE(../_start-graphql-server.md)__ - -__INLINE(../../_using-the-graphql-api.md)__ - -### 6. Evolving the example - -If you want to change the GraphQL API, you need to adjust the GraphQL schema in [`./src/schema.graphql`](./src/schema.graphql) and the respective resolver functions. - -
Adding an operation without updating the datamodel - -To add new operation that can be based on the current [datamodel](./prisma/datamodel.prisma), you first need to add the operation to the GraphQL schema's `Query` or `Mutation` type and then add the corresponding resolver function. - -For example, to add a new mutation that updates a user's name, you can extend the `Mutation` type as follows: - -```diff -type Mutation { - signupUser(email: String!, name: String): User! - createDraft(title: String!, content: String, authorEmail: String!): Post! - deletePost(id: ID!): Post - publish(id: ID!): Post -+ updateUserName(id: ID!, newName: String!): User -} -``` - -Then add the new resolver to the `resolvers` object in [`./src/index.js`](./src/index.js): - -```diff -const resolvers = { - // ... - Mutation: { - // ... -+ updateUserName(parent, { id, newName }, context) { -+ return context.prisma.updateUser({ -+ where: { -+ id -+ }, -+ data: { -+ name: newName -+ } -+ }) -+ } - } -} -``` - -You can now send the following mutation to your GraphQL API: - -```graphql -mutation { - updateUserName( - id: "__USER_ID__" - newName: "John") - ) { - id - name - } -} -``` - -
- -
Adding an operation and updating the datamodel - -Some new API features can't be covered with the existing datamodel. For example, you might want to add _comment_ feature to the API, so that users can leave comments on posts. - -For that, you first need to adjust the Prisma datamodel in [`./prisma/datamodel.prisma`](./prisma/datamodel.prisma): - -```diff -type User { - id: ID! @unique - email: String! @unique - name: String - posts: [Post!]! -+ comments: [Comment!]! -} - -type Post { - id: ID! @unique - createdAt: DateTime! - updatedAt: DateTime! - published: Boolean! @default(value: "false") - title: String! - content: String - author: User! -+ comments: [Comment!]! -} - -+ type Comment { -+ id: ID! @unique -+ text: String! -+ writtenBy: User! -+ post: Post! -+ } -``` - -After having updated the datamodel, you need to deploy the changes: - -``` -prisma deploy -``` - -Note that this also invokes `prisma generate` (because of the `post-deploy` hook in [`prisma.yml`](./prisma/prisma.yml)) which regenerates the Prisma client in [`./src/generated/prisma-client`](./src/generated/prisma-client). - -To now enable users to add comments to posts, you need to add the `Comment` type as well as the corresponding operation to the GraphQL schema in [`./src/schema.graphql`](./src/schema.graphql): - -```diff -type Query { - # ... as before -} - -type Mutation { - signupUser(email: String!, name: String): User! - createDraft(title: String!, content: String, authorEmail: String!): Post! - deletePost(id: ID!): Post - publish(id: ID!): Post - updateUserName(id: ID!, newName: String!): User -+ writeComment(text: String!, postId: ID!, userId!: ID!): Comment -} - -type User { - id: ID! - email: String! - name: String - posts: [Post!]! -+ comments: [Comment!]! -} - -type Post { - id: ID! - createdAt: DateTime! - updatedAt: DateTime! - published: Boolean! - title: String! - content: String - author: User! -+ comments: [Comment!]! -} - -+ type Comment { -+ id: ID! -+ text: String! -+ writtenBy: User! -+ post: Post! -+ } -``` - -Next, you need to implement the resolver for the new operation in [`./src/index.js`](./src/index.js): - -```diff -const resolvers = { - // ... - Mutation: { - // ... -+ writeComment(parent, { postId, userId}, context) { -+ return context.prisma.createComment({ -+ text, -+ post: { -+ connect: { id: postId } -+ }, -+ writtenBy: { -+ connect: { id: userId } -+ } -+ }) -+ } - } -} -``` - -Finally, because `Comment` has a relation to `Post` and `User`, you need to update the type resolvers as well so that the relation can be properly resolved (learn more about why this is necessary in [this](https://www.prisma.io/blog/graphql-server-basics-the-schema-ac5e2950214e/) blog article): - -```diff -const resolvers = { - // ... - User: { - // ... -+ comments: ({ id }, args, context) { -+ return context.prisma.user({ id }).comments() -+ } - }, - Post: { - // ... -+ comments: ({ id }, args, context) { -+ return context.prisma.post({ id }).comments() -+ } - }, -+ Comment: { -+ writtenBy: ({ id }, args, context) { -+ return context.prisma.comment({ id }).writtenBy() -+ }, -+ post: ({ id }, args, context) { -+ return context.prisma.comment({ id }).post() -+ }, -+ } -} -``` - -You can now send the following mutation to your GraphQL API: - -```graphql -mutation { - writeComment( - userId: "__USER_ID__" - postId: "__POST_ID__" - text: "I like turtles 🐢" - ) { - id - name - } -} -``` - -
- -__INLINE(../_next-steps.md)__ - -## The idea behind the example - -The Prisma client is used as a replacement for a traditional ORM in this example. It bridges the gap between your GraphQL resolvers and your database by providing a powerful CRUD API for the types that are defined in your Prisma datamodel. \ No newline at end of file diff --git a/.github/readmes/node/grpc/README.md b/.github/readmes/node/grpc/README.md deleted file mode 100644 index 9c0bd918b57b..000000000000 --- a/.github/readmes/node/grpc/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# gRPC Server Example - -This example shows how to implement a **gRPC API with Node.js** and Prisma. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/node/grpc -__INLINE(../_setup-2.md)__ - -### 4. Start the gRPC server - -``` -npm run start -``` - -The server is now running on `0.0.0.0:50051`. - -### 5. Using the gRPC API - -To use the gRPC API, you need a gRPC client. We provide several client scripts inside the [`./client`](./client) directory. Each script is named according to the operation it performs against the gRPC API (e.g. the [`feed.js`](./client/feed.js) script sends the [`Feed`](./service.proto#L7) operation). Each script can be invoked by running the corresponding NPM script defined in [`package.json`](./package.json), e.g. `npm run feed`. - -In case you prefer a GUI client, we recommend [BloomRPC](https://github.com/uw-labs/bloomrpc): - -![](https://imgur.com/0EiIo03.png) - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/node/rest-express/README.md b/.github/readmes/node/rest-express/README.md deleted file mode 100644 index 80323f58fb00..000000000000 --- a/.github/readmes/node/rest-express/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# REST API Example - -This example shows how to implement a **REST API** using [Express.JS](https://expressjs.com/de/) and Prisma. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/node/rest-express -__INLINE(../_setup-2.md)__ - -### 4. Start the REST API server - -``` -npm run start -``` - -The server is now running on `http://localhost:3000`. You can send the API requests implemented in `index.js`, e.g. [`http://localhost:3000/feed`](http://localhost:3000/feed). - -__INLINE(../../_using-the-rest-api.md)__ - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/node/script/README.md b/.github/readmes/node/script/README.md deleted file mode 100644 index 36a552ebc7d3..000000000000 --- a/.github/readmes/node/script/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Simple Node Script Example - -This example shows how to use the Prisma client in a **simple Node script** to read and write data in a database. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/node/script -__INLINE(../_setup-2.md)__ - -### 4. Run the script - -Execute the script with this command: - -``` -npm run start -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/_next-steps.md b/.github/readmes/typescript/_next-steps.md deleted file mode 100644 index 46a39a7defe5..000000000000 --- a/.github/readmes/typescript/_next-steps.md +++ /dev/null @@ -1,5 +0,0 @@ -## Next steps - -- [Use Prisma with an existing database](https://www.prisma.io/docs/-t003/) -- [Explore the Prisma client API](https://www.prisma.io/client/client-typescript) -- [Learn more about the GraphQL schema](https://www.prisma.io/blog/graphql-server-basics-the-schema-ac5e2950214e/) \ No newline at end of file diff --git a/.github/readmes/typescript/_setup-1.md b/.github/readmes/typescript/_setup-1.md deleted file mode 100644 index f5fcb69916cb..000000000000 --- a/.github/readmes/typescript/_setup-1.md +++ /dev/null @@ -1,13 +0,0 @@ -## How to use - -### 1. Download example & install dependencies - -Clone the repository: - -``` -git clone git@github.com:prisma/prisma-examples.git -``` - -Install Node dependencies: - -``` \ No newline at end of file diff --git a/.github/readmes/typescript/_setup-2.md b/.github/readmes/typescript/_setup-2.md deleted file mode 100644 index d05c2a47bc45..000000000000 --- a/.github/readmes/typescript/_setup-2.md +++ /dev/null @@ -1,64 +0,0 @@ -npm install -``` - -### 2. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -npm install -g prisma -``` - -### 3. Set up database & deploy Prisma datamodel - -For this example, you'll use a free _demo database_ (AWS Aurora) hosted in Prisma Cloud. To set up your database, run: - -``` -prisma deploy -``` - -Then, follow these steps in the interactive CLI wizard: - -1. Select **Demo server** -1. **Authenticate** with Prisma Cloud in your browser (if necessary) -1. Back in your terminal, **confirm all suggested values** - -
- Alternative: Run Prisma locally via Docker - -1. Ensure you have Docker installed on your machine. If not, you can get it from [here](https://store.docker.com/search?offering=community&type=edition). -1. Create `docker-compose.yml` for MySQL (see [here](https://www.prisma.io/docs/prisma-server/database-connector-POSTGRES-jgfr/) for Postgres): - ```yml - version: '3' - services: - prisma: - image: prismagraphql/prisma:1.27 - restart: always - ports: - - "4466:4466" - environment: - PRISMA_CONFIG: | - port: 4466 - databases: - default: - connector: mysql - host: mysql - port: 3306 - user: root - password: prisma - migrations: true - mysql: - image: mysql:5.7 - restart: always - environment: - MYSQL_ROOT_PASSWORD: prisma - volumes: - - mysql:/var/lib/mysql - volumes: - mysql: - ``` -1. Run `docker-compose up -d` -1. Set the `endpoint` in `prisma.yml` to `http://localhost:4466` -1. Run `prisma deploy` - -
\ No newline at end of file diff --git a/.github/readmes/typescript/_start-graphql-server.md b/.github/readmes/typescript/_start-graphql-server.md deleted file mode 100644 index de3531c94450..000000000000 --- a/.github/readmes/typescript/_start-graphql-server.md +++ /dev/null @@ -1,9 +0,0 @@ -### 4. Start the GraphQL server - -Launch your GraphQL server with this command: - -``` -npm run start -``` - -Navigate to [http://localhost:4000](http://localhost:4000) in your browser to explore the API of your GraphQL server in a [GraphQL Playground](https://github.com/prisma/graphql-playground). \ No newline at end of file diff --git a/.github/readmes/typescript/circleci/README.md b/.github/readmes/typescript/circleci/README.md deleted file mode 100644 index 8535c4e9ffb3..000000000000 --- a/.github/readmes/typescript/circleci/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# CircleCI Configuration Example - -This example shows how to configute a CI setup using [CircleCI](https://circleci.com/) for Prisma. - -## Get started - -> **Note**: The project setup in this example is minimalistic. You can use it as a reference example for your own project, but you might want to evolve it into a more advanced setup. - -### 1. Download the example - -Clone the repository: - -``` -git clone git@github.com:prisma/prisma-examples.git -``` - -Install Node dependencies: - -``` -cd prisma-examples/typescript-circleci -``` - -### 2. Set up repository locally and on GitHub - -Next, navigate into the downloaded folder and initiate a new git repository: - -```sh -cd typescript-circleci -git init . -git add . -git commit -m "Initial commit" -``` - -In your GitHub account, create a new repository and copy its git URL, e.g.: `git@github.com:w0wka91/circleci-prisma.git` - -Add a new remote to your local git repository: - -```sh -git remote add origin git@github.com:w0wka91/circleci-prisma.git -``` - -Push your project to github: - -```sh -git push --set-upstream origin master -``` - -### 3. Add project in CircleCI - -Now, log in your [CircleCI](https://circleci.com/dashboard) account, add your github repository as a new project and click on `Start Building`. - -### 4. Verify the build - -In your CircleCI account, review the build and confirm that the build went through. - -Here is a description of the performed steps that are expected to happen (compare to `.circleci/config.yml` as well): - -1. We spin up a new Prisma server and database using `docker-compose up -d`. -2. We confirm that the Docker setup is correct with `docker ps`. -3. We install the `npm` dependencies with `npm install`. -4. We sleep 20 seconds to allow for the two Docker containers to finish their setup. -5. We run `prisma deploy` with the locally installed version of Prisma. This will set up a new service `circleci` at stage `test` and seed some data according to `prisma.yml`. -6. We run a short jest test where we fetch all users from the prisma server using prisma-client diff --git a/.github/readmes/typescript/cli-app/README.md b/.github/readmes/typescript/cli-app/README.md deleted file mode 100644 index f46e3fb7d558..000000000000 --- a/.github/readmes/typescript/cli-app/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Simple TODO-App Example (CLI) - -This example shows how to implement a **TODO-app as a CLI tool** with TypeScript and Prisma. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/typescript/cli-app -__INLINE(../_setup-2.md)__ - -### 4. Use the CLI app - -``` -npm run cli -``` - -#### Add a `Todo` item - -``` -npm run cli add Groceries -``` - -#### List all `Todo` items - -``` -npm run cli list -``` - -#### Delete a `Todo` item - -``` -npm run cli delete Groceries -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/docker-mongodb/README.md b/.github/readmes/typescript/docker-mongodb/README.md deleted file mode 100644 index cc0d0824d662..000000000000 --- a/.github/readmes/typescript/docker-mongodb/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# MongoDB with Docker Example - -This example shows how to **set up Prisma using Docker and MongoDB** locally on your machine. It then uses the Prisma client in a simple TypeScript script to read and write data in the database. - -> When using MongoDB with Prisma, you use a [new datamodel format](https://www.prisma.io/docs/-b6a7/). Learn more in the [docs](https://www.prisma.io/docs/-b6o5/). - -__INLINE(../_setup-1.md)__ -cd prisma-examples/typescript/docker-mongodb -npm install -``` - -### 2. Launch Prisma with Docker - -This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): - -``` -docker-compose up -d -``` - -### 3. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -npm install -g prisma -``` - -### 4. Set up database & deploy Prisma datamodel - -To deploy the datamodel for this example, run the following command: - -``` -prisma deploy -``` - -### 5. Run the script - -Execute the script with this command: - -``` -npm run start -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/docker-mysql/README.md b/.github/readmes/typescript/docker-mysql/README.md deleted file mode 100644 index 154460c06f4b..000000000000 --- a/.github/readmes/typescript/docker-mysql/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# MySQL with Docker Example - -This example shows how to **set up Prisma using Docker and MySQL** locally on your machine. It then uses the Prisma client in a simple TypeScript script to read and write data in the database. - -> This example uses a new and empty database. **Learn how to connect Prisma to your existing database [here](https://www.prisma.io/docs/-t003/)**. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/typescript/docker-mysql -npm install -``` - -### 2. Launch Prisma with Docker - -This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): - -``` -docker-compose up -d -``` - -### 3. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -npm install -g prisma -``` - -### 4. Set up database & deploy Prisma datamodel - -To deploy the datamodel for this example, run the following command: - -``` -prisma deploy -``` - -### 5. Run the script - -Execute the script with this command: - -``` -npm run start -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/docker-postgres/README.md b/.github/readmes/typescript/docker-postgres/README.md deleted file mode 100644 index aa22b2c35d75..000000000000 --- a/.github/readmes/typescript/docker-postgres/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# PostgreSQL with Docker Example - -This example shows how to **set up Prisma using Docker and PostgreSQL** locally on your machine. It then uses the Prisma client in a simple TypeScript script to read and write data in the database. - -> This example uses a new and empty database. **Learn how to connect Prisma to your existing database [here](https://www.prisma.io/docs/-t003/)**. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/typescript/docker-postgres -npm install -``` - -### 2. Launch Prisma with Docker - -This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): - -``` -docker-compose up -d -``` - -### 3. Install the Prisma CLI - -To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): - -``` -npm install -g prisma -``` - -### 4. Set up database & deploy Prisma datamodel - -To deploy the datamodel for this example, run the following command: - -``` -prisma deploy -``` - -### 5. Run the script - -Execute the script with this command: - -``` -npm run start -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/graphql-auth/README.md b/.github/readmes/typescript/graphql-auth/README.md deleted file mode 100644 index 9f1e734c0b3c..000000000000 --- a/.github/readmes/typescript/graphql-auth/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# GraphQL Server with Authentication & Permissions - -This example shows how to implement a **GraphQL server with an email-password-based authentication workflow and authentication rules**, based on Prisma, [graphql-yoga](https://github.com/prisma/graphql-yoga), [graphql-shield](https://github.com/maticzav/graphql-shield) & [GraphQL Nexus](https://graphql-nexus.com/). - -__INLINE(../_setup-1.md)__ -cd prisma-examples/typescript/graphql-auth -__INLINE(../_setup-2.md)__ - -__INLINE(../_start-graphql-server.md)__ - -__INLINE(../../_using-the-graphql-api-auth.md)__ - -### 6. Changing the GraphQL schema - -To make changes to the GraphQL schema, you need to manipulate the [`Query`](./src/resolvers/Query.ts) and [`Mutation`](./src/resolvers/Mutation.ts) types. - -Note that the [`start`](./package.json#L6) script also starts a development server that automatically updates your schema every time you save a file. This way, the auto-generated [GraphQL schema](./src/generated/schema.graphql) updates whenever you make changes in to the `Query` or `Mutation` types inside your TypeScript code. - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/graphql-crud/README.md b/.github/readmes/typescript/graphql-crud/README.md deleted file mode 100644 index 944f5ebcacae..000000000000 --- a/.github/readmes/typescript/graphql-crud/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# CRUD GraphQL API Example - -This example shows how to implement a **CRUD GraphQL API with TypeScript** based on Prisma, [graphql-yoga](https://github.com/prisma/graphql-yoga) and [GraphQL Nexus](https://graphql-nexus.com/). - -__INLINE(../_setup-1.md)__ -cd prisma-examples/typescript/graphql-crud -__INLINE(../_setup-2.md)__ - -__INLINE(../_start-graphql-server.md)__ - -__INLINE(../../_using-the-graphql-api-crud.md)__ - -### 6. Changing the GraphQL schema - -To make changes to the GraphQL schema, you need to manipulate the `Query` and `Mutation` types that are defined in [`index.ts`](./src/index.ts). - -Note that the [`start`](./package.json#L6) script also starts a development server that automatically updates your schema every time you save a file. This way, the auto-generated [GraphQL schema](./src/generated/schema.graphql) updates whenever you make changes in to the `Query` or `Mutation` types inside your TypeScript code. - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/graphql-subscriptions/README.md b/.github/readmes/typescript/graphql-subscriptions/README.md deleted file mode 100644 index c7651ad043bb..000000000000 --- a/.github/readmes/typescript/graphql-subscriptions/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# GraphQL Server with Realtime Subscriptions Example - -This example shows how to implement **GraphQL server with realtime subscriptions** based on Prisma & [graphql-yoga](https://github.com/prisma/graphql-yoga). - -__INLINE(../_setup-1.md)__ -cd prisma-examples/typescript/graphql-subscriptions -__INLINE(../_setup-2.md)__ - -__INLINE(../_start-graphql-server.md)__ - -__INLINE(../../_using-the-graphql-api-subs.md)__ - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/graphql/README.md b/.github/readmes/typescript/graphql/README.md deleted file mode 100644 index bb29f0f94bb3..000000000000 --- a/.github/readmes/typescript/graphql/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# GraphQL Server Example - -This example shows how to implement a **GraphQL server with TypeScript** based on Prisma, [graphql-yoga](https://github.com/prisma/graphql-yoga) and [GraphQL Nexus](https://graphql-nexus.com/). - -__INLINE(../_setup-1.md)__ -cd prisma-examples/typescript/graphql -__INLINE(../_setup-2.md)__ - -__INLINE(../_start-graphql-server.md)__ - -__INLINE(../../_using-the-graphql-api.md)__ - -### 6. Changing the GraphQL schema - -To make changes to the GraphQL schema, you need to manipulate the `Query` and `Mutation` types that are defined in [`index.ts`](./src/index.ts). - -Note that the [`start`](./package.json#L6) script also starts a development server that automatically updates your schema every time you save a file. This way, the auto-generated [GraphQL schema](./src/generated/schema.graphql) updates whenever you make changes in to the `Query` or `Mutation` types inside your TypeScript code. - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/grpc/README.md b/.github/readmes/typescript/grpc/README.md deleted file mode 100644 index 722f85741684..000000000000 --- a/.github/readmes/typescript/grpc/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# gRPC Server Example - -This example shows how to implement a **gRPC API with TypeScript** and Prisma. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/typescript/grpc -__INLINE(../_setup-2.md)__ - -### 4. Start the gRPC server - -``` -npm run start -``` - -The server is now running on `0.0.0.0:50051`. - -### 5. Using the gRPC API - -To use the gRPC API, you need a gRPC client. We provide several client scripts inside the [`./client`](./client) directory. Each script is named according to the operation it performs against the gRPC API (e.g. the [`feed.js`](./client/feed.js) script sends the [`Feed`](./service.proto#L7) operation). Each script can be invoked by running the corresponding NPM script defined in [`package.json`](./package.json), e.g. `npm run feed`. - -In case you prefer a GUI client, we recommend [BloomRPC](https://github.com/uw-labs/bloomrpc): - -![](https://imgur.com/0EiIo03.png) - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/rest-express/README.md b/.github/readmes/typescript/rest-express/README.md deleted file mode 100644 index 0d138c9e7d6b..000000000000 --- a/.github/readmes/typescript/rest-express/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# REST API Example - -This example shows how to implement a **REST API with TypeScript** using [Express.JS](https://expressjs.com/de/) and Prisma. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/typescript/rest-express -__INLINE(../_setup-2.md)__ - -### 4. Start the REST API server - -``` -npm run start -``` - -The server is now running on `http://localhost:3000`. You can send the API requests implemented in `index.js`, e.g. [`http://localhost:3000/feed`](http://localhost:3000/feed). - -__INLINE(../../_using-the-rest-api.md)__ - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/script/README.md b/.github/readmes/typescript/script/README.md deleted file mode 100644 index 74d4c3d389aa..000000000000 --- a/.github/readmes/typescript/script/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Simple TypeScript Script Example - -This example shows how to use the Prisma client in a **simple TypeScript script** to read and write data in a database. - -__INLINE(../_setup-1.md)__ -cd prisma-examples/typescript/script -__INLINE(../_setup-2.md)__ - -### 4. Run the script - -Execute the script with this command: - -``` -npm run start -``` - -__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/renovate.json b/.github/renovate.json index 52b9e0974747..1f923479a3cd 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,11 +1,28 @@ { - "extends": [ - "config:base", - "docker:disable", - ":skipStatusChecks" - ], + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:recommended", ":disableRateLimiting", "docker:disable"], + "schedule": ["before 8am every weekday", "every weekend"], + "rebaseWhen": "conflicted", + "prConcurrentLimit": 30, "automerge": true, "major": { "automerge": false - } + }, + "rangeStrategy": "pin", + "baseBranches": ["latest"], + "reviewers": ["nikolasburk", "jharrell"], + "configMigration": true, + "packageRules": [ + { + "matchBaseBranches": ["latest"], + "matchPackageNames": ["nexus-plugin-prisma"], + "enabled": true + }, + { + "matchBaseBranches": ["latest"], + "matchPackageNames": ["prisma", "@prisma/client"], + "enabled": true, + "matchUpdateTypes": ["major"] + } + ] } diff --git a/.github/scripts/get-packages.js b/.github/scripts/get-packages.js new file mode 100644 index 000000000000..ce20f2e3c9a4 --- /dev/null +++ b/.github/scripts/get-packages.js @@ -0,0 +1,38 @@ +const glob = require('glob') +const path = require('path') + +const core = require('@actions/core') + +const getTestName = (filePath) => { + return path.dirname(filePath).split(path.sep).pop() +} + +const getBaseFolder = (filePath) => { + let pathTokens = path.dirname(filePath).split(path.sep) + pathTokens.pop() + return pathTokens.pop() +} + +async function main() { + const cwd = process.cwd() + + const files = glob + .sync('**/package.json', { + cwd: cwd, + ignore: '**/node_modules/**', + }) + .filter((file) => { + const folder = getBaseFolder(file) + const allowList = ['orm', 'databases', 'data-modeling'] + return allowList.includes(folder) + }) + .map((file) => { + const folder = getBaseFolder(file) + const test = getTestName(file) + return { path: `${folder}/${test}` } + }) + + core.setOutput('matrix', JSON.stringify({ include: files })) +} + +main() diff --git a/.github/scripts/package.json b/.github/scripts/package.json new file mode 100644 index 000000000000..56a9427eba24 --- /dev/null +++ b/.github/scripts/package.json @@ -0,0 +1,12 @@ +{ + "name": "scripts", + "version": "1.0.0", + "main": "index.js", + "license": "MIT", + "devDependencies": { + "glob": "10.4.5" + }, + "dependencies": { + "@actions/core": "1.11.1" + } +} diff --git a/.github/scripts/test-all.sh b/.github/scripts/test-all.sh new file mode 100644 index 000000000000..89936daedc96 --- /dev/null +++ b/.github/scripts/test-all.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +set -eu + +item="$1" +dir="$(pwd)" + +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "---------------------" +echo "running $item" + +case "$item" in + *".github"*|*"deployment-platforms"*|*"databases"*) + echo "ignoring $item" + exit 0 + ;; +esac + +cd "$(dirname "$item")/" + +## ACTION + +echo "+++++++++++" +echo "executing .github/tests/$(dirname "$item")/run.sh (tests)" +run_file="$dir/.github/tests/$(dirname "$item")/run.sh" + +if [ -f "$run_file" ]; then + set +e + bash "$run_file" + code=$? + set -e + + cd "$dir" + + if [ $code -ne 0 ]; then + echo "$(dirname "$item") failed" + exit $code + fi +else + echo "no test file set up for $item," + echo "please create a test shell file at $run_file" + exit 1 +fi + +## END + +echo "$item done" + +# somehow ports are still in use in GitHub actions, so kill everything here again +pkill node || true diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 93be6ab21739..000000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 45 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 10 -# Issues with these labels will never be considered stale -exemptLabels: - - status/on-hold - - status/candidate -# Label to use when marking an issue as stale -staleLabel: status/stale -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed in 10 days if no further activity occurs. - Thank you for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false -# Limit to only `issues` -only: issues diff --git a/.github/tests/README.md b/.github/tests/README.md new file mode 100644 index 000000000000..e6bfe5a5a4fd --- /dev/null +++ b/.github/tests/README.md @@ -0,0 +1,6 @@ +# Tests + +This internal directory defines test scripts for our CI. Each project gets its +own test script, but we use this hidden directory so we don't need to define it +in each public project, since users checking out our examples don't care about +that. diff --git a/.github/tests/data-modeling/delegated-types/run.sh b/.github/tests/data-modeling/delegated-types/run.sh new file mode 100644 index 000000000000..7aab6f474a72 --- /dev/null +++ b/.github/tests/data-modeling/delegated-types/run.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -eu + +npm install +npx prisma migrate dev --name init +npm run test diff --git a/.github/tests/databases/postgresql-supabase/run.sh b/.github/tests/databases/postgresql-supabase/run.sh new file mode 100644 index 000000000000..ab052ffa23e9 --- /dev/null +++ b/.github/tests/databases/postgresql-supabase/run.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# A blank script that always passes +true diff --git a/.github/tests/databases/prisma-postgres/run.sh b/.github/tests/databases/prisma-postgres/run.sh new file mode 100644 index 000000000000..8e4ebd1ca802 --- /dev/null +++ b/.github/tests/databases/prisma-postgres/run.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -euo pipefail + +# Move to Prisma project +cd ../../../.. +cd databases/prisma-postgres + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [[ "$WAITED" -ge "$MAX_WAIT" ]]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Go back to databases/prisma-postgres + +# Run migration +echo "📐 Running prisma migrate dev..." +npx prisma migrate dev --name init --skip-seed + +# Run queries (if any) +echo "🧪 Running queries..." +npm run queries || echo "ℹ️ No queries script defined." + +# Cleanup +echo "🛑 Shutting down Prisma Dev (PID $NODE_PID)..." +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/databases/sql-server/run.sh b/.github/tests/databases/sql-server/run.sh new file mode 100644 index 000000000000..ab052ffa23e9 --- /dev/null +++ b/.github/tests/databases/sql-server/run.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# A blank script that always passes +true diff --git a/.github/tests/orm/ai-sdk-nextjs/run.sh b/.github/tests/orm/ai-sdk-nextjs/run.sh new file mode 100644 index 000000000000..c284b89201bf --- /dev/null +++ b/.github/tests/orm/ai-sdk-nextjs/run.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/ai-sdk-nextjs" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null + +npm install +npx prisma migrate dev --name init --schema prisma/schema.prisma +npx prisma db seed +npm run dev & +pid=$! + +sleep 15 + +# check frontend +curl --fail 'http://localhost:3000/' + +kill "$pid" +echo "🛑 App stopped (PID $pid)" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/astro/run.sh b/.github/tests/orm/astro/run.sh new file mode 100644 index 000000000000..1f1111d69ae2 --- /dev/null +++ b/.github/tests/orm/astro/run.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/astro" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null + +npm install +npx prisma migrate dev --name init --schema prisma/schema.prisma +npm run dev & +pid=$! + +sleep 15 + +# check frontend +curl --fail 'http://localhost:4321/' + + +kill "$pid" +echo "🛑 App stopped (PID $pid)" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/authjs-nextjs/run.sh b/.github/tests/orm/authjs-nextjs/run.sh new file mode 100644 index 000000000000..21e22765a624 --- /dev/null +++ b/.github/tests/orm/authjs-nextjs/run.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/authjs-nextjs" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null + +npm install +npx prisma migrate dev --name init --schema prisma/schema.prisma +npx prisma db seed +npm run dev & +pid=$! + +sleep 15 + +# check frontend +curl --fail 'http://localhost:3000/' + +kill "$pid" +echo "🛑 App stopped (PID $pid)" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/betterauth-nextjs/run.sh b/.github/tests/orm/betterauth-nextjs/run.sh new file mode 100644 index 000000000000..8c225943cdce --- /dev/null +++ b/.github/tests/orm/betterauth-nextjs/run.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/betterauth-nextjs" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null + +npm install +npx prisma migrate dev --name init --schema prisma/schema.prisma +npx prisma db seed +npm run dev & +pid=$! + +sleep 15 + +# check frontend +curl --fail 'http://localhost:3000/' + +kill "$pid" +echo "🛑 App stopped (PID $pid)" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/clerk-nextjs/run.sh b/.github/tests/orm/clerk-nextjs/run.sh new file mode 100644 index 000000000000..c01289666f19 --- /dev/null +++ b/.github/tests/orm/clerk-nextjs/run.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/clerk-nextjs" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null + +npm install +npx prisma migrate dev --name init +npm run dev & +pid=$! + +sleep 15 + +# check frontend +curl --fail 'http://localhost:3000/' + +kill "$pid" +echo "🛑 App stopped (PID $pid)" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/express/run.sh b/.github/tests/orm/express/run.sh new file mode 100755 index 000000000000..1ac18f61645a --- /dev/null +++ b/.github/tests/orm/express/run.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/express" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to databases/prisma-postgres + +# Run migrations + seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +npm run dev & +pid=$! + +sleep 20 + +# Run Postman tests (relative to where the script was originally called) +npx newman run "$REPO_ROOT/.github/tests/postman_collections/rest.json" --bail + + +kill "$pid" +echo "🛑 App stopped (PID $pid)" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/fastify-graphql-sdl-first/run.sh b/.github/tests/orm/fastify-graphql-sdl-first/run.sh new file mode 100644 index 000000000000..bf5c405993a9 --- /dev/null +++ b/.github/tests/orm/fastify-graphql-sdl-first/run.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for fastify-graphql-sdl-first..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/fastify-graphql-sdl-first" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/fastify-graphql-sdl-first + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +npm run dev & +pid=$! + +sleep 20 + +# Run GraphQL Postman collection +echo "🧪 Running Postman tests..." +npx newman run "$REPO_ROOT/.github/tests/postman_collections/graphql-hapi.json" --bail + +# Cleanup +echo "🛑 Shutting down app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/fastify-graphql/run.sh b/.github/tests/orm/fastify-graphql/run.sh new file mode 100644 index 000000000000..97b81285598f --- /dev/null +++ b/.github/tests/orm/fastify-graphql/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for fastify-graphql..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/fastify-graphql" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/fastify-graphql + +# Run migrations and seed +npx prisma migrate reset --force --skip-seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +npm run dev & +pid=$! + +sleep 20 + +# Run GraphQL Postman tests +echo "🧪 Running Postman tests..." +npx newman run "$REPO_ROOT/.github/tests/postman_collections/graphql-hapi.json" --bail + +# Cleanup +echo "🛑 Shutting down app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/fastify/run.sh b/.github/tests/orm/fastify/run.sh new file mode 100644 index 000000000000..ce97da683288 --- /dev/null +++ b/.github/tests/orm/fastify/run.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for fastify..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/fastify" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/fastify + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +npm run dev & +pid=$! + +sleep 20 + +# Run REST Postman tests +echo "🧪 Running Postman tests..." +npx newman run "$REPO_ROOT/.github/tests/postman_collections/rest.json" --bail + +# Cleanup +echo "🛑 Shutting down app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/graphql-auth/run.sh b/.github/tests/orm/graphql-auth/run.sh new file mode 100644 index 000000000000..153290cf1432 --- /dev/null +++ b/.github/tests/orm/graphql-auth/run.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for graphql-auth..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/graphql-auth" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/graphql-auth + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +npm run dev & +pid=$! + +sleep 15 + +# Test GraphQL endpoint +echo "🧪 Testing GraphQL API..." +curl --fail 'http://localhost:4000/' \ + -H 'Accept-Encoding: gzip, deflate, br' \ + -H 'Content-Type: application/json' \ + -H 'Accept: application/json' \ + -H 'Connection: keep-alive' \ + -H 'DNT: 1' \ + -H 'Origin: http://localhost:4000' \ + --data-binary '{"query":"query {\n feed {\n id\n content\n author {\n id\n name\n email\n }\n }\n}"}' \ + --compressed + +# Cleanup +echo "🛑 Shutting down app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/graphql-nexus/run.sh b/.github/tests/orm/graphql-nexus/run.sh new file mode 100644 index 000000000000..5942d32c008a --- /dev/null +++ b/.github/tests/orm/graphql-nexus/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for graphql-nexus..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/graphql-nexus" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/graphql-nexus + +# Run migrations and seed +npx prisma migrate reset --force --skip-seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +npm run dev & +pid=$! + +sleep 20 + +# Run GraphQL Newman test +echo "🧪 Running Newman tests..." +npx newman run ../../.github/tests/postman_collections/graphql.json --bail --verbose + +# Cleanup +echo "🛑 Shutting down app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/graphql-sdl-first/run.sh b/.github/tests/orm/graphql-sdl-first/run.sh new file mode 100644 index 000000000000..24eda9d645eb --- /dev/null +++ b/.github/tests/orm/graphql-sdl-first/run.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for graphql-sdl-first..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/graphql-sdl-first" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/graphql-sdl-first + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +npm run dev & +pid=$! + +sleep 20 + +# Run GraphQL Newman test +echo "🧪 Running Newman tests..." +npx newman run ../../.github/tests/postman_collections/graphql.json --bail + +# Cleanup +echo "🛑 Shutting down app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/graphql-subscriptions/run.sh b/.github/tests/orm/graphql-subscriptions/run.sh new file mode 100644 index 000000000000..4d00d09639d9 --- /dev/null +++ b/.github/tests/orm/graphql-subscriptions/run.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for graphql-subscriptions..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/graphql-subscriptions" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/graphql-subscriptions + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the GraphQL subscriptions server +echo "🚀 Starting app..." +npm run dev & +pid=$! + +sleep 15 + +# Run test query +echo "🔎 Running sample GraphQL query..." +curl --fail 'http://localhost:4000/graphql' \ + -H 'Accept-Encoding: gzip, deflate, br' \ + -H 'Content-Type: application/json' \ + -H 'Accept: application/json' \ + -H 'Connection: keep-alive' \ + -H 'DNT: 1' \ + -H 'Origin: http://localhost:4000' \ + --data-binary '{"query":"query {\n feed {\n id\n title\n content\n }\n}"}' \ + --compressed + +# Cleanup +echo "🛑 Shutting down app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/graphql/run.sh b/.github/tests/orm/graphql/run.sh new file mode 100644 index 000000000000..df45db90b3d9 --- /dev/null +++ b/.github/tests/orm/graphql/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for graphql..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/graphql" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/graphql + +# Run migrations and seed +npx prisma migrate reset --force --skip-seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +npm run dev & +pid=$! + +sleep 20 + +# Run GraphQL Postman collection +echo "🧪 Running Postman tests..." +npx newman run "$REPO_ROOT/.github/tests/postman_collections/graphql.json" --bail + +# Cleanup +echo "🛑 Shutting down app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/grpc/run.sh b/.github/tests/orm/grpc/run.sh new file mode 100644 index 000000000000..2c7475d63d77 --- /dev/null +++ b/.github/tests/orm/grpc/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for grpc..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/grpc" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/grpc + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the gRPC app +echo "🚀 Starting gRPC app..." +npm run dev & +pid=$! + +sleep 10 + +# Trigger gRPC query logic (e.g. feeding test data) +echo "🧪 Running feed task..." +npm run feed + +# Cleanup +echo "🛑 Shutting down gRPC app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/hapi-graphql-sdl-first/run.sh b/.github/tests/orm/hapi-graphql-sdl-first/run.sh new file mode 100644 index 000000000000..88e94af66f6b --- /dev/null +++ b/.github/tests/orm/hapi-graphql-sdl-first/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for hapi-graphql-sdl-first..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/hapi-graphql-sdl-first" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/hapi-graphql-sdl-first + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +echo "🚀 Starting Hapi GraphQL app..." +npm run dev & +pid=$! + +sleep 20 + +# Run Postman test +echo "🧪 Running Newman test for GraphQL Hapi..." +npx newman run "$REPO_ROOT/.github/tests/postman_collections/graphql-hapi.json" --bail + +# Cleanup +echo "🛑 Shutting down Hapi app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/hapi-graphql/run.sh b/.github/tests/orm/hapi-graphql/run.sh new file mode 100644 index 000000000000..1cf3ba81cb58 --- /dev/null +++ b/.github/tests/orm/hapi-graphql/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for hapi-graphql..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/hapi-graphql" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/hapi-graphql + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +echo "🚀 Starting Hapi GraphQL app..." +npm run dev & +pid=$! + +sleep 20 + +# Run Postman test +echo "🧪 Running Newman test for GraphQL Hapi..." +npx newman run "$REPO_ROOT/.github/tests/postman_collections/graphql-hapi.json" --bail + +# Cleanup +echo "🛑 Shutting down Hapi app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/hapi/run.sh b/.github/tests/orm/hapi/run.sh new file mode 100644 index 000000000000..f0b734f5fc30 --- /dev/null +++ b/.github/tests/orm/hapi/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for hapi..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/hapi" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/hapi + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +echo "🚀 Starting Hapi app..." +npm run dev & +pid=$! + +sleep 20 + +# Run REST tests via Postman +echo "🧪 Running Newman test for REST API..." +npx newman run "$REPO_ROOT/.github/tests/postman_collections/rest.json" --bail + +# Cleanup +echo "🛑 Shutting down Hapi app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/hono/run.sh b/.github/tests/orm/hono/run.sh new file mode 100644 index 000000000000..7d10e7676f8d --- /dev/null +++ b/.github/tests/orm/hono/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for hono..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/hono" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/hono + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +echo "🚀 Starting Hono app..." +npm run dev & +pid=$! + +sleep 15 + +# Check frontend +echo "🔎 Verifying root frontend route..." +curl --fail 'http://localhost:3000/' + +# Cleanup +echo "🛑 Shutting down Hono app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/koa/run.sh b/.github/tests/orm/koa/run.sh new file mode 100644 index 000000000000..8f4103b0b8a2 --- /dev/null +++ b/.github/tests/orm/koa/run.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for koa..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/koa" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/koa + +# Run migrations and seed +npx prisma migrate reset --force --skip-seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +echo "🚀 Starting Koa app..." +npm run dev & +pid=$! + +sleep 20 + +# Run Postman test +echo "🧪 Running Newman test for REST Koa..." +npx newman run "$REPO_ROOT/.github/tests/postman_collections/rest.json" --bail + +# Cleanup +echo "🛑 Shutting down Koa app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/nest-graphql-sdl-first/run.sh b/.github/tests/orm/nest-graphql-sdl-first/run.sh new file mode 100644 index 000000000000..38f301ab0c63 --- /dev/null +++ b/.github/tests/orm/nest-graphql-sdl-first/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for nest-graphql-sdl-first..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/nest-graphql-sdl-first" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/nest-graphql-sdl-first + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +echo "🚀 Starting NestJS GraphQL app..." +npm run dev & +pid=$! + +sleep 20 + +# Run Postman GraphQL test +echo "🧪 Running Newman test for NestJS GraphQL..." +npx newman run "$REPO_ROOT/.github/tests/postman_collections/graphql-nestjs.json" --bail + +# Cleanup +echo "🛑 Shutting down NestJS app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/nest-graphql/run.sh b/.github/tests/orm/nest-graphql/run.sh new file mode 100644 index 000000000000..2273f55d3d48 --- /dev/null +++ b/.github/tests/orm/nest-graphql/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for nest-graphql..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/nest-graphql" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/nest-graphql + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +echo "🚀 Starting NestJS GraphQL app..." +npm run dev & +pid=$! + +sleep 20 + +# Run Postman test +echo "🧪 Running Newman test for NestJS GraphQL..." +npx newman run "$REPO_ROOT/.github/tests/postman_collections/graphql-nestjs.json" --bail + +# Cleanup +echo "🛑 Shutting down NestJS app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/nest/run.sh b/.github/tests/orm/nest/run.sh new file mode 100644 index 000000000000..1767486756cf --- /dev/null +++ b/.github/tests/orm/nest/run.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for nest..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/nest" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/nest + +# Run migrations and seed +npx prisma migrate reset --force --skip-seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +echo "🚀 Starting NestJS app..." +npm run dev & +pid=$! + +sleep 20 + +# Run Postman test +echo "🧪 Running Newman test for REST NestJS..." +npx newman run "$REPO_ROOT/.github/tests/postman_collections/rest.json" --bail + +# Cleanup +echo "🛑 Shutting down NestJS app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/nextjs-graphql/run.sh b/.github/tests/orm/nextjs-graphql/run.sh new file mode 100644 index 000000000000..8a4aaba08b3a --- /dev/null +++ b/.github/tests/orm/nextjs-graphql/run.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for nextjs-graphql..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/nextjs-graphql" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/nextjs-graphql + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +echo "🚀 Starting Next.js app..." +npm run dev & +pid=$! + +sleep 15 + +# Check GraphQL API +echo "🔎 Verifying /api/graphql endpoint..." +curl --fail 'http://localhost:3000/api/graphql' \ + -H 'Accept-Encoding: gzip, deflate, br' \ + -H 'Content-Type: application/json' \ + -H 'Accept: application/json' \ + -H 'Connection: keep-alive' \ + -H 'DNT: 1' \ + -H 'Origin: http://localhost:4000' \ + --data-binary '{"query":"query {\n feed {\n id\n content\n author {\n id\n name\n email\n }\n }\n}"}' \ + --compressed + +# Check frontend +echo "🔎 Verifying root frontend route..." +curl --fail 'http://localhost:3000/' + +# Cleanup +echo "🛑 Shutting down Next.js app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/nextjs-trpc/run.sh b/.github/tests/orm/nextjs-trpc/run.sh new file mode 100644 index 000000000000..159c0d53a754 --- /dev/null +++ b/.github/tests/orm/nextjs-trpc/run.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for nextjs-trpc..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/nextjs-trpc" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install --legacy-peer-deps + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null + +# Run migrations +npx prisma migrate dev --name init + +# Start the app +echo "🚀 Starting Next.js app..." +npm run dev & +pid=$! + +sleep 15 + +# Check frontend (Next defaults to port 3000) +echo "🔎 Verifying root frontend route..." +curl --fail 'http://localhost:3000/' + +# Cleanup +echo "🛑 Shutting down Next.js app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true + + diff --git a/.github/tests/orm/nextjs/run.sh b/.github/tests/orm/nextjs/run.sh new file mode 100644 index 000000000000..cf632322516e --- /dev/null +++ b/.github/tests/orm/nextjs/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for nextjs..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/nextjs" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/nextjs + +# Run migrations and seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +echo "🚀 Starting Next.js app..." +npm run dev & +pid=$! + +sleep 15 + +# Check frontend +echo "🔎 Verifying root frontend route..." +curl --fail 'http://localhost:3000/' + +# Cleanup +echo "🛑 Shutting down Next.js app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/nuxt-prisma-module/run.sh b/.github/tests/orm/nuxt-prisma-module/run.sh new file mode 100644 index 000000000000..d1e6d88a2695 --- /dev/null +++ b/.github/tests/orm/nuxt-prisma-module/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# This script simply returns true +exit 0 diff --git a/.github/tests/orm/nuxt/run.sh b/.github/tests/orm/nuxt/run.sh new file mode 100644 index 000000000000..ae5fbe2f90d5 --- /dev/null +++ b/.github/tests/orm/nuxt/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for nuxt..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/nuxt" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/nuxt + +# Run migration + seed +npx prisma migrate dev --name init +npx prisma db seed + +# Start the app +echo "🧪 Starting Nuxt app..." +npm run dev & +pid=$! + +sleep 15 + +# Check frontend +echo "🔎 Checking http://localhost:3000/" +curl --fail 'http://localhost:3000/' + +# Cleanup +echo "🛑 Shutting down Nuxt app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/postgis-express/run.sh b/.github/tests/orm/postgis-express/run.sh new file mode 100644 index 000000000000..1ef02f838dce --- /dev/null +++ b/.github/tests/orm/postgis-express/run.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -eu + +npm install && npm run test diff --git a/.github/tests/orm/prisma-mocking-javascript/run.sh b/.github/tests/orm/prisma-mocking-javascript/run.sh new file mode 100644 index 000000000000..c0474751b08c --- /dev/null +++ b/.github/tests/orm/prisma-mocking-javascript/run.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -eu + +npm install +npx prisma generate + +npm run test diff --git a/.github/tests/orm/react-router-7/run.sh b/.github/tests/orm/react-router-7/run.sh new file mode 100644 index 000000000000..087721f9043f --- /dev/null +++ b/.github/tests/orm/react-router-7/run.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for react-router-7..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/react-router-7" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/react-router-7 + +# Run migrations and seed +echo "📐 Running Prisma migrations and seeding..." +DATABASE_URL="$DATABASE_URL" npx prisma migrate reset --force --skip-seed +DATABASE_URL="$DATABASE_URL" npx prisma migrate dev --name init +DATABASE_URL="$DATABASE_URL" npx prisma db seed + +# Start the app +echo "🚀 Starting the React Router 7 app..." +npm run dev & +pid=$! + +# Wait for server +sleep 15 + +# Test frontend +echo "🧪 Checking frontend response..." +curl --fail 'http://localhost:5173/' + +# Cleanup +echo "🛑 Shutting down React Router app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/script/run.sh b/.github/tests/orm/script/run.sh new file mode 100644 index 000000000000..73762b826565 --- /dev/null +++ b/.github/tests/orm/script/run.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for script..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/script" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/script + +# Run migrations (reset and dev) +npx prisma migrate dev --name init + +# Run script (assumes it terminates; remove `&` if it blocks) +npm run dev + +# Cleanup Prisma Dev server +echo "🛑 Shutting down Prisma Dev (PID $NODE_PID)..." +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/solid-start/run.sh b/.github/tests/orm/solid-start/run.sh new file mode 100644 index 000000000000..2a152354c85f --- /dev/null +++ b/.github/tests/orm/solid-start/run.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for solid-start..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/solid-start" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/solid-start + +# Run migrations +npx prisma migrate dev --name init + +# Start the app +echo "🧪 Starting app..." +npm run dev & +pid=$! + +sleep 15 + +# Check frontend +echo "🔎 Checking http://localhost:3000/" +curl --fail 'http://localhost:3000/' + +# Cleanup +echo "🛑 Shutting down app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/starter/run.sh b/.github/tests/orm/starter/run.sh new file mode 100644 index 000000000000..47eca0c26905 --- /dev/null +++ b/.github/tests/orm/starter/run.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -eu + +npm install +npm run build diff --git a/.github/tests/orm/sveltekit/run.sh b/.github/tests/orm/sveltekit/run.sh new file mode 100644 index 000000000000..60043b80d814 --- /dev/null +++ b/.github/tests/orm/sveltekit/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for sveltekit..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/sveltekit" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/sveltekit + +# Run migrations + seed +npx prisma migrate dev --name init --schema prisma/schema.prisma +npx prisma db seed + +# Start the app +echo "🧪 Starting app..." +npm run dev & +pid=$! + +sleep 15 + +# Check frontend +echo "🔎 Checking http://localhost:5173/" +curl --fail 'http://localhost:5173/' + +# Cleanup +echo "🛑 Shutting down app (PID $pid) and Prisma Dev (PID $NODE_PID)..." +kill "$pid" +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/testing-express/run.sh b/.github/tests/orm/testing-express/run.sh new file mode 100644 index 000000000000..11ff07d97770 --- /dev/null +++ b/.github/tests/orm/testing-express/run.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +set -eu + +echo "🔍 Starting test setup for testing-express..." + +echo "📂 Current working directory before REPO_ROOT: $(pwd)" +echo "📁 Listing contents:" +ls -la + +REPO_ROOT="$(git rev-parse --show-toplevel)" +echo "📌 Detected repo root: $REPO_ROOT" + +cd "$REPO_ROOT/orm/testing-express" +echo "📂 Changed directory to: $(pwd)" + +echo "📦 Installing test deps..." +npm install + +# Go to Node script dir and install its deps +NODE_SCRIPT_DIR="../../.github/get-ppg-dev" +pushd "$NODE_SCRIPT_DIR" > /dev/null +npm install + +# Start Prisma Dev server +LOG_FILE="./ppg-dev-url.log" +rm -f "$LOG_FILE" +touch "$LOG_FILE" + +echo "🚀 Starting Prisma Dev in background..." +node index.js >"$LOG_FILE" & +NODE_PID=$! + +# Wait for DATABASE_URL +echo "🔎 Waiting for Prisma Dev to emit DATABASE_URL..." +MAX_WAIT=60 +WAITED=0 +until grep -q '^prisma+postgres://' "$LOG_FILE"; do + sleep 1 + WAITED=$((WAITED + 1)) + if [ "$WAITED" -ge "$MAX_WAIT" ]; then + echo "❌ Timeout waiting for DATABASE_URL" + cat "$LOG_FILE" + kill "$NODE_PID" || true + exit 1 + fi +done + +DB_URL=$(grep '^prisma+postgres://' "$LOG_FILE" | tail -1) +export DATABASE_URL="$DB_URL" +echo "✅ DATABASE_URL: $DATABASE_URL" + +popd > /dev/null # Back to orm/testing-express + +# Run migrations + seed +npx prisma migrate dev --name init +npx prisma db seed + +# Run test suite +echo "🧪 Running tests..." +npm run test + +# Cleanup +echo "🛑 Shutting down Prisma Dev (PID $NODE_PID)..." +kill "$NODE_PID" +wait "$NODE_PID" || true diff --git a/.github/tests/orm/typedsql/run.sh b/.github/tests/orm/typedsql/run.sh new file mode 100644 index 000000000000..15a976e00e3b --- /dev/null +++ b/.github/tests/orm/typedsql/run.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -eu + +npm install +npx prisma migrate dev --name init +npx prisma generate --sql +npm run test diff --git a/.github/tests/package.json b/.github/tests/package.json deleted file mode 100644 index 63f5781aed28..000000000000 --- a/.github/tests/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "prisma-examples", - "version": "1.0.0", - "repository": "git@github.com:prisma/prisma-examples.git", - "license": "MIT", - "scripts": { - "test": "yarn prettier-check && yarn build-readmes", - "build-readmes": "inline-markdown --input ../readmes --output ../..", - "prettier-check": "prettier-check --config .prettierrc \"../../{node,flow,typescript}/*/{src,test,prisma}/**/*.{ts,js}\"", - "prettier-fix": "prettier --config .prettierrc --write \"../../{node,flow,typescript}/*/{src,test,prisma}/**/*.{ts,js}\"" - }, - "devDependencies": { - "inline-markdown": "0.1.6", - "prettier": "1.16.4", - "prettier-check": "2.0.0" - } -} diff --git a/.github/tests/postman_collections/graphql-hapi.json b/.github/tests/postman_collections/graphql-hapi.json new file mode 100644 index 000000000000..61215675449a --- /dev/null +++ b/.github/tests/postman_collections/graphql-hapi.json @@ -0,0 +1,564 @@ +{ + "info": { + "_postman_id": "ce5cf911-9948-44ef-8a34-b00b90c1cba6", + "name": "prisma-examples-graphql-hapi", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "users", + "item": [ + { + "name": "signup", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const signupUser = {\r", + " \"data\": {\r", + " \"signupUser\": {\r", + " \"id\": 4\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(signupUser);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n signupUser(data: { name: \"Sarah\", email: \"sarah@prisma.io\" }) {\r\n id\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000/graphql", + "host": ["localhost"], + "port": "4000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "createDraft", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const draft = {\r", + " \"data\": {\r", + " \"createDraft\": {\r", + " \"id\": 5,\r", + " \"viewCount\": 0,\r", + " \"published\": false,\r", + " \"author\": {\r", + " \"id\": 1,\r", + " \"name\": \"Alice\"\r", + " }\r", + " }\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(draft);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n createDraft(\r\n data: { title: \"Join the Prisma Discord\", content: \"https://pris.ly/discord/" }\r\n authorEmail: \"alice@prisma.io\"\r\n ) {\r\n id\r\n viewCount\r\n published\r\n author {\r\n id\r\n name\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000/graphql", + "host": ["localhost"], + "port": "4000", + "path": ["graphql"] + } + }, + "response": [] + } + ] + }, + { + "name": "posts", + "item": [ + { + "name": "feed", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": 1,\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": 1,\r", + " \"name\": \"Alice\",\r", + " \"email\": \"alice@prisma.io\"\r", + " }\r", + " },\r", + " {\r", + " \"id\": 2,\r", + " \"title\": \"Follow Prisma on Twitter\",\r", + " \"content\": \"https://www.twitter.com/prisma/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": 2,\r", + " \"name\": \"Nilu\",\r", + " \"email\": \"nilu@prisma.io\"\r", + " }\r", + " },\r", + " {\r", + " \"id\": 3,\r", + " \"title\": \"Ask a question about Prisma on GitHub\",\r", + " \"content\": \"https://www.github.com/prisma/prisma/discussions/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": 3,\r", + " \"name\": \"Mahmoud\",\r", + " \"email\": \"mahmoud@prisma.io\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query {\r\n feed {\r\n id\r\n title\r\n content\r\n published\r\n author {\r\n id\r\n name\r\n email\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000/graphql", + "host": ["localhost"], + "port": "4000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "feed-searchString", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": 1,\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true\r", + " },\r", + " {\r", + " \"id\": 2,\r", + " \"title\": \"Follow Prisma on Twitter\",\r", + " \"content\": \"https://www.twitter.com/prisma/",\r", + " \"published\": true\r", + " },\r", + " {\r", + " \"id\": 3,\r", + " \"title\": \"Ask a question about Prisma on GitHub\",\r", + " \"content\": \"https://www.github.com/prisma/prisma/discussions/",\r", + " \"published\": true\r", + " }\r", + " ]\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n feed(\r\n searchString: \"Prisma\"\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000/graphql", + "host": ["localhost"], + "port": "4000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "feed-pagination_order", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": 1,\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true\r", + " }\r", + " ]\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n feed(\r\n skip: 2\r\n take: 2\r\n orderBy: { updatedAt: desc }\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000/graphql", + "host": ["localhost"], + "port": "4000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "postById", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"postById\": {\r", + " \"id\": 4,\r", + " \"title\": \"Prisma on YouTube\",\r", + " \"content\": \"https://pris.ly/youtube/",\r", + " \"published\": false\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n postById(id: 4) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000/graphql", + "host": ["localhost"], + "port": "4000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "draftsByUser", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const draftsByUser = {\r", + " \"data\": {\r", + " \"draftsByUser\": [\r", + " {\r", + " \"id\": 4,\r", + " \"title\": \"Prisma on YouTube\",\r", + " \"content\": \"https://pris.ly/youtube/",\r", + " \"published\": false,\r", + " \"author\": {\r", + " \"id\": 3,\r", + " \"name\": \"Mahmoud\",\r", + " \"email\": \"mahmoud@prisma.io\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(draftsByUser);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n draftsByUser(\r\n userUniqueInput: {\r\n email: \"mahmoud@prisma.io\"\r\n }\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n author {\r\n id\r\n name\r\n email\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000/graphql", + "host": ["localhost"], + "port": "4000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "togglePublishPost", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"togglePublishPost\": {\r", + " \"id\": 5,\r", + " \"published\": true\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n togglePublishPost(id: 5) {\r\n id\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000/graphql", + "host": ["localhost"], + "port": "4000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "incrementPostViewCount", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"incrementPostViewCount\": {\r", + " \"id\": 5,\r", + " \"viewCount\": 1\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n incrementPostViewCount(id: 5) {\r\n id\r\n viewCount\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000/graphql", + "host": ["localhost"], + "port": "4000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "deletePost", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"deletePost\": {\r", + " \"id\": 5\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n deletePost(id: 5) {\r\n id\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000/graphql", + "host": ["localhost"], + "port": "4000", + "path": ["graphql"] + } + }, + "response": [] + } + ] + } + ] +} diff --git a/.github/tests/postman_collections/graphql-nestjs.json b/.github/tests/postman_collections/graphql-nestjs.json new file mode 100644 index 000000000000..8e3ffcafc078 --- /dev/null +++ b/.github/tests/postman_collections/graphql-nestjs.json @@ -0,0 +1,564 @@ +{ + "info": { + "_postman_id": "f321f81e-ceea-46a9-82a5-16cb5119f671", + "name": "prisma-examples-graphql-nestjs", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "users", + "item": [ + { + "name": "signup", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const signupUser = {\r", + " \"data\": {\r", + " \"signupUser\": {\r", + " \"id\": 4\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(signupUser);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n signupUser(data: { name: \"Sarah\", email: \"sarah@prisma.io\" }) {\r\n id\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:3000/graphql", + "host": ["localhost"], + "port": "3000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "createDraft", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const draft = {\r", + " \"data\": {\r", + " \"createDraft\": {\r", + " \"id\": 5,\r", + " \"viewCount\": 0,\r", + " \"published\": false,\r", + " \"author\": {\r", + " \"id\": 1,\r", + " \"name\": \"Alice\"\r", + " }\r", + " }\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(draft);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n createDraft(\r\n data: { title: \"Join the Prisma Discord\", content: \"https://pris.ly/discord/" }\r\n authorEmail: \"alice@prisma.io\"\r\n ) {\r\n id\r\n viewCount\r\n published\r\n author {\r\n id\r\n name\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:3000/graphql", + "host": ["localhost"], + "port": "3000", + "path": ["graphql"] + } + }, + "response": [] + } + ] + }, + { + "name": "posts", + "item": [ + { + "name": "feed", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": 1,\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": 1,\r", + " \"name\": \"Alice\",\r", + " \"email\": \"alice@prisma.io\"\r", + " }\r", + " },\r", + " {\r", + " \"id\": 2,\r", + " \"title\": \"Follow Prisma on Twitter\",\r", + " \"content\": \"https://www.twitter.com/prisma/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": 2,\r", + " \"name\": \"Nilu\",\r", + " \"email\": \"nilu@prisma.io\"\r", + " }\r", + " },\r", + " {\r", + " \"id\": 3,\r", + " \"title\": \"Ask a question about Prisma on GitHub\",\r", + " \"content\": \"https://www.github.com/prisma/prisma/discussions/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": 3,\r", + " \"name\": \"Mahmoud\",\r", + " \"email\": \"mahmoud@prisma.io\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query {\r\n feed {\r\n id\r\n title\r\n content\r\n published\r\n author {\r\n id\r\n name\r\n email\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:3000/graphql", + "host": ["localhost"], + "port": "3000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "feed-searchString", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": 1,\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true\r", + " },\r", + " {\r", + " \"id\": 2,\r", + " \"title\": \"Follow Prisma on Twitter\",\r", + " \"content\": \"https://www.twitter.com/prisma/",\r", + " \"published\": true\r", + " },\r", + " {\r", + " \"id\": 3,\r", + " \"title\": \"Ask a question about Prisma on GitHub\",\r", + " \"content\": \"https://www.github.com/prisma/prisma/discussions/",\r", + " \"published\": true\r", + " }\r", + " ]\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n feed(\r\n searchString: \"Prisma\"\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:3000/graphql", + "host": ["localhost"], + "port": "3000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "feed-pagination_order", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": 1,\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true\r", + " }\r", + " ]\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n feed(\r\n skip: 2\r\n take: 2\r\n orderBy: { updatedAt: desc }\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:3000/graphql", + "host": ["localhost"], + "port": "3000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "postById", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"postById\": {\r", + " \"id\": 4,\r", + " \"title\": \"Prisma on YouTube\",\r", + " \"content\": \"https://pris.ly/youtube/",\r", + " \"published\": false\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n postById(id: 4) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:3000/graphql", + "host": ["localhost"], + "port": "3000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "draftsByUser", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const draftsByUser = {\r", + " \"data\": {\r", + " \"draftsByUser\": [\r", + " {\r", + " \"id\": 4,\r", + " \"title\": \"Prisma on YouTube\",\r", + " \"content\": \"https://pris.ly/youtube/",\r", + " \"published\": false,\r", + " \"author\": {\r", + " \"id\": 3,\r", + " \"name\": \"Mahmoud\",\r", + " \"email\": \"mahmoud@prisma.io\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(draftsByUser);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n draftsByUser(\r\n userUniqueInput: {\r\n email: \"mahmoud@prisma.io\"\r\n }\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n author {\r\n id\r\n name\r\n email\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:3000/graphql", + "host": ["localhost"], + "port": "3000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "togglePublishPost", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"togglePublishPost\": {\r", + " \"id\": 5,\r", + " \"published\": true\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n togglePublishPost(id: 5) {\r\n id\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:3000/graphql", + "host": ["localhost"], + "port": "3000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "incrementPostViewCount", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"incrementPostViewCount\": {\r", + " \"id\": 5,\r", + " \"viewCount\": 1\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n incrementPostViewCount(id: 5) {\r\n id\r\n viewCount\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:3000/graphql", + "host": ["localhost"], + "port": "3000", + "path": ["graphql"] + } + }, + "response": [] + }, + { + "name": "deletePost", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"deletePost\": {\r", + " \"id\": 5\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n deletePost(id: 5) {\r\n id\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:3000/graphql", + "host": ["localhost"], + "port": "3000", + "path": ["graphql"] + } + }, + "response": [] + } + ] + } + ] +} diff --git a/.github/tests/postman_collections/graphql-typegraphql.json b/.github/tests/postman_collections/graphql-typegraphql.json new file mode 100644 index 000000000000..4118d85840b0 --- /dev/null +++ b/.github/tests/postman_collections/graphql-typegraphql.json @@ -0,0 +1,554 @@ +{ + "info": { + "_postman_id": "a2666eb5-efb3-45b4-8064-8b57823aed94", + "name": "prisma-examples-graphql-typegraphql", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "users", + "item": [ + { + "name": "signup", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const signupUser = {\r", + " \"data\": {\r", + " \"signupUser\": {\r", + " \"id\": \"4\"\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(signupUser);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n signupUser(data: { name: \"Sarah\", email: \"sarah@prisma.io\" }) {\r\n id\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "createDraft", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const draft = {\r", + " \"data\": {\r", + " \"createDraft\": {\r", + " \"id\": \"5\",\r", + " \"viewCount\": 0,\r", + " \"published\": false,\r", + " \"author\": {\r", + " \"id\": \"1\",\r", + " \"name\": \"Alice\"\r", + " }\r", + " }\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(draft);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n createDraft(\r\n data: { title: \"Join the Prisma Discord\", content: \"https://pris.ly/discord/" }\r\n authorEmail: \"alice@prisma.io\"\r\n ) {\r\n id\r\n viewCount\r\n published\r\n author {\r\n id\r\n name\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + } + ] + }, + { + "name": "posts", + "item": [ + { + "name": "feed", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": \"1\",\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": \"1\",\r", + " \"name\": \"Alice\",\r", + " \"email\": \"alice@prisma.io\"\r", + " }\r", + " },\r", + " {\r", + " \"id\": \"2\",\r", + " \"title\": \"Follow Prisma on Twitter\",\r", + " \"content\": \"https://www.twitter.com/prisma/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": \"2\",\r", + " \"name\": \"Nilu\",\r", + " \"email\": \"nilu@prisma.io\"\r", + " }\r", + " },\r", + " {\r", + " \"id\": \"3\",\r", + " \"title\": \"Ask a question about Prisma on GitHub\",\r", + " \"content\": \"https://www.github.com/prisma/prisma/discussions/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": \"3\",\r", + " \"name\": \"Mahmoud\",\r", + " \"email\": \"mahmoud@prisma.io\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query {\r\n feed {\r\n id\r\n title\r\n content\r\n published\r\n author {\r\n id\r\n name\r\n email\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "feed-searchString", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": \"1\",\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true\r", + " },\r", + " {\r", + " \"id\": \"2\",\r", + " \"title\": \"Follow Prisma on Twitter\",\r", + " \"content\": \"https://www.twitter.com/prisma/",\r", + " \"published\": true\r", + " },\r", + " {\r", + " \"id\": \"3\",\r", + " \"title\": \"Ask a question about Prisma on GitHub\",\r", + " \"content\": \"https://www.github.com/prisma/prisma/discussions/",\r", + " \"published\": true\r", + " }\r", + " ]\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n feed(\r\n searchString: \"Prisma\"\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "feed-pagination_order", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": \"1\",\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true\r", + " }\r", + " ]\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n feed(\r\n skip: 2\r\n take: 2\r\n orderBy: { updatedAt: desc }\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "postById", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"postById\": {\r", + " \"id\": \"4\",\r", + " \"title\": \"Prisma on YouTube\",\r", + " \"content\": \"https://pris.ly/youtube/",\r", + " \"published\": false\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n postById(id: 4) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "draftsByUser", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const draftsByUser = {\r", + " \"data\": {\r", + " \"draftsByUser\": [\r", + " {\r", + " \"id\": \"4\",\r", + " \"title\": \"Prisma on YouTube\",\r", + " \"content\": \"https://pris.ly/youtube/",\r", + " \"published\": false,\r", + " \"author\": {\r", + " \"id\": \"3\",\r", + " \"name\": \"Mahmoud\",\r", + " \"email\": \"mahmoud@prisma.io\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(draftsByUser);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n draftsByUser(\r\n userUniqueInput: {\r\n email: \"mahmoud@prisma.io\"\r\n }\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n author {\r\n id\r\n name\r\n email\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "togglePublishPost", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"togglePublishPost\": {\r", + " \"id\": \"5\",\r", + " \"published\": true\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n togglePublishPost(id: 5) {\r\n id\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "incrementPostViewCount", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"incrementPostViewCount\": {\r", + " \"id\": \"5\",\r", + " \"viewCount\": 1\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n incrementPostViewCount(id: 5) {\r\n id\r\n viewCount\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "deletePost", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"deletePost\": {\r", + " \"id\": \"5\"\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n deletePost(id: 5) {\r\n id\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + } + ] + } + ] +} diff --git a/.github/tests/postman_collections/graphql.json b/.github/tests/postman_collections/graphql.json new file mode 100644 index 000000000000..3fc74ed20966 --- /dev/null +++ b/.github/tests/postman_collections/graphql.json @@ -0,0 +1,554 @@ +{ + "info": { + "_postman_id": "2ebc4c96-bff0-4d4a-a0c0-d2ada09847a1", + "name": "prisma-examples-graphql", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "users", + "item": [ + { + "name": "signup", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const signupUser = {\r", + " \"data\": {\r", + " \"signupUser\": {\r", + " \"id\": 4\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(signupUser);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n signupUser(data: { name: \"Sarah\", email: \"sarah@prisma.io\" }) {\r\n id\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "createDraft", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const draft = {\r", + " \"data\": {\r", + " \"createDraft\": {\r", + " \"id\": 5,\r", + " \"viewCount\": 0,\r", + " \"published\": false,\r", + " \"author\": {\r", + " \"id\": 1,\r", + " \"name\": \"Alice\"\r", + " }\r", + " }\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(draft);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n createDraft(\r\n data: { title: \"Join the Prisma Discord\", content: \"https://pris.ly/discord/" }\r\n authorEmail: \"alice@prisma.io\"\r\n ) {\r\n id\r\n viewCount\r\n published\r\n author {\r\n id\r\n name\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + } + ] + }, + { + "name": "posts", + "item": [ + { + "name": "feed", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": 1,\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": 1,\r", + " \"name\": \"Alice\",\r", + " \"email\": \"alice@prisma.io\"\r", + " }\r", + " },\r", + " {\r", + " \"id\": 2,\r", + " \"title\": \"Follow Prisma on Twitter\",\r", + " \"content\": \"https://www.twitter.com/prisma/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": 2,\r", + " \"name\": \"Nilu\",\r", + " \"email\": \"nilu@prisma.io\"\r", + " }\r", + " },\r", + " {\r", + " \"id\": 3,\r", + " \"title\": \"Ask a question about Prisma on GitHub\",\r", + " \"content\": \"https://www.github.com/prisma/prisma/discussions/",\r", + " \"published\": true,\r", + " \"author\": {\r", + " \"id\": 3,\r", + " \"name\": \"Mahmoud\",\r", + " \"email\": \"mahmoud@prisma.io\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query {\r\n feed {\r\n id\r\n title\r\n content\r\n published\r\n author {\r\n id\r\n name\r\n email\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "feed-searchString", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": 1,\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true\r", + " },\r", + " {\r", + " \"id\": 2,\r", + " \"title\": \"Follow Prisma on Twitter\",\r", + " \"content\": \"https://www.twitter.com/prisma/",\r", + " \"published\": true\r", + " },\r", + " {\r", + " \"id\": 3,\r", + " \"title\": \"Ask a question about Prisma on GitHub\",\r", + " \"content\": \"https://www.github.com/prisma/prisma/discussions/",\r", + " \"published\": true\r", + " }\r", + " ]\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n feed(\r\n searchString: \"Prisma\"\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "feed-pagination_order", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"feed\": [\r", + " {\r", + " \"id\": 1,\r", + " \"title\": \"Join the Prisma Discord\",\r", + " \"content\": \"https://pris.ly/discord/",\r", + " \"published\": true\r", + " }\r", + " ]\r", + " }\r", + "}\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n feed(\r\n skip: 2\r\n take: 2\r\n orderBy: { updatedAt: desc }\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "postById", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const feed = {\r", + " \"data\": {\r", + " \"postById\": {\r", + " \"id\": 4,\r", + " \"title\": \"Prisma on YouTube\",\r", + " \"content\": \"https://pris.ly/youtube/",\r", + " \"published\": false\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(feed);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n postById(id: 4 ) {\r\n id\r\n title\r\n content\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "draftsByUser", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const draftsByUser = {\r", + " \"data\": {\r", + " \"draftsByUser\": [\r", + " {\r", + " \"id\": 4,\r", + " \"title\": \"Prisma on YouTube\",\r", + " \"content\": \"https://pris.ly/youtube/",\r", + " \"published\": false,\r", + " \"author\": {\r", + " \"id\": 3,\r", + " \"name\": \"Mahmoud\",\r", + " \"email\": \"mahmoud@prisma.io\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(draftsByUser);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n draftsByUser(\r\n userUniqueInput: {\r\n email: \"mahmoud@prisma.io\"\r\n }\r\n ) {\r\n id\r\n title\r\n content\r\n published\r\n author {\r\n id\r\n name\r\n email\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "togglePublishPost", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"togglePublishPost\": {\r", + " \"id\": 5,\r", + " \"published\": true\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n togglePublishPost(id: 5) {\r\n id\r\n published\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "incrementPostViewCount", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"incrementPostViewCount\": {\r", + " \"id\": 5,\r", + " \"viewCount\": 1\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n incrementPostViewCount(id: 5) {\r\n id\r\n viewCount\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + }, + { + "name": "deletePost", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Response body is valid\", function () {\r", + " const post = {\r", + " \"data\": {\r", + " \"deletePost\": {\r", + " \"id\": 5\r", + " }\r", + " }\r", + " }\r", + " \r", + " const jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(post);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation {\r\n deletePost(id: 5) {\r\n id\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "localhost:4000", + "host": ["localhost"], + "port": "4000" + } + }, + "response": [] + } + ] + } + ] +} diff --git a/.github/tests/postman_collections/rest.json b/.github/tests/postman_collections/rest.json new file mode 100644 index 000000000000..e6166330c61a --- /dev/null +++ b/.github/tests/postman_collections/rest.json @@ -0,0 +1,473 @@ +{ + "info": { + "_postman_id": "0f8cc0ab-4554-4537-b23f-fa62e80a6302", + "name": "prisma-examples-rest", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "users", + "item": [ + { + "name": "allUsers", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', () => {\r", + " pm.expect(pm.response.code).to.be.oneOf([200,201])\r", + "})\r", + "\r", + "pm.test('Response body is valid', function () {\r", + " const allUsers = [\r", + " {\r", + " \"id\": 1,\r", + " \"email\": \"alice@prisma.io\",\r", + " \"name\": \"Alice\"\r", + " },\r", + " {\r", + " \"id\": 2,\r", + " \"email\": \"nilu@prisma.io\",\r", + " \"name\": \"Nilu\"\r", + " },\r", + " {\r", + " \"id\": 3,\r", + " \"email\": \"mahmoud@prisma.io\",\r", + " \"name\": \"Mahmoud\"\r", + " }\r", + " ]\r", + " \r", + " const jsonData = pm.response.json()\r", + " pm.expect(jsonData).to.eql(allUsers)\r", + "})\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:3000/users", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "users" + ] + } + }, + "response": [] + }, + { + "name": "getUserDrafts", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', () => {\r", + " pm.expect(pm.response.code).to.be.oneOf([200,201])\r", + "})\r", + "\r", + "pm.test('Response body is valid', function () {\r", + " const jsonData = pm.response.json()\r", + " pm.expect(jsonData[0].id).to.eql(4)\r", + " pm.expect(jsonData[0].title).to.eql(\"Prisma on YouTube\")\r", + " pm.expect(jsonData[0].content).to.eql(\"https://pris.ly/youtube/")\r", + " pm.expect(jsonData[0].published).to.eql(false)\r", + " pm.expect(jsonData[0].viewCount).to.eql(0)\r", + " pm.expect(jsonData[0].authorId).to.eql(3)\r", + "})\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:3000/user/3/drafts", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "user", + "3", + "drafts" + ] + } + }, + "response": [] + }, + { + "name": "signup", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', () => {\r", + " pm.expect(pm.response.code).to.be.oneOf([200,201])\r", + "})\r", + "\r", + "pm.test('Response body is valid', function () {\r", + " var jsonData = pm.response.json()\r", + " pm.expect(jsonData.id).to.eql(4)\r", + " pm.expect(jsonData.name).to.eql(\"Alex\")\r", + " pm.expect(jsonData.email).to.eql(\"alex@prisma.io\")\r", + "})\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n\t\"name\": \"Alex\",\r\n\t\"email\": \"alex@prisma.io\",\r\n\t\"posts\":[\r\n\t\t{\r\n\t\t\t\"title\": \"Prisma and APIs\",\r\n \"content\": \"This works pretty smoothly with any type of API\"\r\n\t\t}\r\n\t]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:3000/signup", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "signup" + ] + } + }, + "response": [] + } + ], + "auth": { + "type": "noauth" + }, + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ] + }, + { + "name": "posts", + "item": [ + { + "name": "feed", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', () => {\r", + " pm.expect(pm.response.code).to.be.oneOf([200,201])\r", + "})\r", + "\r", + "pm.test('Response body is valid', function () {\r", + " const jsonData = pm.response.json()\r", + " pm.expect(jsonData[0].id).to.eql(1)\r", + " pm.expect(jsonData[0].title).to.eql(\"Join the Prisma Discord\")\r", + " pm.expect(jsonData[0].content).to.eql(\"https://pris.ly/discord/")\r", + " pm.expect(jsonData[0].published).to.eql(true)\r", + " pm.expect(jsonData[0].viewCount).to.eql(0)\r", + " pm.expect(jsonData[0].authorId).to.eql(1)\r", + "})" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:3000/feed?searchString=discord", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "feed" + ], + "query": [ + { + "key": "searchString", + "value": "discord" + } + ] + } + }, + "response": [] + }, + { + "name": "getPostById", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', () => {\r", + " pm.expect(pm.response.code).to.be.oneOf([200,201])\r", + "})\r", + "\r", + "pm.test('Response body is valid', function () { \r", + " const jsonData = pm.response.json()\r", + " pm.expect(jsonData.id).to.eql(3)\r", + " pm.expect(jsonData.title).to.eql(\"Ask a question about Prisma on GitHub\")\r", + " pm.expect(jsonData.content).to.eql(\"https://www.github.com/prisma/prisma/discussions/")\r", + " pm.expect(jsonData.published).to.eql(true)\r", + " pm.expect(jsonData.authorId).to.eql(3)\r", + "})" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:3000/post/3", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "post", + "3" + ] + } + }, + "response": [] + }, + { + "name": "togglePublish", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', () => {\r", + " pm.expect(pm.response.code).to.be.oneOf([200,201])\r", + "})\r", + "\r", + "pm.test('Response body is valid', function () {\r", + " const jsonData = pm.response.json()\r", + " pm.expect(jsonData.id).to.eql(4)\r", + " pm.expect(jsonData.title).to.eql(\"Prisma on YouTube\")\r", + " pm.expect(jsonData.content).to.eql(\"https://pris.ly/youtube/")\r", + " pm.expect(jsonData.published).to.eql(true)\r", + " pm.expect(jsonData.viewCount).to.eql(0)\r", + " pm.expect(jsonData.authorId).to.eql(3)\r", + "})\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [], + "url": { + "raw": "http://localhost:3000/publish/4", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "publish", + "4" + ] + } + }, + "response": [] + }, + { + "name": "incrementPostViewCount", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', () => {\r", + " pm.expect(pm.response.code).to.be.oneOf([200,201])\r", + "})\r", + "\r", + "pm.test('Response body is valid', function () {\r", + " const jsonData = pm.response.json()\r", + " pm.expect(jsonData.id).to.eql(4)\r", + " pm.expect(jsonData.title).to.eql(\"Prisma on YouTube\")\r", + " pm.expect(jsonData.content).to.eql(\"https://pris.ly/youtube/")\r", + " pm.expect(jsonData.published).to.eql(true)\r", + " pm.expect(jsonData.viewCount).to.eql(1)\r", + " pm.expect(jsonData.authorId).to.eql(3)\r", + "})\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [], + "url": { + "raw": "http://localhost:3000/post/4/views", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "post", + "4", + "views" + ] + } + }, + "response": [] + }, + { + "name": "createDraft", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', () => {\r", + " pm.expect(pm.response.code).to.be.oneOf([200,201])\r", + "})\r", + "\r", + "pm.test('Response body is valid', function () {\r", + " const jsonData = pm.response.json()\r", + " pm.expect(jsonData.id).to.eql(6)\r", + " pm.expect(jsonData.title).to.eql(\"Postman and Newman - Testing APIs\")\r", + " pm.expect(jsonData.content).to.eql(null)\r", + " pm.expect(jsonData.published).to.eql(false)\r", + " pm.expect(jsonData.viewCount).to.eql(0)\r", + " pm.expect(jsonData.authorId).to.eql(2)\r", + "})\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n\t\"title\":\"Postman and Newman - Testing APIs\",\r\n\t\"authorEmail\":\"nilu@prisma.io\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:3000/post", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "post" + ] + } + }, + "response": [] + }, + { + "name": "deletePost", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', () => {\r", + " pm.expect(pm.response.code).to.be.oneOf([200,201])\r", + "})\r", + "\r", + "pm.test('Response body is valid', function () {\r", + " const jsonData = pm.response.json()\r", + " pm.expect(jsonData.id).to.eql(6)\r", + " pm.expect(jsonData.title).to.eql(\"Postman and Newman - Testing APIs\")\r", + " pm.expect(jsonData.content).to.eql(null)\r", + " pm.expect(jsonData.published).to.eql(false)\r", + " pm.expect(jsonData.viewCount).to.eql(0)\r", + " pm.expect(jsonData.authorId).to.eql(2)\r", + "})\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:3000/post/6", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "post", + "6" + ] + } + }, + "response": [] + } + ] + } + ], + "variable": [ + { + "key": "allUsers", + "value": "const users = [\r\n {\r\n \"id\": 1,\r\n \"email\": \"alice@prisma.io\",\r\n \"name\": \"Alice\"\r\n },\r\n {\r\n \"id\": 2,\r\n \"email\": \"nilu@prisma.io\",\r\n \"name\": \"Nilu\"\r\n },\r\n {\r\n \"id\": 3,\r\n \"email\": \"mahmoud@prisma.io\",\r\n \"name\": \"Mahmoud\"\r\n },\r\n {\r\n \"id\": 4,\r\n \"email\": \"alex@prisma.io\",\r\n \"name\": \"Alex\"\r\n }\r\n]" + } + ] +} diff --git a/.github/tests/yarn.lock b/.github/tests/yarn.lock deleted file mode 100644 index 9daa4a00d2c7..000000000000 --- a/.github/tests/yarn.lock +++ /dev/null @@ -1,390 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@types/mkdirp@^0.5.2": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.5.2.tgz#503aacfe5cc2703d5484326b1b27efa67a339c1f" - dependencies: - "@types/node" "*" - -"@types/node@*": - version "10.12.9" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.9.tgz#a07bfa74331471e1dc22a47eb72026843f7b95c8" - -"@types/yargs@^12.0.1": - version "12.0.1" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-12.0.1.tgz#c5ce4ad64499010ae4dc2acd9b14d49749a44233" - -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - -ansi-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" - -balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -camelcase@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42" - -cliui@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49" - dependencies: - string-width "^2.1.1" - strip-ansi "^4.0.0" - wrap-ansi "^2.0.0" - -code-point-at@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - -cross-spawn@^5.0.1: - version "5.1.0" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" - dependencies: - lru-cache "^4.0.1" - shebang-command "^1.2.0" - which "^1.2.9" - -cross-spawn@^6.0.0: - version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" - dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" - -decamelize@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - -execa@^0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.10.0.tgz#ff456a8f53f90f8eccc71a96d11bdfc7f082cb50" - dependencies: - cross-spawn "^6.0.0" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - -execa@^0.6.0: - version "0.6.3" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.6.3.tgz#57b69a594f081759c69e5370f0d17b9cb11658fe" - dependencies: - cross-spawn "^5.0.1" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - -find-up@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" - dependencies: - locate-path "^3.0.0" - -get-caller-file@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" - -get-stream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - -inline-markdown@0.1.6: - version "0.1.6" - resolved "https://registry.yarnpkg.com/inline-markdown/-/inline-markdown-0.1.6.tgz#5ba1284c85058f586773313561c05b66afd0bbf8" - dependencies: - "@types/mkdirp" "^0.5.2" - "@types/yargs" "^12.0.1" - mkdirp "^0.5.1" - recursive-readdir "^2.2.2" - yargs "^12.0.5" - -invert-kv@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" - -is-fullwidth-code-point@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" - dependencies: - number-is-nan "^1.0.0" - -is-fullwidth-code-point@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" - -is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - -lcid@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf" - dependencies: - invert-kv "^2.0.0" - -locate-path@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" - dependencies: - p-locate "^3.0.0" - path-exists "^3.0.0" - -lru-cache@^4.0.1: - version "4.1.4" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.4.tgz#51cc46e8e6d9530771c857e24ccc720ecdbcc031" - dependencies: - pseudomap "^1.0.2" - yallist "^3.0.2" - -map-age-cleaner@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a" - dependencies: - p-defer "^1.0.0" - -mem@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/mem/-/mem-4.0.0.tgz#6437690d9471678f6cc83659c00cbafcd6b0cdaf" - dependencies: - map-age-cleaner "^0.1.1" - mimic-fn "^1.0.0" - p-is-promise "^1.1.0" - -mimic-fn@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" - -minimatch@3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - dependencies: - brace-expansion "^1.1.7" - -minimist@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - -mkdirp@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" - dependencies: - minimist "0.0.8" - -nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" - -npm-run-path@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" - dependencies: - path-key "^2.0.0" - -number-is-nan@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" - -os-locale@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.0.1.tgz#3b014fbf01d87f60a1e5348d80fe870dc82c4620" - dependencies: - execa "^0.10.0" - lcid "^2.0.0" - mem "^4.0.0" - -p-defer@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" - -p-finally@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - -p-is-promise@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-1.1.0.tgz#9c9456989e9f6588017b0434d56097675c3da05e" - -p-limit@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.0.0.tgz#e624ed54ee8c460a778b3c9f3670496ff8a57aec" - dependencies: - p-try "^2.0.0" - -p-locate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" - dependencies: - p-limit "^2.0.0" - -p-try@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1" - -path-exists@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" - -path-key@^2.0.0, path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - -prettier-check@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/prettier-check/-/prettier-check-2.0.0.tgz#edd086ee12d270579233ccb136a16e6afcfba1ae" - dependencies: - execa "^0.6.0" - -prettier@1.16.4: - version "1.16.4" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.4.tgz#73e37e73e018ad2db9c76742e2647e21790c9717" - -pseudomap@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - -recursive-readdir@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/recursive-readdir/-/recursive-readdir-2.2.2.tgz#9946fb3274e1628de6e36b2f6714953b4845094f" - dependencies: - minimatch "3.0.4" - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - -require-main-filename@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" - -semver@^5.5.0: - version "5.6.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" - -set-blocking@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - dependencies: - shebang-regex "^1.0.0" - -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - -signal-exit@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" - -string-width@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - strip-ansi "^3.0.0" - -string-width@^2.0.0, string-width@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" - dependencies: - is-fullwidth-code-point "^2.0.0" - strip-ansi "^4.0.0" - -strip-ansi@^3.0.0, strip-ansi@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - dependencies: - ansi-regex "^2.0.0" - -strip-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" - dependencies: - ansi-regex "^3.0.0" - -strip-eof@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" - -which-module@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" - -which@^1.2.9: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - dependencies: - isexe "^2.0.0" - -wrap-ansi@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" - dependencies: - string-width "^1.0.1" - strip-ansi "^3.0.1" - -"y18n@^3.2.1 || ^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" - -yallist@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9" - -yargs-parser@^11.1.1: - version "11.1.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4" - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" - -yargs@^12.0.5: - version "12.0.5" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13" - dependencies: - cliui "^4.0.0" - decamelize "^1.2.0" - find-up "^3.0.0" - get-caller-file "^1.0.1" - os-locale "^3.0.0" - require-directory "^2.1.1" - require-main-filename "^1.0.1" - set-blocking "^2.0.0" - string-width "^2.0.0" - which-module "^2.0.0" - y18n "^3.2.1 || ^4.0.0" - yargs-parser "^11.1.1" diff --git a/.github/tests/.prettierrc b/.github/tools/.prettierrc similarity index 100% rename from .github/tests/.prettierrc rename to .github/tools/.prettierrc diff --git a/.github/tools/package.json b/.github/tools/package.json new file mode 100644 index 000000000000..89a16b0d4589 --- /dev/null +++ b/.github/tools/package.json @@ -0,0 +1,17 @@ +{ + "name": "prisma-client-examples", + "version": "1.0.0", + "repository": "git@github.com:prisma/prisma-client-js.git", + "license": "MIT", + "scripts": { + "test": "yarn prettier-check", + "prettier-check": "prettier-check --config .prettierrc \"../../orm/*/{src,test,prisma}/**/*.{ts,tsx}\"", + "prettier-fix": "prettier --config .prettierrc --write \"../../orm/*/{src,test,prisma}/**/*.{ts,tsx}\"" + }, + "devDependencies": { + "inline-markdown": "0.1.6", + "prettier": "3.6.2", + "prettier-check": "2.0.0", + "watch": "1.0.2" + } +} diff --git a/.github/workflows/test-cockroachdb.yaml b/.github/workflows/test-cockroachdb.yaml new file mode 100644 index 000000000000..30cc181255b2 --- /dev/null +++ b/.github/workflows/test-cockroachdb.yaml @@ -0,0 +1,43 @@ +name: test-cockroachdb +on: + push: + paths: + - databases/cockroachdb/** + branches: + - latest + - dev + - patch-dev + pull_request: + paths: + - databases/cockroachdb/** + +env: + CI: 1 + PRISMA_TELEMETRY_INFORMATION: 'prisma-examples test-cockroachdb.yaml' + +jobs: + test: + defaults: + run: + working-directory: databases/cockroachdb + runs-on: ubuntu-latest + + env: + DATABASE_URL: postgresql://root@127.0.0.1:26257/prisma?sslmode=disable + + steps: + - uses: actions/checkout@v4 + - name: Start a single CockroachDB instance with Docker + env: + COCKROACHDB_DOCKER_TAG: 'cockroachdb/cockroach:latest-v21.2' + run: | + docker pull $COCKROACHDB_DOCKER_TAG + docker run -d --name roach --hostname roach -p 26257:26257 -p 8080:8080 -v "${{ github.workspace }}:/app" $COCKROACHDB_DOCKER_TAG start-single-node --insecure + sudo apt update && sudo apt install wait-for-it -y + wait-for-it -h localhost -p 26257 + - uses: actions/setup-node@v4 + with: + node-version: '22.16.0' + - run: npm install + - run: npx prisma migrate dev --name "init" + - run: npm run test diff --git a/.github/workflows/test-mongodb.yaml b/.github/workflows/test-mongodb.yaml new file mode 100644 index 000000000000..9511b2028c6f --- /dev/null +++ b/.github/workflows/test-mongodb.yaml @@ -0,0 +1,46 @@ +name: test-mongodb +on: + push: + paths: + - databases/mongodb/** + branches: + - latest + - dev + - patch-dev + pull_request: + paths: + - databases/mongodb/** + +env: + CI: 1 + PRISMA_TELEMETRY_INFORMATION: 'prisma-examples test-mongodb.yaml' + +jobs: + test: + defaults: + run: + working-directory: databases/mongodb + runs-on: ubuntu-latest + # Service containers to run with `container-job` + services: + # Label used to access the service container + mongodb: + # Docker Hub image + image: prismagraphql/mongo-single-replica:4.4.3-bionic + env: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: prisma + ports: + - 27017:27017 + + env: + DATABASE_URL: mongodb://root:prisma@localhost:27017/prisma-mongo?authSource=admin&retryWrites=true&w=majority + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22.16.0' + - run: npm install + - run: npx prisma generate + - run: npm run test diff --git a/.github/workflows/test-sql-server.yaml b/.github/workflows/test-sql-server.yaml new file mode 100644 index 000000000000..e0348e174388 --- /dev/null +++ b/.github/workflows/test-sql-server.yaml @@ -0,0 +1,48 @@ +name: test-sql-server +on: + push: + paths: + - databases/sql-server/** + branches: + - latest + - dev + - patch-dev + pull_request: + paths: + - databases/sql-server/** + +env: + CI: 1 + PRISMA_TELEMETRY_INFORMATION: 'prisma-examples test-sql-server.yaml' + +jobs: + test: + defaults: + run: + working-directory: databases/sql-server + runs-on: ubuntu-latest + # Service containers to run with `container-job` + services: + # Label used to access the service container + sql-server: + # Docker Hub image + image: mcr.microsoft.com/mssql/server:2025-latest + env: + ACCEPT_EULA: Y + SA_PASSWORD: 'Pr1sm4_Pr1sm4' + # Maps tcp port 1433 on service container to the host + ports: + - '1433:1433' + options: --health-cmd="/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U SA -P ${SA_PASSWORD} -Q 'SELECT 1' || exit 1" --health-interval 10s --health-timeout 5s --health-retries 5 + + env: + DATABASE_URL: sqlserver://localhost:1433;database=prisma-demo;user=SA;password=Pr1sm4_Pr1sm4;trustServerCertificate=true;encrypt=true + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22.16.0' + - run: npm install + - run: npx prisma migrate dev --name "init" + - run: npm run test diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 000000000000..3e08dca62729 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,75 @@ +name: test +on: + push: + paths: + - orm/** + branches: + - latest + pull_request: + +env: + CI: 1 + PRISMA_TELEMETRY_INFORMATION: 'prisma-examples test.yaml' + SLACK_WEBHOOK_URL_FAILING: ${{ secrets.SLACK_WEBHOOK_URL_FAILING }} + SKIP_PRISMA_VERSION_CHECK: true # Skip Prisma version check in typegraphl-prisma (https://github.com/MichalLytek/typegraphql-prisma/blob/fc7cfa756a60dd6671a902c38f00ee74698a681a/Readme.md#lifting-prisma-version-restriction) + +jobs: + projects-matrix: + if: github.repository_owner == 'prisma' + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22.16.0' + + - name: install deps + run: cd .github/scripts && yarn install + + - name: get list of projects as json array + id: set-matrix + run: node .github/scripts/get-packages.js + test-prisma-postgres: + if: github.repository_owner == 'prisma' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run prisma-postgres test + working-directory: .github/tests/databases/prisma-postgres + run: | + chmod +x run.sh + ./run.sh + test: + needs: projects-matrix + if: github.repository_owner == 'prisma' + runs-on: ubuntu-latest + env: + PPG_TEST_DATABASE_URL: ${{ secrets.PPG_TEST_DATABASE_URL }} + strategy: + fail-fast: false + matrix: ${{fromJson(needs.projects-matrix.outputs.matrix)}} + services: + postgres: + image: postgis/postgis:14-3.1-alpine + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: testing + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - '5432:5432' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22.16.0' + + - name: test + run: bash .github/scripts/test-all.sh ./${{ matrix.path }}/package.json diff --git a/.gitignore b/.gitignore index 3a976e4e7310..7ce1e5f6c84d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,32 @@ -node_modules -yarn-error.log -vendor -tmp -dist +# This gitignore file is used only internally for this repository, +# you should not use this in your own projects. Instead, navigate into +# an example folder and use the folder as the project root (it also contains a +# projects-specific .gitignore). + +node_modules/ +generated/ +yarn-error.log/ +vendor/ +tmp/ +dist/ .DS_Store .idea tmp-resolvers package-lock.json flow-typed -yarn.lock \ No newline at end of file +yarn.lock +orm/**/migrations/ +misc/**/migrations/ +databases/**/migrations/ +orm/**/package-lock.json +misc/**/package-lock.json +experimental/**/package-lock.json + +databases/**/package-lock.json +experimental/**/*.db +.next +.vscode/ +.nuxt +dev.db +*.env* +!.env.example diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000000..a77793ecc520 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/hydrogen diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000000..9250d263397a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +*.mdx +*.md \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000000..e3b414c7e090 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "semi": false, + "singleQuote": true, + "trailingComma": "all" +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000000..526474604dde --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "Prisma.prisma", + ] +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2c6bbafca51b..749d850b75cc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,9 @@ # Contribution Guidelines +## Commit messages + +Please use [conventional commits](https://www.conventionalcommits.org) (also known as _semantic commits_) to ensure consistent and descriptive commit messages when submitting PRs. + ## General guidelines Every example should follow a number of guidelines. @@ -9,7 +13,6 @@ Every example should follow a number of guidelines. - Simple and minimal instead of complex and production-ready - Focus on one specific Prisma use case - Easily extensible -- Require global installation of the Prisma CLI but all other dependencies (e.g. `graphqlgen`) only as dev dependencies and invoked via a script (e.g. `npm run graphqlgen`) ### README guidelines @@ -27,8 +30,8 @@ For each language, there should be one example that shows how to: - build a **REST API** with Prisma client - build a **CLI** application with Prisma client -The datamodel and developed APIs should be consistent across languages. This enables easier testing of the examples. The domain for all applications (except the CLI app) is a simple blogging application. - +The schemas and developed APIs should be consistent across languages. This enables easier testing of the examples. The domain for all applications (except the CLI app) is a simple blogging application. + ## Ways to contribute @@ -323,23 +326,12 @@ The easiest way to contribute is by adding a missing example. Check [this](https ### Adding a new example -Before submitting a PR for a new example, please first open an issue that explains the idea of the example and specifies what it will look like (e.g. how the Prisma datamodel will be defined or what kind of API will be built). It'll then be discussed in the issue whether your example is going to be added to the collection. To accelerate the process, you can ping @nikolasburk in the public [Prisma Slack](https://slack.prisma.io). +Before submitting a PR for a new example, please first open an issue that explains the idea of the example and specifies what it will look like (e.g. how the Prisma datamodel will be defined or what kind of API will be built). It'll then be discussed in the issue whether your example is going to be added to the collection. To accelerate the process, you can ping @nikolasburk in the public [Prisma Discord](https://pris.ly/discord). -Once approved, you can add your example to [list of missing examples](https://github.com/prisma/prisma-examples/issues/311) and start implementing it. +Once approved, you can add your example to [list of missing examples](https://github.com/prisma/prisma-examples/issues/311) and start implementing it. ### Improving an existing example -If you find a bug in an example, please feel free to open an issue or submit a PR so the bug gets fixed. If you want to make structural changes to an existing example (e.g. changing the datamodel or the API operations), please open an issue about this first where the changes can be discussed. To accelerate the process, you can ping @nikolasburk in the public [Prisma Slack](https://slack.prisma.io). +If you find a bug in an example, please feel free to open an issue or submit a PR so the bug gets fixed. If you want to make structural changes to an existing example (e.g. changing the datamodel or the API operations), please open an issue about this first where the changes can be discussed. To accelerate the process, you can ping @nikolasburk in the public [Prisma Discord](https://pris.ly/discord). Once approved, you can go ahead and implement the changes. - -### Improving a README - -The READMEs for all projects are being auto-generated based on the templates located in [`./github/readmes`](./github/readmes). If you find a typo or other parts of the README that should be improved, please do not edit the README directly but instead add your changes to the corresponding template. - -For example, if you found an issue in the `node/graphql` README, do not edit the [`./node/graphql/README.md`](./node/graphql/README.md) file but instead add your changes to [.`/.github/readmes/node/graphql/README.md`](./.github/readmes/node/graphql/README.md). Then build the READMEs using our custom script: - -``` -cd .github/tests -yarn build-readmes -``` \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000000..261eeb9e9f8b --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 78cc24453c57..a8e70c2bcc4d 100644 --- a/README.md +++ b/README.md @@ -1,68 +1,179 @@ -# Prisma Examples [![CircleCI](https://circleci.com/gh/prisma/prisma-examples.svg?style=shield)](https://circleci.com/gh/prisma/prisma-examples) +
-This repository contains a number of ready-to-run examples demonstrating various use cases of [Prisma](https://www.prisma.io). Pick an example and follow the instructions in the corresponding README. +
+

Prisma Examples

+

Ready-to-run Prisma example projects 🚀

+ Website +   •   + Docs +   •   + Blog +   •   + Discord +   •   + Twitter +   •   + Demo videos +
+ +
+ +
+ +[![test](https://github.com/prisma/prisma-examples/workflows/test/badge.svg?branch=latest)](https://github.com/prisma/prisma-examples/actions?query=workflow%3Atest+branch%3Alatest) + +[View full CI status](#ci-status) + +
+ +
+ +This repository contains a number of ready-to-run example projects demonstrating various use cases of Prisma. Pick an example and follow the instructions in the corresponding README. + +You can also find links to [real-world and production ready examples](#real-world--production-ready-example-projects-with-prisma) further below in this README. Are you missing an example? Please feel free to [open an issue](https://github.com/prisma/prisma-examples/issues/new) (read the [contribution guidelines](./CONTRIBUTING.md) for more info). -## TypeScript - -| Demo | Description | -|:------|:----------| -| [`script`](https://github.com/prisma/prisma-examples/tree/master/typescript/script) | Simple usage of Prisma client in script | -| [`graphql`](https://github.com/prisma/prisma-examples/tree/master/typescript/graphql) | Simple GraphQL server | -| [`graphql-crud`](https://github.com/prisma/prisma-examples/tree/master/typescript/graphql-crud) | GraphQL server with full CRUD API | -| [`graphql-auth`](https://github.com/prisma/prisma-examples/tree/master/typescript/graphql-auth) | GraphQL server with email-password authentication & permissions | -| [`graphql-subscriptions`](https://github.com/prisma/prisma-examples/tree/master/typescript/graphql-subscriptions) | GraphQL server with realtime subscriptions | -| [`rest-express`](https://github.com/prisma/prisma-examples/tree/master/typescript/rest-express) | Simple REST API with Express.JS | -| [`grpc`](https://github.com/prisma/prisma-examples/tree/master/typescript/grpc) | Simple gRPC API | -| [`docker-mongodb`](https://github.com/prisma/prisma-examples/tree/master/typescript/docker-mongodb) | Set up Prisma locally with MongoDB | -| [`docker-mysql`](https://github.com/prisma/prisma-examples/tree/master/typescript/docker-mysql) | Set up Prisma locally with MySQL | -| [`docker-postgres`](https://github.com/prisma/prisma-examples/tree/master/typescript/docker-postgres) | Set up Prisma locally with PostgreSQL | -| [`cli-app`](https://github.com/prisma/prisma-examples/tree/master/typescript/cli-app) | Simple CLI TODO list app | - -## Node.js - -| Demo | Description | -|:------|:----------| -| [`script`](https://github.com/prisma/prisma-examples/tree/master/node/script) | Simple usage of Prisma client in script | -| [`graphql`](https://github.com/prisma/prisma-examples/tree/master/node/graphql) | Simple GraphQL server | -| [`graphql-auth`](https://github.com/prisma/prisma-examples/tree/master/node/graphql-auth) | GraphQL server with email-password authentication & permissions | -| [`graphql-subscriptions`](https://github.com/prisma/prisma-examples/tree/master/node/graphql-subscriptions) | GraphQL server with realtime subscriptions | -| [`rest-express`](https://github.com/prisma/prisma-examples/tree/master/node/rest-express) | Simple REST API with Express.JS | -| [`grpc`](https://github.com/prisma/prisma-examples/tree/master/node/grpc) | Simple gRPC API | -| [`docker-mongodb`](https://github.com/prisma/prisma-examples/tree/master/node/docker-mongodb) | Set up Prisma locally with MongoDB | -| [`docker-mysql`](https://github.com/prisma/prisma-examples/tree/master/node/docker-mysql) | Set up Prisma locally with MySQL | -| [`docker-postgres`](https://github.com/prisma/prisma-examples/tree/master/node/docker-postgres) | Set up Prisma locally with PostgreSQL | -| [`cli-app`](https://github.com/prisma/prisma-examples/tree/master/node/cli-app) | Simple CLI TODO list app | - - -## Golang - -| Demo | Description | -|:------|:----------| -| [`script`](https://github.com/prisma/prisma-examples/tree/master/go/script) | Simple usage of Prisma client in script | -| [`graphql`](https://github.com/prisma/prisma-examples/tree/master/go/graphql) | Simple GraphQL server | -| [`rest-gin`](https://github.com/prisma/prisma-examples/tree/master/go/rest-gin) | Simple REST API with [Gin](https://github.com/gin-gonic/gin) | -| [`http-mux`](https://github.com/prisma/prisma-examples/tree/master/go/http-mux) | Simple REST API with [gorilla/mux](https://github.com/gorilla/mux) | -| [`docker-mongodb`](https://github.com/prisma/prisma-examples/tree/master/go/docker-mongodb) | Set up Prisma locally with MongoDB | -| [`docker-mysql`](https://github.com/prisma/prisma-examples/tree/master/go/docker-mysql) | Set up Prisma locally with MySQL | -| [`docker-postgres`](https://github.com/prisma/prisma-examples/tree/master/go/docker-postgres) | Set up Prisma locally with PostgreSQL | -| [`cli-app`](https://github.com/prisma/prisma-examples/tree/master/go/cli-app) | Simple CLI TODO list app | - -## Flow - -| Demo | Description | -|:------|:----------| -| [`script`](https://github.com/prisma/prisma-examples/tree/master/flow/script) | Simple usage of Prisma client in script | -| [`graphql`](https://github.com/prisma/prisma-examples/tree/master/flow/graphql) | Simple GraphQL server | - - -## Reference Implementations - -If you're looking for a more complex real-world application you can check out the following repositories: - -| Repo | Language | Description | -|:-----|:--------:|:-------------| -| [`graphql-prisma-typescript`](https://github.com/prisma/graphql-prisma-typescript) | [TypeScript](https://www.typescriptlang.org/) | TypeScript-based GraphQL server (Airbnb clone) | +## Prisma ORM + +### Fullstack + +| Demo | Description | +| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [`nextjs-api-routes`](https://github.com/prisma/prisma-examples/tree/latest/orm/nextjs-api-routes) | [Next.js](https://nextjs.org/) app with a REST API (using [Next.js API routes](https://nextjs.org/docs/api-routes/introduction)) | +| [`nextjs-graphql`](https://github.com/prisma/prisma-examples/tree/latest/orm/nextjs-graphql) | [Next.js](https://nextjs.org/) app with a GraphQL API (using [Apollo Server](https://github.com/apollographql/apollo-server) and [GraphQL Nexus](https://github.com/graphql-nexus/nexus)) | +| [`nextjs-trpc`](https://github.com/prisma/prisma-examples/tree/latest/orm/nextjs-trpc) | [Next.js](https://nextjs.org/) app with [tRPC ](https://trpc.io/) | +| [`nuxt`](https://github.com/prisma/prisma-examples/tree/latest/orm/nuxt) | [Nuxt.js](https://nuxt.com/) app with a REST API | +| [`sveltekit`](https://github.com/prisma/prisma-examples/tree/latest/orm/sveltekit) | [SvelteKit](https://kit.svelte.dev/) app using SvelteKit's [actions](https://kit.svelte.dev/docs/form-actions) and [load](https://kit.svelte.dev/docs/form-actions#loading-data) functions | +| [`remix`](https://github.com/prisma/prisma-examples/tree/latest/orm/remix) | [Remix](https://remix.run/) app | +| [`nuxt-prisma-module`](https://github.com/prisma/prisma-examples/tree/latest/orm/nuxt-prisma-module) | A nuxt example app using the [Prisma Nuxt module](https://github.com/prisma/nuxt-prisma) | + +### Backend only + +| Demo | Description | +| :----------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [`graphql-auth`](https://github.com/prisma/prisma-examples/tree/latest/orm/graphql-auth) | GraphQL server with email-password authentication & permissions | +| [`graphql-sdl-first`](https://github.com/prisma/prisma-examples/tree/latest/orm/graphql-sdl-first) | GraphQL server based on [GraphQL Yoga](https://the-guild.dev/graphql/yoga-server) | +| [`graphql-subscriptions`](https://github.com/prisma/prisma-examples/tree/latest/orm/graphql-subscriptions) | GraphQL server with realtime subscriptions based on [`apollo-server`](https://www.apollographql.com/docs/apollo-server/) and [Nexus Schema](https://github.com/graphql-nexus/schema) | +| [`graphql-typegraphql`](https://github.com/prisma/prisma-examples/tree/latest/orm/graphql-typegraphql) | GraphQL server based on [`@apollo/server`](https://www.apollographql.com/docs/apollo-server) and [TypeGraphQL](https://github.com/MichalLytek/type-graphql) | +| [`graphql-typegraphql-crud`](https://github.com/prisma/prisma-examples/tree/latest/orm/graphql-typegraphql-crud) | CRUD GraphQL API based on [`@apollo/server`](https://www.apollographql.com/docs/apollo-server) and [TypeGraphQL](https://github.com/MichalLytek/type-graphql) | +| [`fastify-graphql`](https://github.com/prisma/prisma-examples/tree/latest/orm/fastify-graphql) | GraphQL server based on [Fastify](https://fastify.io/), [Mercurius](https://mercurius.dev/), and the SDL-first approach of [`graphql-tools`](https://www.graphql-tools.com/docs/generate-schema/) | +| [`fastify-graphql-sdl-first`](https://github.com/prisma/prisma-examples/tree/latest/orm/fastify-graphql-sdl-first) | GraphQL server based on [Fastify](https://fastify.io/), [Mercurius](https://mercurius.dev/), and the SDL-first approach of [`graphql-tools`](https://www.graphql-tools.com/docs/generate-schema/) | +| [`hapi-graphql`](https://github.com/prisma/prisma-examples/tree/latest/orm/hapi-graphql) | GraphQL server based on [Hapi](https://hapi.dev/) and [Nexus Schema](https://github.com/graphql-nexus/schema) | +| [`hapi-graphql-sdl-first`](https://github.com/prisma/prisma-examples/tree/latest/orm/hapi-graphql-sdl-first) | GraphQL server based on [Hapi](https://hapi.dev/) and the SDL-first approach of [Apollo Server Integration for Hapi](https://www.npmjs.com/package/@as-integrations/hapi) | +| [`nest-graphql`](https://github.com/prisma/prisma-examples/tree/latest/orm/nest-graphql) | GraphQL server based on [NestJS](https://nestjs.com/) (code-first) | +| [`nest-graphql-sdl-first`](https://github.com/prisma/prisma-examples/tree/latest/orm/nest-graphql-sdl-first) | GraphQL server based on [NestJS](https://nestjs.com/) and the SDL-first approach of [`graphql-tools`](https://www.apollographql.com/docs/graphql-tools/) | +| [`graphql`](https://github.com/prisma/prisma-examples/tree/latest/orm/graphql) | GraphQL server based on [GraphQL Yoga](https://the-guild.dev/graphql/yoga-server) and [Pothos](https://pothos-graphql.dev/) | +| [`graphql-nexus`](https://github.com/prisma/prisma-examples/tree/latest/orm/graphql-nexus) | GraphQL server based on [`@apollo/server`](https://www.apollographql.com/docs/apollo-server) and [Nexus Schema](https://github.com/graphql-nexus/schema) | +| [`grpc`](https://github.com/prisma/prisma-examples/tree/latest/orm/grpc) | gRPC API including runnable client scripts for testing | +| [`postgis-express`](https://github.com/prisma/prisma-examples/tree/latest/orm/postgis-express) | Demo of spatial queries using [Postgis](http://postgis.net/) and [Express](https://expressjs.com/) | +| [`express`](https://github.com/prisma/prisma-examples/tree/latest/orm/express) | REST API with [Express](https://expressjs.com/) | +| [`fastify`](https://github.com/prisma/prisma-examples/tree/latest/orm/fastify) | REST API with [Fastify](https://www.fastify.io/) | +| [`koa`](https://github.com/prisma/prisma-examples/tree/latest/orm/koa) | REST API with [Koa](https://koajs.com/) | +| [`hapi`](https://github.com/prisma/prisma-examples/tree/latest/orm/hapi) | REST API with [hapi](https://hapi.dev/) | +| [`nest`](https://github.com/prisma/prisma-examples/tree/latest/orm/nest) | REST API with [NestJS](https://docs.nestjs.com/) | +| [`script`](https://github.com/prisma/prisma-examples/tree/latest/orm/script) | Usage of Prisma Client JS in a TypeScript script | +| [`testing-express`](https://github.com/prisma/prisma-examples/tree/latest/orm/testing-express) | Demo of integration tests with [Jest](https://jestjs.io/), [Supertest](https://github.com/visionmedia/supertest) and [Express](https://expressjs.com/) | + +### New `prisma-client` generator + +The following examples are fullstack examples using the new [`prisma-client`](https://www.prisma.io/docs/orm/prisma-schema/overview/generators#prisma-client-early-access) generator: +| Demo | Description | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | +| [`nextjs-starter-webpack`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/nextjs-starter-webpack) | A Next.js 15 starter that uses Webpack 5 as the bundler and runs on Node.js. | +| [`nextjs-starter-turbopack`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/nextjs-starter-turbopack) | A Next.js 15 starter powered by Turbopack (alpha) for bundling, running on Node.js. | +| [`neextjs-starter-webpack-monorepo`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/neextjs-starter-webpack-monorepo) | A monorepo-based Next.js 15 starter using Webpack 5 and Node.js, managed with `pnpm`. | +| [`nextjs-starter-webpack-with-middleware`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/nextjs-starter-webpack-with-middleware) | A Next.js 15 starter with Webpack 5, running on Node.js for main pages and Vercel Edge Light for middleware. | + + +## Prisma Accelerate + +The [`accelerate`](./accelerate) folder contains examples of projects using [Prisma Accelerate](https://www.prisma.io/data-platform/accelerate) for connection pooling and global caching. + +| Demo | Description | +| -------------------------------------------------------- | --------------------------------------------------------------------------------- | +| [`starter`](./accelerate/starter) | A simple starter project using Prisma Accelerate's caching and connection pooling | +| [`nextjs-starter`](./accelerate/nextjs-starter) | A Next.js project using Prisma Accelerate's caching and connection pooling | +| [`svelte-starter`](./accelerate/svelte-starter/) | A SvelteKit project using Prisma Accelerate's caching and connection pooling | +| [`solidstart-starter`](./accelerate/solidstart-starter/) | A Solidstart project using Prisma Accelerate's caching and connection pooling | +| [`remix-starter`](./accelerate/remix-starter/) | A Remix project using Prisma Accelerate's caching and connection pooling | +| [`nuxt-starter`](./accelerate/nuxtjs-starter/) | A Nuxt.js project using Prisma Accelerate's caching and connection pooling | +| [`astro-starter`](./accelerate/astro-starter/) | An Astro project using Prisma Accelerate's caching and connection pooling | + +## Prisma Optimize + +The [`optimize`](./optimize) folder contains examples of projects using [Prisma Optimize](https://www.prisma.io/data-platform/optimize) to identify and improve the performance of slow queries. +| Demo | Description | +| ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | +| [`starter`](./optimize/starter) | A Prisma Optimize starter app | +| [`optimize-excessive-rows`](./optimize/optimize-excessive-rows) | An example app demonstrating the "Excessive number of rows returned" recommendation provided by Optimize. | +| [`optimize-full-table-scan`](./optimize/optimize-full-table-scan) | An example app demonstrating the "Full table scans caused by `LIKE` operations" recommendation provided by Optimize. | +| [`optimize-unindexed-column`](./optimize/optimize-unindexed-column) | An example app demonstrating the "Query filtering on an unindexed column" recommendation provided by Optimize. | + +## Deployment platforms + +The projects in the [`deployment-platforms`](./deployment-platforms) directory show what "Prisma Client"-based deployment setups look like for various deployment providers. Learn more about [deployment](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/deployment) in the Prisma documentation. + +## Real-world & production-ready example projects with Prisma + +- [Inbox Zero](https://github.com/elie222/inbox-zero): Open source email management tools to reach inbox zero fast +- [NextCRM](https://github.com/pdovhomilja/nextcrm-app): An open-source Customer Relationship Management system (CRM) +- [Papermark](https://github.com/mfts/papermark/): An open-source DocSend alternative with built-in analytics and custom domains +- [Hoppscotch](https://github.com/hoppscotch/hoppscotch): An open-source API development ecosystem +- [FeastQR](https://github.com/jakubczarnowski/FeastQR): An open-source SaaS online menu system for restaurants +- [Formbricks](https://github.com/formbricks/formbricks): An open-source survey and experience management tool +- [OpenformStack](https://github.com/naveennaidu/OpenformStack): An open-source form backend that allows you to collect form submissions without writing any backend code +- [Documenso](https://documenso.com/): An open-source alternative to Docusign +- [abby](https://github.com/tryabby/abby): An open-source feature flag, remote config and A/B testing platform for developers +- [ghostfolio](https://ghostfol.io/en/start): An open-source dashboard for your personal finances +- [revert](https://www.revert.dev/): An open-source unified API to build B2B product integrations +- [Scholarsome](https://scholarsome.com/): An interactive, studying system +- [Dittofeed](https://www.dittofeed.com): An open-source customer engagement; intuitive marketing tools that scale +- [Trigger.dev](https://trigger.dev/): Effortless automation built for developers (Zapier alternative) +- [Webstudio](https://github.com/webstudio-is/webstudio-designer): A NoCode visual design tool for building apps and websites +- [Dyrector](https://github.com/dyrector-io/dyrectorio): A self-hosted container management platform +- [reduced.to](https://github.com/origranot/reduced.to): An open-source link shortener +- [Linen](https://github.com/Linen-dev/linen.dev): An open-source alternative to Slack and Discord with lots of great features +- [Coolify](https://github.com/coollabsio/coolify): An open-source & self-hostable Heroku / Netlify alternative +- [Dub.co](https://dub.co): An open-source link management platform for modern marketing teams +- [Umami](https://github.com/mikecao/umami): A simple, fast, privacy-focused alternative to Google Analytics +- [Rallly](https://github.com/lukevella/rallly): A self-hostable doodle poll alternative (based on Next.js, tRPC, and TailwindCSS) +- [Typebot](https://github.com/baptisteArno/typebot.io): A conversational form builder that you can self-host +- [Cal.com](https://github.com/calcom/cal.com): An open-source alternative to Calendly (calender-based event scheduling service) +- [Beam](https://github.com/planetscale/beam): A simple tool that allows members to write posts to share across your organization (based on Next.js) +- [Dundring](https://github.com/sivertschou/dundring): An in-browser training application created to control and track you training with a smart bike trainer +- [Expense.fyi](https://github.com/gokulkrishh/expense.fyi): A tool for tracking and managing expenses +- [Letterpad](https://github.com/letterpad/letterpad): A publishing platform for creatives +- [Teable](https://github.com/teableio/teable): A no-code real-time database built on Postgres with a simple interface for enterprise-level app development. +
+ +## Starter kits + +- [T3 Stack](https://create.t3.gg/): Starter kit based on Next.js, TypeScript, tRPC, Prisma, Tailwind CSS, and NextAuth.js. +- [Indie Stack](https://github.com/remix-run/indie-stack): Remix Stack for deploying to Fly with SQLite, authentication, testing, linting, and formatting. +- [Blues Stack](https://github.com/remix-run/blues-stack): Remix Stack for deploying to Fly with PostgreSQL, authentication, testing, linting, and formatting. +- [NestJS Prisma Starter](https://github.com/notiz-dev/nestjs-prisma-starter): NestJS, Prisma, and authentication starter template. +- [Supastarter](https://supastarter.dev/): Full-stack SaaS starter kit using Next.js/Nuxt.js/SvelteKit and Prisma with authentication, emails, payment, testing, linting, and formatting. +- [Saas Kit Prisma](https://github.com/Saas-Starter-Kit/Saas-Kit-prisma): Full-stack SaaS starter kit using React.js, Next.js, TypeScript, Tailwind, Shadcn, Stripe, NextAuth, Prisma, Postgres, and Playwright. +- [Saas Kit Prisma by BoxyHQ](https://github.com/boxyhq/saas-starter-kit): An open-source enterprise SaaS starter kit using Prisma ORM. +- [NextReady](https://nextready.dev): A ready-to-use Next.js boilerplate with Prisma, TypeScript, Tailwind CSS, and more. + +## Badges + +[![Made with Prisma](http://made-with.prisma.io/dark.svg)](https://prisma.io) [![Made with Prisma](http://made-with.prisma.io/indigo.svg)](https://prisma.io) + +Built something awesome with Prisma? 🌟 Show it off with these [badges](https://github.com/prisma/presskit?tab=readme-ov-file#badges), perfect for your readme or website. + +``` +[![Made with Prisma](http://made-with.prisma.io/dark.svg)](https://prisma.io) +``` + +``` +[![Made with Prisma](http://made-with.prisma.io/indigo.svg)](https://prisma.io) +``` + +## Security + +If you have a security issue to report, please contact us at [security@prisma.io](mailto:security@prisma.io?subject=[GitHub]%20Prisma%202%20Security%20Report%20Examples) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000000..5d93b0ad8d99 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,3 @@ +# Security Policy + +If you have a security issue to report, please contact us at [security@prisma.io](mailto:security@prisma.io). diff --git a/accelerate/accelerate-hacker-news/.env.example b/accelerate/accelerate-hacker-news/.env.example new file mode 100644 index 000000000000..ec5b630d21d1 --- /dev/null +++ b/accelerate/accelerate-hacker-news/.env.example @@ -0,0 +1,2 @@ +DIRECT_URL= +DATABASE_URL= diff --git a/accelerate/accelerate-hacker-news/.eslintrc.json b/accelerate/accelerate-hacker-news/.eslintrc.json new file mode 100644 index 000000000000..37224185490e --- /dev/null +++ b/accelerate/accelerate-hacker-news/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": ["next/core-web-vitals", "next/typescript"] +} diff --git a/accelerate/accelerate-hacker-news/.gitignore b/accelerate/accelerate-hacker-news/.gitignore new file mode 100644 index 000000000000..1dadbb67dd23 --- /dev/null +++ b/accelerate/accelerate-hacker-news/.gitignore @@ -0,0 +1,39 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js +.yarn/install-state.gz + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts + +prisma/migrations +package-lock.json diff --git a/accelerate/accelerate-hacker-news/README.md b/accelerate/accelerate-hacker-news/README.md new file mode 100644 index 000000000000..3a2ed477aef2 --- /dev/null +++ b/accelerate/accelerate-hacker-news/README.md @@ -0,0 +1,89 @@ +# Prisma Accelerate Hacker News Clone + +This project showcases how to use Prisma ORM with Prisma Accelerate, leveraging caching and on-demand cache invalidation, in a Next.js application to build a minimal Hacker News clone. + +This app retrieves and caches the [top 20 latest posts](/app/page.tsx#L8) with a long Time-to-Live ([TTL](https://www.prisma.io/docs/accelerate/caching#time-to-live-ttl)). The cache is invalidated on-demand whenever a post is [upvoted](/app/actions/addVotes.ts) or a [new post is added](/app/submit/actions/addPost.ts). + +![GIF of interaction](demo.gif) + +## Prerequisites + +To successfully run the project, you will need the following: + +- The **connection string** of a PostgreSQL database +- Your **Accelerate connection string** (containing your **Accelerate API key**) which you can get by enabling Accelerate in a project in your [Prisma Data Platform](https://pris.ly/pdp) account (learn more in the [docs](https://www.prisma.io/docs/platform/concepts/environments#api-keys)) + +## Getting started + +### 1. Clone the repository + +Clone the repository, navigate into it and install dependencies: + +``` +git clone git@github.com:prisma/prisma-examples.git --depth=1 +cd prisma-examples/accelerate/accelerate-hacker-news +npm install +``` + +### 2. Configure environment variables + +Create a `.env` in the root of the project directory: + +```bash +cp .env.example .env +``` + +Now, open the `.env` file and set the `DATABASE_URL` and `DIRECT_URL` environment variables with the values of your connection string and your Accelerate connection string: + +```bash +# .env + +# Accelerate connection string (used for queries by Prisma Client) +DATABASE_URL="__YOUR_ACCELERATE_CONNECTION_STRING__" + +# Database connection string (used for migrations by Prisma Migrate) +DIRECT_URL="__YOUR_DATABASE_CONNECTION_STRING__" +``` + +Note that `__YOUR_DATABASE_CONNECTION_STRING__` and `__YOUR_ACCELERATE_CONNECTION_STRING__` are placeholder values that you need to replace with the values of your database and Accelerate connection strings. Notice that the Accelerate connection string has the following structure: `prisma://accelerate.prisma-data.net/?api_key=__YOUR_ACCELERATE_API_KEY__`. + +### 3. Run a migration to create the `Post` table + +The Prisma schema file contains a single `Post` model. You can map this model to the database and create the corresponding `Post` table using the following command: + +``` +npx prisma migrate dev --name init +``` + +### 4. Generate Prisma Client for Accelerate + +When using Accelerate, Prisma Client doesn't need a query engine. That's why you should generate it as follows: + +``` +npx prisma generate --no-engine +``` + +### 5. Start the app + +You can run the app with the following command: + +``` +npm run dev +``` + +You should now be able to: + +- See the most recent post at http://localhost:3000 and upvote it by clicking the ▲ button. +- Submit a new post by navigating to http://localhost:3000/submit. + +When you make changes, it might take a few seconds to invalidate the cache and display the latest changes. + +## Resources + +- [Accelerate Speed Test](https://accelerate-speed-test.vercel.app/) +- [Accelerate documentation](https://www.prisma.io/docs/accelerate) +- Check out the [Prisma docs](https://www.prisma.io/docs) +- [Join our community on Discord](https://pris.ly/discord?utm_source=github&utm_medium=prisma_examples&utm_content=next_steps_section) to share feedback and interact with other users. +- [Subscribe to our YouTube channel](https://pris.ly/youtube?utm_source=github&utm_medium=prisma_examples&utm_content=next_steps_section) for live demos and video tutorials. +- [Follow us on X](https://pris.ly/x?utm_source=github&utm_medium=prisma_examples&utm_content=next_steps_section) for the latest updates. +- Report issues or ask [questions on GitHub](https://pris.ly/github?utm_source=github&utm_medium=prisma_examples&utm_content=next_steps_section). diff --git a/accelerate/accelerate-hacker-news/app/actions/addVotes.ts b/accelerate/accelerate-hacker-news/app/actions/addVotes.ts new file mode 100644 index 000000000000..2f209ea7a4d3 --- /dev/null +++ b/accelerate/accelerate-hacker-news/app/actions/addVotes.ts @@ -0,0 +1,26 @@ +'use server' + +import prisma from '@/lib/db' + +export async function addVotes(id: number) { + // console.log({ + // updating: id, + // }) + + await prisma.post.update({ + where: { + id: id, + }, + data: { + vote: { + increment: 1, + }, + }, + }) + + await prisma.$accelerate.invalidate({ + tags: ['posts'], + }) + + return id +} diff --git a/accelerate/accelerate-hacker-news/app/favicon.ico b/accelerate/accelerate-hacker-news/app/favicon.ico new file mode 100644 index 000000000000..718d6fea4835 Binary files /dev/null and b/accelerate/accelerate-hacker-news/app/favicon.ico differ diff --git a/accelerate/accelerate-hacker-news/app/fonts/GeistMonoVF.woff b/accelerate/accelerate-hacker-news/app/fonts/GeistMonoVF.woff new file mode 100644 index 000000000000..f2ae185cbfd1 Binary files /dev/null and b/accelerate/accelerate-hacker-news/app/fonts/GeistMonoVF.woff differ diff --git a/accelerate/accelerate-hacker-news/app/fonts/GeistVF.woff b/accelerate/accelerate-hacker-news/app/fonts/GeistVF.woff new file mode 100644 index 000000000000..1b62daacff96 Binary files /dev/null and b/accelerate/accelerate-hacker-news/app/fonts/GeistVF.woff differ diff --git a/accelerate/accelerate-hacker-news/app/globals.css b/accelerate/accelerate-hacker-news/app/globals.css new file mode 100644 index 000000000000..13d40b892057 --- /dev/null +++ b/accelerate/accelerate-hacker-news/app/globals.css @@ -0,0 +1,27 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +:root { + --background: #ffffff; + --foreground: #171717; +} + +@media (prefers-color-scheme: dark) { + :root { + --background: #0a0a0a; + --foreground: #ededed; + } +} + +body { + color: var(--foreground); + background: var(--background); + font-family: Arial, Helvetica, sans-serif; +} + +@layer utilities { + .text-balance { + text-wrap: balance; + } +} diff --git a/accelerate/accelerate-hacker-news/app/layout.tsx b/accelerate/accelerate-hacker-news/app/layout.tsx new file mode 100644 index 000000000000..ffed14949dba --- /dev/null +++ b/accelerate/accelerate-hacker-news/app/layout.tsx @@ -0,0 +1,37 @@ +import type { Metadata } from 'next' +import localFont from 'next/font/local' +import './globals.css' + +const geistSans = localFont({ + src: './fonts/GeistVF.woff', + variable: '--font-geist-sans', + weight: '100 900', +}) +const geistMono = localFont({ + src: './fonts/GeistMonoVF.woff', + variable: '--font-geist-mono', + weight: '100 900', +}) + +export const metadata: Metadata = { + title: 'Accelerate Hacker News Clone', + description: 'A minimal hackernews clone using Prisma Accelerate', +} + +export default function RootLayout({ + children, +}: Readonly<{ + children: React.ReactNode +}>) { + return ( + + +
+
{children}
+
+ + + ) +} diff --git a/accelerate/accelerate-hacker-news/app/page.tsx b/accelerate/accelerate-hacker-news/app/page.tsx new file mode 100644 index 000000000000..6e2911a80d5c --- /dev/null +++ b/accelerate/accelerate-hacker-news/app/page.tsx @@ -0,0 +1,50 @@ +import { Post } from '@/components/Posts' +import prisma from '@/lib/db' + +export const dynamic = 'force-dynamic' +export const revalidate = 0 + +export default async function Home() { + const { data, info } = await prisma.post + .findMany({ + take: 20, + orderBy: { + createdAt: 'desc', + }, + cacheStrategy: { + ttl: 400, + tags: ['posts'], + }, + }) + .withAccelerateInfo() + + console.log({ info }) + + return ( + <> +
+

+ Accelerate Hacker News Clone +

+ + submit + +
+
+
    + {data.map((post, itemNo) => ( +
  1. + +
  2. + ))} +
+
+ + ) +} diff --git a/accelerate/accelerate-hacker-news/app/submit/actions/addPost.ts b/accelerate/accelerate-hacker-news/app/submit/actions/addPost.ts new file mode 100644 index 000000000000..a22f66fc3b21 --- /dev/null +++ b/accelerate/accelerate-hacker-news/app/submit/actions/addPost.ts @@ -0,0 +1,25 @@ +'use server' + +import prisma from '@/lib/db' + +export async function createPost(formData: FormData) { + const title = formData.get('title') + const text = formData.get('text') + const url = formData.get('url') + + const newPost = await prisma.post.create({ + data: { + title: title?.toString() ?? '', + content: text?.toString() ?? '', + url: url?.toString() ?? '', + vote: 0, + }, + }) + + await prisma.$accelerate.invalidate({ + tags: ['posts'], + }) + + // console.log({ newPost }, 'has been created.') + return newPost +} diff --git a/accelerate/accelerate-hacker-news/app/submit/page.tsx b/accelerate/accelerate-hacker-news/app/submit/page.tsx new file mode 100644 index 000000000000..02de69d93099 --- /dev/null +++ b/accelerate/accelerate-hacker-news/app/submit/page.tsx @@ -0,0 +1,14 @@ +import { PostForm } from '@/components/PostSubmissionForm' + +export default function Submit() { + return ( + <> +
+

Submit

+
+
+ +
+ + ) +} diff --git a/accelerate/accelerate-hacker-news/components/PostSubmissionForm.tsx b/accelerate/accelerate-hacker-news/components/PostSubmissionForm.tsx new file mode 100644 index 000000000000..3c90c7dc677e --- /dev/null +++ b/accelerate/accelerate-hacker-news/components/PostSubmissionForm.tsx @@ -0,0 +1,69 @@ +'use client' +import { createPost } from '@/app/submit/actions/addPost' +import { useRef } from 'react' + +export const PostForm = () => { + const ref = useRef(null) + return ( + <> +
{ + await createPost(formData) + ref.current?.reset() + }} + className="grid grid-cols-2 max-w-lg p-4 space-y-2 space-x-1" + > + + + + + + + +