-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from hayes/mh--prisma-crud-spike
create prisma utils plugin
- Loading branch information
Showing
55 changed files
with
1,635 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ | |
"author": "Michael Hayes", | ||
"license": "ISC", | ||
"keywords": [ | ||
"giraphql", | ||
"pothos", | ||
"graphql", | ||
"auth", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
prisma | ||
test | ||
tests | ||
.turbo | ||
babel.config.js | ||
tsconfig.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ISC License (ISC) | ||
Copyright 2021 Michael Hayes | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Prisma utils for Pothos | ||
|
||
This package is highly experimental and not ready for production use |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env node | ||
require('../lib/generator.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* | ||
!.gitignore | ||
!.npmignore | ||
!package.json |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"name": "@pothos/plugin-prisma-utils", | ||
"version": "0.0.0", | ||
"description": "A Pothos plugin containing utility functions for building prisma inputs", | ||
"main": "./lib/index.js", | ||
"types": "./lib/index.d.ts", | ||
"module": "./esm/index.js", | ||
"exports": { | ||
"import": "./esm/index.js", | ||
"require": "./lib/index.js" | ||
}, | ||
"scripts": { | ||
"generate": "prisma generate", | ||
"type": "tsc --project tsconfig.type.json", | ||
"build": "pnpm build:clean && pnpm build:cjs && pnpm build:esm && pnpm build:dts", | ||
"build:clean": "git clean -dfX esm lib", | ||
"build:cjs": "swc src -d lib --config-file ../../.swcrc -C module.type=commonjs", | ||
"build:esm": "swc src -d esm --config-file ../../.swcrc -C module.type=es6 && pnpm esm:extensions", | ||
"build:dts": "tsc", | ||
"esm:extensions": "TS_NODE_PROJECT=../../tsconfig.json node -r @swc-node/register ../../.config/esm-transformer.ts", | ||
"test": "pnpm vitest --run" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/hayes/pothos.git" | ||
}, | ||
"author": "Michael Hayes", | ||
"license": "ISC", | ||
"keywords": [ | ||
"pothos", | ||
"graphql", | ||
"schema", | ||
"typescript", | ||
"prisma" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"prisma": { | ||
"seed": "node prisma/seed.mjs" | ||
}, | ||
"dependencies": { | ||
"@prisma/generator-helper": "^4.1.0" | ||
}, | ||
"peerDependencies": { | ||
"@pothos/plugin-prisma": "workspace:*", | ||
"@prisma/client": "*", | ||
"graphql": ">=15.1.0" | ||
}, | ||
"devDependencies": { | ||
"@pothos/core": "workspace:*", | ||
"@pothos/plugin-prisma": "workspace:*", | ||
"@pothos/test-utils": "workspace:*", | ||
"@prisma/client": "^4.1.0", | ||
"graphql": "16.3.0", | ||
"graphql-tag": "^2.12.6", | ||
"prisma": "^4.1.0" | ||
} | ||
} |
Binary file not shown.
135 changes: 135 additions & 0 deletions
135
packages/plugin-prisma-utils/prisma/migrations/20220610181027_init/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
-- CreateTable | ||
CREATE TABLE "Post" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
"title" TEXT NOT NULL, | ||
"content" TEXT, | ||
"published" BOOLEAN NOT NULL DEFAULT false, | ||
"authorId" INTEGER NOT NULL, | ||
CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Media" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"url" TEXT NOT NULL, | ||
"uploadedById" INTEGER, | ||
CONSTRAINT "Media_uploadedById_fkey" FOREIGN KEY ("uploadedById") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "PostMedia" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"postId" INTEGER NOT NULL, | ||
"mediaId" INTEGER NOT NULL, | ||
"order" INTEGER NOT NULL, | ||
CONSTRAINT "PostMedia_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, | ||
CONSTRAINT "PostMedia_mediaId_fkey" FOREIGN KEY ("mediaId") REFERENCES "Media" ("id") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Comment" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"content" TEXT NOT NULL, | ||
"authorId" INTEGER NOT NULL, | ||
"postId" INTEGER NOT NULL, | ||
CONSTRAINT "Comment_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, | ||
CONSTRAINT "Comment_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Profile" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"bio" TEXT, | ||
"userId" INTEGER NOT NULL, | ||
CONSTRAINT "Profile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"email" TEXT NOT NULL, | ||
"name" TEXT | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Follow" ( | ||
"fromId" INTEGER NOT NULL, | ||
"toId" INTEGER NOT NULL, | ||
|
||
PRIMARY KEY ("fromId", "toId"), | ||
CONSTRAINT "Follow_fromId_fkey" FOREIGN KEY ("fromId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, | ||
CONSTRAINT "Follow_toId_fkey" FOREIGN KEY ("toId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Unrelated" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"name" TEXT | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "WithID" ( | ||
"id" TEXT NOT NULL PRIMARY KEY | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "WithUnique" ( | ||
"id" TEXT NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "WithCompositeID" ( | ||
"a" TEXT NOT NULL, | ||
"b" TEXT NOT NULL, | ||
|
||
PRIMARY KEY ("a", "b") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "WithCompositeUnique" ( | ||
"a" TEXT NOT NULL, | ||
"c" TEXT, | ||
"b" TEXT NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "FindUniqueRelations" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"withID_id" TEXT NOT NULL, | ||
"withUnique_id" TEXT NOT NULL, | ||
"withCompositeID_a" TEXT NOT NULL, | ||
"withCompositeID_b" TEXT NOT NULL, | ||
"withCompositeUnique_a" TEXT NOT NULL, | ||
"withCompositeUnique_b" TEXT NOT NULL, | ||
CONSTRAINT "FindUniqueRelations_withID_id_fkey" FOREIGN KEY ("withID_id") REFERENCES "WithID" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, | ||
CONSTRAINT "FindUniqueRelations_withUnique_id_fkey" FOREIGN KEY ("withUnique_id") REFERENCES "WithUnique" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, | ||
CONSTRAINT "FindUniqueRelations_withCompositeID_a_withCompositeID_b_fkey" FOREIGN KEY ("withCompositeID_a", "withCompositeID_b") REFERENCES "WithCompositeID" ("a", "b") ON DELETE RESTRICT ON UPDATE CASCADE, | ||
CONSTRAINT "FindUniqueRelations_withCompositeUnique_a_withCompositeUnique_b_fkey" FOREIGN KEY ("withCompositeUnique_a", "withCompositeUnique_b") REFERENCES "WithCompositeUnique" ("a", "b") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Post_createdAt_key" ON "Post"("createdAt"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Comment_createdAt_key" ON "Comment"("createdAt"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Profile_userId_key" ON "Profile"("userId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "WithUnique_id_key" ON "WithUnique"("id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "WithCompositeUnique_c_key" ON "WithCompositeUnique"("c"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "WithCompositeUnique_a_c_key" ON "WithCompositeUnique"("a", "c"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "WithCompositeUnique_a_b_key" ON "WithCompositeUnique"("a", "b"); |
3 changes: 3 additions & 0 deletions
3
packages/plugin-prisma-utils/prisma/migrations/migration_lock.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "sqlite" |
Oops, something went wrong.
dc5704a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
pothos – ./
pothos.vercel.app
www.pothos-graphql.dev
pothos-graphql.dev
pothos-git-main-mhayes.vercel.app
pothos-mhayes.vercel.app