├── .eslintrc ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .vscode └── settings.json ├── CONTRIBUTING.md ├── README.md ├── changelog.md ├── examples ├── inputs-simple-sqlite │ ├── .env │ ├── nodemon.json │ ├── package.json │ ├── prisma │ │ ├── .gitignore │ │ ├── migrations │ │ │ ├── 20220709164918_create_tables │ │ │ │ └── migration.sql │ │ │ ├── 20220729173933_user_special_fields │ │ │ │ └── migration.sql │ │ │ ├── 20220907201641_modal │ │ │ │ └── migration.sql │ │ │ ├── 20230820173627_big_int_id │ │ │ │ └── migration.sql │ │ │ ├── 20231109185946_userlast_model_for_checking_new_constraint │ │ │ │ └── migration.sql │ │ │ └── migration_lock.toml │ │ └── schema.prisma │ ├── src │ │ ├── db.ts │ │ ├── generated │ │ │ └── objects.d.ts │ │ ├── schema │ │ │ ├── __generated__ │ │ │ │ ├── Comment │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── mutations │ │ │ │ │ │ ├── createMany.base.ts │ │ │ │ │ │ ├── createOne.base.ts │ │ │ │ │ │ ├── deleteMany.base.ts │ │ │ │ │ │ ├── deleteOne.base.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── updateMany.base.ts │ │ │ │ │ │ ├── updateOne.base.ts │ │ │ │ │ │ └── upsertOne.base.ts │ │ │ │ │ ├── object.base.ts │ │ │ │ │ └── queries │ │ │ │ │ │ ├── count.base.ts │ │ │ │ │ │ ├── findFirst.base.ts │ │ │ │ │ │ ├── findMany.base.ts │ │ │ │ │ │ ├── findUnique.base.ts │ │ │ │ │ │ └── index.ts │ │ │ │ ├── ExtraModal │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── mutations │ │ │ │ │ │ ├── createMany.base.ts │ │ │ │ │ │ ├── createOne.base.ts │ │ │ │ │ │ ├── deleteMany.base.ts │ │ │ │ │ │ ├── deleteOne.base.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── updateMany.base.ts │ │ │ │ │ │ ├── updateOne.base.ts │ │ │ │ │ │ └── upsertOne.base.ts │ │ │ │ │ ├── object.base.ts │ │ │ │ │ └── queries │ │ │ │ │ │ ├── count.base.ts │ │ │ │ │ │ ├── findFirst.base.ts │ │ │ │ │ │ ├── findMany.base.ts │ │ │ │ │ │ ├── findUnique.base.ts │ │ │ │ │ │ └── index.ts │ │ │ │ ├── Follow │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── mutations │ │ │ │ │ │ ├── createMany.base.ts │ │ │ │ │ │ ├── createOne.base.ts │ │ │ │ │ │ ├── deleteMany.base.ts │ │ │ │ │ │ ├── deleteOne.base.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── updateMany.base.ts │ │ │ │ │ │ ├── updateOne.base.ts │ │ │ │ │ │ └── upsertOne.base.ts │ │ │ │ │ ├── object.base.ts │ │ │ │ │ └── queries │ │ │ │ │ │ ├── count.base.ts │ │ │ │ │ │ ├── findFirst.base.ts │ │ │ │ │ │ ├── findMany.base.ts │ │ │ │ │ │ ├── findUnique.base.ts │ │ │ │ │ │ └── index.ts │ │ │ │ ├── IdOnly │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── mutations │ │ │ │ │ │ ├── createMany.base.ts │ │ │ │ │ │ ├── createOne.base.ts │ │ │ │ │ │ ├── deleteMany.base.ts │ │ │ │ │ │ ├── deleteOne.base.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── updateMany.base.ts │ │ │ │ │ │ ├── updateOne.base.ts │ │ │ │ │ │ └── upsertOne.base.ts │ │ │ │ │ ├── object.base.ts │ │ │ │ │ └── queries │ │ │ │ │ │ ├── count.base.ts │ │ │ │ │ │ ├── findFirst.base.ts │ │ │ │ │ │ ├── findMany.base.ts │ │ │ │ │ │ ├── findUnique.base.ts │ │ │ │ │ │ └── index.ts │ │ │ │ ├── Post │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── mutations │ │ │ │ │ │ ├── createMany.base.ts │ │ │ │ │ │ ├── createOne.base.ts │ │ │ │ │ │ ├── deleteMany.base.ts │ │ │ │ │ │ ├── deleteOne.base.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── updateMany.base.ts │ │ │ │ │ │ ├── updateOne.base.ts │ │ │ │ │ │ └── upsertOne.base.ts │ │ │ │ │ ├── object.base.ts │ │ │ │ │ └── queries │ │ │ │ │ │ ├── count.base.ts │ │ │ │ │ │ ├── findFirst.base.ts │ │ │ │ │ │ ├── findMany.base.ts │ │ │ │ │ │ ├── findUnique.base.ts │ │ │ │ │ │ └── index.ts │ │ │ │ ├── Profile │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── mutations │ │ │ │ │ │ ├── createMany.base.ts │ │ │ │ │ │ ├── createOne.base.ts │ │ │ │ │ │ ├── deleteMany.base.ts │ │ │ │ │ │ ├── deleteOne.base.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── updateMany.base.ts │ │ │ │ │ │ ├── updateOne.base.ts │ │ │ │ │ │ └── upsertOne.base.ts │ │ │ │ │ ├── object.base.ts │ │ │ │ │ └── queries │ │ │ │ │ │ ├── count.base.ts │ │ │ │ │ │ ├── findFirst.base.ts │ │ │ │ │ │ ├── findMany.base.ts │ │ │ │ │ │ ├── findUnique.base.ts │ │ │ │ │ │ └── index.ts │ │ │ │ ├── Unrelated │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── mutations │ │ │ │ │ │ ├── createMany.base.ts │ │ │ │ │ │ ├── createOne.base.ts │ │ │ │ │ │ ├── deleteMany.base.ts │ │ │ │ │ │ ├── deleteOne.base.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── updateMany.base.ts │ │ │ │ │ │ ├── updateOne.base.ts │ │ │ │ │ │ └── upsertOne.base.ts │ │ │ │ │ ├── object.base.ts │ │ │ │ │ └── queries │ │ │ │ │ │ ├── count.base.ts │ │ │ │ │ │ ├── findFirst.base.ts │ │ │ │ │ │ ├── findMany.base.ts │ │ │ │ │ │ ├── findUnique.base.ts │ │ │ │ │ │ └── index.ts │ │ │ │ ├── User │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── mutations │ │ │ │ │ │ ├── createMany.base.ts │ │ │ │ │ │ ├── createOne.base.ts │ │ │ │ │ │ ├── deleteMany.base.ts │ │ │ │ │ │ ├── deleteOne.base.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── updateMany.base.ts │ │ │ │ │ │ ├── updateOne.base.ts │ │ │ │ │ │ └── upsertOne.base.ts │ │ │ │ │ ├── object.base.ts │ │ │ │ │ └── queries │ │ │ │ │ │ ├── count.base.ts │ │ │ │ │ │ ├── findFirst.base.ts │ │ │ │ │ │ ├── findMany.base.ts │ │ │ │ │ │ ├── findUnique.base.ts │ │ │ │ │ │ └── index.ts │ │ │ │ ├── UserLast │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── mutations │ │ │ │ │ │ ├── createMany.base.ts │ │ │ │ │ │ ├── createOne.base.ts │ │ │ │ │ │ ├── deleteMany.base.ts │ │ │ │ │ │ ├── deleteOne.base.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── updateMany.base.ts │ │ │ │ │ │ ├── updateOne.base.ts │ │ │ │ │ │ └── upsertOne.base.ts │ │ │ │ │ ├── object.base.ts │ │ │ │ │ └── queries │ │ │ │ │ │ ├── count.base.ts │ │ │ │ │ │ ├── findFirst.base.ts │ │ │ │ │ │ ├── findMany.base.ts │ │ │ │ │ │ ├── findUnique.base.ts │ │ │ │ │ │ └── index.ts │ │ │ │ ├── WithScalars │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── mutations │ │ │ │ │ │ ├── createMany.base.ts │ │ │ │ │ │ ├── createOne.base.ts │ │ │ │ │ │ ├── deleteMany.base.ts │ │ │ │ │ │ ├── deleteOne.base.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── updateMany.base.ts │ │ │ │ │ │ ├── updateOne.base.ts │ │ │ │ │ │ └── upsertOne.base.ts │ │ │ │ │ ├── object.base.ts │ │ │ │ │ └── queries │ │ │ │ │ │ ├── count.base.ts │ │ │ │ │ │ ├── findFirst.base.ts │ │ │ │ │ │ ├── findMany.base.ts │ │ │ │ │ │ ├── findUnique.base.ts │ │ │ │ │ │ └── index.ts │ │ │ │ ├── WithoutID │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── mutations │ │ │ │ │ │ ├── createMany.base.ts │ │ │ │ │ │ ├── createOne.base.ts │ │ │ │ │ │ ├── deleteMany.base.ts │ │ │ │ │ │ ├── deleteOne.base.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── updateMany.base.ts │ │ │ │ │ │ ├── updateOne.base.ts │ │ │ │ │ │ └── upsertOne.base.ts │ │ │ │ │ ├── object.base.ts │ │ │ │ │ └── queries │ │ │ │ │ │ ├── count.base.ts │ │ │ │ │ │ ├── findFirst.base.ts │ │ │ │ │ │ ├── findMany.base.ts │ │ │ │ │ │ ├── findUnique.base.ts │ │ │ │ │ │ └── index.ts │ │ │ │ ├── autocrud.ts │ │ │ │ ├── inputs.ts │ │ │ │ ├── objects.ts │ │ │ │ └── utils.ts │ │ │ ├── builder.ts │ │ │ ├── configs.js │ │ │ ├── index-2-custom-model.ts │ │ │ ├── index-3-global-crud-handle-resolvers.ts │ │ │ ├── index-4-custom-resolvers.ts │ │ │ └── index.ts │ │ └── server.ts │ ├── tsconfig.json │ └── yarn.lock └── readme.md ├── jest.config.ts ├── package.json ├── src ├── bin.ts ├── crudGenerator │ ├── index.test.ts │ ├── index.ts │ ├── templates │ │ ├── mutation.ts │ │ ├── object.ts │ │ ├── query.ts │ │ ├── resolver.ts │ │ └── root.ts │ └── utils │ │ ├── generator.ts │ │ ├── objectFields.test.ts │ │ ├── objectFields.ts │ │ └── parts.ts ├── env.ts ├── generator.ts ├── index.ts ├── inputsGenerator │ ├── index.test.ts │ ├── index.ts │ └── utils │ │ ├── dmmf.test.ts │ │ ├── dmmf.ts │ │ ├── inputFields.ts │ │ ├── parser.test.ts │ │ ├── parser.ts │ │ ├── parts.test.ts │ │ ├── parts.ts │ │ └── templates.ts ├── tests │ ├── complexSchema.prisma │ ├── configs.js │ ├── getPrismaSchema.ts │ ├── health.test.ts │ └── simpleSchema.prisma └── utils │ ├── config.test.ts │ ├── config.ts │ ├── configUtils.ts │ ├── filesystem.ts │ ├── replacer.ts │ ├── string.ts │ └── template.ts ├── tsconfig.json └── yarn.lock /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["standard", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"], 3 | "env": { 4 | "node": true 5 | }, 6 | "ignorePatterns": ["examples/*"], 7 | "rules": { 8 | "prettier/prettier": [ 9 | "error", 10 | { 11 | "semi": false, 12 | "printWidth": 120, 13 | "tabWidth": 2, 14 | "tabs": false, 15 | "singleQuote": true, 16 | "quoteProps": "consistent", 17 | "jsxSingleQuote": false, 18 | "trailingComma": "all", 19 | "bracketSpacing": true, 20 | "bracketSameLine": false, 21 | "arrowParens": "always", 22 | "endOfLine": "auto" 23 | } 24 | ], 25 | "@typescript-eslint/no-unused-vars": [ 26 | "warn", 27 | { 28 | "argsIgnorePattern": "^_", 29 | "varsIgnorePattern": "^_", 30 | "caughtErrorsIgnorePattern": "^_" 31 | } 32 | ], 33 | "import/order": ["warn", { 34 | "groups": ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"], 35 | "newlines-between": "never", 36 | "alphabetize": { 37 | "order": "asc", 38 | "caseInsensitive": true 39 | } 40 | }] 41 | }, 42 | "parser": "@typescript-eslint/parser", 43 | "plugins": ["@typescript-eslint"], 44 | "parserOptions": { 45 | "ecmaVersion": "latest", 46 | "sourceType": "module" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - master 8 | 9 | pull_request: 10 | types: [opened, synchronize] 11 | 12 | workflow_dispatch: 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | strategy: 18 | matrix: 19 | prisma-version: [4.7.0, 4.8.0] 20 | node-version: [16, 18] 21 | 22 | name: Node ${{ matrix.node-version }} with Prisma ${{ matrix.prisma-version }} 23 | steps: 24 | - name: 🛑 Cancel Previous Runs 25 | uses: styfle/cancel-workflow-action@0.11.0 26 | 27 | - name: ⬇️ Checkout repo 28 | uses: actions/checkout@v3 29 | 30 | - name: ⎔ Setup Node.js environment 31 | uses: actions/setup-node@v3 32 | with: 33 | node-version: ${{ matrix.node-version }} 34 | cache: "yarn" 35 | 36 | - name: 🏗 Swap Prisma version to ~${{ matrix.prisma-version }} 37 | run: | 38 | sed -i -E 's|"prisma": ".*"|"prisma": "~${{ matrix.prisma-version }}"|g' package.json 39 | sed -i -E 's|"\@prisma/client": ".*"|"\@prisma/client": "~${{ matrix.prisma-version }}"|g' package.json 40 | sed -i -E 's|"\@prisma/generator-helper": ".*"|"\@prisma/generator-helper": "~${{ matrix.prisma-version }}"|g' package.json 41 | sed -i -E 's|"\@prisma/internals": ".*"|"\@prisma/internals": "~${{ matrix.prisma-version }}"|g' package.json 42 | 43 | - name: 📥 Install dependencies 44 | run: yarn install 45 | 46 | - name: 🧪 Run tests 47 | run: yarn test 48 | 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | __snapshots__ 4 | generated/* 5 | dmmf.json 6 | log.txt 7 | yarn*.log 8 | dist 9 | tsconfig.tsbuildinfo 10 | TEST-* 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.eol": "\n", 3 | "typescript.tsdk": "node_modules/typescript/lib", 4 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Disclosures 2 | 3 | - We don't use tsconfig paths, because of examples (the prisma generate don't support paths) -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/.env: -------------------------------------------------------------------------------- 1 | POTHOS_CRUD_CONFIG_PATH="../src/schema/configs.js" -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src", ".env"], 3 | "ext": "ts", 4 | "exec": "yarn build && yarn start" 5 | } 6 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "inputs-simple", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "scripts": { 7 | "generate": "prisma generate", 8 | "generate-debug": "npx cross-env DEBUG=* prisma generate", 9 | "migrate": "prisma migrate dev", 10 | "type": "tsc --noEmit", 11 | "dev": "nodemon", 12 | "build": "tsup ./src/server.ts", 13 | "start": "node dist/server.js", 14 | "tscheck": "tsc --noEmit" 15 | }, 16 | "dependencies": { 17 | "@pothos/core": "^4.0.2", 18 | "@pothos/plugin-prisma": "^4.0.3", 19 | "@prisma/client": "5.17.0", 20 | "apollo-server": "^3.13.0", 21 | "graphql": "^16.8.1" 22 | }, 23 | "devDependencies": { 24 | "nodemon": "^3.1.0", 25 | "prisma": "^5.17.0", 26 | "ts-node": "^10.9.2", 27 | "tsup": "^8.0.2", 28 | "typescript": "^5.5.3" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/prisma/.gitignore: -------------------------------------------------------------------------------- 1 | *.db* -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/prisma/migrations/20220729173933_user_special_fields/migration.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Warnings: 3 | 4 | - Added the required column `birthdate` to the `User` table without a default value. This is not possible if the table is not empty. 5 | - Added the required column `login` to the `User` table without a default value. This is not possible if the table is not empty. 6 | - Added the required column `password` to the `User` table without a default value. This is not possible if the table is not empty. 7 | 8 | */ 9 | -- RedefineTables 10 | PRAGMA foreign_keys=OFF; 11 | CREATE TABLE "new_User" ( 12 | "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 13 | "firstName" TEXT NOT NULL, 14 | "lastName" TEXT NOT NULL, 15 | "birthdate" DATETIME NOT NULL, 16 | "login" TEXT NOT NULL, 17 | "password" TEXT NOT NULL, 18 | "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 19 | "updatedAt" DATETIME 20 | ); 21 | INSERT INTO "new_User" ("createdAt", "firstName", "id", "lastName", "updatedAt") SELECT "createdAt", "firstName", "id", "lastName", "updatedAt" FROM "User"; 22 | DROP TABLE "User"; 23 | ALTER TABLE "new_User" RENAME TO "User"; 24 | PRAGMA foreign_key_check; 25 | PRAGMA foreign_keys=ON; 26 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/prisma/migrations/20220907201641_modal/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "ExtraModal" ( 3 | "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 4 | "title" TEXT NOT NULL, 5 | "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 6 | "updatedAt" DATETIME 7 | ); 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/prisma/migrations/20230820173627_big_int_id/migration.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Warnings: 3 | 4 | - The primary key for the `WithScalars` table will be changed. If it partially fails, the table could be left without primary key constraint. 5 | - You are about to alter the column `id` on the `WithScalars` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. 6 | 7 | */ 8 | -- RedefineTables 9 | PRAGMA foreign_keys=OFF; 10 | CREATE TABLE "new_WithScalars" ( 11 | "id" BIGINT NOT NULL PRIMARY KEY, 12 | "string" TEXT, 13 | "boolean" BOOLEAN, 14 | "int" INTEGER, 15 | "float" REAL, 16 | "decimal" DECIMAL, 17 | "bigint" BIGINT, 18 | "datetime" DATETIME, 19 | "bytes" BLOB 20 | ); 21 | INSERT INTO "new_WithScalars" ("bigint", "boolean", "bytes", "datetime", "decimal", "float", "id", "int", "string") SELECT "bigint", "boolean", "bytes", "datetime", "decimal", "float", "id", "int", "string" FROM "WithScalars"; 22 | DROP TABLE "WithScalars"; 23 | ALTER TABLE "new_WithScalars" RENAME TO "WithScalars"; 24 | PRAGMA foreign_key_check; 25 | PRAGMA foreign_keys=ON; 26 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/prisma/migrations/20231109185946_userlast_model_for_checking_new_constraint/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "UserLast" ( 3 | "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 4 | "name" TEXT NOT NULL 5 | ); 6 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | # It should be added in your version-control system (i.e. Git) 3 | provider = "sqlite" -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/db.ts: -------------------------------------------------------------------------------- 1 | import { PrismaClient } from '@prisma/client'; 2 | 3 | export const db = new PrismaClient({ 4 | // log: ['error', 'info', 'query', 'warn'], 5 | }); 6 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | CommentObject, 3 | CommentIdFieldObject, 4 | CommentCommentFieldObject, 5 | CommentAuthorFieldObject, 6 | CommentPostFieldObject, 7 | CommentAuthorIdFieldObject, 8 | CommentPostIdFieldObject 9 | } from './object.base'; 10 | export { 11 | createManyCommentMutation, 12 | createOneCommentMutation, 13 | deleteManyCommentMutation, 14 | deleteOneCommentMutation, 15 | updateManyCommentMutation, 16 | updateOneCommentMutation, 17 | upsertOneCommentMutation, 18 | createManyCommentMutationObject, 19 | createOneCommentMutationObject, 20 | deleteManyCommentMutationObject, 21 | deleteOneCommentMutationObject, 22 | updateManyCommentMutationObject, 23 | updateOneCommentMutationObject, 24 | upsertOneCommentMutationObject 25 | } from './mutations'; 26 | export { 27 | findFirstCommentQuery, 28 | findManyCommentQuery, 29 | countCommentQuery, 30 | findUniqueCommentQuery, 31 | findFirstCommentQueryObject, 32 | findManyCommentQueryObject, 33 | countCommentQueryObject, 34 | findUniqueCommentQueryObject 35 | } from './queries'; 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/mutations/createMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createManyCommentMutationArgs = builder.args((t) => ({ data: t.field({ type: [Inputs.CommentCreateInput], required: true }) })) 7 | 8 | export const createManyCommentMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: ['Comment'], 11 | nullable: false, 12 | args: createManyCommentMutationArgs, 13 | resolve: async (_query, _root, args, _context, _info) => 14 | await db.$transaction(args.data.map((data) => db.comment.create({ data }))), 15 | }), 16 | ); 17 | 18 | export const createManyCommentMutation = defineMutation((t) => ({ 19 | createManyComment: t.prismaField(createManyCommentMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/mutations/createOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createOneCommentMutationArgs = builder.args((t) => ({ data: t.field({ type: Inputs.CommentCreateInput, required: true }) })) 7 | 8 | export const createOneCommentMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'Comment', 11 | nullable: false, 12 | args: createOneCommentMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.comment.create({ data: args.data, ...query }), 15 | }), 16 | ); 17 | 18 | export const createOneCommentMutation = defineMutation((t) => ({ 19 | createOneComment: t.prismaField(createOneCommentMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/mutations/deleteMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const deleteManyCommentMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.CommentWhereInput, required: true }) })) 8 | 9 | export const deleteManyCommentMutationObject = defineMutationFunction((t) => 10 | defineMutationObject({ 11 | type: BatchPayload, 12 | nullable: true, 13 | args: deleteManyCommentMutationArgs, 14 | resolve: async (_root, args, _context, _info) => 15 | await db.comment.deleteMany({ where: args.where }), 16 | }), 17 | ); 18 | 19 | export const deleteManyCommentMutation = defineMutation((t) => ({ 20 | deleteManyComment: t.field(deleteManyCommentMutationObject(t)), 21 | })); 22 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/mutations/deleteOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const deleteOneCommentMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.CommentWhereUniqueInput, required: true }) })) 7 | 8 | export const deleteOneCommentMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'Comment', 11 | nullable: true, 12 | args: deleteOneCommentMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.comment.delete({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const deleteOneCommentMutation = defineMutation((t) => ({ 19 | deleteOneComment: t.prismaField(deleteOneCommentMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/mutations/index.ts: -------------------------------------------------------------------------------- 1 | export { createManyCommentMutation, createManyCommentMutationObject } from './createMany.base'; 2 | export { createOneCommentMutation, createOneCommentMutationObject } from './createOne.base'; 3 | export { deleteManyCommentMutation, deleteManyCommentMutationObject } from './deleteMany.base'; 4 | export { deleteOneCommentMutation, deleteOneCommentMutationObject } from './deleteOne.base'; 5 | export { updateManyCommentMutation, updateManyCommentMutationObject } from './updateMany.base'; 6 | export { updateOneCommentMutation, updateOneCommentMutationObject } from './updateOne.base'; 7 | export { upsertOneCommentMutation, upsertOneCommentMutationObject } from './upsertOne.base'; 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/mutations/updateMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const updateManyCommentMutationArgs = builder.args((t) => ({ 8 | where: t.field({ type: Inputs.CommentWhereInput, required: false }), 9 | data: t.field({ type: Inputs.CommentUpdateManyMutationInput, required: true }), 10 | })) 11 | 12 | export const updateManyCommentMutationObject = defineMutationFunction((t) => 13 | defineMutationObject({ 14 | type: BatchPayload, 15 | nullable: false, 16 | args: updateManyCommentMutationArgs, 17 | resolve: async (_root, args, _context, _info) => 18 | await db.comment.updateMany({ where: args.where || undefined, data: args.data }), 19 | }), 20 | ); 21 | 22 | export const updateManyCommentMutation = defineMutation((t) => ({ 23 | updateManyComment: t.field(updateManyCommentMutationObject(t)), 24 | })); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/mutations/updateOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const updateOneCommentMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.CommentWhereUniqueInput, required: true }), 8 | data: t.field({ type: Inputs.CommentUpdateInput, required: true }), 9 | })) 10 | 11 | export const updateOneCommentMutationObject = defineMutationFunction((t) => 12 | defineMutationPrismaObject({ 13 | type: 'Comment', 14 | nullable: true, 15 | args: updateOneCommentMutationArgs, 16 | resolve: async (query, _root, args, _context, _info) => 17 | await db.comment.update({ where: args.where, data: args.data, ...query }), 18 | }), 19 | ); 20 | 21 | export const updateOneCommentMutation = defineMutation((t) => ({ 22 | updateOneComment: t.prismaField(updateOneCommentMutationObject(t)), 23 | })); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/mutations/upsertOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const upsertOneCommentMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.CommentWhereUniqueInput, required: true }), 8 | create: t.field({ type: Inputs.CommentCreateInput, required: true }), 9 | update: t.field({ type: Inputs.CommentUpdateInput, required: true }), 10 | })) 11 | 12 | export const upsertOneCommentMutationObject = defineMutationFunction((t) => 13 | defineMutationPrismaObject({ 14 | type: 'Comment', 15 | nullable: false, 16 | args: upsertOneCommentMutationArgs, 17 | resolve: async (query, _root, args, _context, _info) => 18 | await db.comment.upsert({ 19 | where: args.where, 20 | create: args.create, 21 | update: args.update, 22 | ...query, 23 | }), 24 | }), 25 | ); 26 | 27 | export const upsertOneCommentMutation = defineMutation((t) => ({ 28 | upsertOneComment: t.prismaField(upsertOneCommentMutationObject(t)), 29 | })); 30 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/queries/count.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryObject } from '../../utils'; 5 | 6 | export const countCommentQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.CommentWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.CommentOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.CommentWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.CommentScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const countCommentQueryObject = defineQueryFunction((t) => 16 | defineQueryObject({ 17 | type: 'Int', 18 | nullable: false, 19 | args: countCommentQueryArgs, 20 | resolve: async (_root, args, _context, _info) => 21 | await db.comment.count({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | skip: args.skip || undefined, 26 | orderBy: args.orderBy || undefined, 27 | }), 28 | }), 29 | ); 30 | 31 | export const countCommentQuery = defineQuery((t) => ({ 32 | countComment: t.field(countCommentQueryObject(t)), 33 | })); 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/queries/findFirst.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findFirstCommentQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.CommentWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.CommentOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.CommentWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.CommentScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findFirstCommentQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: 'Comment', 18 | nullable: true, 19 | args: findFirstCommentQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.comment.findFirst({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findFirstCommentQuery = defineQuery((t) => ({ 34 | findFirstComment: t.prismaField(findFirstCommentQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/queries/findMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findManyCommentQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.CommentWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.CommentOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.CommentWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.CommentScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findManyCommentQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: ['Comment'], 18 | nullable: false, 19 | args: findManyCommentQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.comment.findMany({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findManyCommentQuery = defineQuery((t) => ({ 34 | findManyComment: t.prismaField(findManyCommentQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/queries/findUnique.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findUniqueCommentQueryArgs = builder.args((t) => ({ where: t.field({ type: Inputs.CommentWhereUniqueInput, required: true }) })) 7 | 8 | export const findUniqueCommentQueryObject = defineQueryFunction((t) => 9 | defineQueryPrismaObject({ 10 | type: 'Comment', 11 | nullable: true, 12 | args: findUniqueCommentQueryArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.comment.findUnique({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const findUniqueCommentQuery = defineQuery((t) => ({ 19 | findUniqueComment: t.prismaField(findUniqueCommentQueryObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Comment/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { findFirstCommentQuery, findFirstCommentQueryObject } from './findFirst.base'; 2 | export { findManyCommentQuery, findManyCommentQueryObject } from './findMany.base'; 3 | export { countCommentQuery, countCommentQueryObject } from './count.base'; 4 | export { findUniqueCommentQuery, findUniqueCommentQueryObject } from './findUnique.base'; 5 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | ExtraModalObject, 3 | ExtraModalIdFieldObject, 4 | ExtraModalTitleFieldObject, 5 | ExtraModalCreatedAtFieldObject, 6 | ExtraModalUpdatedAtFieldObject 7 | } from './object.base'; 8 | export { 9 | createManyExtraModalMutation, 10 | createOneExtraModalMutation, 11 | deleteManyExtraModalMutation, 12 | deleteOneExtraModalMutation, 13 | updateManyExtraModalMutation, 14 | updateOneExtraModalMutation, 15 | upsertOneExtraModalMutation, 16 | createManyExtraModalMutationObject, 17 | createOneExtraModalMutationObject, 18 | deleteManyExtraModalMutationObject, 19 | deleteOneExtraModalMutationObject, 20 | updateManyExtraModalMutationObject, 21 | updateOneExtraModalMutationObject, 22 | upsertOneExtraModalMutationObject 23 | } from './mutations'; 24 | export { 25 | findFirstExtraModalQuery, 26 | findManyExtraModalQuery, 27 | countExtraModalQuery, 28 | findUniqueExtraModalQuery, 29 | findFirstExtraModalQueryObject, 30 | findManyExtraModalQueryObject, 31 | countExtraModalQueryObject, 32 | findUniqueExtraModalQueryObject 33 | } from './queries'; 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/mutations/createMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createManyExtraModalMutationArgs = builder.args((t) => ({ data: t.field({ type: [Inputs.ExtraModalCreateInput], required: true }) })) 7 | 8 | export const createManyExtraModalMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: ['ExtraModal'], 11 | nullable: false, 12 | args: createManyExtraModalMutationArgs, 13 | resolve: async (_query, _root, args, _context, _info) => 14 | await db.$transaction(args.data.map((data) => db.extraModal.create({ data }))), 15 | }), 16 | ); 17 | 18 | export const createManyExtraModalMutation = defineMutation((t) => ({ 19 | createManyExtraModal: t.prismaField(createManyExtraModalMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/mutations/createOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createOneExtraModalMutationArgs = builder.args((t) => ({ data: t.field({ type: Inputs.ExtraModalCreateInput, required: true }) })) 7 | 8 | export const createOneExtraModalMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'ExtraModal', 11 | nullable: false, 12 | args: createOneExtraModalMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.extraModal.create({ data: args.data, ...query }), 15 | }), 16 | ); 17 | 18 | export const createOneExtraModalMutation = defineMutation((t) => ({ 19 | createOneExtraModal: t.prismaField(createOneExtraModalMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/mutations/deleteMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const deleteManyExtraModalMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.ExtraModalWhereInput, required: true }) })) 8 | 9 | export const deleteManyExtraModalMutationObject = defineMutationFunction((t) => 10 | defineMutationObject({ 11 | type: BatchPayload, 12 | nullable: true, 13 | args: deleteManyExtraModalMutationArgs, 14 | resolve: async (_root, args, _context, _info) => 15 | await db.extraModal.deleteMany({ where: args.where }), 16 | }), 17 | ); 18 | 19 | export const deleteManyExtraModalMutation = defineMutation((t) => ({ 20 | deleteManyExtraModal: t.field(deleteManyExtraModalMutationObject(t)), 21 | })); 22 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/mutations/deleteOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const deleteOneExtraModalMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.ExtraModalWhereUniqueInput, required: true }) })) 7 | 8 | export const deleteOneExtraModalMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'ExtraModal', 11 | nullable: true, 12 | args: deleteOneExtraModalMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.extraModal.delete({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const deleteOneExtraModalMutation = defineMutation((t) => ({ 19 | deleteOneExtraModal: t.prismaField(deleteOneExtraModalMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/mutations/index.ts: -------------------------------------------------------------------------------- 1 | export { createManyExtraModalMutation, createManyExtraModalMutationObject } from './createMany.base'; 2 | export { createOneExtraModalMutation, createOneExtraModalMutationObject } from './createOne.base'; 3 | export { deleteManyExtraModalMutation, deleteManyExtraModalMutationObject } from './deleteMany.base'; 4 | export { deleteOneExtraModalMutation, deleteOneExtraModalMutationObject } from './deleteOne.base'; 5 | export { updateManyExtraModalMutation, updateManyExtraModalMutationObject } from './updateMany.base'; 6 | export { updateOneExtraModalMutation, updateOneExtraModalMutationObject } from './updateOne.base'; 7 | export { upsertOneExtraModalMutation, upsertOneExtraModalMutationObject } from './upsertOne.base'; 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/mutations/updateMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const updateManyExtraModalMutationArgs = builder.args((t) => ({ 8 | where: t.field({ type: Inputs.ExtraModalWhereInput, required: false }), 9 | data: t.field({ type: Inputs.ExtraModalUpdateManyMutationInput, required: true }), 10 | })) 11 | 12 | export const updateManyExtraModalMutationObject = defineMutationFunction((t) => 13 | defineMutationObject({ 14 | type: BatchPayload, 15 | nullable: false, 16 | args: updateManyExtraModalMutationArgs, 17 | resolve: async (_root, args, _context, _info) => 18 | await db.extraModal.updateMany({ where: args.where || undefined, data: args.data }), 19 | }), 20 | ); 21 | 22 | export const updateManyExtraModalMutation = defineMutation((t) => ({ 23 | updateManyExtraModal: t.field(updateManyExtraModalMutationObject(t)), 24 | })); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/mutations/updateOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const updateOneExtraModalMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.ExtraModalWhereUniqueInput, required: true }), 8 | data: t.field({ type: Inputs.ExtraModalUpdateInput, required: true }), 9 | })) 10 | 11 | export const updateOneExtraModalMutationObject = defineMutationFunction((t) => 12 | defineMutationPrismaObject({ 13 | type: 'ExtraModal', 14 | nullable: true, 15 | args: updateOneExtraModalMutationArgs, 16 | resolve: async (query, _root, args, _context, _info) => 17 | await db.extraModal.update({ where: args.where, data: args.data, ...query }), 18 | }), 19 | ); 20 | 21 | export const updateOneExtraModalMutation = defineMutation((t) => ({ 22 | updateOneExtraModal: t.prismaField(updateOneExtraModalMutationObject(t)), 23 | })); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/mutations/upsertOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const upsertOneExtraModalMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.ExtraModalWhereUniqueInput, required: true }), 8 | create: t.field({ type: Inputs.ExtraModalCreateInput, required: true }), 9 | update: t.field({ type: Inputs.ExtraModalUpdateInput, required: true }), 10 | })) 11 | 12 | export const upsertOneExtraModalMutationObject = defineMutationFunction((t) => 13 | defineMutationPrismaObject({ 14 | type: 'ExtraModal', 15 | nullable: false, 16 | args: upsertOneExtraModalMutationArgs, 17 | resolve: async (query, _root, args, _context, _info) => 18 | await db.extraModal.upsert({ 19 | where: args.where, 20 | create: args.create, 21 | update: args.update, 22 | ...query, 23 | }), 24 | }), 25 | ); 26 | 27 | export const upsertOneExtraModalMutation = defineMutation((t) => ({ 28 | upsertOneExtraModal: t.prismaField(upsertOneExtraModalMutationObject(t)), 29 | })); 30 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/object.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { builder } from '../../builder'; 3 | import { 4 | definePrismaObject, 5 | defineFieldObject, 6 | defineRelationFunction, 7 | defineRelationObject, 8 | } from '../utils'; 9 | 10 | export const ExtraModalObject = definePrismaObject('ExtraModal', { 11 | description: undefined, 12 | findUnique: ({ id }) => ({ id }), 13 | fields: (t) => ({ 14 | id: t.field(ExtraModalIdFieldObject), 15 | title: t.field(ExtraModalTitleFieldObject), 16 | createdAt: t.field(ExtraModalCreatedAtFieldObject), 17 | updatedAt: t.field(ExtraModalUpdatedAtFieldObject), 18 | }), 19 | }); 20 | 21 | export const ExtraModalIdFieldObject = defineFieldObject('ExtraModal', { 22 | type: "ID", 23 | description: undefined, 24 | nullable: false, 25 | resolve: (parent) => String(parent.id), 26 | }); 27 | 28 | export const ExtraModalTitleFieldObject = defineFieldObject('ExtraModal', { 29 | type: "String", 30 | description: 'The title of extramodal', 31 | nullable: false, 32 | resolve: (parent) => parent.title, 33 | }); 34 | 35 | export const ExtraModalCreatedAtFieldObject = defineFieldObject('ExtraModal', { 36 | type: Inputs.DateTime, 37 | description: 'createdAt description', 38 | nullable: false, 39 | resolve: (parent) => parent.createdAt, 40 | }); 41 | 42 | export const ExtraModalUpdatedAtFieldObject = defineFieldObject('ExtraModal', { 43 | type: Inputs.DateTime, 44 | description: undefined, 45 | nullable: true, 46 | resolve: (parent) => parent.updatedAt, 47 | }); 48 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/queries/count.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryObject } from '../../utils'; 5 | 6 | export const countExtraModalQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.ExtraModalWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.ExtraModalOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.ExtraModalWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.ExtraModalScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const countExtraModalQueryObject = defineQueryFunction((t) => 16 | defineQueryObject({ 17 | type: 'Int', 18 | nullable: false, 19 | args: countExtraModalQueryArgs, 20 | resolve: async (_root, args, _context, _info) => 21 | await db.extraModal.count({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | skip: args.skip || undefined, 26 | orderBy: args.orderBy || undefined, 27 | }), 28 | }), 29 | ); 30 | 31 | export const countExtraModalQuery = defineQuery((t) => ({ 32 | countExtraModal: t.field(countExtraModalQueryObject(t)), 33 | })); 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/queries/findFirst.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findFirstExtraModalQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.ExtraModalWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.ExtraModalOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.ExtraModalWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.ExtraModalScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findFirstExtraModalQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: 'ExtraModal', 18 | nullable: true, 19 | args: findFirstExtraModalQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.extraModal.findFirst({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findFirstExtraModalQuery = defineQuery((t) => ({ 34 | findFirstExtraModal: t.prismaField(findFirstExtraModalQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/queries/findMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findManyExtraModalQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.ExtraModalWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.ExtraModalOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.ExtraModalWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.ExtraModalScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findManyExtraModalQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: ['ExtraModal'], 18 | nullable: false, 19 | args: findManyExtraModalQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.extraModal.findMany({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findManyExtraModalQuery = defineQuery((t) => ({ 34 | findManyExtraModal: t.prismaField(findManyExtraModalQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/queries/findUnique.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findUniqueExtraModalQueryArgs = builder.args((t) => ({ where: t.field({ type: Inputs.ExtraModalWhereUniqueInput, required: true }) })) 7 | 8 | export const findUniqueExtraModalQueryObject = defineQueryFunction((t) => 9 | defineQueryPrismaObject({ 10 | type: 'ExtraModal', 11 | nullable: true, 12 | args: findUniqueExtraModalQueryArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.extraModal.findUnique({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const findUniqueExtraModalQuery = defineQuery((t) => ({ 19 | findUniqueExtraModal: t.prismaField(findUniqueExtraModalQueryObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/ExtraModal/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { findFirstExtraModalQuery, findFirstExtraModalQueryObject } from './findFirst.base'; 2 | export { findManyExtraModalQuery, findManyExtraModalQueryObject } from './findMany.base'; 3 | export { countExtraModalQuery, countExtraModalQueryObject } from './count.base'; 4 | export { findUniqueExtraModalQuery, findUniqueExtraModalQueryObject } from './findUnique.base'; 5 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | FollowObject, 3 | FollowFromIdFieldObject, 4 | FollowToIdFieldObject, 5 | FollowFromFieldObject, 6 | FollowToFieldObject 7 | } from './object.base'; 8 | export { 9 | createManyFollowMutation, 10 | createOneFollowMutation, 11 | deleteManyFollowMutation, 12 | deleteOneFollowMutation, 13 | updateManyFollowMutation, 14 | updateOneFollowMutation, 15 | upsertOneFollowMutation, 16 | createManyFollowMutationObject, 17 | createOneFollowMutationObject, 18 | deleteManyFollowMutationObject, 19 | deleteOneFollowMutationObject, 20 | updateManyFollowMutationObject, 21 | updateOneFollowMutationObject, 22 | upsertOneFollowMutationObject 23 | } from './mutations'; 24 | export { 25 | findFirstFollowQuery, 26 | findManyFollowQuery, 27 | countFollowQuery, 28 | findUniqueFollowQuery, 29 | findFirstFollowQueryObject, 30 | findManyFollowQueryObject, 31 | countFollowQueryObject, 32 | findUniqueFollowQueryObject 33 | } from './queries'; 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/mutations/createMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createManyFollowMutationArgs = builder.args((t) => ({ data: t.field({ type: [Inputs.FollowCreateInput], required: true }) })) 7 | 8 | export const createManyFollowMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: ['Follow'], 11 | nullable: false, 12 | args: createManyFollowMutationArgs, 13 | resolve: async (_query, _root, args, _context, _info) => 14 | await db.$transaction(args.data.map((data) => db.follow.create({ data }))), 15 | }), 16 | ); 17 | 18 | export const createManyFollowMutation = defineMutation((t) => ({ 19 | createManyFollow: t.prismaField(createManyFollowMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/mutations/createOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createOneFollowMutationArgs = builder.args((t) => ({ data: t.field({ type: Inputs.FollowCreateInput, required: true }) })) 7 | 8 | export const createOneFollowMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'Follow', 11 | nullable: false, 12 | args: createOneFollowMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.follow.create({ data: args.data, ...query }), 15 | }), 16 | ); 17 | 18 | export const createOneFollowMutation = defineMutation((t) => ({ 19 | createOneFollow: t.prismaField(createOneFollowMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/mutations/deleteMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const deleteManyFollowMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.FollowWhereInput, required: true }) })) 8 | 9 | export const deleteManyFollowMutationObject = defineMutationFunction((t) => 10 | defineMutationObject({ 11 | type: BatchPayload, 12 | nullable: true, 13 | args: deleteManyFollowMutationArgs, 14 | resolve: async (_root, args, _context, _info) => 15 | await db.follow.deleteMany({ where: args.where }), 16 | }), 17 | ); 18 | 19 | export const deleteManyFollowMutation = defineMutation((t) => ({ 20 | deleteManyFollow: t.field(deleteManyFollowMutationObject(t)), 21 | })); 22 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/mutations/deleteOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const deleteOneFollowMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.FollowWhereUniqueInput, required: true }) })) 7 | 8 | export const deleteOneFollowMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'Follow', 11 | nullable: true, 12 | args: deleteOneFollowMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.follow.delete({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const deleteOneFollowMutation = defineMutation((t) => ({ 19 | deleteOneFollow: t.prismaField(deleteOneFollowMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/mutations/index.ts: -------------------------------------------------------------------------------- 1 | export { createManyFollowMutation, createManyFollowMutationObject } from './createMany.base'; 2 | export { createOneFollowMutation, createOneFollowMutationObject } from './createOne.base'; 3 | export { deleteManyFollowMutation, deleteManyFollowMutationObject } from './deleteMany.base'; 4 | export { deleteOneFollowMutation, deleteOneFollowMutationObject } from './deleteOne.base'; 5 | export { updateManyFollowMutation, updateManyFollowMutationObject } from './updateMany.base'; 6 | export { updateOneFollowMutation, updateOneFollowMutationObject } from './updateOne.base'; 7 | export { upsertOneFollowMutation, upsertOneFollowMutationObject } from './upsertOne.base'; 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/mutations/updateMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const updateManyFollowMutationArgs = builder.args((t) => ({ 8 | where: t.field({ type: Inputs.FollowWhereInput, required: false }), 9 | data: t.field({ type: Inputs.FollowUpdateManyMutationInput, required: true }), 10 | })) 11 | 12 | export const updateManyFollowMutationObject = defineMutationFunction((t) => 13 | defineMutationObject({ 14 | type: BatchPayload, 15 | nullable: false, 16 | args: updateManyFollowMutationArgs, 17 | resolve: async (_root, args, _context, _info) => 18 | await db.follow.updateMany({ where: args.where || undefined, data: args.data }), 19 | }), 20 | ); 21 | 22 | export const updateManyFollowMutation = defineMutation((t) => ({ 23 | updateManyFollow: t.field(updateManyFollowMutationObject(t)), 24 | })); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/mutations/updateOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const updateOneFollowMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.FollowWhereUniqueInput, required: true }), 8 | data: t.field({ type: Inputs.FollowUpdateInput, required: true }), 9 | })) 10 | 11 | export const updateOneFollowMutationObject = defineMutationFunction((t) => 12 | defineMutationPrismaObject({ 13 | type: 'Follow', 14 | nullable: true, 15 | args: updateOneFollowMutationArgs, 16 | resolve: async (query, _root, args, _context, _info) => 17 | await db.follow.update({ where: args.where, data: args.data, ...query }), 18 | }), 19 | ); 20 | 21 | export const updateOneFollowMutation = defineMutation((t) => ({ 22 | updateOneFollow: t.prismaField(updateOneFollowMutationObject(t)), 23 | })); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/mutations/upsertOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const upsertOneFollowMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.FollowWhereUniqueInput, required: true }), 8 | create: t.field({ type: Inputs.FollowCreateInput, required: true }), 9 | update: t.field({ type: Inputs.FollowUpdateInput, required: true }), 10 | })) 11 | 12 | export const upsertOneFollowMutationObject = defineMutationFunction((t) => 13 | defineMutationPrismaObject({ 14 | type: 'Follow', 15 | nullable: false, 16 | args: upsertOneFollowMutationArgs, 17 | resolve: async (query, _root, args, _context, _info) => 18 | await db.follow.upsert({ 19 | where: args.where, 20 | create: args.create, 21 | update: args.update, 22 | ...query, 23 | }), 24 | }), 25 | ); 26 | 27 | export const upsertOneFollowMutation = defineMutation((t) => ({ 28 | upsertOneFollow: t.prismaField(upsertOneFollowMutationObject(t)), 29 | })); 30 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/object.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { builder } from '../../builder'; 3 | import { 4 | definePrismaObject, 5 | defineFieldObject, 6 | defineRelationFunction, 7 | defineRelationObject, 8 | } from '../utils'; 9 | 10 | export const FollowObject = definePrismaObject('Follow', { 11 | description: undefined, 12 | findUnique: (fields) => ({ compositeID: fields }), 13 | fields: (t) => ({ 14 | fromId: t.field(FollowFromIdFieldObject), 15 | toId: t.field(FollowToIdFieldObject), 16 | From: t.relation('From', FollowFromFieldObject), 17 | To: t.relation('To', FollowToFieldObject), 18 | }), 19 | }); 20 | 21 | export const FollowFromIdFieldObject = defineFieldObject('Follow', { 22 | type: "Int", 23 | description: undefined, 24 | nullable: false, 25 | resolve: (parent) => parent.fromId, 26 | }); 27 | 28 | export const FollowToIdFieldObject = defineFieldObject('Follow', { 29 | type: "Int", 30 | description: undefined, 31 | nullable: false, 32 | resolve: (parent) => parent.toId, 33 | }); 34 | 35 | export const FollowFromFieldObject = defineRelationObject('Follow', 'From', { 36 | description: undefined, 37 | nullable: false, 38 | args: undefined, 39 | query: undefined, 40 | }); 41 | 42 | export const FollowToFieldObject = defineRelationObject('Follow', 'To', { 43 | description: undefined, 44 | nullable: false, 45 | args: undefined, 46 | query: undefined, 47 | }); 48 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/queries/count.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryObject } from '../../utils'; 5 | 6 | export const countFollowQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.FollowWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.FollowOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.FollowWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.FollowScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const countFollowQueryObject = defineQueryFunction((t) => 16 | defineQueryObject({ 17 | type: 'Int', 18 | nullable: false, 19 | args: countFollowQueryArgs, 20 | resolve: async (_root, args, _context, _info) => 21 | await db.follow.count({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | skip: args.skip || undefined, 26 | orderBy: args.orderBy || undefined, 27 | }), 28 | }), 29 | ); 30 | 31 | export const countFollowQuery = defineQuery((t) => ({ 32 | countFollow: t.field(countFollowQueryObject(t)), 33 | })); 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/queries/findFirst.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findFirstFollowQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.FollowWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.FollowOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.FollowWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.FollowScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findFirstFollowQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: 'Follow', 18 | nullable: true, 19 | args: findFirstFollowQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.follow.findFirst({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findFirstFollowQuery = defineQuery((t) => ({ 34 | findFirstFollow: t.prismaField(findFirstFollowQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/queries/findMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findManyFollowQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.FollowWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.FollowOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.FollowWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.FollowScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findManyFollowQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: ['Follow'], 18 | nullable: false, 19 | args: findManyFollowQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.follow.findMany({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findManyFollowQuery = defineQuery((t) => ({ 34 | findManyFollow: t.prismaField(findManyFollowQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/queries/findUnique.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findUniqueFollowQueryArgs = builder.args((t) => ({ where: t.field({ type: Inputs.FollowWhereUniqueInput, required: true }) })) 7 | 8 | export const findUniqueFollowQueryObject = defineQueryFunction((t) => 9 | defineQueryPrismaObject({ 10 | type: 'Follow', 11 | nullable: true, 12 | args: findUniqueFollowQueryArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.follow.findUnique({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const findUniqueFollowQuery = defineQuery((t) => ({ 19 | findUniqueFollow: t.prismaField(findUniqueFollowQueryObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Follow/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { findFirstFollowQuery, findFirstFollowQueryObject } from './findFirst.base'; 2 | export { findManyFollowQuery, findManyFollowQueryObject } from './findMany.base'; 3 | export { countFollowQuery, countFollowQueryObject } from './count.base'; 4 | export { findUniqueFollowQuery, findUniqueFollowQueryObject } from './findUnique.base'; 5 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | IdOnlyObject, 3 | IdOnlyIdFieldObject 4 | } from './object.base'; 5 | export { 6 | createManyIdOnlyMutation, 7 | createOneIdOnlyMutation, 8 | deleteManyIdOnlyMutation, 9 | deleteOneIdOnlyMutation, 10 | updateManyIdOnlyMutation, 11 | updateOneIdOnlyMutation, 12 | upsertOneIdOnlyMutation, 13 | createManyIdOnlyMutationObject, 14 | createOneIdOnlyMutationObject, 15 | deleteManyIdOnlyMutationObject, 16 | deleteOneIdOnlyMutationObject, 17 | updateManyIdOnlyMutationObject, 18 | updateOneIdOnlyMutationObject, 19 | upsertOneIdOnlyMutationObject 20 | } from './mutations'; 21 | export { 22 | findFirstIdOnlyQuery, 23 | findManyIdOnlyQuery, 24 | countIdOnlyQuery, 25 | findUniqueIdOnlyQuery, 26 | findFirstIdOnlyQueryObject, 27 | findManyIdOnlyQueryObject, 28 | countIdOnlyQueryObject, 29 | findUniqueIdOnlyQueryObject 30 | } from './queries'; 31 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/mutations/createMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createManyIdOnlyMutationArgs = builder.args((t) => ({ data: t.field({ type: [Inputs.IdOnlyCreateInput], required: true }) })) 7 | 8 | export const createManyIdOnlyMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: ['IdOnly'], 11 | nullable: false, 12 | args: createManyIdOnlyMutationArgs, 13 | resolve: async (_query, _root, args, _context, _info) => 14 | await db.$transaction(args.data.map((data) => db.idOnly.create({ data }))), 15 | }), 16 | ); 17 | 18 | export const createManyIdOnlyMutation = defineMutation((t) => ({ 19 | createManyIdOnly: t.prismaField(createManyIdOnlyMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/mutations/createOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createOneIdOnlyMutationArgs = builder.args((t) => ({ data: t.field({ type: Inputs.IdOnlyCreateInput, required: true }) })) 7 | 8 | export const createOneIdOnlyMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'IdOnly', 11 | nullable: false, 12 | args: createOneIdOnlyMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.idOnly.create({ data: args.data, ...query }), 15 | }), 16 | ); 17 | 18 | export const createOneIdOnlyMutation = defineMutation((t) => ({ 19 | createOneIdOnly: t.prismaField(createOneIdOnlyMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/mutations/deleteMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const deleteManyIdOnlyMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.IdOnlyWhereInput, required: true }) })) 8 | 9 | export const deleteManyIdOnlyMutationObject = defineMutationFunction((t) => 10 | defineMutationObject({ 11 | type: BatchPayload, 12 | nullable: true, 13 | args: deleteManyIdOnlyMutationArgs, 14 | resolve: async (_root, args, _context, _info) => 15 | await db.idOnly.deleteMany({ where: args.where }), 16 | }), 17 | ); 18 | 19 | export const deleteManyIdOnlyMutation = defineMutation((t) => ({ 20 | deleteManyIdOnly: t.field(deleteManyIdOnlyMutationObject(t)), 21 | })); 22 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/mutations/deleteOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const deleteOneIdOnlyMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.IdOnlyWhereUniqueInput, required: true }) })) 7 | 8 | export const deleteOneIdOnlyMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'IdOnly', 11 | nullable: true, 12 | args: deleteOneIdOnlyMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.idOnly.delete({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const deleteOneIdOnlyMutation = defineMutation((t) => ({ 19 | deleteOneIdOnly: t.prismaField(deleteOneIdOnlyMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/mutations/index.ts: -------------------------------------------------------------------------------- 1 | export { createManyIdOnlyMutation, createManyIdOnlyMutationObject } from './createMany.base'; 2 | export { createOneIdOnlyMutation, createOneIdOnlyMutationObject } from './createOne.base'; 3 | export { deleteManyIdOnlyMutation, deleteManyIdOnlyMutationObject } from './deleteMany.base'; 4 | export { deleteOneIdOnlyMutation, deleteOneIdOnlyMutationObject } from './deleteOne.base'; 5 | export { updateManyIdOnlyMutation, updateManyIdOnlyMutationObject } from './updateMany.base'; 6 | export { updateOneIdOnlyMutation, updateOneIdOnlyMutationObject } from './updateOne.base'; 7 | export { upsertOneIdOnlyMutation, upsertOneIdOnlyMutationObject } from './upsertOne.base'; 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/mutations/updateMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const updateManyIdOnlyMutationArgs = builder.args((t) => ({ 8 | where: t.field({ type: Inputs.IdOnlyWhereInput, required: false }), 9 | data: t.field({ type: Inputs.IdOnlyUpdateManyMutationInput, required: true }), 10 | })) 11 | 12 | export const updateManyIdOnlyMutationObject = defineMutationFunction((t) => 13 | defineMutationObject({ 14 | type: BatchPayload, 15 | nullable: false, 16 | args: updateManyIdOnlyMutationArgs, 17 | resolve: async (_root, args, _context, _info) => 18 | await db.idOnly.updateMany({ where: args.where || undefined, data: args.data }), 19 | }), 20 | ); 21 | 22 | export const updateManyIdOnlyMutation = defineMutation((t) => ({ 23 | updateManyIdOnly: t.field(updateManyIdOnlyMutationObject(t)), 24 | })); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/mutations/updateOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const updateOneIdOnlyMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.IdOnlyWhereUniqueInput, required: true }), 8 | data: t.field({ type: Inputs.IdOnlyUpdateInput, required: true }), 9 | })) 10 | 11 | export const updateOneIdOnlyMutationObject = defineMutationFunction((t) => 12 | defineMutationPrismaObject({ 13 | type: 'IdOnly', 14 | nullable: true, 15 | args: updateOneIdOnlyMutationArgs, 16 | resolve: async (query, _root, args, _context, _info) => 17 | await db.idOnly.update({ where: args.where, data: args.data, ...query }), 18 | }), 19 | ); 20 | 21 | export const updateOneIdOnlyMutation = defineMutation((t) => ({ 22 | updateOneIdOnly: t.prismaField(updateOneIdOnlyMutationObject(t)), 23 | })); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/mutations/upsertOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const upsertOneIdOnlyMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.IdOnlyWhereUniqueInput, required: true }), 8 | create: t.field({ type: Inputs.IdOnlyCreateInput, required: true }), 9 | update: t.field({ type: Inputs.IdOnlyUpdateInput, required: true }), 10 | })) 11 | 12 | export const upsertOneIdOnlyMutationObject = defineMutationFunction((t) => 13 | defineMutationPrismaObject({ 14 | type: 'IdOnly', 15 | nullable: false, 16 | args: upsertOneIdOnlyMutationArgs, 17 | resolve: async (query, _root, args, _context, _info) => 18 | await db.idOnly.upsert({ 19 | where: args.where, 20 | create: args.create, 21 | update: args.update, 22 | ...query, 23 | }), 24 | }), 25 | ); 26 | 27 | export const upsertOneIdOnlyMutation = defineMutation((t) => ({ 28 | upsertOneIdOnly: t.prismaField(upsertOneIdOnlyMutationObject(t)), 29 | })); 30 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/object.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { builder } from '../../builder'; 3 | import { 4 | definePrismaObject, 5 | defineFieldObject, 6 | defineRelationFunction, 7 | defineRelationObject, 8 | } from '../utils'; 9 | 10 | export const IdOnlyObject = definePrismaObject('IdOnly', { 11 | description: undefined, 12 | findUnique: ({ id }) => ({ id }), 13 | fields: (t) => ({ 14 | id: t.field(IdOnlyIdFieldObject), 15 | }), 16 | }); 17 | 18 | export const IdOnlyIdFieldObject = defineFieldObject('IdOnly', { 19 | type: "ID", 20 | description: undefined, 21 | nullable: false, 22 | resolve: (parent) => String(parent.id), 23 | }); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/queries/count.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryObject } from '../../utils'; 5 | 6 | export const countIdOnlyQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.IdOnlyWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.IdOnlyOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.IdOnlyWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.IdOnlyScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const countIdOnlyQueryObject = defineQueryFunction((t) => 16 | defineQueryObject({ 17 | type: 'Int', 18 | nullable: false, 19 | args: countIdOnlyQueryArgs, 20 | resolve: async (_root, args, _context, _info) => 21 | await db.idOnly.count({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | skip: args.skip || undefined, 26 | orderBy: args.orderBy || undefined, 27 | }), 28 | }), 29 | ); 30 | 31 | export const countIdOnlyQuery = defineQuery((t) => ({ 32 | countIdOnly: t.field(countIdOnlyQueryObject(t)), 33 | })); 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/queries/findFirst.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findFirstIdOnlyQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.IdOnlyWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.IdOnlyOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.IdOnlyWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.IdOnlyScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findFirstIdOnlyQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: 'IdOnly', 18 | nullable: true, 19 | args: findFirstIdOnlyQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.idOnly.findFirst({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findFirstIdOnlyQuery = defineQuery((t) => ({ 34 | findFirstIdOnly: t.prismaField(findFirstIdOnlyQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/queries/findMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findManyIdOnlyQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.IdOnlyWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.IdOnlyOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.IdOnlyWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.IdOnlyScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findManyIdOnlyQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: ['IdOnly'], 18 | nullable: false, 19 | args: findManyIdOnlyQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.idOnly.findMany({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findManyIdOnlyQuery = defineQuery((t) => ({ 34 | findManyIdOnly: t.prismaField(findManyIdOnlyQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/queries/findUnique.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findUniqueIdOnlyQueryArgs = builder.args((t) => ({ where: t.field({ type: Inputs.IdOnlyWhereUniqueInput, required: true }) })) 7 | 8 | export const findUniqueIdOnlyQueryObject = defineQueryFunction((t) => 9 | defineQueryPrismaObject({ 10 | type: 'IdOnly', 11 | nullable: true, 12 | args: findUniqueIdOnlyQueryArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.idOnly.findUnique({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const findUniqueIdOnlyQuery = defineQuery((t) => ({ 19 | findUniqueIdOnly: t.prismaField(findUniqueIdOnlyQueryObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/IdOnly/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { findFirstIdOnlyQuery, findFirstIdOnlyQueryObject } from './findFirst.base'; 2 | export { findManyIdOnlyQuery, findManyIdOnlyQueryObject } from './findMany.base'; 3 | export { countIdOnlyQuery, countIdOnlyQueryObject } from './count.base'; 4 | export { findUniqueIdOnlyQuery, findUniqueIdOnlyQueryObject } from './findUnique.base'; 5 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | PostObject, 3 | PostIdFieldObject, 4 | PostTitleFieldObject, 5 | PostContentFieldObject, 6 | PostAuthorFieldObject, 7 | PostCommentsFieldObject, 8 | PostAuthorIdFieldObject 9 | } from './object.base'; 10 | export { 11 | createManyPostMutation, 12 | createOnePostMutation, 13 | deleteManyPostMutation, 14 | deleteOnePostMutation, 15 | updateManyPostMutation, 16 | updateOnePostMutation, 17 | upsertOnePostMutation, 18 | createManyPostMutationObject, 19 | createOnePostMutationObject, 20 | deleteManyPostMutationObject, 21 | deleteOnePostMutationObject, 22 | updateManyPostMutationObject, 23 | updateOnePostMutationObject, 24 | upsertOnePostMutationObject 25 | } from './mutations'; 26 | export { 27 | findFirstPostQuery, 28 | findManyPostQuery, 29 | countPostQuery, 30 | findUniquePostQuery, 31 | findFirstPostQueryObject, 32 | findManyPostQueryObject, 33 | countPostQueryObject, 34 | findUniquePostQueryObject 35 | } from './queries'; 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/mutations/createMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createManyPostMutationArgs = builder.args((t) => ({ data: t.field({ type: [Inputs.PostCreateInput], required: true }) })) 7 | 8 | export const createManyPostMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: ['Post'], 11 | nullable: false, 12 | args: createManyPostMutationArgs, 13 | resolve: async (_query, _root, args, _context, _info) => 14 | await db.$transaction(args.data.map((data) => db.post.create({ data }))), 15 | }), 16 | ); 17 | 18 | export const createManyPostMutation = defineMutation((t) => ({ 19 | createManyPost: t.prismaField(createManyPostMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/mutations/createOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createOnePostMutationArgs = builder.args((t) => ({ data: t.field({ type: Inputs.PostCreateInput, required: true }) })) 7 | 8 | export const createOnePostMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'Post', 11 | nullable: false, 12 | args: createOnePostMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.post.create({ data: args.data, ...query }), 15 | }), 16 | ); 17 | 18 | export const createOnePostMutation = defineMutation((t) => ({ 19 | createOnePost: t.prismaField(createOnePostMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/mutations/deleteMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const deleteManyPostMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.PostWhereInput, required: true }) })) 8 | 9 | export const deleteManyPostMutationObject = defineMutationFunction((t) => 10 | defineMutationObject({ 11 | type: BatchPayload, 12 | nullable: true, 13 | args: deleteManyPostMutationArgs, 14 | resolve: async (_root, args, _context, _info) => 15 | await db.post.deleteMany({ where: args.where }), 16 | }), 17 | ); 18 | 19 | export const deleteManyPostMutation = defineMutation((t) => ({ 20 | deleteManyPost: t.field(deleteManyPostMutationObject(t)), 21 | })); 22 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/mutations/deleteOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const deleteOnePostMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.PostWhereUniqueInput, required: true }) })) 7 | 8 | export const deleteOnePostMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'Post', 11 | nullable: true, 12 | args: deleteOnePostMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.post.delete({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const deleteOnePostMutation = defineMutation((t) => ({ 19 | deleteOnePost: t.prismaField(deleteOnePostMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/mutations/index.ts: -------------------------------------------------------------------------------- 1 | export { createManyPostMutation, createManyPostMutationObject } from './createMany.base'; 2 | export { createOnePostMutation, createOnePostMutationObject } from './createOne.base'; 3 | export { deleteManyPostMutation, deleteManyPostMutationObject } from './deleteMany.base'; 4 | export { deleteOnePostMutation, deleteOnePostMutationObject } from './deleteOne.base'; 5 | export { updateManyPostMutation, updateManyPostMutationObject } from './updateMany.base'; 6 | export { updateOnePostMutation, updateOnePostMutationObject } from './updateOne.base'; 7 | export { upsertOnePostMutation, upsertOnePostMutationObject } from './upsertOne.base'; 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/mutations/updateMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const updateManyPostMutationArgs = builder.args((t) => ({ 8 | where: t.field({ type: Inputs.PostWhereInput, required: false }), 9 | data: t.field({ type: Inputs.PostUpdateManyMutationInput, required: true }), 10 | })) 11 | 12 | export const updateManyPostMutationObject = defineMutationFunction((t) => 13 | defineMutationObject({ 14 | type: BatchPayload, 15 | nullable: false, 16 | args: updateManyPostMutationArgs, 17 | resolve: async (_root, args, _context, _info) => 18 | await db.post.updateMany({ where: args.where || undefined, data: args.data }), 19 | }), 20 | ); 21 | 22 | export const updateManyPostMutation = defineMutation((t) => ({ 23 | updateManyPost: t.field(updateManyPostMutationObject(t)), 24 | })); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/mutations/updateOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const updateOnePostMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.PostWhereUniqueInput, required: true }), 8 | data: t.field({ type: Inputs.PostUpdateInput, required: true }), 9 | })) 10 | 11 | export const updateOnePostMutationObject = defineMutationFunction((t) => 12 | defineMutationPrismaObject({ 13 | type: 'Post', 14 | nullable: true, 15 | args: updateOnePostMutationArgs, 16 | resolve: async (query, _root, args, _context, _info) => 17 | await db.post.update({ where: args.where, data: args.data, ...query }), 18 | }), 19 | ); 20 | 21 | export const updateOnePostMutation = defineMutation((t) => ({ 22 | updateOnePost: t.prismaField(updateOnePostMutationObject(t)), 23 | })); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/mutations/upsertOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const upsertOnePostMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.PostWhereUniqueInput, required: true }), 8 | create: t.field({ type: Inputs.PostCreateInput, required: true }), 9 | update: t.field({ type: Inputs.PostUpdateInput, required: true }), 10 | })) 11 | 12 | export const upsertOnePostMutationObject = defineMutationFunction((t) => 13 | defineMutationPrismaObject({ 14 | type: 'Post', 15 | nullable: false, 16 | args: upsertOnePostMutationArgs, 17 | resolve: async (query, _root, args, _context, _info) => 18 | await db.post.upsert({ 19 | where: args.where, 20 | create: args.create, 21 | update: args.update, 22 | ...query, 23 | }), 24 | }), 25 | ); 26 | 27 | export const upsertOnePostMutation = defineMutation((t) => ({ 28 | upsertOnePost: t.prismaField(upsertOnePostMutationObject(t)), 29 | })); 30 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/queries/count.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryObject } from '../../utils'; 5 | 6 | export const countPostQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.PostWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.PostOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.PostWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.PostScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const countPostQueryObject = defineQueryFunction((t) => 16 | defineQueryObject({ 17 | type: 'Int', 18 | nullable: false, 19 | args: countPostQueryArgs, 20 | resolve: async (_root, args, _context, _info) => 21 | await db.post.count({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | skip: args.skip || undefined, 26 | orderBy: args.orderBy || undefined, 27 | }), 28 | }), 29 | ); 30 | 31 | export const countPostQuery = defineQuery((t) => ({ 32 | countPost: t.field(countPostQueryObject(t)), 33 | })); 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/queries/findFirst.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findFirstPostQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.PostWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.PostOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.PostWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.PostScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findFirstPostQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: 'Post', 18 | nullable: true, 19 | args: findFirstPostQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.post.findFirst({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findFirstPostQuery = defineQuery((t) => ({ 34 | findFirstPost: t.prismaField(findFirstPostQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/queries/findMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findManyPostQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.PostWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.PostOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.PostWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.PostScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findManyPostQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: ['Post'], 18 | nullable: false, 19 | args: findManyPostQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.post.findMany({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findManyPostQuery = defineQuery((t) => ({ 34 | findManyPost: t.prismaField(findManyPostQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/queries/findUnique.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findUniquePostQueryArgs = builder.args((t) => ({ where: t.field({ type: Inputs.PostWhereUniqueInput, required: true }) })) 7 | 8 | export const findUniquePostQueryObject = defineQueryFunction((t) => 9 | defineQueryPrismaObject({ 10 | type: 'Post', 11 | nullable: true, 12 | args: findUniquePostQueryArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.post.findUnique({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const findUniquePostQuery = defineQuery((t) => ({ 19 | findUniquePost: t.prismaField(findUniquePostQueryObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Post/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { findFirstPostQuery, findFirstPostQueryObject } from './findFirst.base'; 2 | export { findManyPostQuery, findManyPostQueryObject } from './findMany.base'; 3 | export { countPostQuery, countPostQueryObject } from './count.base'; 4 | export { findUniquePostQuery, findUniquePostQueryObject } from './findUnique.base'; 5 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | ProfileObject, 3 | ProfileIdFieldObject, 4 | ProfileBioFieldObject, 5 | ProfileUserFieldObject, 6 | ProfileUserIdFieldObject 7 | } from './object.base'; 8 | export { 9 | createManyProfileMutation, 10 | createOneProfileMutation, 11 | deleteManyProfileMutation, 12 | deleteOneProfileMutation, 13 | updateManyProfileMutation, 14 | updateOneProfileMutation, 15 | upsertOneProfileMutation, 16 | createManyProfileMutationObject, 17 | createOneProfileMutationObject, 18 | deleteManyProfileMutationObject, 19 | deleteOneProfileMutationObject, 20 | updateManyProfileMutationObject, 21 | updateOneProfileMutationObject, 22 | upsertOneProfileMutationObject 23 | } from './mutations'; 24 | export { 25 | findFirstProfileQuery, 26 | findManyProfileQuery, 27 | countProfileQuery, 28 | findUniqueProfileQuery, 29 | findFirstProfileQueryObject, 30 | findManyProfileQueryObject, 31 | countProfileQueryObject, 32 | findUniqueProfileQueryObject 33 | } from './queries'; 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/mutations/createMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createManyProfileMutationArgs = builder.args((t) => ({ data: t.field({ type: [Inputs.ProfileCreateInput], required: true }) })) 7 | 8 | export const createManyProfileMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: ['Profile'], 11 | nullable: false, 12 | args: createManyProfileMutationArgs, 13 | resolve: async (_query, _root, args, _context, _info) => 14 | await db.$transaction(args.data.map((data) => db.profile.create({ data }))), 15 | }), 16 | ); 17 | 18 | export const createManyProfileMutation = defineMutation((t) => ({ 19 | createManyProfile: t.prismaField(createManyProfileMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/mutations/createOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createOneProfileMutationArgs = builder.args((t) => ({ data: t.field({ type: Inputs.ProfileCreateInput, required: true }) })) 7 | 8 | export const createOneProfileMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'Profile', 11 | nullable: false, 12 | args: createOneProfileMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.profile.create({ data: args.data, ...query }), 15 | }), 16 | ); 17 | 18 | export const createOneProfileMutation = defineMutation((t) => ({ 19 | createOneProfile: t.prismaField(createOneProfileMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/mutations/deleteMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const deleteManyProfileMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.ProfileWhereInput, required: true }) })) 8 | 9 | export const deleteManyProfileMutationObject = defineMutationFunction((t) => 10 | defineMutationObject({ 11 | type: BatchPayload, 12 | nullable: true, 13 | args: deleteManyProfileMutationArgs, 14 | resolve: async (_root, args, _context, _info) => 15 | await db.profile.deleteMany({ where: args.where }), 16 | }), 17 | ); 18 | 19 | export const deleteManyProfileMutation = defineMutation((t) => ({ 20 | deleteManyProfile: t.field(deleteManyProfileMutationObject(t)), 21 | })); 22 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/mutations/deleteOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const deleteOneProfileMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.ProfileWhereUniqueInput, required: true }) })) 7 | 8 | export const deleteOneProfileMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'Profile', 11 | nullable: true, 12 | args: deleteOneProfileMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.profile.delete({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const deleteOneProfileMutation = defineMutation((t) => ({ 19 | deleteOneProfile: t.prismaField(deleteOneProfileMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/mutations/index.ts: -------------------------------------------------------------------------------- 1 | export { createManyProfileMutation, createManyProfileMutationObject } from './createMany.base'; 2 | export { createOneProfileMutation, createOneProfileMutationObject } from './createOne.base'; 3 | export { deleteManyProfileMutation, deleteManyProfileMutationObject } from './deleteMany.base'; 4 | export { deleteOneProfileMutation, deleteOneProfileMutationObject } from './deleteOne.base'; 5 | export { updateManyProfileMutation, updateManyProfileMutationObject } from './updateMany.base'; 6 | export { updateOneProfileMutation, updateOneProfileMutationObject } from './updateOne.base'; 7 | export { upsertOneProfileMutation, upsertOneProfileMutationObject } from './upsertOne.base'; 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/mutations/updateMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const updateManyProfileMutationArgs = builder.args((t) => ({ 8 | where: t.field({ type: Inputs.ProfileWhereInput, required: false }), 9 | data: t.field({ type: Inputs.ProfileUpdateManyMutationInput, required: true }), 10 | })) 11 | 12 | export const updateManyProfileMutationObject = defineMutationFunction((t) => 13 | defineMutationObject({ 14 | type: BatchPayload, 15 | nullable: false, 16 | args: updateManyProfileMutationArgs, 17 | resolve: async (_root, args, _context, _info) => 18 | await db.profile.updateMany({ where: args.where || undefined, data: args.data }), 19 | }), 20 | ); 21 | 22 | export const updateManyProfileMutation = defineMutation((t) => ({ 23 | updateManyProfile: t.field(updateManyProfileMutationObject(t)), 24 | })); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/mutations/updateOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const updateOneProfileMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.ProfileWhereUniqueInput, required: true }), 8 | data: t.field({ type: Inputs.ProfileUpdateInput, required: true }), 9 | })) 10 | 11 | export const updateOneProfileMutationObject = defineMutationFunction((t) => 12 | defineMutationPrismaObject({ 13 | type: 'Profile', 14 | nullable: true, 15 | args: updateOneProfileMutationArgs, 16 | resolve: async (query, _root, args, _context, _info) => 17 | await db.profile.update({ where: args.where, data: args.data, ...query }), 18 | }), 19 | ); 20 | 21 | export const updateOneProfileMutation = defineMutation((t) => ({ 22 | updateOneProfile: t.prismaField(updateOneProfileMutationObject(t)), 23 | })); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/mutations/upsertOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const upsertOneProfileMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.ProfileWhereUniqueInput, required: true }), 8 | create: t.field({ type: Inputs.ProfileCreateInput, required: true }), 9 | update: t.field({ type: Inputs.ProfileUpdateInput, required: true }), 10 | })) 11 | 12 | export const upsertOneProfileMutationObject = defineMutationFunction((t) => 13 | defineMutationPrismaObject({ 14 | type: 'Profile', 15 | nullable: false, 16 | args: upsertOneProfileMutationArgs, 17 | resolve: async (query, _root, args, _context, _info) => 18 | await db.profile.upsert({ 19 | where: args.where, 20 | create: args.create, 21 | update: args.update, 22 | ...query, 23 | }), 24 | }), 25 | ); 26 | 27 | export const upsertOneProfileMutation = defineMutation((t) => ({ 28 | upsertOneProfile: t.prismaField(upsertOneProfileMutationObject(t)), 29 | })); 30 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/object.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { builder } from '../../builder'; 3 | import { 4 | definePrismaObject, 5 | defineFieldObject, 6 | defineRelationFunction, 7 | defineRelationObject, 8 | } from '../utils'; 9 | 10 | export const ProfileObject = definePrismaObject('Profile', { 11 | description: undefined, 12 | findUnique: ({ id }) => ({ id }), 13 | fields: (t) => ({ 14 | id: t.field(ProfileIdFieldObject), 15 | bio: t.field(ProfileBioFieldObject), 16 | User: t.relation('User', ProfileUserFieldObject), 17 | userId: t.field(ProfileUserIdFieldObject), 18 | }), 19 | }); 20 | 21 | export const ProfileIdFieldObject = defineFieldObject('Profile', { 22 | type: "ID", 23 | description: undefined, 24 | nullable: false, 25 | resolve: (parent) => String(parent.id), 26 | }); 27 | 28 | export const ProfileBioFieldObject = defineFieldObject('Profile', { 29 | type: "String", 30 | description: undefined, 31 | nullable: true, 32 | resolve: (parent) => parent.bio, 33 | }); 34 | 35 | export const ProfileUserFieldObject = defineRelationObject('Profile', 'User', { 36 | description: undefined, 37 | nullable: false, 38 | args: undefined, 39 | query: undefined, 40 | }); 41 | 42 | export const ProfileUserIdFieldObject = defineFieldObject('Profile', { 43 | type: "Int", 44 | description: undefined, 45 | nullable: false, 46 | resolve: (parent) => parent.userId, 47 | }); 48 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/queries/count.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryObject } from '../../utils'; 5 | 6 | export const countProfileQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.ProfileWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.ProfileOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.ProfileWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.ProfileScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const countProfileQueryObject = defineQueryFunction((t) => 16 | defineQueryObject({ 17 | type: 'Int', 18 | nullable: false, 19 | args: countProfileQueryArgs, 20 | resolve: async (_root, args, _context, _info) => 21 | await db.profile.count({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | skip: args.skip || undefined, 26 | orderBy: args.orderBy || undefined, 27 | }), 28 | }), 29 | ); 30 | 31 | export const countProfileQuery = defineQuery((t) => ({ 32 | countProfile: t.field(countProfileQueryObject(t)), 33 | })); 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/queries/findFirst.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findFirstProfileQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.ProfileWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.ProfileOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.ProfileWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.ProfileScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findFirstProfileQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: 'Profile', 18 | nullable: true, 19 | args: findFirstProfileQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.profile.findFirst({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findFirstProfileQuery = defineQuery((t) => ({ 34 | findFirstProfile: t.prismaField(findFirstProfileQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/queries/findMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findManyProfileQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.ProfileWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.ProfileOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.ProfileWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.ProfileScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findManyProfileQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: ['Profile'], 18 | nullable: false, 19 | args: findManyProfileQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.profile.findMany({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findManyProfileQuery = defineQuery((t) => ({ 34 | findManyProfile: t.prismaField(findManyProfileQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/queries/findUnique.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findUniqueProfileQueryArgs = builder.args((t) => ({ where: t.field({ type: Inputs.ProfileWhereUniqueInput, required: true }) })) 7 | 8 | export const findUniqueProfileQueryObject = defineQueryFunction((t) => 9 | defineQueryPrismaObject({ 10 | type: 'Profile', 11 | nullable: true, 12 | args: findUniqueProfileQueryArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.profile.findUnique({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const findUniqueProfileQuery = defineQuery((t) => ({ 19 | findUniqueProfile: t.prismaField(findUniqueProfileQueryObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Profile/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { findFirstProfileQuery, findFirstProfileQueryObject } from './findFirst.base'; 2 | export { findManyProfileQuery, findManyProfileQueryObject } from './findMany.base'; 3 | export { countProfileQuery, countProfileQueryObject } from './count.base'; 4 | export { findUniqueProfileQuery, findUniqueProfileQueryObject } from './findUnique.base'; 5 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | UnrelatedObject, 3 | UnrelatedIdFieldObject, 4 | UnrelatedNameFieldObject 5 | } from './object.base'; 6 | export { 7 | createManyUnrelatedMutation, 8 | createOneUnrelatedMutation, 9 | deleteManyUnrelatedMutation, 10 | deleteOneUnrelatedMutation, 11 | updateManyUnrelatedMutation, 12 | updateOneUnrelatedMutation, 13 | upsertOneUnrelatedMutation, 14 | createManyUnrelatedMutationObject, 15 | createOneUnrelatedMutationObject, 16 | deleteManyUnrelatedMutationObject, 17 | deleteOneUnrelatedMutationObject, 18 | updateManyUnrelatedMutationObject, 19 | updateOneUnrelatedMutationObject, 20 | upsertOneUnrelatedMutationObject 21 | } from './mutations'; 22 | export { 23 | findFirstUnrelatedQuery, 24 | findManyUnrelatedQuery, 25 | countUnrelatedQuery, 26 | findUniqueUnrelatedQuery, 27 | findFirstUnrelatedQueryObject, 28 | findManyUnrelatedQueryObject, 29 | countUnrelatedQueryObject, 30 | findUniqueUnrelatedQueryObject 31 | } from './queries'; 32 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/mutations/createMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createManyUnrelatedMutationArgs = builder.args((t) => ({ data: t.field({ type: [Inputs.UnrelatedCreateInput], required: true }) })) 7 | 8 | export const createManyUnrelatedMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: ['Unrelated'], 11 | nullable: false, 12 | args: createManyUnrelatedMutationArgs, 13 | resolve: async (_query, _root, args, _context, _info) => 14 | await db.$transaction(args.data.map((data) => db.unrelated.create({ data }))), 15 | }), 16 | ); 17 | 18 | export const createManyUnrelatedMutation = defineMutation((t) => ({ 19 | createManyUnrelated: t.prismaField(createManyUnrelatedMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/mutations/createOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createOneUnrelatedMutationArgs = builder.args((t) => ({ data: t.field({ type: Inputs.UnrelatedCreateInput, required: true }) })) 7 | 8 | export const createOneUnrelatedMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'Unrelated', 11 | nullable: false, 12 | args: createOneUnrelatedMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.unrelated.create({ data: args.data, ...query }), 15 | }), 16 | ); 17 | 18 | export const createOneUnrelatedMutation = defineMutation((t) => ({ 19 | createOneUnrelated: t.prismaField(createOneUnrelatedMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/mutations/deleteMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const deleteManyUnrelatedMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.UnrelatedWhereInput, required: true }) })) 8 | 9 | export const deleteManyUnrelatedMutationObject = defineMutationFunction((t) => 10 | defineMutationObject({ 11 | type: BatchPayload, 12 | nullable: true, 13 | args: deleteManyUnrelatedMutationArgs, 14 | resolve: async (_root, args, _context, _info) => 15 | await db.unrelated.deleteMany({ where: args.where }), 16 | }), 17 | ); 18 | 19 | export const deleteManyUnrelatedMutation = defineMutation((t) => ({ 20 | deleteManyUnrelated: t.field(deleteManyUnrelatedMutationObject(t)), 21 | })); 22 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/mutations/deleteOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const deleteOneUnrelatedMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.UnrelatedWhereUniqueInput, required: true }) })) 7 | 8 | export const deleteOneUnrelatedMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'Unrelated', 11 | nullable: true, 12 | args: deleteOneUnrelatedMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.unrelated.delete({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const deleteOneUnrelatedMutation = defineMutation((t) => ({ 19 | deleteOneUnrelated: t.prismaField(deleteOneUnrelatedMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/mutations/index.ts: -------------------------------------------------------------------------------- 1 | export { createManyUnrelatedMutation, createManyUnrelatedMutationObject } from './createMany.base'; 2 | export { createOneUnrelatedMutation, createOneUnrelatedMutationObject } from './createOne.base'; 3 | export { deleteManyUnrelatedMutation, deleteManyUnrelatedMutationObject } from './deleteMany.base'; 4 | export { deleteOneUnrelatedMutation, deleteOneUnrelatedMutationObject } from './deleteOne.base'; 5 | export { updateManyUnrelatedMutation, updateManyUnrelatedMutationObject } from './updateMany.base'; 6 | export { updateOneUnrelatedMutation, updateOneUnrelatedMutationObject } from './updateOne.base'; 7 | export { upsertOneUnrelatedMutation, upsertOneUnrelatedMutationObject } from './upsertOne.base'; 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/mutations/updateMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const updateManyUnrelatedMutationArgs = builder.args((t) => ({ 8 | where: t.field({ type: Inputs.UnrelatedWhereInput, required: false }), 9 | data: t.field({ type: Inputs.UnrelatedUpdateManyMutationInput, required: true }), 10 | })) 11 | 12 | export const updateManyUnrelatedMutationObject = defineMutationFunction((t) => 13 | defineMutationObject({ 14 | type: BatchPayload, 15 | nullable: false, 16 | args: updateManyUnrelatedMutationArgs, 17 | resolve: async (_root, args, _context, _info) => 18 | await db.unrelated.updateMany({ where: args.where || undefined, data: args.data }), 19 | }), 20 | ); 21 | 22 | export const updateManyUnrelatedMutation = defineMutation((t) => ({ 23 | updateManyUnrelated: t.field(updateManyUnrelatedMutationObject(t)), 24 | })); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/mutations/updateOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const updateOneUnrelatedMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UnrelatedWhereUniqueInput, required: true }), 8 | data: t.field({ type: Inputs.UnrelatedUpdateInput, required: true }), 9 | })) 10 | 11 | export const updateOneUnrelatedMutationObject = defineMutationFunction((t) => 12 | defineMutationPrismaObject({ 13 | type: 'Unrelated', 14 | nullable: true, 15 | args: updateOneUnrelatedMutationArgs, 16 | resolve: async (query, _root, args, _context, _info) => 17 | await db.unrelated.update({ where: args.where, data: args.data, ...query }), 18 | }), 19 | ); 20 | 21 | export const updateOneUnrelatedMutation = defineMutation((t) => ({ 22 | updateOneUnrelated: t.prismaField(updateOneUnrelatedMutationObject(t)), 23 | })); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/mutations/upsertOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const upsertOneUnrelatedMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UnrelatedWhereUniqueInput, required: true }), 8 | create: t.field({ type: Inputs.UnrelatedCreateInput, required: true }), 9 | update: t.field({ type: Inputs.UnrelatedUpdateInput, required: true }), 10 | })) 11 | 12 | export const upsertOneUnrelatedMutationObject = defineMutationFunction((t) => 13 | defineMutationPrismaObject({ 14 | type: 'Unrelated', 15 | nullable: false, 16 | args: upsertOneUnrelatedMutationArgs, 17 | resolve: async (query, _root, args, _context, _info) => 18 | await db.unrelated.upsert({ 19 | where: args.where, 20 | create: args.create, 21 | update: args.update, 22 | ...query, 23 | }), 24 | }), 25 | ); 26 | 27 | export const upsertOneUnrelatedMutation = defineMutation((t) => ({ 28 | upsertOneUnrelated: t.prismaField(upsertOneUnrelatedMutationObject(t)), 29 | })); 30 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/object.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { builder } from '../../builder'; 3 | import { 4 | definePrismaObject, 5 | defineFieldObject, 6 | defineRelationFunction, 7 | defineRelationObject, 8 | } from '../utils'; 9 | 10 | export const UnrelatedObject = definePrismaObject('Unrelated', { 11 | description: undefined, 12 | findUnique: ({ id }) => ({ id }), 13 | fields: (t) => ({ 14 | id: t.field(UnrelatedIdFieldObject), 15 | name: t.field(UnrelatedNameFieldObject), 16 | }), 17 | }); 18 | 19 | export const UnrelatedIdFieldObject = defineFieldObject('Unrelated', { 20 | type: "ID", 21 | description: undefined, 22 | nullable: false, 23 | resolve: (parent) => String(parent.id), 24 | }); 25 | 26 | export const UnrelatedNameFieldObject = defineFieldObject('Unrelated', { 27 | type: "String", 28 | description: undefined, 29 | nullable: true, 30 | resolve: (parent) => parent.name, 31 | }); 32 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/queries/count.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryObject } from '../../utils'; 5 | 6 | export const countUnrelatedQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UnrelatedWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.UnrelatedOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.UnrelatedWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.UnrelatedScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const countUnrelatedQueryObject = defineQueryFunction((t) => 16 | defineQueryObject({ 17 | type: 'Int', 18 | nullable: false, 19 | args: countUnrelatedQueryArgs, 20 | resolve: async (_root, args, _context, _info) => 21 | await db.unrelated.count({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | skip: args.skip || undefined, 26 | orderBy: args.orderBy || undefined, 27 | }), 28 | }), 29 | ); 30 | 31 | export const countUnrelatedQuery = defineQuery((t) => ({ 32 | countUnrelated: t.field(countUnrelatedQueryObject(t)), 33 | })); 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/queries/findFirst.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findFirstUnrelatedQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UnrelatedWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.UnrelatedOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.UnrelatedWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.UnrelatedScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findFirstUnrelatedQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: 'Unrelated', 18 | nullable: true, 19 | args: findFirstUnrelatedQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.unrelated.findFirst({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findFirstUnrelatedQuery = defineQuery((t) => ({ 34 | findFirstUnrelated: t.prismaField(findFirstUnrelatedQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/queries/findMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findManyUnrelatedQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UnrelatedWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.UnrelatedOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.UnrelatedWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.UnrelatedScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findManyUnrelatedQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: ['Unrelated'], 18 | nullable: false, 19 | args: findManyUnrelatedQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.unrelated.findMany({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findManyUnrelatedQuery = defineQuery((t) => ({ 34 | findManyUnrelated: t.prismaField(findManyUnrelatedQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/queries/findUnique.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findUniqueUnrelatedQueryArgs = builder.args((t) => ({ where: t.field({ type: Inputs.UnrelatedWhereUniqueInput, required: true }) })) 7 | 8 | export const findUniqueUnrelatedQueryObject = defineQueryFunction((t) => 9 | defineQueryPrismaObject({ 10 | type: 'Unrelated', 11 | nullable: true, 12 | args: findUniqueUnrelatedQueryArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.unrelated.findUnique({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const findUniqueUnrelatedQuery = defineQuery((t) => ({ 19 | findUniqueUnrelated: t.prismaField(findUniqueUnrelatedQueryObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/Unrelated/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { findFirstUnrelatedQuery, findFirstUnrelatedQueryObject } from './findFirst.base'; 2 | export { findManyUnrelatedQuery, findManyUnrelatedQueryObject } from './findMany.base'; 3 | export { countUnrelatedQuery, countUnrelatedQueryObject } from './count.base'; 4 | export { findUniqueUnrelatedQuery, findUniqueUnrelatedQueryObject } from './findUnique.base'; 5 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | UserObject, 3 | UserIdFieldObject, 4 | UserFirstNameFieldObject, 5 | UserLastNameFieldObject, 6 | UserBirthdateFieldObject, 7 | UserLoginFieldObject, 8 | UserPasswordFieldObject, 9 | UserPostsFieldObject, 10 | UserCommentsFieldObject, 11 | UserCreatedAtFieldObject, 12 | UserUpdatedAtFieldObject, 13 | UserProfileFieldObject, 14 | UserFollowersFieldObject, 15 | UserFollowingFieldObject 16 | } from './object.base'; 17 | export { 18 | createManyUserMutation, 19 | createOneUserMutation, 20 | deleteManyUserMutation, 21 | deleteOneUserMutation, 22 | updateManyUserMutation, 23 | updateOneUserMutation, 24 | upsertOneUserMutation, 25 | createManyUserMutationObject, 26 | createOneUserMutationObject, 27 | deleteManyUserMutationObject, 28 | deleteOneUserMutationObject, 29 | updateManyUserMutationObject, 30 | updateOneUserMutationObject, 31 | upsertOneUserMutationObject 32 | } from './mutations'; 33 | export { 34 | findFirstUserQuery, 35 | findManyUserQuery, 36 | countUserQuery, 37 | findUniqueUserQuery, 38 | findFirstUserQueryObject, 39 | findManyUserQueryObject, 40 | countUserQueryObject, 41 | findUniqueUserQueryObject 42 | } from './queries'; 43 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/mutations/createMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createManyUserMutationArgs = builder.args((t) => ({ data: t.field({ type: [Inputs.UserCreateInput], required: true }) })) 7 | 8 | export const createManyUserMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: ['User'], 11 | nullable: false, 12 | args: createManyUserMutationArgs, 13 | resolve: async (_query, _root, args, _context, _info) => 14 | await db.$transaction(args.data.map((data) => db.user.create({ data }))), 15 | }), 16 | ); 17 | 18 | export const createManyUserMutation = defineMutation((t) => ({ 19 | createManyUser: t.prismaField(createManyUserMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/mutations/createOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createOneUserMutationArgs = builder.args((t) => ({ data: t.field({ type: Inputs.UserCreateInput, required: true }) })) 7 | 8 | export const createOneUserMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'User', 11 | nullable: false, 12 | args: createOneUserMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.user.create({ data: args.data, ...query }), 15 | }), 16 | ); 17 | 18 | export const createOneUserMutation = defineMutation((t) => ({ 19 | createOneUser: t.prismaField(createOneUserMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/mutations/deleteMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const deleteManyUserMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.UserWhereInput, required: true }) })) 8 | 9 | export const deleteManyUserMutationObject = defineMutationFunction((t) => 10 | defineMutationObject({ 11 | type: BatchPayload, 12 | nullable: true, 13 | args: deleteManyUserMutationArgs, 14 | resolve: async (_root, args, _context, _info) => 15 | await db.user.deleteMany({ where: args.where }), 16 | }), 17 | ); 18 | 19 | export const deleteManyUserMutation = defineMutation((t) => ({ 20 | deleteManyUser: t.field(deleteManyUserMutationObject(t)), 21 | })); 22 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/mutations/deleteOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const deleteOneUserMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.UserWhereUniqueInput, required: true }) })) 7 | 8 | export const deleteOneUserMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'User', 11 | nullable: true, 12 | args: deleteOneUserMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.user.delete({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const deleteOneUserMutation = defineMutation((t) => ({ 19 | deleteOneUser: t.prismaField(deleteOneUserMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/mutations/index.ts: -------------------------------------------------------------------------------- 1 | export { createManyUserMutation, createManyUserMutationObject } from './createMany.base'; 2 | export { createOneUserMutation, createOneUserMutationObject } from './createOne.base'; 3 | export { deleteManyUserMutation, deleteManyUserMutationObject } from './deleteMany.base'; 4 | export { deleteOneUserMutation, deleteOneUserMutationObject } from './deleteOne.base'; 5 | export { updateManyUserMutation, updateManyUserMutationObject } from './updateMany.base'; 6 | export { updateOneUserMutation, updateOneUserMutationObject } from './updateOne.base'; 7 | export { upsertOneUserMutation, upsertOneUserMutationObject } from './upsertOne.base'; 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/mutations/updateMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const updateManyUserMutationArgs = builder.args((t) => ({ 8 | where: t.field({ type: Inputs.UserWhereInput, required: false }), 9 | data: t.field({ type: Inputs.UserUpdateManyMutationInput, required: true }), 10 | })) 11 | 12 | export const updateManyUserMutationObject = defineMutationFunction((t) => 13 | defineMutationObject({ 14 | type: BatchPayload, 15 | nullable: false, 16 | args: updateManyUserMutationArgs, 17 | resolve: async (_root, args, _context, _info) => 18 | await db.user.updateMany({ where: args.where || undefined, data: args.data }), 19 | }), 20 | ); 21 | 22 | export const updateManyUserMutation = defineMutation((t) => ({ 23 | updateManyUser: t.field(updateManyUserMutationObject(t)), 24 | })); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/mutations/updateOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const updateOneUserMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UserWhereUniqueInput, required: true }), 8 | data: t.field({ type: Inputs.UserUpdateInput, required: true }), 9 | })) 10 | 11 | export const updateOneUserMutationObject = defineMutationFunction((t) => 12 | defineMutationPrismaObject({ 13 | type: 'User', 14 | nullable: true, 15 | args: updateOneUserMutationArgs, 16 | resolve: async (query, _root, args, _context, _info) => 17 | await db.user.update({ where: args.where, data: args.data, ...query }), 18 | }), 19 | ); 20 | 21 | export const updateOneUserMutation = defineMutation((t) => ({ 22 | updateOneUser: t.prismaField(updateOneUserMutationObject(t)), 23 | })); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/mutations/upsertOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const upsertOneUserMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UserWhereUniqueInput, required: true }), 8 | create: t.field({ type: Inputs.UserCreateInput, required: true }), 9 | update: t.field({ type: Inputs.UserUpdateInput, required: true }), 10 | })) 11 | 12 | export const upsertOneUserMutationObject = defineMutationFunction((t) => 13 | defineMutationPrismaObject({ 14 | type: 'User', 15 | nullable: false, 16 | args: upsertOneUserMutationArgs, 17 | resolve: async (query, _root, args, _context, _info) => 18 | await db.user.upsert({ 19 | where: args.where, 20 | create: args.create, 21 | update: args.update, 22 | ...query, 23 | }), 24 | }), 25 | ); 26 | 27 | export const upsertOneUserMutation = defineMutation((t) => ({ 28 | upsertOneUser: t.prismaField(upsertOneUserMutationObject(t)), 29 | })); 30 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/queries/count.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryObject } from '../../utils'; 5 | 6 | export const countUserQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UserWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.UserOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.UserWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.UserScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const countUserQueryObject = defineQueryFunction((t) => 16 | defineQueryObject({ 17 | type: 'Int', 18 | nullable: false, 19 | args: countUserQueryArgs, 20 | resolve: async (_root, args, _context, _info) => 21 | await db.user.count({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | skip: args.skip || undefined, 26 | orderBy: args.orderBy || undefined, 27 | }), 28 | }), 29 | ); 30 | 31 | export const countUserQuery = defineQuery((t) => ({ 32 | countUser: t.field(countUserQueryObject(t)), 33 | })); 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/queries/findFirst.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findFirstUserQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UserWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.UserOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.UserWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.UserScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findFirstUserQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: 'User', 18 | nullable: true, 19 | args: findFirstUserQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.user.findFirst({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findFirstUserQuery = defineQuery((t) => ({ 34 | findFirstUser: t.prismaField(findFirstUserQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/queries/findMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findManyUserQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UserWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.UserOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.UserWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.UserScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findManyUserQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: ['User'], 18 | nullable: false, 19 | args: findManyUserQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.user.findMany({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findManyUserQuery = defineQuery((t) => ({ 34 | findManyUser: t.prismaField(findManyUserQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/queries/findUnique.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findUniqueUserQueryArgs = builder.args((t) => ({ where: t.field({ type: Inputs.UserWhereUniqueInput, required: true }) })) 7 | 8 | export const findUniqueUserQueryObject = defineQueryFunction((t) => 9 | defineQueryPrismaObject({ 10 | type: 'User', 11 | nullable: true, 12 | args: findUniqueUserQueryArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.user.findUnique({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const findUniqueUserQuery = defineQuery((t) => ({ 19 | findUniqueUser: t.prismaField(findUniqueUserQueryObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/User/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { findFirstUserQuery, findFirstUserQueryObject } from './findFirst.base'; 2 | export { findManyUserQuery, findManyUserQueryObject } from './findMany.base'; 3 | export { countUserQuery, countUserQueryObject } from './count.base'; 4 | export { findUniqueUserQuery, findUniqueUserQueryObject } from './findUnique.base'; 5 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | UserLastObject, 3 | UserLastIdFieldObject, 4 | UserLastNameFieldObject 5 | } from './object.base'; 6 | export { 7 | createManyUserLastMutation, 8 | createOneUserLastMutation, 9 | deleteManyUserLastMutation, 10 | deleteOneUserLastMutation, 11 | updateManyUserLastMutation, 12 | updateOneUserLastMutation, 13 | upsertOneUserLastMutation, 14 | createManyUserLastMutationObject, 15 | createOneUserLastMutationObject, 16 | deleteManyUserLastMutationObject, 17 | deleteOneUserLastMutationObject, 18 | updateManyUserLastMutationObject, 19 | updateOneUserLastMutationObject, 20 | upsertOneUserLastMutationObject 21 | } from './mutations'; 22 | export { 23 | findFirstUserLastQuery, 24 | findManyUserLastQuery, 25 | countUserLastQuery, 26 | findUniqueUserLastQuery, 27 | findFirstUserLastQueryObject, 28 | findManyUserLastQueryObject, 29 | countUserLastQueryObject, 30 | findUniqueUserLastQueryObject 31 | } from './queries'; 32 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/mutations/createMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createManyUserLastMutationArgs = builder.args((t) => ({ data: t.field({ type: [Inputs.UserLastCreateInput], required: true }) })) 7 | 8 | export const createManyUserLastMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: ['UserLast'], 11 | nullable: false, 12 | args: createManyUserLastMutationArgs, 13 | resolve: async (_query, _root, args, _context, _info) => 14 | await db.$transaction(args.data.map((data) => db.userLast.create({ data }))), 15 | }), 16 | ); 17 | 18 | export const createManyUserLastMutation = defineMutation((t) => ({ 19 | createManyUserLast: t.prismaField(createManyUserLastMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/mutations/createOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createOneUserLastMutationArgs = builder.args((t) => ({ data: t.field({ type: Inputs.UserLastCreateInput, required: true }) })) 7 | 8 | export const createOneUserLastMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'UserLast', 11 | nullable: false, 12 | args: createOneUserLastMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.userLast.create({ data: args.data, ...query }), 15 | }), 16 | ); 17 | 18 | export const createOneUserLastMutation = defineMutation((t) => ({ 19 | createOneUserLast: t.prismaField(createOneUserLastMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/mutations/deleteMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const deleteManyUserLastMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.UserLastWhereInput, required: true }) })) 8 | 9 | export const deleteManyUserLastMutationObject = defineMutationFunction((t) => 10 | defineMutationObject({ 11 | type: BatchPayload, 12 | nullable: true, 13 | args: deleteManyUserLastMutationArgs, 14 | resolve: async (_root, args, _context, _info) => 15 | await db.userLast.deleteMany({ where: args.where }), 16 | }), 17 | ); 18 | 19 | export const deleteManyUserLastMutation = defineMutation((t) => ({ 20 | deleteManyUserLast: t.field(deleteManyUserLastMutationObject(t)), 21 | })); 22 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/mutations/deleteOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const deleteOneUserLastMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.UserLastWhereUniqueInput, required: true }) })) 7 | 8 | export const deleteOneUserLastMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'UserLast', 11 | nullable: true, 12 | args: deleteOneUserLastMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.userLast.delete({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const deleteOneUserLastMutation = defineMutation((t) => ({ 19 | deleteOneUserLast: t.prismaField(deleteOneUserLastMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/mutations/index.ts: -------------------------------------------------------------------------------- 1 | export { createManyUserLastMutation, createManyUserLastMutationObject } from './createMany.base'; 2 | export { createOneUserLastMutation, createOneUserLastMutationObject } from './createOne.base'; 3 | export { deleteManyUserLastMutation, deleteManyUserLastMutationObject } from './deleteMany.base'; 4 | export { deleteOneUserLastMutation, deleteOneUserLastMutationObject } from './deleteOne.base'; 5 | export { updateManyUserLastMutation, updateManyUserLastMutationObject } from './updateMany.base'; 6 | export { updateOneUserLastMutation, updateOneUserLastMutationObject } from './updateOne.base'; 7 | export { upsertOneUserLastMutation, upsertOneUserLastMutationObject } from './upsertOne.base'; 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/mutations/updateMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const updateManyUserLastMutationArgs = builder.args((t) => ({ 8 | where: t.field({ type: Inputs.UserLastWhereInput, required: false }), 9 | data: t.field({ type: Inputs.UserLastUpdateManyMutationInput, required: true }), 10 | })) 11 | 12 | export const updateManyUserLastMutationObject = defineMutationFunction((t) => 13 | defineMutationObject({ 14 | type: BatchPayload, 15 | nullable: false, 16 | args: updateManyUserLastMutationArgs, 17 | resolve: async (_root, args, _context, _info) => 18 | await db.userLast.updateMany({ where: args.where || undefined, data: args.data }), 19 | }), 20 | ); 21 | 22 | export const updateManyUserLastMutation = defineMutation((t) => ({ 23 | updateManyUserLast: t.field(updateManyUserLastMutationObject(t)), 24 | })); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/mutations/updateOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const updateOneUserLastMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UserLastWhereUniqueInput, required: true }), 8 | data: t.field({ type: Inputs.UserLastUpdateInput, required: true }), 9 | })) 10 | 11 | export const updateOneUserLastMutationObject = defineMutationFunction((t) => 12 | defineMutationPrismaObject({ 13 | type: 'UserLast', 14 | nullable: true, 15 | args: updateOneUserLastMutationArgs, 16 | resolve: async (query, _root, args, _context, _info) => 17 | await db.userLast.update({ where: args.where, data: args.data, ...query }), 18 | }), 19 | ); 20 | 21 | export const updateOneUserLastMutation = defineMutation((t) => ({ 22 | updateOneUserLast: t.prismaField(updateOneUserLastMutationObject(t)), 23 | })); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/mutations/upsertOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const upsertOneUserLastMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UserLastWhereUniqueInput, required: true }), 8 | create: t.field({ type: Inputs.UserLastCreateInput, required: true }), 9 | update: t.field({ type: Inputs.UserLastUpdateInput, required: true }), 10 | })) 11 | 12 | export const upsertOneUserLastMutationObject = defineMutationFunction((t) => 13 | defineMutationPrismaObject({ 14 | type: 'UserLast', 15 | nullable: false, 16 | args: upsertOneUserLastMutationArgs, 17 | resolve: async (query, _root, args, _context, _info) => 18 | await db.userLast.upsert({ 19 | where: args.where, 20 | create: args.create, 21 | update: args.update, 22 | ...query, 23 | }), 24 | }), 25 | ); 26 | 27 | export const upsertOneUserLastMutation = defineMutation((t) => ({ 28 | upsertOneUserLast: t.prismaField(upsertOneUserLastMutationObject(t)), 29 | })); 30 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/object.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { builder } from '../../builder'; 3 | import { 4 | definePrismaObject, 5 | defineFieldObject, 6 | defineRelationFunction, 7 | defineRelationObject, 8 | } from '../utils'; 9 | 10 | export const UserLastObject = definePrismaObject('UserLast', { 11 | description: 'Its for check for duplicating User.LastName and UserLast.Name', 12 | findUnique: ({ id }) => ({ id }), 13 | fields: (t) => ({ 14 | id: t.field(UserLastIdFieldObject), 15 | name: t.field(UserLastNameFieldObject), 16 | }), 17 | }); 18 | 19 | export const UserLastIdFieldObject = defineFieldObject('UserLast', { 20 | type: "ID", 21 | description: undefined, 22 | nullable: false, 23 | resolve: (parent) => String(parent.id), 24 | }); 25 | 26 | export const UserLastNameFieldObject = defineFieldObject('UserLast', { 27 | type: "String", 28 | description: undefined, 29 | nullable: false, 30 | resolve: (parent) => parent.name, 31 | }); 32 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/queries/count.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryObject } from '../../utils'; 5 | 6 | export const countUserLastQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UserLastWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.UserLastOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.UserLastWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.UserLastScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const countUserLastQueryObject = defineQueryFunction((t) => 16 | defineQueryObject({ 17 | type: 'Int', 18 | nullable: false, 19 | args: countUserLastQueryArgs, 20 | resolve: async (_root, args, _context, _info) => 21 | await db.userLast.count({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | skip: args.skip || undefined, 26 | orderBy: args.orderBy || undefined, 27 | }), 28 | }), 29 | ); 30 | 31 | export const countUserLastQuery = defineQuery((t) => ({ 32 | countUserLast: t.field(countUserLastQueryObject(t)), 33 | })); 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/queries/findFirst.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findFirstUserLastQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UserLastWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.UserLastOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.UserLastWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.UserLastScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findFirstUserLastQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: 'UserLast', 18 | nullable: true, 19 | args: findFirstUserLastQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.userLast.findFirst({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findFirstUserLastQuery = defineQuery((t) => ({ 34 | findFirstUserLast: t.prismaField(findFirstUserLastQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/queries/findMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findManyUserLastQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.UserLastWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.UserLastOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.UserLastWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.UserLastScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findManyUserLastQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: ['UserLast'], 18 | nullable: false, 19 | args: findManyUserLastQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.userLast.findMany({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findManyUserLastQuery = defineQuery((t) => ({ 34 | findManyUserLast: t.prismaField(findManyUserLastQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/queries/findUnique.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findUniqueUserLastQueryArgs = builder.args((t) => ({ where: t.field({ type: Inputs.UserLastWhereUniqueInput, required: true }) })) 7 | 8 | export const findUniqueUserLastQueryObject = defineQueryFunction((t) => 9 | defineQueryPrismaObject({ 10 | type: 'UserLast', 11 | nullable: true, 12 | args: findUniqueUserLastQueryArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.userLast.findUnique({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const findUniqueUserLastQuery = defineQuery((t) => ({ 19 | findUniqueUserLast: t.prismaField(findUniqueUserLastQueryObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/UserLast/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { findFirstUserLastQuery, findFirstUserLastQueryObject } from './findFirst.base'; 2 | export { findManyUserLastQuery, findManyUserLastQueryObject } from './findMany.base'; 3 | export { countUserLastQuery, countUserLastQueryObject } from './count.base'; 4 | export { findUniqueUserLastQuery, findUniqueUserLastQueryObject } from './findUnique.base'; 5 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | WithScalarsObject, 3 | WithScalarsIdFieldObject, 4 | WithScalarsStringFieldObject, 5 | WithScalarsBooleanFieldObject, 6 | WithScalarsIntFieldObject, 7 | WithScalarsFloatFieldObject, 8 | WithScalarsDecimalFieldObject, 9 | WithScalarsBigintFieldObject, 10 | WithScalarsDatetimeFieldObject, 11 | WithScalarsBytesFieldObject 12 | } from './object.base'; 13 | export { 14 | createManyWithScalarsMutation, 15 | createOneWithScalarsMutation, 16 | deleteManyWithScalarsMutation, 17 | deleteOneWithScalarsMutation, 18 | updateManyWithScalarsMutation, 19 | updateOneWithScalarsMutation, 20 | upsertOneWithScalarsMutation, 21 | createManyWithScalarsMutationObject, 22 | createOneWithScalarsMutationObject, 23 | deleteManyWithScalarsMutationObject, 24 | deleteOneWithScalarsMutationObject, 25 | updateManyWithScalarsMutationObject, 26 | updateOneWithScalarsMutationObject, 27 | upsertOneWithScalarsMutationObject 28 | } from './mutations'; 29 | export { 30 | findFirstWithScalarsQuery, 31 | findManyWithScalarsQuery, 32 | countWithScalarsQuery, 33 | findUniqueWithScalarsQuery, 34 | findFirstWithScalarsQueryObject, 35 | findManyWithScalarsQueryObject, 36 | countWithScalarsQueryObject, 37 | findUniqueWithScalarsQueryObject 38 | } from './queries'; 39 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/mutations/createMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createManyWithScalarsMutationArgs = builder.args((t) => ({ data: t.field({ type: [Inputs.WithScalarsCreateInput], required: true }) })) 7 | 8 | export const createManyWithScalarsMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: ['WithScalars'], 11 | nullable: false, 12 | args: createManyWithScalarsMutationArgs, 13 | resolve: async (_query, _root, args, _context, _info) => 14 | await db.$transaction(args.data.map((data) => db.withScalars.create({ data }))), 15 | }), 16 | ); 17 | 18 | export const createManyWithScalarsMutation = defineMutation((t) => ({ 19 | createManyWithScalars: t.prismaField(createManyWithScalarsMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/mutations/createOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createOneWithScalarsMutationArgs = builder.args((t) => ({ data: t.field({ type: Inputs.WithScalarsCreateInput, required: true }) })) 7 | 8 | export const createOneWithScalarsMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'WithScalars', 11 | nullable: false, 12 | args: createOneWithScalarsMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.withScalars.create({ data: args.data, ...query }), 15 | }), 16 | ); 17 | 18 | export const createOneWithScalarsMutation = defineMutation((t) => ({ 19 | createOneWithScalars: t.prismaField(createOneWithScalarsMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/mutations/deleteMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const deleteManyWithScalarsMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.WithScalarsWhereInput, required: true }) })) 8 | 9 | export const deleteManyWithScalarsMutationObject = defineMutationFunction((t) => 10 | defineMutationObject({ 11 | type: BatchPayload, 12 | nullable: true, 13 | args: deleteManyWithScalarsMutationArgs, 14 | resolve: async (_root, args, _context, _info) => 15 | await db.withScalars.deleteMany({ where: args.where }), 16 | }), 17 | ); 18 | 19 | export const deleteManyWithScalarsMutation = defineMutation((t) => ({ 20 | deleteManyWithScalars: t.field(deleteManyWithScalarsMutationObject(t)), 21 | })); 22 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/mutations/deleteOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const deleteOneWithScalarsMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.WithScalarsWhereUniqueInput, required: true }) })) 7 | 8 | export const deleteOneWithScalarsMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'WithScalars', 11 | nullable: true, 12 | args: deleteOneWithScalarsMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.withScalars.delete({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const deleteOneWithScalarsMutation = defineMutation((t) => ({ 19 | deleteOneWithScalars: t.prismaField(deleteOneWithScalarsMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/mutations/index.ts: -------------------------------------------------------------------------------- 1 | export { createManyWithScalarsMutation, createManyWithScalarsMutationObject } from './createMany.base'; 2 | export { createOneWithScalarsMutation, createOneWithScalarsMutationObject } from './createOne.base'; 3 | export { deleteManyWithScalarsMutation, deleteManyWithScalarsMutationObject } from './deleteMany.base'; 4 | export { deleteOneWithScalarsMutation, deleteOneWithScalarsMutationObject } from './deleteOne.base'; 5 | export { updateManyWithScalarsMutation, updateManyWithScalarsMutationObject } from './updateMany.base'; 6 | export { updateOneWithScalarsMutation, updateOneWithScalarsMutationObject } from './updateOne.base'; 7 | export { upsertOneWithScalarsMutation, upsertOneWithScalarsMutationObject } from './upsertOne.base'; 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/mutations/updateMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const updateManyWithScalarsMutationArgs = builder.args((t) => ({ 8 | where: t.field({ type: Inputs.WithScalarsWhereInput, required: false }), 9 | data: t.field({ type: Inputs.WithScalarsUpdateManyMutationInput, required: true }), 10 | })) 11 | 12 | export const updateManyWithScalarsMutationObject = defineMutationFunction((t) => 13 | defineMutationObject({ 14 | type: BatchPayload, 15 | nullable: false, 16 | args: updateManyWithScalarsMutationArgs, 17 | resolve: async (_root, args, _context, _info) => 18 | await db.withScalars.updateMany({ where: args.where || undefined, data: args.data }), 19 | }), 20 | ); 21 | 22 | export const updateManyWithScalarsMutation = defineMutation((t) => ({ 23 | updateManyWithScalars: t.field(updateManyWithScalarsMutationObject(t)), 24 | })); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/mutations/updateOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const updateOneWithScalarsMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.WithScalarsWhereUniqueInput, required: true }), 8 | data: t.field({ type: Inputs.WithScalarsUpdateInput, required: true }), 9 | })) 10 | 11 | export const updateOneWithScalarsMutationObject = defineMutationFunction((t) => 12 | defineMutationPrismaObject({ 13 | type: 'WithScalars', 14 | nullable: true, 15 | args: updateOneWithScalarsMutationArgs, 16 | resolve: async (query, _root, args, _context, _info) => 17 | await db.withScalars.update({ where: args.where, data: args.data, ...query }), 18 | }), 19 | ); 20 | 21 | export const updateOneWithScalarsMutation = defineMutation((t) => ({ 22 | updateOneWithScalars: t.prismaField(updateOneWithScalarsMutationObject(t)), 23 | })); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/mutations/upsertOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const upsertOneWithScalarsMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.WithScalarsWhereUniqueInput, required: true }), 8 | create: t.field({ type: Inputs.WithScalarsCreateInput, required: true }), 9 | update: t.field({ type: Inputs.WithScalarsUpdateInput, required: true }), 10 | })) 11 | 12 | export const upsertOneWithScalarsMutationObject = defineMutationFunction((t) => 13 | defineMutationPrismaObject({ 14 | type: 'WithScalars', 15 | nullable: false, 16 | args: upsertOneWithScalarsMutationArgs, 17 | resolve: async (query, _root, args, _context, _info) => 18 | await db.withScalars.upsert({ 19 | where: args.where, 20 | create: args.create, 21 | update: args.update, 22 | ...query, 23 | }), 24 | }), 25 | ); 26 | 27 | export const upsertOneWithScalarsMutation = defineMutation((t) => ({ 28 | upsertOneWithScalars: t.prismaField(upsertOneWithScalarsMutationObject(t)), 29 | })); 30 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/queries/count.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryObject } from '../../utils'; 5 | 6 | export const countWithScalarsQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.WithScalarsWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.WithScalarsOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.WithScalarsWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.WithScalarsScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const countWithScalarsQueryObject = defineQueryFunction((t) => 16 | defineQueryObject({ 17 | type: 'Int', 18 | nullable: false, 19 | args: countWithScalarsQueryArgs, 20 | resolve: async (_root, args, _context, _info) => 21 | await db.withScalars.count({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | skip: args.skip || undefined, 26 | orderBy: args.orderBy || undefined, 27 | }), 28 | }), 29 | ); 30 | 31 | export const countWithScalarsQuery = defineQuery((t) => ({ 32 | countWithScalars: t.field(countWithScalarsQueryObject(t)), 33 | })); 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/queries/findUnique.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findUniqueWithScalarsQueryArgs = builder.args((t) => ({ where: t.field({ type: Inputs.WithScalarsWhereUniqueInput, required: true }) })) 7 | 8 | export const findUniqueWithScalarsQueryObject = defineQueryFunction((t) => 9 | defineQueryPrismaObject({ 10 | type: 'WithScalars', 11 | nullable: true, 12 | args: findUniqueWithScalarsQueryArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.withScalars.findUnique({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const findUniqueWithScalarsQuery = defineQuery((t) => ({ 19 | findUniqueWithScalars: t.prismaField(findUniqueWithScalarsQueryObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithScalars/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { findFirstWithScalarsQuery, findFirstWithScalarsQueryObject } from './findFirst.base'; 2 | export { findManyWithScalarsQuery, findManyWithScalarsQueryObject } from './findMany.base'; 3 | export { countWithScalarsQuery, countWithScalarsQueryObject } from './count.base'; 4 | export { findUniqueWithScalarsQuery, findUniqueWithScalarsQueryObject } from './findUnique.base'; 5 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | WithoutIDObject, 3 | WithoutIDNameFieldObject 4 | } from './object.base'; 5 | export { 6 | createManyWithoutIDMutation, 7 | createOneWithoutIDMutation, 8 | deleteManyWithoutIDMutation, 9 | deleteOneWithoutIDMutation, 10 | updateManyWithoutIDMutation, 11 | updateOneWithoutIDMutation, 12 | upsertOneWithoutIDMutation, 13 | createManyWithoutIDMutationObject, 14 | createOneWithoutIDMutationObject, 15 | deleteManyWithoutIDMutationObject, 16 | deleteOneWithoutIDMutationObject, 17 | updateManyWithoutIDMutationObject, 18 | updateOneWithoutIDMutationObject, 19 | upsertOneWithoutIDMutationObject 20 | } from './mutations'; 21 | export { 22 | findFirstWithoutIDQuery, 23 | findManyWithoutIDQuery, 24 | countWithoutIDQuery, 25 | findUniqueWithoutIDQuery, 26 | findFirstWithoutIDQueryObject, 27 | findManyWithoutIDQueryObject, 28 | countWithoutIDQueryObject, 29 | findUniqueWithoutIDQueryObject 30 | } from './queries'; 31 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/mutations/createMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createManyWithoutIDMutationArgs = builder.args((t) => ({ data: t.field({ type: [Inputs.WithoutIDCreateInput], required: true }) })) 7 | 8 | export const createManyWithoutIDMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: ['WithoutID'], 11 | nullable: false, 12 | args: createManyWithoutIDMutationArgs, 13 | resolve: async (_query, _root, args, _context, _info) => 14 | await db.$transaction(args.data.map((data) => db.withoutID.create({ data }))), 15 | }), 16 | ); 17 | 18 | export const createManyWithoutIDMutation = defineMutation((t) => ({ 19 | createManyWithoutID: t.prismaField(createManyWithoutIDMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/mutations/createOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const createOneWithoutIDMutationArgs = builder.args((t) => ({ data: t.field({ type: Inputs.WithoutIDCreateInput, required: true }) })) 7 | 8 | export const createOneWithoutIDMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'WithoutID', 11 | nullable: false, 12 | args: createOneWithoutIDMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.withoutID.create({ data: args.data, ...query }), 15 | }), 16 | ); 17 | 18 | export const createOneWithoutIDMutation = defineMutation((t) => ({ 19 | createOneWithoutID: t.prismaField(createOneWithoutIDMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/mutations/deleteMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const deleteManyWithoutIDMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.WithoutIDWhereInput, required: true }) })) 8 | 9 | export const deleteManyWithoutIDMutationObject = defineMutationFunction((t) => 10 | defineMutationObject({ 11 | type: BatchPayload, 12 | nullable: true, 13 | args: deleteManyWithoutIDMutationArgs, 14 | resolve: async (_root, args, _context, _info) => 15 | await db.withoutID.deleteMany({ where: args.where }), 16 | }), 17 | ); 18 | 19 | export const deleteManyWithoutIDMutation = defineMutation((t) => ({ 20 | deleteManyWithoutID: t.field(deleteManyWithoutIDMutationObject(t)), 21 | })); 22 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/mutations/deleteOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const deleteOneWithoutIDMutationArgs = builder.args((t) => ({ where: t.field({ type: Inputs.WithoutIDWhereUniqueInput, required: true }) })) 7 | 8 | export const deleteOneWithoutIDMutationObject = defineMutationFunction((t) => 9 | defineMutationPrismaObject({ 10 | type: 'WithoutID', 11 | nullable: true, 12 | args: deleteOneWithoutIDMutationArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.withoutID.delete({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const deleteOneWithoutIDMutation = defineMutation((t) => ({ 19 | deleteOneWithoutID: t.prismaField(deleteOneWithoutIDMutationObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/mutations/index.ts: -------------------------------------------------------------------------------- 1 | export { createManyWithoutIDMutation, createManyWithoutIDMutationObject } from './createMany.base'; 2 | export { createOneWithoutIDMutation, createOneWithoutIDMutationObject } from './createOne.base'; 3 | export { deleteManyWithoutIDMutation, deleteManyWithoutIDMutationObject } from './deleteMany.base'; 4 | export { deleteOneWithoutIDMutation, deleteOneWithoutIDMutationObject } from './deleteOne.base'; 5 | export { updateManyWithoutIDMutation, updateManyWithoutIDMutationObject } from './updateMany.base'; 6 | export { updateOneWithoutIDMutation, updateOneWithoutIDMutationObject } from './updateOne.base'; 7 | export { upsertOneWithoutIDMutation, upsertOneWithoutIDMutationObject } from './upsertOne.base'; 8 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/mutations/updateMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { BatchPayload } from '../../objects'; 3 | import { db } from '@/db'; 4 | import { builder } from '../../../builder'; 5 | import { defineMutation, defineMutationFunction, defineMutationObject } from '../../utils'; 6 | 7 | export const updateManyWithoutIDMutationArgs = builder.args((t) => ({ 8 | where: t.field({ type: Inputs.WithoutIDWhereInput, required: false }), 9 | data: t.field({ type: Inputs.WithoutIDUpdateManyMutationInput, required: true }), 10 | })) 11 | 12 | export const updateManyWithoutIDMutationObject = defineMutationFunction((t) => 13 | defineMutationObject({ 14 | type: BatchPayload, 15 | nullable: false, 16 | args: updateManyWithoutIDMutationArgs, 17 | resolve: async (_root, args, _context, _info) => 18 | await db.withoutID.updateMany({ where: args.where || undefined, data: args.data }), 19 | }), 20 | ); 21 | 22 | export const updateManyWithoutIDMutation = defineMutation((t) => ({ 23 | updateManyWithoutID: t.field(updateManyWithoutIDMutationObject(t)), 24 | })); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/mutations/updateOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const updateOneWithoutIDMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.WithoutIDWhereUniqueInput, required: true }), 8 | data: t.field({ type: Inputs.WithoutIDUpdateInput, required: true }), 9 | })) 10 | 11 | export const updateOneWithoutIDMutationObject = defineMutationFunction((t) => 12 | defineMutationPrismaObject({ 13 | type: 'WithoutID', 14 | nullable: true, 15 | args: updateOneWithoutIDMutationArgs, 16 | resolve: async (query, _root, args, _context, _info) => 17 | await db.withoutID.update({ where: args.where, data: args.data, ...query }), 18 | }), 19 | ); 20 | 21 | export const updateOneWithoutIDMutation = defineMutation((t) => ({ 22 | updateOneWithoutID: t.prismaField(updateOneWithoutIDMutationObject(t)), 23 | })); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/mutations/upsertOne.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils'; 5 | 6 | export const upsertOneWithoutIDMutationArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.WithoutIDWhereUniqueInput, required: true }), 8 | create: t.field({ type: Inputs.WithoutIDCreateInput, required: true }), 9 | update: t.field({ type: Inputs.WithoutIDUpdateInput, required: true }), 10 | })) 11 | 12 | export const upsertOneWithoutIDMutationObject = defineMutationFunction((t) => 13 | defineMutationPrismaObject({ 14 | type: 'WithoutID', 15 | nullable: false, 16 | args: upsertOneWithoutIDMutationArgs, 17 | resolve: async (query, _root, args, _context, _info) => 18 | await db.withoutID.upsert({ 19 | where: args.where, 20 | create: args.create, 21 | update: args.update, 22 | ...query, 23 | }), 24 | }), 25 | ); 26 | 27 | export const upsertOneWithoutIDMutation = defineMutation((t) => ({ 28 | upsertOneWithoutID: t.prismaField(upsertOneWithoutIDMutationObject(t)), 29 | })); 30 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/object.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { builder } from '../../builder'; 3 | import { 4 | definePrismaObject, 5 | defineFieldObject, 6 | defineRelationFunction, 7 | defineRelationObject, 8 | } from '../utils'; 9 | 10 | export const WithoutIDObject = definePrismaObject('WithoutID', { 11 | description: undefined, 12 | findUnique: (fields) => ({ ...fields }), 13 | fields: (t) => ({ 14 | name: t.field(WithoutIDNameFieldObject), 15 | }), 16 | }); 17 | 18 | export const WithoutIDNameFieldObject = defineFieldObject('WithoutID', { 19 | type: "String", 20 | description: undefined, 21 | nullable: false, 22 | resolve: (parent) => parent.name, 23 | }); 24 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/queries/count.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryObject } from '../../utils'; 5 | 6 | export const countWithoutIDQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.WithoutIDWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.WithoutIDOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.WithoutIDWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.WithoutIDScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const countWithoutIDQueryObject = defineQueryFunction((t) => 16 | defineQueryObject({ 17 | type: 'Int', 18 | nullable: false, 19 | args: countWithoutIDQueryArgs, 20 | resolve: async (_root, args, _context, _info) => 21 | await db.withoutID.count({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | skip: args.skip || undefined, 26 | orderBy: args.orderBy || undefined, 27 | }), 28 | }), 29 | ); 30 | 31 | export const countWithoutIDQuery = defineQuery((t) => ({ 32 | countWithoutID: t.field(countWithoutIDQueryObject(t)), 33 | })); 34 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/queries/findFirst.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findFirstWithoutIDQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.WithoutIDWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.WithoutIDOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.WithoutIDWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.WithoutIDScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findFirstWithoutIDQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: 'WithoutID', 18 | nullable: true, 19 | args: findFirstWithoutIDQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.withoutID.findFirst({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findFirstWithoutIDQuery = defineQuery((t) => ({ 34 | findFirstWithoutID: t.prismaField(findFirstWithoutIDQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/queries/findMany.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findManyWithoutIDQueryArgs = builder.args((t) => ({ 7 | where: t.field({ type: Inputs.WithoutIDWhereInput, required: false }), 8 | orderBy: t.field({ type: [Inputs.WithoutIDOrderByWithRelationInput], required: false }), 9 | cursor: t.field({ type: Inputs.WithoutIDWhereUniqueInput, required: false }), 10 | take: t.field({ type: 'Int', required: false }), 11 | skip: t.field({ type: 'Int', required: false }), 12 | distinct: t.field({ type: [Inputs.WithoutIDScalarFieldEnum], required: false }), 13 | })) 14 | 15 | export const findManyWithoutIDQueryObject = defineQueryFunction((t) => 16 | defineQueryPrismaObject({ 17 | type: ['WithoutID'], 18 | nullable: false, 19 | args: findManyWithoutIDQueryArgs, 20 | resolve: async (query, _root, args, _context, _info) => 21 | await db.withoutID.findMany({ 22 | where: args.where || undefined, 23 | cursor: args.cursor || undefined, 24 | take: args.take || undefined, 25 | distinct: args.distinct || undefined, 26 | skip: args.skip || undefined, 27 | orderBy: args.orderBy || undefined, 28 | ...query, 29 | }), 30 | }), 31 | ); 32 | 33 | export const findManyWithoutIDQuery = defineQuery((t) => ({ 34 | findManyWithoutID: t.prismaField(findManyWithoutIDQueryObject(t)), 35 | })); 36 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/queries/findUnique.base.ts: -------------------------------------------------------------------------------- 1 | import * as Inputs from '@/schema/__generated__/inputs' 2 | import { db } from '@/db'; 3 | import { builder } from '../../../builder'; 4 | import { defineQuery, defineQueryFunction, defineQueryPrismaObject } from '../../utils'; 5 | 6 | export const findUniqueWithoutIDQueryArgs = builder.args((t) => ({ where: t.field({ type: Inputs.WithoutIDWhereUniqueInput, required: true }) })) 7 | 8 | export const findUniqueWithoutIDQueryObject = defineQueryFunction((t) => 9 | defineQueryPrismaObject({ 10 | type: 'WithoutID', 11 | nullable: true, 12 | args: findUniqueWithoutIDQueryArgs, 13 | resolve: async (query, _root, args, _context, _info) => 14 | await db.withoutID.findUnique({ where: args.where, ...query }), 15 | }), 16 | ); 17 | 18 | export const findUniqueWithoutIDQuery = defineQuery((t) => ({ 19 | findUniqueWithoutID: t.prismaField(findUniqueWithoutIDQueryObject(t)), 20 | })); 21 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/WithoutID/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { findFirstWithoutIDQuery, findFirstWithoutIDQueryObject } from './findFirst.base'; 2 | export { findManyWithoutIDQuery, findManyWithoutIDQueryObject } from './findMany.base'; 3 | export { countWithoutIDQuery, countWithoutIDQueryObject } from './count.base'; 4 | export { findUniqueWithoutIDQuery, findUniqueWithoutIDQueryObject } from './findUnique.base'; 5 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/__generated__/objects.ts: -------------------------------------------------------------------------------- 1 | import { Prisma } from '@prisma/client'; 2 | import { builder } from '../builder'; 3 | 4 | export const BatchPayload = builder.objectType(builder.objectRef('BatchPayload'), { 5 | description: 'Batch payloads from prisma.', 6 | fields: (t) => ({ 7 | count: t.exposeInt('count', { description: 'Prisma Batch Payload', nullable: false }), 8 | }), 9 | }); 10 | 11 | export const modelNames = [ 12 | 'User', 13 | 'UserLast', 14 | 'Post', 15 | 'ExtraModal', 16 | 'Comment', 17 | 'Profile', 18 | 'Follow', 19 | 'Unrelated', 20 | 'IdOnly', 21 | 'WithoutID', 22 | 'WithScalars', 23 | ] as const; 24 | 25 | export type Model = typeof modelNames[number]; 26 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/builder.ts: -------------------------------------------------------------------------------- 1 | import { Prisma } from '.prisma/client'; 2 | import SchemaBuilder from '@pothos/core'; 3 | import PrismaPlugin from '@pothos/plugin-prisma'; 4 | import { Scalars } from '../../../../src'; 5 | import { db } from '../db'; 6 | import PrismaTypes from '../generated/objects'; 7 | import { Context } from '@/server'; 8 | 9 | export const builder = new SchemaBuilder<{ 10 | Context: Context; 11 | PrismaTypes: PrismaTypes; 12 | Scalars: Scalars; 13 | }>({ 14 | plugins: [PrismaPlugin], 15 | prisma: { 16 | client: db, 17 | }, 18 | }); 19 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/index-2-custom-model.ts: -------------------------------------------------------------------------------- 1 | import { 2 | generateAllCrud, 3 | generateAllObjects, 4 | generateAllQueries, 5 | generateAllMutations, 6 | } from './__generated__/autocrud'; 7 | import { builder } from './builder'; 8 | import { ExtraModalObject } from './__generated__/ExtraModal'; 9 | import { Prisma } from '@prisma/client'; 10 | import { UserUpdateInputFields } from './__generated__/inputs'; 11 | 12 | type Options = Parameters[0]; 13 | const options: Options = { exclude: ['ExtraModal'] }; 14 | 15 | generateAllObjects(options); 16 | generateAllQueries(); 17 | generateAllMutations(); 18 | 19 | builder.prismaObject('ExtraModal', { 20 | ...ExtraModalObject, 21 | description: 'Extra model override description', 22 | fields: (t) => ({ 23 | ...ExtraModalObject.fields(t), 24 | name: t.int({ 25 | args: { 26 | adder: t.arg({ 27 | type: 'Int', 28 | description: 'Adder arg', 29 | required: true, 30 | }), 31 | }, 32 | resolve: (root, args, context, info) => root.id + args.adder, 33 | description: 'My field desc', 34 | }), 35 | }), 36 | }); 37 | 38 | builder.queryType({}); 39 | builder.mutationType({}); 40 | 41 | export const schema = builder.toSchema({}); 42 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/index-4-custom-resolvers.ts: -------------------------------------------------------------------------------- 1 | import { findManyCommentQueryObject } from './__generated__/Comment'; 2 | import { createOneWithScalarsMutationObject } from './__generated__/WithScalars'; 3 | import { builder } from './builder'; 4 | 5 | builder.queryType({ 6 | fields: (t) => ({ 7 | health: t.field({ type: 'String', resolve: () => 'Ok' }), 8 | }), 9 | }); 10 | builder.mutationType({ 11 | fields: (t) => ({ 12 | health: t.field({ type: 'String', resolve: () => 'Ok' }), 13 | }), 14 | }); 15 | 16 | export default builder.mutationFields((t) => { 17 | const createOne = createOneWithScalarsMutationObject(t); 18 | 19 | return { 20 | createOneWithScalars: t.prismaField({ 21 | ...createOne, 22 | args: { ...createOne.args }, 23 | async resolve(query, arent, args, ctx, info) { 24 | const resolved = await createOne.resolve(query, arent, args, ctx, info); 25 | 26 | // Do something here 27 | 28 | return resolved; 29 | }, 30 | }), 31 | }; 32 | }); 33 | 34 | export const a = builder.queryFields((t) => { 35 | const createOne = findManyCommentQueryObject(t); 36 | 37 | return { 38 | findManyComment: t.prismaField({ 39 | ...createOne, 40 | args: { ...createOne.args }, 41 | async resolve(query, arent, args, ctx, info) { 42 | const resolved = await createOne.resolve(query, arent, args, ctx, info); 43 | 44 | // Do something here 45 | 46 | return resolved; 47 | }, 48 | }), 49 | }; 50 | }); 51 | 52 | export const schema = builder.toSchema({}); 53 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/schema/index.ts: -------------------------------------------------------------------------------- 1 | import { builder } from "./builder"; 2 | import { 3 | generateAllCrud, 4 | // generateAllMutations, 5 | // generateAllObjects, 6 | // generateAllQueries, 7 | // generateAllResolvers, 8 | } from "./__generated__/autocrud"; 9 | 10 | generateAllCrud(); // from generated 11 | 12 | builder.queryType({}); 13 | builder.mutationType({}); 14 | 15 | export const schema = builder.toSchema({}); 16 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/src/server.ts: -------------------------------------------------------------------------------- 1 | import { User } from '@prisma/client'; 2 | import { ApolloServer } from 'apollo-server'; 3 | import { db } from './db'; 4 | import { schema } from './schema'; 5 | 6 | export type Context = { 7 | db: typeof db; 8 | user: User | null; 9 | }; 10 | 11 | const server = new ApolloServer({ 12 | schema, 13 | context: async ({ req }): Promise => { 14 | // const user: User | null = await db.user.findFirst({}); 15 | return { 16 | user: null, 17 | db, 18 | }; 19 | }, 20 | }); 21 | 22 | server.listen(process.env.PORT ?? 3000).then(({ url }) => { 23 | console.log(`🚀 Server ready at ${url}`); 24 | }); 25 | -------------------------------------------------------------------------------- /examples/inputs-simple-sqlite/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["ES2023"], 4 | "module": "node16", 5 | "target": "ES2022", 6 | "esModuleInterop": true, 7 | "sourceMap": true, 8 | "outDir": "dist", 9 | "skipLibCheck": true, 10 | "noUncheckedIndexedAccess": true, 11 | "strictNullChecks": true, 12 | "noImplicitAny": true, 13 | "baseUrl": ".", 14 | "paths": { 15 | "@/*": ["src/*"] 16 | } 17 | }, 18 | "include": ["src"], 19 | "exclude": ["node_modules", "dist"] 20 | } 21 | -------------------------------------------------------------------------------- /examples/readme.md: -------------------------------------------------------------------------------- 1 | # Running examples 2 | 3 | ## With source code 4 | 5 | - Clone this repo 6 | - `cd examples/inputs-simple-sqlite` 7 | - `yarn install` 8 | - `yarn migrate` 9 | - `yarn dev` 10 | 11 | ## Without 12 | 13 | - Clone this repo 14 | - `cd examples/inputs-simple-sqlite` 15 | - `yarn install` 16 | - `yarn add prisma-generator-pothos-codegen` 17 | - Replace generator from `/prisma/schema.prisma` from `ts-node --transpile-only ../../src/generator.ts` to `prisma-generator-pothos-codegen` 18 | - `yarn migrate` 19 | - `yarn dev` -------------------------------------------------------------------------------- /jest.config.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * For a detailed explanation regarding each configuration property and type check, visit: 3 | * https://jestjs.io/docs/configuration 4 | */ 5 | 6 | // const { pathsToModuleNameMapper } = require('ts-jest') 7 | // const { compilerOptions } = require('./tsconfig') 8 | // import { pathsToModuleNameMapper } from 'ts-jest' 9 | 10 | export default { 11 | roots: ['/src'], 12 | clearMocks: true, 13 | collectCoverage: true, 14 | coverageDirectory: "coverage", 15 | coverageProvider: "v8", 16 | testMatch: [ 17 | "**/__tests__/**/*.[jt]s?(x)", 18 | "**/?(*.)+(spec|test).[tj]s?(x)" 19 | ], 20 | moduleNameMapper: { 21 | "@/(.*)": "/src/$1" 22 | }, 23 | preset: 'ts-jest', 24 | globals: { 25 | "ts-jest": { 26 | diagnostics: { pathRegex: /\.(spec|test)\.js$/ }, 27 | isolatedModules: true, 28 | tsconfig: 'tsconfig.json', 29 | } 30 | }, 31 | testEnvironment: "node", 32 | }; 33 | -------------------------------------------------------------------------------- /src/bin.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import './generator' 3 | -------------------------------------------------------------------------------- /src/crudGenerator/index.test.ts: -------------------------------------------------------------------------------- 1 | import { getSampleDMMF } from '../tests/getPrismaSchema' 2 | import { getDefaultConfig } from '../utils/config' 3 | import { generateCrud } from '.' 4 | 5 | describe('crudGenerator', () => { 6 | it('should generate all files', async () => { 7 | const dmmf = await getSampleDMMF('complex') 8 | const defaultConfig = getDefaultConfig() 9 | await generateCrud(defaultConfig, dmmf) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /src/crudGenerator/templates/resolver.ts: -------------------------------------------------------------------------------- 1 | import { useTemplate } from '../../utils/template' 2 | 3 | export const makeResolver = ( 4 | root: 'Query' | 'Mutation', 5 | imports: string, 6 | operation: string, 7 | type: string, 8 | nullable: 'true' | 'false', 9 | args: string, 10 | resolve: string, 11 | isPrisma = true, 12 | ) => 13 | useTemplate( 14 | resolverTemplate, 15 | { 16 | root, 17 | object: isPrisma ? 'PrismaObject' : 'Object', 18 | imports, 19 | operation, 20 | type, 21 | nullable, 22 | args, 23 | resolve, 24 | field: isPrisma ? 'prismaField' : 'field', 25 | }, 26 | ['modelName', 'inputsImporter', 'resolverImports', 'builderCalculatedImport'], 27 | ) 28 | 29 | export const resolverTemplate = `#{inputsImporter}#{imports}#{resolverImports}#{builderCalculatedImport} 30 | import { define#{root}, define#{root}Function, define#{root}#{object} } from '../../utils'; 31 | 32 | export const #{operation}#{modelName}#{root}Args = builder.args((t) => (#{args})) 33 | 34 | export const #{operation}#{modelName}#{root}Object = define#{root}Function((t) => 35 | define#{root}#{object}({ 36 | type: #{type}, 37 | nullable: #{nullable}, 38 | args: #{operation}#{modelName}#{root}Args, 39 | resolve: #{resolve}, 40 | }), 41 | ); 42 | 43 | export const #{operation}#{modelName}#{root} = define#{root}((t) => ({ 44 | #{operation}#{modelName}: t.#{field}(#{operation}#{modelName}#{root}Object(t)), 45 | })); 46 | ` 47 | -------------------------------------------------------------------------------- /src/crudGenerator/utils/generator.ts: -------------------------------------------------------------------------------- 1 | import { ConfigInternal } from '../../utils/config' 2 | import { mutations as MutationTemplates } from '../templates/mutation' 3 | import { queries as QueryTemplates } from '../templates/query' 4 | import { GeneratedResolver, writeIndex, writeObject, writeResolvers } from './parts' 5 | import type { DMMF } from '@prisma/generator-helper' 6 | 7 | /** 8 | * @returns List of generated resolvers 9 | */ 10 | export async function generateModel( 11 | config: ConfigInternal, 12 | dmmf: DMMF.Document, 13 | modelName: string, 14 | ): Promise<{ resolvers: GeneratedResolver[]; index: Awaited> }> { 15 | const model = dmmf.datamodel.models.find((m) => m.name === modelName) 16 | if (!model) return { index: [], resolvers: [] } 17 | 18 | await writeObject(config, model) 19 | const queries = await writeResolvers(config, model, 'queries', QueryTemplates) 20 | const mutations = await writeResolvers(config, model, 'mutations', MutationTemplates) 21 | const index = await writeIndex(config, model, { queries, mutations }) 22 | 23 | return { resolvers: [...queries, ...mutations], index } 24 | } 25 | -------------------------------------------------------------------------------- /src/crudGenerator/utils/objectFields.test.ts: -------------------------------------------------------------------------------- 1 | import { escapeQuotesAndMultilineSupport } from '../../utils/string' 2 | import { cleanifyDocumentation } from './objectFields' 3 | 4 | describe('objectFields', () => { 5 | it('cleanifyDocumentation', () => { 6 | expect(cleanifyDocumentation('line 1\nline2\n@Pothos.omit()')).toBe('line 1\nline2') 7 | expect(cleanifyDocumentation('@Pothos.omit(create, update) createdAt description')).toBe('createdAt description') 8 | }) 9 | 10 | it('convertToMultilineString + cleanifyDocumentation', () => { 11 | expect(escapeQuotesAndMultilineSupport(cleanifyDocumentation('line 1\nline2\n@Pothos.omit()'))).toBe( 12 | '`line 1\nline2`', 13 | ) 14 | expect(escapeQuotesAndMultilineSupport(cleanifyDocumentation(''))).toBe(undefined) 15 | expect(escapeQuotesAndMultilineSupport(cleanifyDocumentation('@Pothos.omit(create, update) '))).toBe(undefined) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /src/env.ts: -------------------------------------------------------------------------------- 1 | export const env = { 2 | isTesting: !!process.env.JEST_WORKER_ID, 3 | } 4 | -------------------------------------------------------------------------------- /src/generator.ts: -------------------------------------------------------------------------------- 1 | import { generatorHandler, GeneratorOptions } from '@prisma/generator-helper' 2 | import { generateCrud } from './crudGenerator' 3 | import { generateInputs } from './inputsGenerator' 4 | import { getConfig } from './utils/config' 5 | 6 | // Types from the generator, in `schema.prisma` 7 | type SchemaGeneratorExtensionOptions = { generatorConfigPath?: string } 8 | 9 | // default config from generator, with the path option 10 | export type ExtendedGeneratorOptions = SchemaGeneratorExtensionOptions & GeneratorOptions 11 | 12 | generatorHandler({ 13 | onManifest: () => ({ 14 | prettyName: 'Pothos inputs & crud integration', 15 | requiresGenerators: ['prisma-client-js', 'prisma-pothos-types'], 16 | defaultOutput: './generated/inputs.ts', 17 | }), 18 | onGenerate: async (options) => { 19 | const generatorConfig: ExtendedGeneratorOptions = { ...options, ...options.generator.config } 20 | const config = await getConfig(generatorConfig) 21 | 22 | config.global.beforeGenerate(options.dmmf) 23 | await generateCrud(config, options.dmmf) 24 | await generateInputs(config, options.dmmf) 25 | config.global.afterGenerate(options.dmmf) 26 | }, 27 | }) 28 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export { Scalars } from './inputsGenerator/' 2 | export { Config } from './utils/config' 3 | -------------------------------------------------------------------------------- /src/inputsGenerator/index.test.ts: -------------------------------------------------------------------------------- 1 | import { getSampleDMMF } from '../tests/getPrismaSchema' 2 | import { getDefaultConfig } from '../utils/config' 3 | import { generateInputs } from '.' 4 | 5 | describe('inputsGenerator', () => { 6 | it('should generate inputs', async () => { 7 | const dmmf = await getSampleDMMF('complex') 8 | const defaultConfig = getDefaultConfig() 9 | await generateInputs(defaultConfig, dmmf) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /src/inputsGenerator/index.ts: -------------------------------------------------------------------------------- 1 | import { env } from '../env' 2 | import { ConfigInternal } from '../utils/config' 3 | import { writeFile } from '../utils/filesystem' 4 | import { getEnums, getImports, getScalars, getInputs, getUtil } from './utils/parts' 5 | import type { DMMF } from '@prisma/generator-helper' 6 | 7 | /** Types may vary between Prisma versions */ 8 | export type Scalars = { 9 | DateTime: { 10 | Input: Date 11 | Output: Date 12 | } 13 | Decimal: { 14 | Input: DecimalType 15 | Output: DecimalType 16 | } 17 | BigInt: { 18 | Input: bigint 19 | Output: bigint 20 | } 21 | Json: { 22 | Input: JsonInput 23 | Output: JsonOutput 24 | } 25 | Bytes: { 26 | Input: Buffer 27 | Output: { 28 | type: 'Buffer' 29 | data: number[] 30 | } 31 | } 32 | NEVER: { 33 | Input: void 34 | Output: void 35 | } 36 | } 37 | 38 | export async function generateInputs(config: ConfigInternal, dmmf: DMMF.Document): Promise { 39 | if (env.isTesting) await writeFile(config, 'debug.dmmf', JSON.stringify(dmmf, null, 2), 'dmmf.json') 40 | 41 | const fileLocation = config.inputs.outputFilePath 42 | 43 | const imports = getImports(config, fileLocation) 44 | const util = getUtil() 45 | const scalars = getScalars(config, dmmf) 46 | const enums = getEnums(dmmf) 47 | const inputs = getInputs(config, dmmf) 48 | const content = [imports, util, scalars, enums, inputs].join('\n\n') 49 | 50 | await writeFile(config, 'inputs', content, fileLocation) 51 | } 52 | -------------------------------------------------------------------------------- /src/inputsGenerator/utils/parser.test.ts: -------------------------------------------------------------------------------- 1 | import { parseComment } from './parser' 2 | 3 | describe('parseComment', () => { 4 | test('Check all possible inputs', async () => { 5 | expect(parseComment(`test`)).toMatchInlineSnapshot(`null`) 6 | expect(parseComment(`@Pothos.omit(create, update) createdAt description`)).toMatchInlineSnapshot(` 7 | Array [ 8 | "create", 9 | "update", 10 | ] 11 | `) 12 | expect(parseComment(`@Pothos.omit()`)).toMatchInlineSnapshot(`"all"`) 13 | expect(parseComment(`@Pothos.omit(create)`)).toMatchInlineSnapshot(` 14 | Array [ 15 | "create", 16 | ] 17 | `) 18 | expect(parseComment(`@Pothos.omit(create,update,)`)).toMatchInlineSnapshot(` 19 | Array [ 20 | "create", 21 | "update", 22 | ] 23 | `) 24 | expect(parseComment(`@Pothos.omit(create,update,`)).toMatchInlineSnapshot(`null`) 25 | expect(parseComment(`@Pothos.omit(create,updatex)`)).toMatchInlineSnapshot(`null`) 26 | expect(parseComment(`test @Pothos.omit(create,update) test`)).toMatchInlineSnapshot(` 27 | Array [ 28 | "create", 29 | "update", 30 | ] 31 | `) 32 | }) 33 | }) 34 | -------------------------------------------------------------------------------- /src/inputsGenerator/utils/parser.ts: -------------------------------------------------------------------------------- 1 | const validOptions = ['create', 'update', 'where', 'orderBy'] as const 2 | type Omit = (typeof validOptions)[number] 3 | type OmitType = 'all' | Omit[] 4 | 5 | export function parseComment(comment: string): OmitType | null { 6 | const omitRegex = /@Pothos\.omit\(([^)]*)\)/ 7 | const matches = comment.match(omitRegex) 8 | 9 | if (!matches) { 10 | return null 11 | } 12 | 13 | const omitValues = matches[1] 14 | ?.split(',') 15 | .map((value) => value.trim()) 16 | .filter(Boolean) 17 | 18 | if (!omitValues) return null 19 | 20 | if (omitValues.length === 0) { 21 | return 'all' 22 | } 23 | 24 | const hasUnrecognized = omitValues.some((el) => !validOptions.includes(el as Omit)) 25 | if (hasUnrecognized) return null 26 | 27 | return omitValues as Omit[] 28 | } 29 | -------------------------------------------------------------------------------- /src/tests/configs.js: -------------------------------------------------------------------------------- 1 | // /** @type {import('prisma-generator-pothos-codegen').Config} */ 2 | 3 | /** @type {import('../utils/config').Config} */ 4 | module.exports = { 5 | crud: { 6 | outputDir: './src/schema/__generated__/', 7 | excludeResolversContain: ['User'], 8 | prismaCaller: '_context.db', 9 | disabled: false, 10 | // inputsImporter: "import * as Inputs from '@/schema/inputs'", 11 | deleteOutputDirBeforeGenerate: true, 12 | }, 13 | inputs: { 14 | prismaImporter: `import { Prisma } from '.prisma/client';`, 15 | outputFilePath: './src/schema/__generated__/inputs.ts', 16 | }, 17 | global: {}, 18 | } 19 | -------------------------------------------------------------------------------- /src/tests/getPrismaSchema.ts: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import { getDMMF, getSchema } from '@prisma/internals' 3 | 4 | const simplePrismaSchema = getSchema(path.join(__dirname, './simpleSchema.prisma')) 5 | const complexPrismaSchema = getSchema(path.join(__dirname, './complexSchema.prisma')) 6 | 7 | export const getSampleDMMF = async (type: 'complex' | 'simple') => { 8 | const datamodelSchema = type === 'complex' ? complexPrismaSchema : simplePrismaSchema 9 | 10 | return getDMMF({ 11 | datamodel: await datamodelSchema, 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /src/tests/health.test.ts: -------------------------------------------------------------------------------- 1 | test('should jest run', () => { 2 | expect(true).toBe(true) 3 | }) 4 | -------------------------------------------------------------------------------- /src/tests/simpleSchema.prisma: -------------------------------------------------------------------------------- 1 | datasource db { 2 | provider = "postgresql" 3 | url = "postgresql://postgres:mysecretpassword@localhost:5432/pothos-tests" 4 | } 5 | 6 | generator client { 7 | provider = "prisma-client-js" 8 | // Generate into custom location because this repo has multiple prisma schemas 9 | output = "./client" 10 | } 11 | 12 | model User { 13 | id Int @id @default(autoincrement()) 14 | firstName String 15 | /// lastname description 16 | lastName String 17 | /// relation desc 18 | posts Post[] 19 | createdAt DateTime @default(now()) @db.Timestamp(6) 20 | updatedAt DateTime? @updatedAt 21 | } 22 | 23 | model Post { 24 | id Int @id @default(autoincrement()) 25 | title String 26 | content String 27 | author User @relation(fields: [authorId], references: [id]) 28 | authorId Int 29 | createdAt DateTime @default(now()) @db.Timestamp(6) 30 | updatedAt DateTime? @updatedAt 31 | } -------------------------------------------------------------------------------- /src/utils/configUtils.ts: -------------------------------------------------------------------------------- 1 | import { ConfigInternal } from './config' 2 | 3 | export function getConfigCrudUnderscore(config: ConfigInternal) { 4 | if (config.crud.underscoreBetweenObjectVariableNames) return '_' 5 | return '' 6 | } 7 | -------------------------------------------------------------------------------- /src/utils/filesystem.ts: -------------------------------------------------------------------------------- 1 | import { PathLike } from 'node:fs' 2 | import fs from 'node:fs/promises' 3 | import path from 'node:path' 4 | import { env } from '../env' 5 | import { ConfigInternal } from './config' 6 | import { Replacer, ReplacerSection } from './replacer' 7 | 8 | export const debugLog = async (value: string, timestamp = true) => { 9 | if (!env.isTesting) return 10 | await fs.appendFile('log.txt', `${timestamp ? `${new Date().toISOString()}: ` : ''}${JSON.stringify(value)},\n`) 11 | } 12 | 13 | export const deleteFolder = (path: PathLike) => { 14 | return fs.rm(path, { recursive: true, force: true }) 15 | } 16 | 17 | /** Replace content before writing to file using the replacers set in the config file */ 18 | export const writeFile = async ( 19 | config: ConfigInternal, 20 | section: ReplacerSection, 21 | content: string, 22 | location: string, 23 | ): Promise => { 24 | await debugLog(`Writing to ${location}`) 25 | 26 | const replace = (str: string): string => 27 | [ 28 | config.global.replacer, 29 | ...(section === 'inputs' ? [config.inputs.replacer as unknown as Replacer] : []), 30 | ...(section?.includes('crud') ? [config.crud.replacer as unknown as Replacer] : []), 31 | ].reduce((el, replacer) => replacer(el, section), str) 32 | 33 | try { 34 | const dir = path.dirname(location) 35 | await fs.mkdir(dir, { recursive: true }) 36 | await fs.writeFile(location, replace(content), { flag: 'w' }) 37 | } catch (err) { 38 | await debugLog(JSON.stringify(err)) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/utils/replacer.ts: -------------------------------------------------------------------------------- 1 | export type ReplacerSection = 2 | | 'crud.model.object' 3 | | 'crud.model.index' 4 | | 'crud.model.resolver' 5 | | 'crud.model.resolverIndex' 6 | | 'crud.objects' 7 | | 'crud.utils' 8 | | 'crud.autocrud' 9 | | 'inputs' 10 | | 'debug.log' 11 | | 'debug.dmmf' 12 | 13 | export type Replacer = ( 14 | generated: string, 15 | section: keyof { [S in ReplacerSection as S extends `${T}${infer _}` ? S : never]: never }, 16 | ) => string 17 | -------------------------------------------------------------------------------- /src/utils/string.ts: -------------------------------------------------------------------------------- 1 | export const firstLetterUpperCase = (s: string) => s[0]?.toUpperCase() + s.slice(1) 2 | 3 | export const firstLetterLowerCase = (s: string) => s[0]?.toLowerCase() + s.slice(1) 4 | 5 | export const getCompositeName = (fields: readonly string[]) => fields.map((f) => f).join('_') 6 | 7 | export const escapeQuotesAndMultilineSupport = (input: string | undefined): string | undefined => { 8 | if (!input) return undefined 9 | const withScapedQuotes = input.replace(/['"`´]/g, '\\$&') 10 | const isMultiline = withScapedQuotes.includes('\n') 11 | return isMultiline ? `\`${withScapedQuotes}\`` : `'${withScapedQuotes}'` 12 | } 13 | -------------------------------------------------------------------------------- /src/utils/template.ts: -------------------------------------------------------------------------------- 1 | type Variables = T extends `${infer _}#{${infer VarName}}${infer Tail}` 2 | ? VarName | Variables 3 | : never 4 | 5 | export const useTemplate = | null = null>( 6 | template: T, 7 | variables: Omit<{ [V in Variables]: string }, S extends null ? '' : S>, 8 | skip?: S[], 9 | ): string => { 10 | let newTemplate: string = template 11 | Object.entries(variables).forEach(([name, value]) => { 12 | if (!skip?.includes(name as S)) newTemplate = newTemplate.replace(new RegExp(`#{${name}}`, 'g'), value as string) 13 | }) 14 | return newTemplate 15 | } 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": false, 4 | "allowSyntheticDefaultImports": true, 5 | "esModuleInterop": true, 6 | "experimentalDecorators": false, 7 | "forceConsistentCasingInFileNames": true, 8 | "lib": ["esnext"], 9 | "module": "commonjs", 10 | "moduleResolution": "node", 11 | "noEmitOnError": false, 12 | "noImplicitOverride": true, 13 | "noImplicitReturns": true, 14 | "pretty": true, 15 | "strict": true, 16 | "noUncheckedIndexedAccess": true, 17 | "removeComments": false, 18 | "skipLibCheck": false, 19 | "sourceMap": true, 20 | "outDir": "dist", 21 | "target": "es2019", 22 | "composite": true, 23 | "resolveJsonModule": true, 24 | "declaration": true, 25 | "noFallthroughCasesInSwitch": true, 26 | "baseUrl": ".", 27 | "newLine": "lf" 28 | }, 29 | "include": ["src", "./package.json"], 30 | "exclude": ["node_modules", "dist", "src/**/*.spec.ts", "src/**/*.test.ts", "src/**/tests/**/*.ts"], 31 | } 32 | --------------------------------------------------------------------------------