diff --git a/.circleci/config.yml b/.circleci/config.yml index a96c6cc27abf..e16c3d730bc8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,6 +38,8 @@ jobs: - run: cd typescript/rest-express && yarn && prisma generate && yarn tsc - run: cd typescript/script && yarn && prisma generate && yarn tsc - run: cd typescript/docker-mongodb && yarn && prisma generate + - run: cd typescript/docker-mysql && yarn && prisma generate + - run: cd typescript/docker-postgres && yarn && prisma generate flow: docker: diff --git a/.github/prisma-configs/configure.sh b/.github/prisma-configs/configure.sh index 2f9e03a0d974..c3213ce57b30 100644 --- a/.github/prisma-configs/configure.sh +++ b/.github/prisma-configs/configure.sh @@ -28,6 +28,8 @@ cp ./typescript/prisma.yml ../../typescript/graphql-auth/prisma cp ./typescript/prisma.yml ../../typescript/graphql-subscriptions/prisma cp ./typescript/prisma.yml ../../typescript/script/prisma cp ./typescript/mongo/prisma.yml ../../typescript/docker-mongodb/prisma +cp ./typescript/mysql-and-postgres/prisma.yml ../../typescript/docker-mysql/prisma +cp ./typescript/mysql-and-postgres/prisma.yml ../../typescript/docker-postgres/prisma # TypeScript (tsconfig.json) cp ./typescript/tsconfig.json ../../typescript/cli-app @@ -39,6 +41,8 @@ cp ./typescript/tsconfig-graphql.json ../../typescript/graphql-subscriptions mv ../../typescript/graphql-subscriptions/tsconfig-graphql.json ../../typescript/graphql-subscriptions/tsconfig.json cp ./typescript/tsconfig.json ../../typescript/script cp ./typescript/tsconfig.json ../../typescript/docker-mongodb +cp ./typescript/tsconfig.json ../../typescript/docker-mysql +cp ./typescript/tsconfig.json ../../typescript/docker-postgres # TypeScript (graphqlgen) cp ./typescript/graphqlgen.yml ../../typescript/graphql @@ -52,7 +56,6 @@ cp ./flow/prisma.yml ../../flow/script/prisma # Flow (.flowconfig) cp ./flow/.flowconfig ../../flow/graphql cp ./flow/.flowconfig ../../flow/script -\ # Go cp ./go/prisma.yml ../../go/cli-app/prisma diff --git a/.github/prisma-configs/typescript/mysql-and-postgres/prisma.yml b/.github/prisma-configs/typescript/mysql-and-postgres/prisma.yml new file mode 100644 index 000000000000..681e3dd881d1 --- /dev/null +++ b/.github/prisma-configs/typescript/mysql-and-postgres/prisma.yml @@ -0,0 +1,19 @@ +# Specifies the HTTP endpoint of your Prisma API. +endpoint: http://localhost:4466 + +# Defines your models, each model is mapped to the database as a collection. +datamodel: datamodel.prisma + +# Specifies the language and directory for the generated Prisma client. +generate: + - generator: typescript-client + output: ../src/generated/prisma-client/ + +# Ensures Prisma client is re-generated after a datamodel change. +hooks: + post-deploy: + - prisma generate + +# Seeds initial data into the database by running a script. +seed: + import: seed.graphql \ No newline at end of file diff --git a/.github/readmes/typescript/docker-mysql/README.md b/.github/readmes/typescript/docker-mysql/README.md new file mode 100644 index 000000000000..d14e8097c6c1 --- /dev/null +++ b/.github/readmes/typescript/docker-mysql/README.md @@ -0,0 +1,44 @@ +# MySQL with Docker Example + +This example shows how to **set up Prisma using Docker and MySQL** locally on your machine. It then uses the Prisma client in a simple TypeScript script to read and write data in the database. + +> This example uses a new and empty database. **Learn how to connect Prisma to your existing database [here](https://www.prisma.io/docs/-a003/)**. + +__INLINE(../_setup-1.md)__ +cd prisma-examples/typescript/docker-mysql +npm install +``` + +### 2. Launch Prisma with Docker + +This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): + +``` +docker-compose up -d +``` + +### 3. Install the Prisma CLI + +To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): + +``` +npm install -g prisma +``` + +### 4. Set up database & deploy Prisma datamodel + +To deploy the datamodel for this example, run the following command: + +``` +prisma deploy +``` + +### 5. Run the script + +Execute the script with this command: + +``` +npm run start +``` + +__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/.github/readmes/typescript/docker-postgres/README.md b/.github/readmes/typescript/docker-postgres/README.md new file mode 100644 index 000000000000..0955a89365ec --- /dev/null +++ b/.github/readmes/typescript/docker-postgres/README.md @@ -0,0 +1,44 @@ +# PostgreSQL with Docker Example + +This example shows how to **set up Prisma using Docker and PostgreSQL** locally on your machine. It then uses the Prisma client in a simple TypeScript script to read and write data in the database. + +> This example uses a new and empty database. **Learn how to connect Prisma to your existing database [here](https://www.prisma.io/docs/-a003/)**. + +__INLINE(../_setup-1.md)__ +cd prisma-examples/typescript/docker-postgres +npm install +``` + +### 2. Launch Prisma with Docker + +This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): + +``` +docker-compose up -d +``` + +### 3. Install the Prisma CLI + +To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): + +``` +npm install -g prisma +``` + +### 4. Set up database & deploy Prisma datamodel + +To deploy the datamodel for this example, run the following command: + +``` +prisma deploy +``` + +### 5. Run the script + +Execute the script with this command: + +``` +npm run start +``` + +__INLINE(../_next-steps.md)__ \ No newline at end of file diff --git a/typescript/docker-mysql/README.md b/typescript/docker-mysql/README.md new file mode 100644 index 000000000000..7314c5fae59d --- /dev/null +++ b/typescript/docker-mysql/README.md @@ -0,0 +1,60 @@ +# MySQL with Docker Example + +This example shows how to **set up Prisma using Docker and MySQL** locally on your machine. It then uses the Prisma client in a simple TypeScript script to read and write data in the database. + +> This example uses a new and empty database. **Learn how to connect Prisma to your existing database [here](https://www.prisma.io/docs/-a003/)**. + +## How to use + +### 1. Download example & install dependencies + +Clone the repository: + +``` +git clone git@github.com:prisma/prisma-examples.git +``` + +Install Node dependencies: + +``` +cd prisma-examples/typescript/docker-mysql +npm install +``` + +### 2. Launch Prisma with Docker + +This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): + +``` +docker-compose up -d +``` + +### 3. Install the Prisma CLI + +To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): + +``` +npm install -g prisma +``` + +### 4. Set up database & deploy Prisma datamodel + +To deploy the datamodel for this example, run the following command: + +``` +prisma deploy +``` + +### 5. Run the script + +Execute the script with this command: + +``` +npm run start +``` + +## Next steps + +- [Use Prisma with an existing database](https://www.prisma.io/docs/-t003/) +- [Explore the Prisma client API](https://www.prisma.io/client/client-typescript) +- [Learn more about the GraphQL schema](https://www.prisma.io/blog/graphql-server-basics-the-schema-ac5e2950214e/) \ No newline at end of file diff --git a/typescript/docker-mysql/docker-compose.yml b/typescript/docker-mysql/docker-compose.yml new file mode 100644 index 000000000000..60f2bd558709 --- /dev/null +++ b/typescript/docker-mysql/docker-compose.yml @@ -0,0 +1,30 @@ +version: '3' +services: + prisma: + image: prismagraphql/prisma:1.24 + restart: always + ports: + - "4466:4466" + environment: + PRISMA_CONFIG: | + port: 4466 + # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security + # managementApiSecret: my-secret + databases: + default: + connector: mysql + host: mysql + user: root + password: prisma + rawAccess: true + port: 3306 + migrations: true + mysql: + image: mysql:5.7 + restart: always + environment: + MYSQL_ROOT_PASSWORD: prisma + volumes: + - mysql:/var/lib/mysql +volumes: + mysql: \ No newline at end of file diff --git a/typescript/docker-mysql/package.json b/typescript/docker-mysql/package.json new file mode 100644 index 000000000000..b55fcfd922f9 --- /dev/null +++ b/typescript/docker-mysql/package.json @@ -0,0 +1,15 @@ +{ + "name": "docker-mysql", + "license": "MIT", + "dependencies": { + "prisma-client-lib": "1.24.0" + }, + "scripts": { + "start": "ts-node src/script.ts" + }, + "devDependencies": { + "@types/graphql": "^14.0.5", + "ts-node": "^7.0.1", + "typescript": "^3.2.2" + } +} diff --git a/typescript/docker-mysql/prisma/datamodel.prisma b/typescript/docker-mysql/prisma/datamodel.prisma new file mode 100644 index 000000000000..6955534d1911 --- /dev/null +++ b/typescript/docker-mysql/prisma/datamodel.prisma @@ -0,0 +1,24 @@ +type User { + id: ID! @unique + email: String! @unique + name: String + posts: [Post!]! + comments: [Comment!]! +} + +type Post { + id: ID! @unique + createdAt: DateTime! + updatedAt: DateTime! + title: String! + content: String + published: Boolean! @default(value: "false") + author: User! + comments: [Comment!]! +} + +type Comment { + id: ID! @unique + text: String! + writtenBy: User! +} \ No newline at end of file diff --git a/typescript/docker-mysql/prisma/prisma.yml b/typescript/docker-mysql/prisma/prisma.yml new file mode 100644 index 000000000000..681e3dd881d1 --- /dev/null +++ b/typescript/docker-mysql/prisma/prisma.yml @@ -0,0 +1,19 @@ +# Specifies the HTTP endpoint of your Prisma API. +endpoint: http://localhost:4466 + +# Defines your models, each model is mapped to the database as a collection. +datamodel: datamodel.prisma + +# Specifies the language and directory for the generated Prisma client. +generate: + - generator: typescript-client + output: ../src/generated/prisma-client/ + +# Ensures Prisma client is re-generated after a datamodel change. +hooks: + post-deploy: + - prisma generate + +# Seeds initial data into the database by running a script. +seed: + import: seed.graphql \ No newline at end of file diff --git a/typescript/docker-mysql/prisma/seed.graphql b/typescript/docker-mysql/prisma/seed.graphql new file mode 100644 index 000000000000..d74316b769fe --- /dev/null +++ b/typescript/docker-mysql/prisma/seed.graphql @@ -0,0 +1,42 @@ +mutation { + user1: createUser(data: { + email: "alice@prisma.io" + name: "Alice" + posts: { + create: { + title: "Join us for GraphQL Conf 2019 in Berlin" + content: "https://www.graphqlconf.org/" + published: true + } + } + }) { + id + } + + user2: createUser(data: { + email: "bob@prisma.io" + name: "Bob" + posts: { + create: [{ + title: "Subscribe to GraphQL Weekly for community news" + content: "https://graphqlweekly.com/" + published: true + comments: { + create: [{ + text: "Can recommend 💯", + writtenBy: { + connect: { + email: "alice@prisma.io" + } + } + }] + } + } { + title: "Follow Prisma on Twitter" + content: "https://twitter.com/prisma" + }] + } + }) { + id + } +} \ No newline at end of file diff --git a/typescript/docker-mysql/src/generated/prisma-client/index.ts b/typescript/docker-mysql/src/generated/prisma-client/index.ts new file mode 100644 index 000000000000..9d3e850da268 --- /dev/null +++ b/typescript/docker-mysql/src/generated/prisma-client/index.ts @@ -0,0 +1,1347 @@ +// Code generated by Prisma (prisma@1.24.0). DO NOT EDIT. +// Please don't change this file manually but run `prisma generate` to update it. +// For more information, please read the docs: https://www.prisma.io/docs/prisma-client/ + +import { DocumentNode } from "graphql"; +import { + makePrismaClientClass, + BaseClientOptions, + Model +} from "prisma-client-lib"; +import { typeDefs } from "./prisma-schema"; + +export type AtLeastOne }> = Partial & + U[keyof U]; + +export interface Exists { + comment: (where?: CommentWhereInput) => Promise; + post: (where?: PostWhereInput) => Promise; + user: (where?: UserWhereInput) => Promise; +} + +export interface Node {} + +export type FragmentableArray = Promise> & Fragmentable; + +export interface Fragmentable { + $fragment(fragment: string | DocumentNode): Promise; +} + +export interface Prisma { + $exists: Exists; + $graphql: ( + query: string, + variables?: { [key: string]: any } + ) => Promise; + + /** + * Queries + */ + + comment: (where: CommentWhereUniqueInput) => CommentPromise; + comments: ( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => FragmentableArray; + commentsConnection: ( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => CommentConnectionPromise; + post: (where: PostWhereUniqueInput) => PostPromise; + posts: ( + args?: { + where?: PostWhereInput; + orderBy?: PostOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => FragmentableArray; + postsConnection: ( + args?: { + where?: PostWhereInput; + orderBy?: PostOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => PostConnectionPromise; + user: (where: UserWhereUniqueInput) => UserPromise; + users: ( + args?: { + where?: UserWhereInput; + orderBy?: UserOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => FragmentableArray; + usersConnection: ( + args?: { + where?: UserWhereInput; + orderBy?: UserOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => UserConnectionPromise; + node: (args: { id: ID_Output }) => Node; + + /** + * Mutations + */ + + createComment: (data: CommentCreateInput) => CommentPromise; + updateComment: ( + args: { data: CommentUpdateInput; where: CommentWhereUniqueInput } + ) => CommentPromise; + updateManyComments: ( + args: { data: CommentUpdateManyMutationInput; where?: CommentWhereInput } + ) => BatchPayloadPromise; + upsertComment: ( + args: { + where: CommentWhereUniqueInput; + create: CommentCreateInput; + update: CommentUpdateInput; + } + ) => CommentPromise; + deleteComment: (where: CommentWhereUniqueInput) => CommentPromise; + deleteManyComments: (where?: CommentWhereInput) => BatchPayloadPromise; + createPost: (data: PostCreateInput) => PostPromise; + updatePost: ( + args: { data: PostUpdateInput; where: PostWhereUniqueInput } + ) => PostPromise; + updateManyPosts: ( + args: { data: PostUpdateManyMutationInput; where?: PostWhereInput } + ) => BatchPayloadPromise; + upsertPost: ( + args: { + where: PostWhereUniqueInput; + create: PostCreateInput; + update: PostUpdateInput; + } + ) => PostPromise; + deletePost: (where: PostWhereUniqueInput) => PostPromise; + deleteManyPosts: (where?: PostWhereInput) => BatchPayloadPromise; + createUser: (data: UserCreateInput) => UserPromise; + updateUser: ( + args: { data: UserUpdateInput; where: UserWhereUniqueInput } + ) => UserPromise; + updateManyUsers: ( + args: { data: UserUpdateManyMutationInput; where?: UserWhereInput } + ) => BatchPayloadPromise; + upsertUser: ( + args: { + where: UserWhereUniqueInput; + create: UserCreateInput; + update: UserUpdateInput; + } + ) => UserPromise; + deleteUser: (where: UserWhereUniqueInput) => UserPromise; + deleteManyUsers: (where?: UserWhereInput) => BatchPayloadPromise; + + /** + * Subscriptions + */ + + $subscribe: Subscription; +} + +export interface Subscription { + comment: ( + where?: CommentSubscriptionWhereInput + ) => CommentSubscriptionPayloadSubscription; + post: ( + where?: PostSubscriptionWhereInput + ) => PostSubscriptionPayloadSubscription; + user: ( + where?: UserSubscriptionWhereInput + ) => UserSubscriptionPayloadSubscription; +} + +export interface ClientConstructor { + new (options?: BaseClientOptions): T; +} + +/** + * Types + */ + +export type PostOrderByInput = + | "id_ASC" + | "id_DESC" + | "createdAt_ASC" + | "createdAt_DESC" + | "updatedAt_ASC" + | "updatedAt_DESC" + | "title_ASC" + | "title_DESC" + | "content_ASC" + | "content_DESC" + | "published_ASC" + | "published_DESC"; + +export type CommentOrderByInput = + | "id_ASC" + | "id_DESC" + | "text_ASC" + | "text_DESC" + | "createdAt_ASC" + | "createdAt_DESC" + | "updatedAt_ASC" + | "updatedAt_DESC"; + +export type UserOrderByInput = + | "id_ASC" + | "id_DESC" + | "email_ASC" + | "email_DESC" + | "name_ASC" + | "name_DESC" + | "createdAt_ASC" + | "createdAt_DESC" + | "updatedAt_ASC" + | "updatedAt_DESC"; + +export type MutationType = "CREATED" | "UPDATED" | "DELETED"; + +export interface CommentUpdateWithWhereUniqueNestedInput { + where: CommentWhereUniqueInput; + data: CommentUpdateDataInput; +} + +export type CommentWhereUniqueInput = AtLeastOne<{ + id: ID_Input; +}>; + +export interface PostCreateWithoutAuthorInput { + title: String; + content?: String; + published?: Boolean; + comments?: CommentCreateManyInput; +} + +export interface UserCreateOneWithoutPostsInput { + create?: UserCreateWithoutPostsInput; + connect?: UserWhereUniqueInput; +} + +export interface CommentCreateManyInput { + create?: CommentCreateInput[] | CommentCreateInput; + connect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; +} + +export interface CommentScalarWhereInput { + id?: ID_Input; + id_not?: ID_Input; + id_in?: ID_Input[] | ID_Input; + id_not_in?: ID_Input[] | ID_Input; + id_lt?: ID_Input; + id_lte?: ID_Input; + id_gt?: ID_Input; + id_gte?: ID_Input; + id_contains?: ID_Input; + id_not_contains?: ID_Input; + id_starts_with?: ID_Input; + id_not_starts_with?: ID_Input; + id_ends_with?: ID_Input; + id_not_ends_with?: ID_Input; + text?: String; + text_not?: String; + text_in?: String[] | String; + text_not_in?: String[] | String; + text_lt?: String; + text_lte?: String; + text_gt?: String; + text_gte?: String; + text_contains?: String; + text_not_contains?: String; + text_starts_with?: String; + text_not_starts_with?: String; + text_ends_with?: String; + text_not_ends_with?: String; + AND?: CommentScalarWhereInput[] | CommentScalarWhereInput; + OR?: CommentScalarWhereInput[] | CommentScalarWhereInput; + NOT?: CommentScalarWhereInput[] | CommentScalarWhereInput; +} + +export interface CommentUpdateInput { + text?: String; + writtenBy?: UserUpdateOneRequiredWithoutCommentsInput; +} + +export interface CommentWhereInput { + id?: ID_Input; + id_not?: ID_Input; + id_in?: ID_Input[] | ID_Input; + id_not_in?: ID_Input[] | ID_Input; + id_lt?: ID_Input; + id_lte?: ID_Input; + id_gt?: ID_Input; + id_gte?: ID_Input; + id_contains?: ID_Input; + id_not_contains?: ID_Input; + id_starts_with?: ID_Input; + id_not_starts_with?: ID_Input; + id_ends_with?: ID_Input; + id_not_ends_with?: ID_Input; + text?: String; + text_not?: String; + text_in?: String[] | String; + text_not_in?: String[] | String; + text_lt?: String; + text_lte?: String; + text_gt?: String; + text_gte?: String; + text_contains?: String; + text_not_contains?: String; + text_starts_with?: String; + text_not_starts_with?: String; + text_ends_with?: String; + text_not_ends_with?: String; + writtenBy?: UserWhereInput; + AND?: CommentWhereInput[] | CommentWhereInput; + OR?: CommentWhereInput[] | CommentWhereInput; + NOT?: CommentWhereInput[] | CommentWhereInput; +} + +export interface UserUpdateOneRequiredWithoutCommentsInput { + create?: UserCreateWithoutCommentsInput; + update?: UserUpdateWithoutCommentsDataInput; + upsert?: UserUpsertWithoutCommentsInput; + connect?: UserWhereUniqueInput; +} + +export interface UserSubscriptionWhereInput { + mutation_in?: MutationType[] | MutationType; + updatedFields_contains?: String; + updatedFields_contains_every?: String[] | String; + updatedFields_contains_some?: String[] | String; + node?: UserWhereInput; + AND?: UserSubscriptionWhereInput[] | UserSubscriptionWhereInput; + OR?: UserSubscriptionWhereInput[] | UserSubscriptionWhereInput; + NOT?: UserSubscriptionWhereInput[] | UserSubscriptionWhereInput; +} + +export interface UserUpdateWithoutCommentsDataInput { + email?: String; + name?: String; + posts?: PostUpdateManyWithoutAuthorInput; +} + +export interface CommentSubscriptionWhereInput { + mutation_in?: MutationType[] | MutationType; + updatedFields_contains?: String; + updatedFields_contains_every?: String[] | String; + updatedFields_contains_some?: String[] | String; + node?: CommentWhereInput; + AND?: CommentSubscriptionWhereInput[] | CommentSubscriptionWhereInput; + OR?: CommentSubscriptionWhereInput[] | CommentSubscriptionWhereInput; + NOT?: CommentSubscriptionWhereInput[] | CommentSubscriptionWhereInput; +} + +export interface PostUpdateManyWithoutAuthorInput { + create?: PostCreateWithoutAuthorInput[] | PostCreateWithoutAuthorInput; + delete?: PostWhereUniqueInput[] | PostWhereUniqueInput; + connect?: PostWhereUniqueInput[] | PostWhereUniqueInput; + disconnect?: PostWhereUniqueInput[] | PostWhereUniqueInput; + update?: + | PostUpdateWithWhereUniqueWithoutAuthorInput[] + | PostUpdateWithWhereUniqueWithoutAuthorInput; + upsert?: + | PostUpsertWithWhereUniqueWithoutAuthorInput[] + | PostUpsertWithWhereUniqueWithoutAuthorInput; + deleteMany?: PostScalarWhereInput[] | PostScalarWhereInput; + updateMany?: + | PostUpdateManyWithWhereNestedInput[] + | PostUpdateManyWithWhereNestedInput; +} + +export interface UserUpdateInput { + email?: String; + name?: String; + posts?: PostUpdateManyWithoutAuthorInput; + comments?: CommentUpdateManyWithoutWrittenByInput; +} + +export interface PostUpdateWithWhereUniqueWithoutAuthorInput { + where: PostWhereUniqueInput; + data: PostUpdateWithoutAuthorDataInput; +} + +export interface PostUpdateManyMutationInput { + title?: String; + content?: String; + published?: Boolean; +} + +export interface PostUpdateWithoutAuthorDataInput { + title?: String; + content?: String; + published?: Boolean; + comments?: CommentUpdateManyInput; +} + +export interface UserUpsertWithoutPostsInput { + update: UserUpdateWithoutPostsDataInput; + create: UserCreateWithoutPostsInput; +} + +export interface CommentUpdateManyInput { + create?: CommentCreateInput[] | CommentCreateInput; + update?: + | CommentUpdateWithWhereUniqueNestedInput[] + | CommentUpdateWithWhereUniqueNestedInput; + upsert?: + | CommentUpsertWithWhereUniqueNestedInput[] + | CommentUpsertWithWhereUniqueNestedInput; + delete?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + connect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + disconnect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + deleteMany?: CommentScalarWhereInput[] | CommentScalarWhereInput; + updateMany?: + | CommentUpdateManyWithWhereNestedInput[] + | CommentUpdateManyWithWhereNestedInput; +} + +export interface CommentUpdateWithoutWrittenByDataInput { + text?: String; +} + +export interface PostUpdateInput { + title?: String; + content?: String; + published?: Boolean; + author?: UserUpdateOneRequiredWithoutPostsInput; + comments?: CommentUpdateManyInput; +} + +export interface CommentUpdateWithWhereUniqueWithoutWrittenByInput { + where: CommentWhereUniqueInput; + data: CommentUpdateWithoutWrittenByDataInput; +} + +export interface CommentUpdateDataInput { + text?: String; + writtenBy?: UserUpdateOneRequiredWithoutCommentsInput; +} + +export interface UserUpdateWithoutPostsDataInput { + email?: String; + name?: String; + comments?: CommentUpdateManyWithoutWrittenByInput; +} + +export interface CommentUpsertWithWhereUniqueNestedInput { + where: CommentWhereUniqueInput; + update: CommentUpdateDataInput; + create: CommentCreateInput; +} + +export interface UserCreateOneWithoutCommentsInput { + create?: UserCreateWithoutCommentsInput; + connect?: UserWhereUniqueInput; +} + +export interface CommentCreateWithoutWrittenByInput { + text: String; +} + +export interface PostCreateManyWithoutAuthorInput { + create?: PostCreateWithoutAuthorInput[] | PostCreateWithoutAuthorInput; + connect?: PostWhereUniqueInput[] | PostWhereUniqueInput; +} + +export interface CommentUpdateManyWithWhereNestedInput { + where: CommentScalarWhereInput; + data: CommentUpdateManyDataInput; +} + +export interface PostWhereInput { + id?: ID_Input; + id_not?: ID_Input; + id_in?: ID_Input[] | ID_Input; + id_not_in?: ID_Input[] | ID_Input; + id_lt?: ID_Input; + id_lte?: ID_Input; + id_gt?: ID_Input; + id_gte?: ID_Input; + id_contains?: ID_Input; + id_not_contains?: ID_Input; + id_starts_with?: ID_Input; + id_not_starts_with?: ID_Input; + id_ends_with?: ID_Input; + id_not_ends_with?: ID_Input; + createdAt?: DateTimeInput; + createdAt_not?: DateTimeInput; + createdAt_in?: DateTimeInput[] | DateTimeInput; + createdAt_not_in?: DateTimeInput[] | DateTimeInput; + createdAt_lt?: DateTimeInput; + createdAt_lte?: DateTimeInput; + createdAt_gt?: DateTimeInput; + createdAt_gte?: DateTimeInput; + updatedAt?: DateTimeInput; + updatedAt_not?: DateTimeInput; + updatedAt_in?: DateTimeInput[] | DateTimeInput; + updatedAt_not_in?: DateTimeInput[] | DateTimeInput; + updatedAt_lt?: DateTimeInput; + updatedAt_lte?: DateTimeInput; + updatedAt_gt?: DateTimeInput; + updatedAt_gte?: DateTimeInput; + title?: String; + title_not?: String; + title_in?: String[] | String; + title_not_in?: String[] | String; + title_lt?: String; + title_lte?: String; + title_gt?: String; + title_gte?: String; + title_contains?: String; + title_not_contains?: String; + title_starts_with?: String; + title_not_starts_with?: String; + title_ends_with?: String; + title_not_ends_with?: String; + content?: String; + content_not?: String; + content_in?: String[] | String; + content_not_in?: String[] | String; + content_lt?: String; + content_lte?: String; + content_gt?: String; + content_gte?: String; + content_contains?: String; + content_not_contains?: String; + content_starts_with?: String; + content_not_starts_with?: String; + content_ends_with?: String; + content_not_ends_with?: String; + published?: Boolean; + published_not?: Boolean; + author?: UserWhereInput; + comments_every?: CommentWhereInput; + comments_some?: CommentWhereInput; + comments_none?: CommentWhereInput; + AND?: PostWhereInput[] | PostWhereInput; + OR?: PostWhereInput[] | PostWhereInput; + NOT?: PostWhereInput[] | PostWhereInput; +} + +export interface CommentUpdateManyDataInput { + text?: String; +} + +export interface UserUpdateManyMutationInput { + email?: String; + name?: String; +} + +export interface PostUpsertWithWhereUniqueWithoutAuthorInput { + where: PostWhereUniqueInput; + update: PostUpdateWithoutAuthorDataInput; + create: PostCreateWithoutAuthorInput; +} + +export type PostWhereUniqueInput = AtLeastOne<{ + id: ID_Input; +}>; + +export interface PostScalarWhereInput { + id?: ID_Input; + id_not?: ID_Input; + id_in?: ID_Input[] | ID_Input; + id_not_in?: ID_Input[] | ID_Input; + id_lt?: ID_Input; + id_lte?: ID_Input; + id_gt?: ID_Input; + id_gte?: ID_Input; + id_contains?: ID_Input; + id_not_contains?: ID_Input; + id_starts_with?: ID_Input; + id_not_starts_with?: ID_Input; + id_ends_with?: ID_Input; + id_not_ends_with?: ID_Input; + createdAt?: DateTimeInput; + createdAt_not?: DateTimeInput; + createdAt_in?: DateTimeInput[] | DateTimeInput; + createdAt_not_in?: DateTimeInput[] | DateTimeInput; + createdAt_lt?: DateTimeInput; + createdAt_lte?: DateTimeInput; + createdAt_gt?: DateTimeInput; + createdAt_gte?: DateTimeInput; + updatedAt?: DateTimeInput; + updatedAt_not?: DateTimeInput; + updatedAt_in?: DateTimeInput[] | DateTimeInput; + updatedAt_not_in?: DateTimeInput[] | DateTimeInput; + updatedAt_lt?: DateTimeInput; + updatedAt_lte?: DateTimeInput; + updatedAt_gt?: DateTimeInput; + updatedAt_gte?: DateTimeInput; + title?: String; + title_not?: String; + title_in?: String[] | String; + title_not_in?: String[] | String; + title_lt?: String; + title_lte?: String; + title_gt?: String; + title_gte?: String; + title_contains?: String; + title_not_contains?: String; + title_starts_with?: String; + title_not_starts_with?: String; + title_ends_with?: String; + title_not_ends_with?: String; + content?: String; + content_not?: String; + content_in?: String[] | String; + content_not_in?: String[] | String; + content_lt?: String; + content_lte?: String; + content_gt?: String; + content_gte?: String; + content_contains?: String; + content_not_contains?: String; + content_starts_with?: String; + content_not_starts_with?: String; + content_ends_with?: String; + content_not_ends_with?: String; + published?: Boolean; + published_not?: Boolean; + AND?: PostScalarWhereInput[] | PostScalarWhereInput; + OR?: PostScalarWhereInput[] | PostScalarWhereInput; + NOT?: PostScalarWhereInput[] | PostScalarWhereInput; +} + +export type UserWhereUniqueInput = AtLeastOne<{ + id: ID_Input; + email?: String; +}>; + +export interface PostUpdateManyWithWhereNestedInput { + where: PostScalarWhereInput; + data: PostUpdateManyDataInput; +} + +export interface UserUpdateOneRequiredWithoutPostsInput { + create?: UserCreateWithoutPostsInput; + update?: UserUpdateWithoutPostsDataInput; + upsert?: UserUpsertWithoutPostsInput; + connect?: UserWhereUniqueInput; +} + +export interface PostUpdateManyDataInput { + title?: String; + content?: String; + published?: Boolean; +} + +export interface UserCreateWithoutCommentsInput { + email: String; + name?: String; + posts?: PostCreateManyWithoutAuthorInput; +} + +export interface UserUpsertWithoutCommentsInput { + update: UserUpdateWithoutCommentsDataInput; + create: UserCreateWithoutCommentsInput; +} + +export interface PostSubscriptionWhereInput { + mutation_in?: MutationType[] | MutationType; + updatedFields_contains?: String; + updatedFields_contains_every?: String[] | String; + updatedFields_contains_some?: String[] | String; + node?: PostWhereInput; + AND?: PostSubscriptionWhereInput[] | PostSubscriptionWhereInput; + OR?: PostSubscriptionWhereInput[] | PostSubscriptionWhereInput; + NOT?: PostSubscriptionWhereInput[] | PostSubscriptionWhereInput; +} + +export interface PostCreateInput { + title: String; + content?: String; + published?: Boolean; + author: UserCreateOneWithoutPostsInput; + comments?: CommentCreateManyInput; +} + +export interface UserCreateWithoutPostsInput { + email: String; + name?: String; + comments?: CommentCreateManyWithoutWrittenByInput; +} + +export interface CommentCreateManyWithoutWrittenByInput { + create?: + | CommentCreateWithoutWrittenByInput[] + | CommentCreateWithoutWrittenByInput; + connect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; +} + +export interface CommentUpdateManyMutationInput { + text?: String; +} + +export interface UserCreateInput { + email: String; + name?: String; + posts?: PostCreateManyWithoutAuthorInput; + comments?: CommentCreateManyWithoutWrittenByInput; +} + +export interface UserWhereInput { + id?: ID_Input; + id_not?: ID_Input; + id_in?: ID_Input[] | ID_Input; + id_not_in?: ID_Input[] | ID_Input; + id_lt?: ID_Input; + id_lte?: ID_Input; + id_gt?: ID_Input; + id_gte?: ID_Input; + id_contains?: ID_Input; + id_not_contains?: ID_Input; + id_starts_with?: ID_Input; + id_not_starts_with?: ID_Input; + id_ends_with?: ID_Input; + id_not_ends_with?: ID_Input; + email?: String; + email_not?: String; + email_in?: String[] | String; + email_not_in?: String[] | String; + email_lt?: String; + email_lte?: String; + email_gt?: String; + email_gte?: String; + email_contains?: String; + email_not_contains?: String; + email_starts_with?: String; + email_not_starts_with?: String; + email_ends_with?: String; + email_not_ends_with?: String; + name?: String; + name_not?: String; + name_in?: String[] | String; + name_not_in?: String[] | String; + name_lt?: String; + name_lte?: String; + name_gt?: String; + name_gte?: String; + name_contains?: String; + name_not_contains?: String; + name_starts_with?: String; + name_not_starts_with?: String; + name_ends_with?: String; + name_not_ends_with?: String; + posts_every?: PostWhereInput; + posts_some?: PostWhereInput; + posts_none?: PostWhereInput; + comments_every?: CommentWhereInput; + comments_some?: CommentWhereInput; + comments_none?: CommentWhereInput; + AND?: UserWhereInput[] | UserWhereInput; + OR?: UserWhereInput[] | UserWhereInput; + NOT?: UserWhereInput[] | UserWhereInput; +} + +export interface CommentCreateInput { + text: String; + writtenBy: UserCreateOneWithoutCommentsInput; +} + +export interface CommentUpdateManyWithoutWrittenByInput { + create?: + | CommentCreateWithoutWrittenByInput[] + | CommentCreateWithoutWrittenByInput; + delete?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + connect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + disconnect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + update?: + | CommentUpdateWithWhereUniqueWithoutWrittenByInput[] + | CommentUpdateWithWhereUniqueWithoutWrittenByInput; + upsert?: + | CommentUpsertWithWhereUniqueWithoutWrittenByInput[] + | CommentUpsertWithWhereUniqueWithoutWrittenByInput; + deleteMany?: CommentScalarWhereInput[] | CommentScalarWhereInput; + updateMany?: + | CommentUpdateManyWithWhereNestedInput[] + | CommentUpdateManyWithWhereNestedInput; +} + +export interface CommentUpsertWithWhereUniqueWithoutWrittenByInput { + where: CommentWhereUniqueInput; + update: CommentUpdateWithoutWrittenByDataInput; + create: CommentCreateWithoutWrittenByInput; +} + +export interface NodeNode { + id: ID_Output; +} + +export interface UserPreviousValues { + id: ID_Output; + email: String; + name?: String; +} + +export interface UserPreviousValuesPromise + extends Promise, + Fragmentable { + id: () => Promise; + email: () => Promise; + name: () => Promise; +} + +export interface UserPreviousValuesSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + email: () => Promise>; + name: () => Promise>; +} + +export interface PostConnection { + pageInfo: PageInfo; + edges: PostEdge[]; +} + +export interface PostConnectionPromise + extends Promise, + Fragmentable { + pageInfo: () => T; + edges: >() => T; + aggregate: () => T; +} + +export interface PostConnectionSubscription + extends Promise>, + Fragmentable { + pageInfo: () => T; + edges: >>() => T; + aggregate: () => T; +} + +export interface Post { + id: ID_Output; + createdAt: DateTimeOutput; + updatedAt: DateTimeOutput; + title: String; + content?: String; + published: Boolean; +} + +export interface PostPromise extends Promise, Fragmentable { + id: () => Promise; + createdAt: () => Promise; + updatedAt: () => Promise; + title: () => Promise; + content: () => Promise; + published: () => Promise; + author: () => T; + comments: >( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; +} + +export interface PostSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + createdAt: () => Promise>; + updatedAt: () => Promise>; + title: () => Promise>; + content: () => Promise>; + published: () => Promise>; + author: () => T; + comments: >>( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; +} + +export interface AggregateComment { + count: Int; +} + +export interface AggregateCommentPromise + extends Promise, + Fragmentable { + count: () => Promise; +} + +export interface AggregateCommentSubscription + extends Promise>, + Fragmentable { + count: () => Promise>; +} + +export interface CommentEdge { + node: Comment; + cursor: String; +} + +export interface CommentEdgePromise extends Promise, Fragmentable { + node: () => T; + cursor: () => Promise; +} + +export interface CommentEdgeSubscription + extends Promise>, + Fragmentable { + node: () => T; + cursor: () => Promise>; +} + +export interface BatchPayload { + count: Long; +} + +export interface BatchPayloadPromise + extends Promise, + Fragmentable { + count: () => Promise; +} + +export interface BatchPayloadSubscription + extends Promise>, + Fragmentable { + count: () => Promise>; +} + +export interface PostPreviousValues { + id: ID_Output; + createdAt: DateTimeOutput; + updatedAt: DateTimeOutput; + title: String; + content?: String; + published: Boolean; +} + +export interface PostPreviousValuesPromise + extends Promise, + Fragmentable { + id: () => Promise; + createdAt: () => Promise; + updatedAt: () => Promise; + title: () => Promise; + content: () => Promise; + published: () => Promise; +} + +export interface PostPreviousValuesSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + createdAt: () => Promise>; + updatedAt: () => Promise>; + title: () => Promise>; + content: () => Promise>; + published: () => Promise>; +} + +export interface PageInfo { + hasNextPage: Boolean; + hasPreviousPage: Boolean; + startCursor?: String; + endCursor?: String; +} + +export interface PageInfoPromise extends Promise, Fragmentable { + hasNextPage: () => Promise; + hasPreviousPage: () => Promise; + startCursor: () => Promise; + endCursor: () => Promise; +} + +export interface PageInfoSubscription + extends Promise>, + Fragmentable { + hasNextPage: () => Promise>; + hasPreviousPage: () => Promise>; + startCursor: () => Promise>; + endCursor: () => Promise>; +} + +export interface UserEdge { + node: User; + cursor: String; +} + +export interface UserEdgePromise extends Promise, Fragmentable { + node: () => T; + cursor: () => Promise; +} + +export interface UserEdgeSubscription + extends Promise>, + Fragmentable { + node: () => T; + cursor: () => Promise>; +} + +export interface CommentConnection { + pageInfo: PageInfo; + edges: CommentEdge[]; +} + +export interface CommentConnectionPromise + extends Promise, + Fragmentable { + pageInfo: () => T; + edges: >() => T; + aggregate: () => T; +} + +export interface CommentConnectionSubscription + extends Promise>, + Fragmentable { + pageInfo: () => T; + edges: >>() => T; + aggregate: () => T; +} + +export interface PostSubscriptionPayload { + mutation: MutationType; + node: Post; + updatedFields: String[]; + previousValues: PostPreviousValues; +} + +export interface PostSubscriptionPayloadPromise + extends Promise, + Fragmentable { + mutation: () => Promise; + node: () => T; + updatedFields: () => Promise; + previousValues: () => T; +} + +export interface PostSubscriptionPayloadSubscription + extends Promise>, + Fragmentable { + mutation: () => Promise>; + node: () => T; + updatedFields: () => Promise>; + previousValues: () => T; +} + +export interface PostEdge { + node: Post; + cursor: String; +} + +export interface PostEdgePromise extends Promise, Fragmentable { + node: () => T; + cursor: () => Promise; +} + +export interface PostEdgeSubscription + extends Promise>, + Fragmentable { + node: () => T; + cursor: () => Promise>; +} + +export interface CommentPreviousValues { + id: ID_Output; + text: String; +} + +export interface CommentPreviousValuesPromise + extends Promise, + Fragmentable { + id: () => Promise; + text: () => Promise; +} + +export interface CommentPreviousValuesSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + text: () => Promise>; +} + +export interface CommentSubscriptionPayload { + mutation: MutationType; + node: Comment; + updatedFields: String[]; + previousValues: CommentPreviousValues; +} + +export interface CommentSubscriptionPayloadPromise + extends Promise, + Fragmentable { + mutation: () => Promise; + node: () => T; + updatedFields: () => Promise; + previousValues: () => T; +} + +export interface CommentSubscriptionPayloadSubscription + extends Promise>, + Fragmentable { + mutation: () => Promise>; + node: () => T; + updatedFields: () => Promise>; + previousValues: () => T; +} + +export interface Comment { + id: ID_Output; + text: String; +} + +export interface CommentPromise extends Promise, Fragmentable { + id: () => Promise; + text: () => Promise; + writtenBy: () => T; +} + +export interface CommentSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + text: () => Promise>; + writtenBy: () => T; +} + +export interface User { + id: ID_Output; + email: String; + name?: String; +} + +export interface UserPromise extends Promise, Fragmentable { + id: () => Promise; + email: () => Promise; + name: () => Promise; + posts: >( + args?: { + where?: PostWhereInput; + orderBy?: PostOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; + comments: >( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; +} + +export interface UserSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + email: () => Promise>; + name: () => Promise>; + posts: >>( + args?: { + where?: PostWhereInput; + orderBy?: PostOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; + comments: >>( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; +} + +export interface UserSubscriptionPayload { + mutation: MutationType; + node: User; + updatedFields: String[]; + previousValues: UserPreviousValues; +} + +export interface UserSubscriptionPayloadPromise + extends Promise, + Fragmentable { + mutation: () => Promise; + node: () => T; + updatedFields: () => Promise; + previousValues: () => T; +} + +export interface UserSubscriptionPayloadSubscription + extends Promise>, + Fragmentable { + mutation: () => Promise>; + node: () => T; + updatedFields: () => Promise>; + previousValues: () => T; +} + +export interface AggregatePost { + count: Int; +} + +export interface AggregatePostPromise + extends Promise, + Fragmentable { + count: () => Promise; +} + +export interface AggregatePostSubscription + extends Promise>, + Fragmentable { + count: () => Promise>; +} + +export interface UserConnection { + pageInfo: PageInfo; + edges: UserEdge[]; +} + +export interface UserConnectionPromise + extends Promise, + Fragmentable { + pageInfo: () => T; + edges: >() => T; + aggregate: () => T; +} + +export interface UserConnectionSubscription + extends Promise>, + Fragmentable { + pageInfo: () => T; + edges: >>() => T; + aggregate: () => T; +} + +export interface AggregateUser { + count: Int; +} + +export interface AggregateUserPromise + extends Promise, + Fragmentable { + count: () => Promise; +} + +export interface AggregateUserSubscription + extends Promise>, + Fragmentable { + count: () => Promise>; +} + +/* +DateTime scalar input type, allowing Date +*/ +export type DateTimeInput = Date | string; + +/* +DateTime scalar output type, which is always a string +*/ +export type DateTimeOutput = string; + +export type Long = string; + +/* +The `Boolean` scalar type represents `true` or `false`. +*/ +export type Boolean = boolean; + +/* +The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. +*/ +export type Int = number; + +/* +The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID. +*/ +export type ID_Input = string | number; +export type ID_Output = string; + +/* +The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text. +*/ +export type String = string; + +/** + * Model Metadata + */ + +export const models: Model[] = [ + { + name: "Comment", + embedded: false + }, + { + name: "Post", + embedded: false + }, + { + name: "User", + embedded: false + } +]; + +/** + * Type Defs + */ + +export const Prisma = makePrismaClientClass>({ + typeDefs, + models, + endpoint: `http://localhost:4466` +}); +export const prisma = new Prisma(); diff --git a/typescript/docker-mysql/src/generated/prisma-client/prisma-schema.ts b/typescript/docker-mysql/src/generated/prisma-client/prisma-schema.ts new file mode 100644 index 000000000000..4d61e9d208c6 --- /dev/null +++ b/typescript/docker-mysql/src/generated/prisma-client/prisma-schema.ts @@ -0,0 +1,761 @@ +export const typeDefs = /* GraphQL */ `type AggregateComment { + count: Int! +} + +type AggregatePost { + count: Int! +} + +type AggregateUser { + count: Int! +} + +type BatchPayload { + count: Long! +} + +type Comment { + id: ID! + text: String! + writtenBy: User! +} + +type CommentConnection { + pageInfo: PageInfo! + edges: [CommentEdge]! + aggregate: AggregateComment! +} + +input CommentCreateInput { + text: String! + writtenBy: UserCreateOneWithoutCommentsInput! +} + +input CommentCreateManyInput { + create: [CommentCreateInput!] + connect: [CommentWhereUniqueInput!] +} + +input CommentCreateManyWithoutWrittenByInput { + create: [CommentCreateWithoutWrittenByInput!] + connect: [CommentWhereUniqueInput!] +} + +input CommentCreateWithoutWrittenByInput { + text: String! +} + +type CommentEdge { + node: Comment! + cursor: String! +} + +enum CommentOrderByInput { + id_ASC + id_DESC + text_ASC + text_DESC + createdAt_ASC + createdAt_DESC + updatedAt_ASC + updatedAt_DESC +} + +type CommentPreviousValues { + id: ID! + text: String! +} + +input CommentScalarWhereInput { + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + text: String + text_not: String + text_in: [String!] + text_not_in: [String!] + text_lt: String + text_lte: String + text_gt: String + text_gte: String + text_contains: String + text_not_contains: String + text_starts_with: String + text_not_starts_with: String + text_ends_with: String + text_not_ends_with: String + AND: [CommentScalarWhereInput!] + OR: [CommentScalarWhereInput!] + NOT: [CommentScalarWhereInput!] +} + +type CommentSubscriptionPayload { + mutation: MutationType! + node: Comment + updatedFields: [String!] + previousValues: CommentPreviousValues +} + +input CommentSubscriptionWhereInput { + mutation_in: [MutationType!] + updatedFields_contains: String + updatedFields_contains_every: [String!] + updatedFields_contains_some: [String!] + node: CommentWhereInput + AND: [CommentSubscriptionWhereInput!] + OR: [CommentSubscriptionWhereInput!] + NOT: [CommentSubscriptionWhereInput!] +} + +input CommentUpdateDataInput { + text: String + writtenBy: UserUpdateOneRequiredWithoutCommentsInput +} + +input CommentUpdateInput { + text: String + writtenBy: UserUpdateOneRequiredWithoutCommentsInput +} + +input CommentUpdateManyDataInput { + text: String +} + +input CommentUpdateManyInput { + create: [CommentCreateInput!] + update: [CommentUpdateWithWhereUniqueNestedInput!] + upsert: [CommentUpsertWithWhereUniqueNestedInput!] + delete: [CommentWhereUniqueInput!] + connect: [CommentWhereUniqueInput!] + disconnect: [CommentWhereUniqueInput!] + deleteMany: [CommentScalarWhereInput!] + updateMany: [CommentUpdateManyWithWhereNestedInput!] +} + +input CommentUpdateManyMutationInput { + text: String +} + +input CommentUpdateManyWithoutWrittenByInput { + create: [CommentCreateWithoutWrittenByInput!] + delete: [CommentWhereUniqueInput!] + connect: [CommentWhereUniqueInput!] + disconnect: [CommentWhereUniqueInput!] + update: [CommentUpdateWithWhereUniqueWithoutWrittenByInput!] + upsert: [CommentUpsertWithWhereUniqueWithoutWrittenByInput!] + deleteMany: [CommentScalarWhereInput!] + updateMany: [CommentUpdateManyWithWhereNestedInput!] +} + +input CommentUpdateManyWithWhereNestedInput { + where: CommentScalarWhereInput! + data: CommentUpdateManyDataInput! +} + +input CommentUpdateWithoutWrittenByDataInput { + text: String +} + +input CommentUpdateWithWhereUniqueNestedInput { + where: CommentWhereUniqueInput! + data: CommentUpdateDataInput! +} + +input CommentUpdateWithWhereUniqueWithoutWrittenByInput { + where: CommentWhereUniqueInput! + data: CommentUpdateWithoutWrittenByDataInput! +} + +input CommentUpsertWithWhereUniqueNestedInput { + where: CommentWhereUniqueInput! + update: CommentUpdateDataInput! + create: CommentCreateInput! +} + +input CommentUpsertWithWhereUniqueWithoutWrittenByInput { + where: CommentWhereUniqueInput! + update: CommentUpdateWithoutWrittenByDataInput! + create: CommentCreateWithoutWrittenByInput! +} + +input CommentWhereInput { + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + text: String + text_not: String + text_in: [String!] + text_not_in: [String!] + text_lt: String + text_lte: String + text_gt: String + text_gte: String + text_contains: String + text_not_contains: String + text_starts_with: String + text_not_starts_with: String + text_ends_with: String + text_not_ends_with: String + writtenBy: UserWhereInput + AND: [CommentWhereInput!] + OR: [CommentWhereInput!] + NOT: [CommentWhereInput!] +} + +input CommentWhereUniqueInput { + id: ID +} + +scalar DateTime + +scalar Long + +type Mutation { + createComment(data: CommentCreateInput!): Comment! + updateComment(data: CommentUpdateInput!, where: CommentWhereUniqueInput!): Comment + updateManyComments(data: CommentUpdateManyMutationInput!, where: CommentWhereInput): BatchPayload! + upsertComment(where: CommentWhereUniqueInput!, create: CommentCreateInput!, update: CommentUpdateInput!): Comment! + deleteComment(where: CommentWhereUniqueInput!): Comment + deleteManyComments(where: CommentWhereInput): BatchPayload! + createPost(data: PostCreateInput!): Post! + updatePost(data: PostUpdateInput!, where: PostWhereUniqueInput!): Post + updateManyPosts(data: PostUpdateManyMutationInput!, where: PostWhereInput): BatchPayload! + upsertPost(where: PostWhereUniqueInput!, create: PostCreateInput!, update: PostUpdateInput!): Post! + deletePost(where: PostWhereUniqueInput!): Post + deleteManyPosts(where: PostWhereInput): BatchPayload! + createUser(data: UserCreateInput!): User! + updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User + updateManyUsers(data: UserUpdateManyMutationInput!, where: UserWhereInput): BatchPayload! + upsertUser(where: UserWhereUniqueInput!, create: UserCreateInput!, update: UserUpdateInput!): User! + deleteUser(where: UserWhereUniqueInput!): User + deleteManyUsers(where: UserWhereInput): BatchPayload! +} + +enum MutationType { + CREATED + UPDATED + DELETED +} + +interface Node { + id: ID! +} + +type PageInfo { + hasNextPage: Boolean! + hasPreviousPage: Boolean! + startCursor: String + endCursor: String +} + +type Post { + id: ID! + createdAt: DateTime! + updatedAt: DateTime! + title: String! + content: String + published: Boolean! + author: User! + comments(where: CommentWhereInput, orderBy: CommentOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Comment!] +} + +type PostConnection { + pageInfo: PageInfo! + edges: [PostEdge]! + aggregate: AggregatePost! +} + +input PostCreateInput { + title: String! + content: String + published: Boolean + author: UserCreateOneWithoutPostsInput! + comments: CommentCreateManyInput +} + +input PostCreateManyWithoutAuthorInput { + create: [PostCreateWithoutAuthorInput!] + connect: [PostWhereUniqueInput!] +} + +input PostCreateWithoutAuthorInput { + title: String! + content: String + published: Boolean + comments: CommentCreateManyInput +} + +type PostEdge { + node: Post! + cursor: String! +} + +enum PostOrderByInput { + id_ASC + id_DESC + createdAt_ASC + createdAt_DESC + updatedAt_ASC + updatedAt_DESC + title_ASC + title_DESC + content_ASC + content_DESC + published_ASC + published_DESC +} + +type PostPreviousValues { + id: ID! + createdAt: DateTime! + updatedAt: DateTime! + title: String! + content: String + published: Boolean! +} + +input PostScalarWhereInput { + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + createdAt: DateTime + createdAt_not: DateTime + createdAt_in: [DateTime!] + createdAt_not_in: [DateTime!] + createdAt_lt: DateTime + createdAt_lte: DateTime + createdAt_gt: DateTime + createdAt_gte: DateTime + updatedAt: DateTime + updatedAt_not: DateTime + updatedAt_in: [DateTime!] + updatedAt_not_in: [DateTime!] + updatedAt_lt: DateTime + updatedAt_lte: DateTime + updatedAt_gt: DateTime + updatedAt_gte: DateTime + title: String + title_not: String + title_in: [String!] + title_not_in: [String!] + title_lt: String + title_lte: String + title_gt: String + title_gte: String + title_contains: String + title_not_contains: String + title_starts_with: String + title_not_starts_with: String + title_ends_with: String + title_not_ends_with: String + content: String + content_not: String + content_in: [String!] + content_not_in: [String!] + content_lt: String + content_lte: String + content_gt: String + content_gte: String + content_contains: String + content_not_contains: String + content_starts_with: String + content_not_starts_with: String + content_ends_with: String + content_not_ends_with: String + published: Boolean + published_not: Boolean + AND: [PostScalarWhereInput!] + OR: [PostScalarWhereInput!] + NOT: [PostScalarWhereInput!] +} + +type PostSubscriptionPayload { + mutation: MutationType! + node: Post + updatedFields: [String!] + previousValues: PostPreviousValues +} + +input PostSubscriptionWhereInput { + mutation_in: [MutationType!] + updatedFields_contains: String + updatedFields_contains_every: [String!] + updatedFields_contains_some: [String!] + node: PostWhereInput + AND: [PostSubscriptionWhereInput!] + OR: [PostSubscriptionWhereInput!] + NOT: [PostSubscriptionWhereInput!] +} + +input PostUpdateInput { + title: String + content: String + published: Boolean + author: UserUpdateOneRequiredWithoutPostsInput + comments: CommentUpdateManyInput +} + +input PostUpdateManyDataInput { + title: String + content: String + published: Boolean +} + +input PostUpdateManyMutationInput { + title: String + content: String + published: Boolean +} + +input PostUpdateManyWithoutAuthorInput { + create: [PostCreateWithoutAuthorInput!] + delete: [PostWhereUniqueInput!] + connect: [PostWhereUniqueInput!] + disconnect: [PostWhereUniqueInput!] + update: [PostUpdateWithWhereUniqueWithoutAuthorInput!] + upsert: [PostUpsertWithWhereUniqueWithoutAuthorInput!] + deleteMany: [PostScalarWhereInput!] + updateMany: [PostUpdateManyWithWhereNestedInput!] +} + +input PostUpdateManyWithWhereNestedInput { + where: PostScalarWhereInput! + data: PostUpdateManyDataInput! +} + +input PostUpdateWithoutAuthorDataInput { + title: String + content: String + published: Boolean + comments: CommentUpdateManyInput +} + +input PostUpdateWithWhereUniqueWithoutAuthorInput { + where: PostWhereUniqueInput! + data: PostUpdateWithoutAuthorDataInput! +} + +input PostUpsertWithWhereUniqueWithoutAuthorInput { + where: PostWhereUniqueInput! + update: PostUpdateWithoutAuthorDataInput! + create: PostCreateWithoutAuthorInput! +} + +input PostWhereInput { + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + createdAt: DateTime + createdAt_not: DateTime + createdAt_in: [DateTime!] + createdAt_not_in: [DateTime!] + createdAt_lt: DateTime + createdAt_lte: DateTime + createdAt_gt: DateTime + createdAt_gte: DateTime + updatedAt: DateTime + updatedAt_not: DateTime + updatedAt_in: [DateTime!] + updatedAt_not_in: [DateTime!] + updatedAt_lt: DateTime + updatedAt_lte: DateTime + updatedAt_gt: DateTime + updatedAt_gte: DateTime + title: String + title_not: String + title_in: [String!] + title_not_in: [String!] + title_lt: String + title_lte: String + title_gt: String + title_gte: String + title_contains: String + title_not_contains: String + title_starts_with: String + title_not_starts_with: String + title_ends_with: String + title_not_ends_with: String + content: String + content_not: String + content_in: [String!] + content_not_in: [String!] + content_lt: String + content_lte: String + content_gt: String + content_gte: String + content_contains: String + content_not_contains: String + content_starts_with: String + content_not_starts_with: String + content_ends_with: String + content_not_ends_with: String + published: Boolean + published_not: Boolean + author: UserWhereInput + comments_every: CommentWhereInput + comments_some: CommentWhereInput + comments_none: CommentWhereInput + AND: [PostWhereInput!] + OR: [PostWhereInput!] + NOT: [PostWhereInput!] +} + +input PostWhereUniqueInput { + id: ID +} + +type Query { + comment(where: CommentWhereUniqueInput!): Comment + comments(where: CommentWhereInput, orderBy: CommentOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Comment]! + commentsConnection(where: CommentWhereInput, orderBy: CommentOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): CommentConnection! + post(where: PostWhereUniqueInput!): Post + posts(where: PostWhereInput, orderBy: PostOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Post]! + postsConnection(where: PostWhereInput, orderBy: PostOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): PostConnection! + user(where: UserWhereUniqueInput!): User + users(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [User]! + usersConnection(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): UserConnection! + node(id: ID!): Node +} + +type Subscription { + comment(where: CommentSubscriptionWhereInput): CommentSubscriptionPayload + post(where: PostSubscriptionWhereInput): PostSubscriptionPayload + user(where: UserSubscriptionWhereInput): UserSubscriptionPayload +} + +type User { + id: ID! + email: String! + name: String + posts(where: PostWhereInput, orderBy: PostOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Post!] + comments(where: CommentWhereInput, orderBy: CommentOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Comment!] +} + +type UserConnection { + pageInfo: PageInfo! + edges: [UserEdge]! + aggregate: AggregateUser! +} + +input UserCreateInput { + email: String! + name: String + posts: PostCreateManyWithoutAuthorInput + comments: CommentCreateManyWithoutWrittenByInput +} + +input UserCreateOneWithoutCommentsInput { + create: UserCreateWithoutCommentsInput + connect: UserWhereUniqueInput +} + +input UserCreateOneWithoutPostsInput { + create: UserCreateWithoutPostsInput + connect: UserWhereUniqueInput +} + +input UserCreateWithoutCommentsInput { + email: String! + name: String + posts: PostCreateManyWithoutAuthorInput +} + +input UserCreateWithoutPostsInput { + email: String! + name: String + comments: CommentCreateManyWithoutWrittenByInput +} + +type UserEdge { + node: User! + cursor: String! +} + +enum UserOrderByInput { + id_ASC + id_DESC + email_ASC + email_DESC + name_ASC + name_DESC + createdAt_ASC + createdAt_DESC + updatedAt_ASC + updatedAt_DESC +} + +type UserPreviousValues { + id: ID! + email: String! + name: String +} + +type UserSubscriptionPayload { + mutation: MutationType! + node: User + updatedFields: [String!] + previousValues: UserPreviousValues +} + +input UserSubscriptionWhereInput { + mutation_in: [MutationType!] + updatedFields_contains: String + updatedFields_contains_every: [String!] + updatedFields_contains_some: [String!] + node: UserWhereInput + AND: [UserSubscriptionWhereInput!] + OR: [UserSubscriptionWhereInput!] + NOT: [UserSubscriptionWhereInput!] +} + +input UserUpdateInput { + email: String + name: String + posts: PostUpdateManyWithoutAuthorInput + comments: CommentUpdateManyWithoutWrittenByInput +} + +input UserUpdateManyMutationInput { + email: String + name: String +} + +input UserUpdateOneRequiredWithoutCommentsInput { + create: UserCreateWithoutCommentsInput + update: UserUpdateWithoutCommentsDataInput + upsert: UserUpsertWithoutCommentsInput + connect: UserWhereUniqueInput +} + +input UserUpdateOneRequiredWithoutPostsInput { + create: UserCreateWithoutPostsInput + update: UserUpdateWithoutPostsDataInput + upsert: UserUpsertWithoutPostsInput + connect: UserWhereUniqueInput +} + +input UserUpdateWithoutCommentsDataInput { + email: String + name: String + posts: PostUpdateManyWithoutAuthorInput +} + +input UserUpdateWithoutPostsDataInput { + email: String + name: String + comments: CommentUpdateManyWithoutWrittenByInput +} + +input UserUpsertWithoutCommentsInput { + update: UserUpdateWithoutCommentsDataInput! + create: UserCreateWithoutCommentsInput! +} + +input UserUpsertWithoutPostsInput { + update: UserUpdateWithoutPostsDataInput! + create: UserCreateWithoutPostsInput! +} + +input UserWhereInput { + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + email: String + email_not: String + email_in: [String!] + email_not_in: [String!] + email_lt: String + email_lte: String + email_gt: String + email_gte: String + email_contains: String + email_not_contains: String + email_starts_with: String + email_not_starts_with: String + email_ends_with: String + email_not_ends_with: String + name: String + name_not: String + name_in: [String!] + name_not_in: [String!] + name_lt: String + name_lte: String + name_gt: String + name_gte: String + name_contains: String + name_not_contains: String + name_starts_with: String + name_not_starts_with: String + name_ends_with: String + name_not_ends_with: String + posts_every: PostWhereInput + posts_some: PostWhereInput + posts_none: PostWhereInput + comments_every: CommentWhereInput + comments_some: CommentWhereInput + comments_none: CommentWhereInput + AND: [UserWhereInput!] + OR: [UserWhereInput!] + NOT: [UserWhereInput!] +} + +input UserWhereUniqueInput { + id: ID + email: String +} +` \ No newline at end of file diff --git a/typescript/docker-mysql/src/script.ts b/typescript/docker-mysql/src/script.ts new file mode 100644 index 000000000000..83d0b1f63571 --- /dev/null +++ b/typescript/docker-mysql/src/script.ts @@ -0,0 +1,67 @@ +import { prisma } from './generated/prisma-client' + +// A `main` function so that we can use async/await +async function main() { + // Retrieve all published posts + const allPosts = await prisma.posts({ + where: { published: true }, + }) + console.log(`Retrieved all published posts: `, allPosts) + + // Create a new post (written by an already existing user with email alice@prisma.io) + const newPost = await prisma.createPost({ + title: 'Join the Prisma Slack community', + content: 'http://slack.prisma.io', + author: { + connect: { + email: 'alice@prisma.io', // Should have been created during initial seeding + }, + }, + }) + console.log(`Created a new post: `, newPost) + + // Publish the new post + const updatedPost = await prisma.updatePost({ + where: { + id: newPost.id, + }, + data: { + published: true, + }, + }) + console.log(`Published the newly created post: `, updatedPost) + + // Write a comment + const postWithComment = await prisma.updatePost({ + where: { + id: newPost.id, + }, + data: { + comments: { + create: { + text: 'Wow, there are so many active members on the Prisma Slack!', + writtenBy: { + connect: { + email: 'bob@prisma.io', + }, + }, + }, + }, + }, + }) + console.log(`Wrote a comment for the new post: `, postWithComment) + + // Retrieve all posts by user with email alice@prisma.io + const postsByUser = await prisma + .user({ + email: 'alice@prisma.io', + }) + .posts() + console.log(`Retrieved all posts from a specific user: `, postsByUser) +} + +main() + .then(() => { + process.exit(0) + }) + .catch(e => console.error(e)) diff --git a/typescript/docker-mysql/tsconfig.json b/typescript/docker-mysql/tsconfig.json new file mode 100644 index 000000000000..669f46efc390 --- /dev/null +++ b/typescript/docker-mysql/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "sourceMap": true, + "outDir": "dist", + "strict": true, + "lib": ["esnext", "dom"] + } +} \ No newline at end of file diff --git a/typescript/docker-postgres/README.md b/typescript/docker-postgres/README.md new file mode 100644 index 000000000000..13fa5a1cd9d0 --- /dev/null +++ b/typescript/docker-postgres/README.md @@ -0,0 +1,60 @@ +# PostgreSQL with Docker Example + +This example shows how to **set up Prisma using Docker and PostgreSQL** locally on your machine. It then uses the Prisma client in a simple TypeScript script to read and write data in the database. + +> This example uses a new and empty database. **Learn how to connect Prisma to your existing database [here](https://www.prisma.io/docs/-a003/)**. + +## How to use + +### 1. Download example & install dependencies + +Clone the repository: + +``` +git clone git@github.com:prisma/prisma-examples.git +``` + +Install Node dependencies: + +``` +cd prisma-examples/typescript/docker-postgres +npm install +``` + +### 2. Launch Prisma with Docker + +This example is based on Docker. If you don't have Docker installed, you can get it from [here](https://store.docker.com/search?type=edition&offering=community). Use the Docker Compose CLI to launch the Docker containers specified in [docker-compose.yml](./docker-compose.yml): + +``` +docker-compose up -d +``` + +### 3. Install the Prisma CLI + +To run the example, you need the Prisma CLI. Please install it via NPM or [using another method](https://www.prisma.io/docs/prisma-cli-and-configuration/using-the-prisma-cli-alx4/#installation): + +``` +npm install -g prisma +``` + +### 4. Set up database & deploy Prisma datamodel + +To deploy the datamodel for this example, run the following command: + +``` +prisma deploy +``` + +### 5. Run the script + +Execute the script with this command: + +``` +npm run start +``` + +## Next steps + +- [Use Prisma with an existing database](https://www.prisma.io/docs/-t003/) +- [Explore the Prisma client API](https://www.prisma.io/client/client-typescript) +- [Learn more about the GraphQL schema](https://www.prisma.io/blog/graphql-server-basics-the-schema-ac5e2950214e/) \ No newline at end of file diff --git a/typescript/docker-postgres/docker-compose.yml b/typescript/docker-postgres/docker-compose.yml new file mode 100644 index 000000000000..7730ea1d3877 --- /dev/null +++ b/typescript/docker-postgres/docker-compose.yml @@ -0,0 +1,31 @@ +version: '3' +services: + prisma: + image: prismagraphql/prisma:1.24 + restart: always + ports: + - "4466:4466" + environment: + PRISMA_CONFIG: | + port: 4466 + # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security + # managementApiSecret: my-secret + databases: + default: + connector: postgres + host: postgres + user: prisma + password: prisma + rawAccess: true + port: 5432 + migrations: true + postgres: + image: postgres + restart: always + environment: + POSTGRES_USER: prisma + POSTGRES_PASSWORD: prisma + volumes: + - postgres:/var/lib/postgresql/data +volumes: + postgres: \ No newline at end of file diff --git a/typescript/docker-postgres/package.json b/typescript/docker-postgres/package.json new file mode 100644 index 000000000000..dcb78aafe19a --- /dev/null +++ b/typescript/docker-postgres/package.json @@ -0,0 +1,15 @@ +{ + "name": "docker-postgres", + "license": "MIT", + "dependencies": { + "prisma-client-lib": "1.24.0" + }, + "scripts": { + "start": "ts-node src/script.ts" + }, + "devDependencies": { + "@types/graphql": "^14.0.5", + "ts-node": "^7.0.1", + "typescript": "^3.2.2" + } +} diff --git a/typescript/docker-postgres/prisma/datamodel.prisma b/typescript/docker-postgres/prisma/datamodel.prisma new file mode 100644 index 000000000000..6955534d1911 --- /dev/null +++ b/typescript/docker-postgres/prisma/datamodel.prisma @@ -0,0 +1,24 @@ +type User { + id: ID! @unique + email: String! @unique + name: String + posts: [Post!]! + comments: [Comment!]! +} + +type Post { + id: ID! @unique + createdAt: DateTime! + updatedAt: DateTime! + title: String! + content: String + published: Boolean! @default(value: "false") + author: User! + comments: [Comment!]! +} + +type Comment { + id: ID! @unique + text: String! + writtenBy: User! +} \ No newline at end of file diff --git a/typescript/docker-postgres/prisma/prisma.yml b/typescript/docker-postgres/prisma/prisma.yml new file mode 100644 index 000000000000..681e3dd881d1 --- /dev/null +++ b/typescript/docker-postgres/prisma/prisma.yml @@ -0,0 +1,19 @@ +# Specifies the HTTP endpoint of your Prisma API. +endpoint: http://localhost:4466 + +# Defines your models, each model is mapped to the database as a collection. +datamodel: datamodel.prisma + +# Specifies the language and directory for the generated Prisma client. +generate: + - generator: typescript-client + output: ../src/generated/prisma-client/ + +# Ensures Prisma client is re-generated after a datamodel change. +hooks: + post-deploy: + - prisma generate + +# Seeds initial data into the database by running a script. +seed: + import: seed.graphql \ No newline at end of file diff --git a/typescript/docker-postgres/prisma/seed.graphql b/typescript/docker-postgres/prisma/seed.graphql new file mode 100644 index 000000000000..d74316b769fe --- /dev/null +++ b/typescript/docker-postgres/prisma/seed.graphql @@ -0,0 +1,42 @@ +mutation { + user1: createUser(data: { + email: "alice@prisma.io" + name: "Alice" + posts: { + create: { + title: "Join us for GraphQL Conf 2019 in Berlin" + content: "https://www.graphqlconf.org/" + published: true + } + } + }) { + id + } + + user2: createUser(data: { + email: "bob@prisma.io" + name: "Bob" + posts: { + create: [{ + title: "Subscribe to GraphQL Weekly for community news" + content: "https://graphqlweekly.com/" + published: true + comments: { + create: [{ + text: "Can recommend 💯", + writtenBy: { + connect: { + email: "alice@prisma.io" + } + } + }] + } + } { + title: "Follow Prisma on Twitter" + content: "https://twitter.com/prisma" + }] + } + }) { + id + } +} \ No newline at end of file diff --git a/typescript/docker-postgres/src/generated/prisma-client/index.ts b/typescript/docker-postgres/src/generated/prisma-client/index.ts new file mode 100644 index 000000000000..9d3e850da268 --- /dev/null +++ b/typescript/docker-postgres/src/generated/prisma-client/index.ts @@ -0,0 +1,1347 @@ +// Code generated by Prisma (prisma@1.24.0). DO NOT EDIT. +// Please don't change this file manually but run `prisma generate` to update it. +// For more information, please read the docs: https://www.prisma.io/docs/prisma-client/ + +import { DocumentNode } from "graphql"; +import { + makePrismaClientClass, + BaseClientOptions, + Model +} from "prisma-client-lib"; +import { typeDefs } from "./prisma-schema"; + +export type AtLeastOne }> = Partial & + U[keyof U]; + +export interface Exists { + comment: (where?: CommentWhereInput) => Promise; + post: (where?: PostWhereInput) => Promise; + user: (where?: UserWhereInput) => Promise; +} + +export interface Node {} + +export type FragmentableArray = Promise> & Fragmentable; + +export interface Fragmentable { + $fragment(fragment: string | DocumentNode): Promise; +} + +export interface Prisma { + $exists: Exists; + $graphql: ( + query: string, + variables?: { [key: string]: any } + ) => Promise; + + /** + * Queries + */ + + comment: (where: CommentWhereUniqueInput) => CommentPromise; + comments: ( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => FragmentableArray; + commentsConnection: ( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => CommentConnectionPromise; + post: (where: PostWhereUniqueInput) => PostPromise; + posts: ( + args?: { + where?: PostWhereInput; + orderBy?: PostOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => FragmentableArray; + postsConnection: ( + args?: { + where?: PostWhereInput; + orderBy?: PostOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => PostConnectionPromise; + user: (where: UserWhereUniqueInput) => UserPromise; + users: ( + args?: { + where?: UserWhereInput; + orderBy?: UserOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => FragmentableArray; + usersConnection: ( + args?: { + where?: UserWhereInput; + orderBy?: UserOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => UserConnectionPromise; + node: (args: { id: ID_Output }) => Node; + + /** + * Mutations + */ + + createComment: (data: CommentCreateInput) => CommentPromise; + updateComment: ( + args: { data: CommentUpdateInput; where: CommentWhereUniqueInput } + ) => CommentPromise; + updateManyComments: ( + args: { data: CommentUpdateManyMutationInput; where?: CommentWhereInput } + ) => BatchPayloadPromise; + upsertComment: ( + args: { + where: CommentWhereUniqueInput; + create: CommentCreateInput; + update: CommentUpdateInput; + } + ) => CommentPromise; + deleteComment: (where: CommentWhereUniqueInput) => CommentPromise; + deleteManyComments: (where?: CommentWhereInput) => BatchPayloadPromise; + createPost: (data: PostCreateInput) => PostPromise; + updatePost: ( + args: { data: PostUpdateInput; where: PostWhereUniqueInput } + ) => PostPromise; + updateManyPosts: ( + args: { data: PostUpdateManyMutationInput; where?: PostWhereInput } + ) => BatchPayloadPromise; + upsertPost: ( + args: { + where: PostWhereUniqueInput; + create: PostCreateInput; + update: PostUpdateInput; + } + ) => PostPromise; + deletePost: (where: PostWhereUniqueInput) => PostPromise; + deleteManyPosts: (where?: PostWhereInput) => BatchPayloadPromise; + createUser: (data: UserCreateInput) => UserPromise; + updateUser: ( + args: { data: UserUpdateInput; where: UserWhereUniqueInput } + ) => UserPromise; + updateManyUsers: ( + args: { data: UserUpdateManyMutationInput; where?: UserWhereInput } + ) => BatchPayloadPromise; + upsertUser: ( + args: { + where: UserWhereUniqueInput; + create: UserCreateInput; + update: UserUpdateInput; + } + ) => UserPromise; + deleteUser: (where: UserWhereUniqueInput) => UserPromise; + deleteManyUsers: (where?: UserWhereInput) => BatchPayloadPromise; + + /** + * Subscriptions + */ + + $subscribe: Subscription; +} + +export interface Subscription { + comment: ( + where?: CommentSubscriptionWhereInput + ) => CommentSubscriptionPayloadSubscription; + post: ( + where?: PostSubscriptionWhereInput + ) => PostSubscriptionPayloadSubscription; + user: ( + where?: UserSubscriptionWhereInput + ) => UserSubscriptionPayloadSubscription; +} + +export interface ClientConstructor { + new (options?: BaseClientOptions): T; +} + +/** + * Types + */ + +export type PostOrderByInput = + | "id_ASC" + | "id_DESC" + | "createdAt_ASC" + | "createdAt_DESC" + | "updatedAt_ASC" + | "updatedAt_DESC" + | "title_ASC" + | "title_DESC" + | "content_ASC" + | "content_DESC" + | "published_ASC" + | "published_DESC"; + +export type CommentOrderByInput = + | "id_ASC" + | "id_DESC" + | "text_ASC" + | "text_DESC" + | "createdAt_ASC" + | "createdAt_DESC" + | "updatedAt_ASC" + | "updatedAt_DESC"; + +export type UserOrderByInput = + | "id_ASC" + | "id_DESC" + | "email_ASC" + | "email_DESC" + | "name_ASC" + | "name_DESC" + | "createdAt_ASC" + | "createdAt_DESC" + | "updatedAt_ASC" + | "updatedAt_DESC"; + +export type MutationType = "CREATED" | "UPDATED" | "DELETED"; + +export interface CommentUpdateWithWhereUniqueNestedInput { + where: CommentWhereUniqueInput; + data: CommentUpdateDataInput; +} + +export type CommentWhereUniqueInput = AtLeastOne<{ + id: ID_Input; +}>; + +export interface PostCreateWithoutAuthorInput { + title: String; + content?: String; + published?: Boolean; + comments?: CommentCreateManyInput; +} + +export interface UserCreateOneWithoutPostsInput { + create?: UserCreateWithoutPostsInput; + connect?: UserWhereUniqueInput; +} + +export interface CommentCreateManyInput { + create?: CommentCreateInput[] | CommentCreateInput; + connect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; +} + +export interface CommentScalarWhereInput { + id?: ID_Input; + id_not?: ID_Input; + id_in?: ID_Input[] | ID_Input; + id_not_in?: ID_Input[] | ID_Input; + id_lt?: ID_Input; + id_lte?: ID_Input; + id_gt?: ID_Input; + id_gte?: ID_Input; + id_contains?: ID_Input; + id_not_contains?: ID_Input; + id_starts_with?: ID_Input; + id_not_starts_with?: ID_Input; + id_ends_with?: ID_Input; + id_not_ends_with?: ID_Input; + text?: String; + text_not?: String; + text_in?: String[] | String; + text_not_in?: String[] | String; + text_lt?: String; + text_lte?: String; + text_gt?: String; + text_gte?: String; + text_contains?: String; + text_not_contains?: String; + text_starts_with?: String; + text_not_starts_with?: String; + text_ends_with?: String; + text_not_ends_with?: String; + AND?: CommentScalarWhereInput[] | CommentScalarWhereInput; + OR?: CommentScalarWhereInput[] | CommentScalarWhereInput; + NOT?: CommentScalarWhereInput[] | CommentScalarWhereInput; +} + +export interface CommentUpdateInput { + text?: String; + writtenBy?: UserUpdateOneRequiredWithoutCommentsInput; +} + +export interface CommentWhereInput { + id?: ID_Input; + id_not?: ID_Input; + id_in?: ID_Input[] | ID_Input; + id_not_in?: ID_Input[] | ID_Input; + id_lt?: ID_Input; + id_lte?: ID_Input; + id_gt?: ID_Input; + id_gte?: ID_Input; + id_contains?: ID_Input; + id_not_contains?: ID_Input; + id_starts_with?: ID_Input; + id_not_starts_with?: ID_Input; + id_ends_with?: ID_Input; + id_not_ends_with?: ID_Input; + text?: String; + text_not?: String; + text_in?: String[] | String; + text_not_in?: String[] | String; + text_lt?: String; + text_lte?: String; + text_gt?: String; + text_gte?: String; + text_contains?: String; + text_not_contains?: String; + text_starts_with?: String; + text_not_starts_with?: String; + text_ends_with?: String; + text_not_ends_with?: String; + writtenBy?: UserWhereInput; + AND?: CommentWhereInput[] | CommentWhereInput; + OR?: CommentWhereInput[] | CommentWhereInput; + NOT?: CommentWhereInput[] | CommentWhereInput; +} + +export interface UserUpdateOneRequiredWithoutCommentsInput { + create?: UserCreateWithoutCommentsInput; + update?: UserUpdateWithoutCommentsDataInput; + upsert?: UserUpsertWithoutCommentsInput; + connect?: UserWhereUniqueInput; +} + +export interface UserSubscriptionWhereInput { + mutation_in?: MutationType[] | MutationType; + updatedFields_contains?: String; + updatedFields_contains_every?: String[] | String; + updatedFields_contains_some?: String[] | String; + node?: UserWhereInput; + AND?: UserSubscriptionWhereInput[] | UserSubscriptionWhereInput; + OR?: UserSubscriptionWhereInput[] | UserSubscriptionWhereInput; + NOT?: UserSubscriptionWhereInput[] | UserSubscriptionWhereInput; +} + +export interface UserUpdateWithoutCommentsDataInput { + email?: String; + name?: String; + posts?: PostUpdateManyWithoutAuthorInput; +} + +export interface CommentSubscriptionWhereInput { + mutation_in?: MutationType[] | MutationType; + updatedFields_contains?: String; + updatedFields_contains_every?: String[] | String; + updatedFields_contains_some?: String[] | String; + node?: CommentWhereInput; + AND?: CommentSubscriptionWhereInput[] | CommentSubscriptionWhereInput; + OR?: CommentSubscriptionWhereInput[] | CommentSubscriptionWhereInput; + NOT?: CommentSubscriptionWhereInput[] | CommentSubscriptionWhereInput; +} + +export interface PostUpdateManyWithoutAuthorInput { + create?: PostCreateWithoutAuthorInput[] | PostCreateWithoutAuthorInput; + delete?: PostWhereUniqueInput[] | PostWhereUniqueInput; + connect?: PostWhereUniqueInput[] | PostWhereUniqueInput; + disconnect?: PostWhereUniqueInput[] | PostWhereUniqueInput; + update?: + | PostUpdateWithWhereUniqueWithoutAuthorInput[] + | PostUpdateWithWhereUniqueWithoutAuthorInput; + upsert?: + | PostUpsertWithWhereUniqueWithoutAuthorInput[] + | PostUpsertWithWhereUniqueWithoutAuthorInput; + deleteMany?: PostScalarWhereInput[] | PostScalarWhereInput; + updateMany?: + | PostUpdateManyWithWhereNestedInput[] + | PostUpdateManyWithWhereNestedInput; +} + +export interface UserUpdateInput { + email?: String; + name?: String; + posts?: PostUpdateManyWithoutAuthorInput; + comments?: CommentUpdateManyWithoutWrittenByInput; +} + +export interface PostUpdateWithWhereUniqueWithoutAuthorInput { + where: PostWhereUniqueInput; + data: PostUpdateWithoutAuthorDataInput; +} + +export interface PostUpdateManyMutationInput { + title?: String; + content?: String; + published?: Boolean; +} + +export interface PostUpdateWithoutAuthorDataInput { + title?: String; + content?: String; + published?: Boolean; + comments?: CommentUpdateManyInput; +} + +export interface UserUpsertWithoutPostsInput { + update: UserUpdateWithoutPostsDataInput; + create: UserCreateWithoutPostsInput; +} + +export interface CommentUpdateManyInput { + create?: CommentCreateInput[] | CommentCreateInput; + update?: + | CommentUpdateWithWhereUniqueNestedInput[] + | CommentUpdateWithWhereUniqueNestedInput; + upsert?: + | CommentUpsertWithWhereUniqueNestedInput[] + | CommentUpsertWithWhereUniqueNestedInput; + delete?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + connect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + disconnect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + deleteMany?: CommentScalarWhereInput[] | CommentScalarWhereInput; + updateMany?: + | CommentUpdateManyWithWhereNestedInput[] + | CommentUpdateManyWithWhereNestedInput; +} + +export interface CommentUpdateWithoutWrittenByDataInput { + text?: String; +} + +export interface PostUpdateInput { + title?: String; + content?: String; + published?: Boolean; + author?: UserUpdateOneRequiredWithoutPostsInput; + comments?: CommentUpdateManyInput; +} + +export interface CommentUpdateWithWhereUniqueWithoutWrittenByInput { + where: CommentWhereUniqueInput; + data: CommentUpdateWithoutWrittenByDataInput; +} + +export interface CommentUpdateDataInput { + text?: String; + writtenBy?: UserUpdateOneRequiredWithoutCommentsInput; +} + +export interface UserUpdateWithoutPostsDataInput { + email?: String; + name?: String; + comments?: CommentUpdateManyWithoutWrittenByInput; +} + +export interface CommentUpsertWithWhereUniqueNestedInput { + where: CommentWhereUniqueInput; + update: CommentUpdateDataInput; + create: CommentCreateInput; +} + +export interface UserCreateOneWithoutCommentsInput { + create?: UserCreateWithoutCommentsInput; + connect?: UserWhereUniqueInput; +} + +export interface CommentCreateWithoutWrittenByInput { + text: String; +} + +export interface PostCreateManyWithoutAuthorInput { + create?: PostCreateWithoutAuthorInput[] | PostCreateWithoutAuthorInput; + connect?: PostWhereUniqueInput[] | PostWhereUniqueInput; +} + +export interface CommentUpdateManyWithWhereNestedInput { + where: CommentScalarWhereInput; + data: CommentUpdateManyDataInput; +} + +export interface PostWhereInput { + id?: ID_Input; + id_not?: ID_Input; + id_in?: ID_Input[] | ID_Input; + id_not_in?: ID_Input[] | ID_Input; + id_lt?: ID_Input; + id_lte?: ID_Input; + id_gt?: ID_Input; + id_gte?: ID_Input; + id_contains?: ID_Input; + id_not_contains?: ID_Input; + id_starts_with?: ID_Input; + id_not_starts_with?: ID_Input; + id_ends_with?: ID_Input; + id_not_ends_with?: ID_Input; + createdAt?: DateTimeInput; + createdAt_not?: DateTimeInput; + createdAt_in?: DateTimeInput[] | DateTimeInput; + createdAt_not_in?: DateTimeInput[] | DateTimeInput; + createdAt_lt?: DateTimeInput; + createdAt_lte?: DateTimeInput; + createdAt_gt?: DateTimeInput; + createdAt_gte?: DateTimeInput; + updatedAt?: DateTimeInput; + updatedAt_not?: DateTimeInput; + updatedAt_in?: DateTimeInput[] | DateTimeInput; + updatedAt_not_in?: DateTimeInput[] | DateTimeInput; + updatedAt_lt?: DateTimeInput; + updatedAt_lte?: DateTimeInput; + updatedAt_gt?: DateTimeInput; + updatedAt_gte?: DateTimeInput; + title?: String; + title_not?: String; + title_in?: String[] | String; + title_not_in?: String[] | String; + title_lt?: String; + title_lte?: String; + title_gt?: String; + title_gte?: String; + title_contains?: String; + title_not_contains?: String; + title_starts_with?: String; + title_not_starts_with?: String; + title_ends_with?: String; + title_not_ends_with?: String; + content?: String; + content_not?: String; + content_in?: String[] | String; + content_not_in?: String[] | String; + content_lt?: String; + content_lte?: String; + content_gt?: String; + content_gte?: String; + content_contains?: String; + content_not_contains?: String; + content_starts_with?: String; + content_not_starts_with?: String; + content_ends_with?: String; + content_not_ends_with?: String; + published?: Boolean; + published_not?: Boolean; + author?: UserWhereInput; + comments_every?: CommentWhereInput; + comments_some?: CommentWhereInput; + comments_none?: CommentWhereInput; + AND?: PostWhereInput[] | PostWhereInput; + OR?: PostWhereInput[] | PostWhereInput; + NOT?: PostWhereInput[] | PostWhereInput; +} + +export interface CommentUpdateManyDataInput { + text?: String; +} + +export interface UserUpdateManyMutationInput { + email?: String; + name?: String; +} + +export interface PostUpsertWithWhereUniqueWithoutAuthorInput { + where: PostWhereUniqueInput; + update: PostUpdateWithoutAuthorDataInput; + create: PostCreateWithoutAuthorInput; +} + +export type PostWhereUniqueInput = AtLeastOne<{ + id: ID_Input; +}>; + +export interface PostScalarWhereInput { + id?: ID_Input; + id_not?: ID_Input; + id_in?: ID_Input[] | ID_Input; + id_not_in?: ID_Input[] | ID_Input; + id_lt?: ID_Input; + id_lte?: ID_Input; + id_gt?: ID_Input; + id_gte?: ID_Input; + id_contains?: ID_Input; + id_not_contains?: ID_Input; + id_starts_with?: ID_Input; + id_not_starts_with?: ID_Input; + id_ends_with?: ID_Input; + id_not_ends_with?: ID_Input; + createdAt?: DateTimeInput; + createdAt_not?: DateTimeInput; + createdAt_in?: DateTimeInput[] | DateTimeInput; + createdAt_not_in?: DateTimeInput[] | DateTimeInput; + createdAt_lt?: DateTimeInput; + createdAt_lte?: DateTimeInput; + createdAt_gt?: DateTimeInput; + createdAt_gte?: DateTimeInput; + updatedAt?: DateTimeInput; + updatedAt_not?: DateTimeInput; + updatedAt_in?: DateTimeInput[] | DateTimeInput; + updatedAt_not_in?: DateTimeInput[] | DateTimeInput; + updatedAt_lt?: DateTimeInput; + updatedAt_lte?: DateTimeInput; + updatedAt_gt?: DateTimeInput; + updatedAt_gte?: DateTimeInput; + title?: String; + title_not?: String; + title_in?: String[] | String; + title_not_in?: String[] | String; + title_lt?: String; + title_lte?: String; + title_gt?: String; + title_gte?: String; + title_contains?: String; + title_not_contains?: String; + title_starts_with?: String; + title_not_starts_with?: String; + title_ends_with?: String; + title_not_ends_with?: String; + content?: String; + content_not?: String; + content_in?: String[] | String; + content_not_in?: String[] | String; + content_lt?: String; + content_lte?: String; + content_gt?: String; + content_gte?: String; + content_contains?: String; + content_not_contains?: String; + content_starts_with?: String; + content_not_starts_with?: String; + content_ends_with?: String; + content_not_ends_with?: String; + published?: Boolean; + published_not?: Boolean; + AND?: PostScalarWhereInput[] | PostScalarWhereInput; + OR?: PostScalarWhereInput[] | PostScalarWhereInput; + NOT?: PostScalarWhereInput[] | PostScalarWhereInput; +} + +export type UserWhereUniqueInput = AtLeastOne<{ + id: ID_Input; + email?: String; +}>; + +export interface PostUpdateManyWithWhereNestedInput { + where: PostScalarWhereInput; + data: PostUpdateManyDataInput; +} + +export interface UserUpdateOneRequiredWithoutPostsInput { + create?: UserCreateWithoutPostsInput; + update?: UserUpdateWithoutPostsDataInput; + upsert?: UserUpsertWithoutPostsInput; + connect?: UserWhereUniqueInput; +} + +export interface PostUpdateManyDataInput { + title?: String; + content?: String; + published?: Boolean; +} + +export interface UserCreateWithoutCommentsInput { + email: String; + name?: String; + posts?: PostCreateManyWithoutAuthorInput; +} + +export interface UserUpsertWithoutCommentsInput { + update: UserUpdateWithoutCommentsDataInput; + create: UserCreateWithoutCommentsInput; +} + +export interface PostSubscriptionWhereInput { + mutation_in?: MutationType[] | MutationType; + updatedFields_contains?: String; + updatedFields_contains_every?: String[] | String; + updatedFields_contains_some?: String[] | String; + node?: PostWhereInput; + AND?: PostSubscriptionWhereInput[] | PostSubscriptionWhereInput; + OR?: PostSubscriptionWhereInput[] | PostSubscriptionWhereInput; + NOT?: PostSubscriptionWhereInput[] | PostSubscriptionWhereInput; +} + +export interface PostCreateInput { + title: String; + content?: String; + published?: Boolean; + author: UserCreateOneWithoutPostsInput; + comments?: CommentCreateManyInput; +} + +export interface UserCreateWithoutPostsInput { + email: String; + name?: String; + comments?: CommentCreateManyWithoutWrittenByInput; +} + +export interface CommentCreateManyWithoutWrittenByInput { + create?: + | CommentCreateWithoutWrittenByInput[] + | CommentCreateWithoutWrittenByInput; + connect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; +} + +export interface CommentUpdateManyMutationInput { + text?: String; +} + +export interface UserCreateInput { + email: String; + name?: String; + posts?: PostCreateManyWithoutAuthorInput; + comments?: CommentCreateManyWithoutWrittenByInput; +} + +export interface UserWhereInput { + id?: ID_Input; + id_not?: ID_Input; + id_in?: ID_Input[] | ID_Input; + id_not_in?: ID_Input[] | ID_Input; + id_lt?: ID_Input; + id_lte?: ID_Input; + id_gt?: ID_Input; + id_gte?: ID_Input; + id_contains?: ID_Input; + id_not_contains?: ID_Input; + id_starts_with?: ID_Input; + id_not_starts_with?: ID_Input; + id_ends_with?: ID_Input; + id_not_ends_with?: ID_Input; + email?: String; + email_not?: String; + email_in?: String[] | String; + email_not_in?: String[] | String; + email_lt?: String; + email_lte?: String; + email_gt?: String; + email_gte?: String; + email_contains?: String; + email_not_contains?: String; + email_starts_with?: String; + email_not_starts_with?: String; + email_ends_with?: String; + email_not_ends_with?: String; + name?: String; + name_not?: String; + name_in?: String[] | String; + name_not_in?: String[] | String; + name_lt?: String; + name_lte?: String; + name_gt?: String; + name_gte?: String; + name_contains?: String; + name_not_contains?: String; + name_starts_with?: String; + name_not_starts_with?: String; + name_ends_with?: String; + name_not_ends_with?: String; + posts_every?: PostWhereInput; + posts_some?: PostWhereInput; + posts_none?: PostWhereInput; + comments_every?: CommentWhereInput; + comments_some?: CommentWhereInput; + comments_none?: CommentWhereInput; + AND?: UserWhereInput[] | UserWhereInput; + OR?: UserWhereInput[] | UserWhereInput; + NOT?: UserWhereInput[] | UserWhereInput; +} + +export interface CommentCreateInput { + text: String; + writtenBy: UserCreateOneWithoutCommentsInput; +} + +export interface CommentUpdateManyWithoutWrittenByInput { + create?: + | CommentCreateWithoutWrittenByInput[] + | CommentCreateWithoutWrittenByInput; + delete?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + connect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + disconnect?: CommentWhereUniqueInput[] | CommentWhereUniqueInput; + update?: + | CommentUpdateWithWhereUniqueWithoutWrittenByInput[] + | CommentUpdateWithWhereUniqueWithoutWrittenByInput; + upsert?: + | CommentUpsertWithWhereUniqueWithoutWrittenByInput[] + | CommentUpsertWithWhereUniqueWithoutWrittenByInput; + deleteMany?: CommentScalarWhereInput[] | CommentScalarWhereInput; + updateMany?: + | CommentUpdateManyWithWhereNestedInput[] + | CommentUpdateManyWithWhereNestedInput; +} + +export interface CommentUpsertWithWhereUniqueWithoutWrittenByInput { + where: CommentWhereUniqueInput; + update: CommentUpdateWithoutWrittenByDataInput; + create: CommentCreateWithoutWrittenByInput; +} + +export interface NodeNode { + id: ID_Output; +} + +export interface UserPreviousValues { + id: ID_Output; + email: String; + name?: String; +} + +export interface UserPreviousValuesPromise + extends Promise, + Fragmentable { + id: () => Promise; + email: () => Promise; + name: () => Promise; +} + +export interface UserPreviousValuesSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + email: () => Promise>; + name: () => Promise>; +} + +export interface PostConnection { + pageInfo: PageInfo; + edges: PostEdge[]; +} + +export interface PostConnectionPromise + extends Promise, + Fragmentable { + pageInfo: () => T; + edges: >() => T; + aggregate: () => T; +} + +export interface PostConnectionSubscription + extends Promise>, + Fragmentable { + pageInfo: () => T; + edges: >>() => T; + aggregate: () => T; +} + +export interface Post { + id: ID_Output; + createdAt: DateTimeOutput; + updatedAt: DateTimeOutput; + title: String; + content?: String; + published: Boolean; +} + +export interface PostPromise extends Promise, Fragmentable { + id: () => Promise; + createdAt: () => Promise; + updatedAt: () => Promise; + title: () => Promise; + content: () => Promise; + published: () => Promise; + author: () => T; + comments: >( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; +} + +export interface PostSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + createdAt: () => Promise>; + updatedAt: () => Promise>; + title: () => Promise>; + content: () => Promise>; + published: () => Promise>; + author: () => T; + comments: >>( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; +} + +export interface AggregateComment { + count: Int; +} + +export interface AggregateCommentPromise + extends Promise, + Fragmentable { + count: () => Promise; +} + +export interface AggregateCommentSubscription + extends Promise>, + Fragmentable { + count: () => Promise>; +} + +export interface CommentEdge { + node: Comment; + cursor: String; +} + +export interface CommentEdgePromise extends Promise, Fragmentable { + node: () => T; + cursor: () => Promise; +} + +export interface CommentEdgeSubscription + extends Promise>, + Fragmentable { + node: () => T; + cursor: () => Promise>; +} + +export interface BatchPayload { + count: Long; +} + +export interface BatchPayloadPromise + extends Promise, + Fragmentable { + count: () => Promise; +} + +export interface BatchPayloadSubscription + extends Promise>, + Fragmentable { + count: () => Promise>; +} + +export interface PostPreviousValues { + id: ID_Output; + createdAt: DateTimeOutput; + updatedAt: DateTimeOutput; + title: String; + content?: String; + published: Boolean; +} + +export interface PostPreviousValuesPromise + extends Promise, + Fragmentable { + id: () => Promise; + createdAt: () => Promise; + updatedAt: () => Promise; + title: () => Promise; + content: () => Promise; + published: () => Promise; +} + +export interface PostPreviousValuesSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + createdAt: () => Promise>; + updatedAt: () => Promise>; + title: () => Promise>; + content: () => Promise>; + published: () => Promise>; +} + +export interface PageInfo { + hasNextPage: Boolean; + hasPreviousPage: Boolean; + startCursor?: String; + endCursor?: String; +} + +export interface PageInfoPromise extends Promise, Fragmentable { + hasNextPage: () => Promise; + hasPreviousPage: () => Promise; + startCursor: () => Promise; + endCursor: () => Promise; +} + +export interface PageInfoSubscription + extends Promise>, + Fragmentable { + hasNextPage: () => Promise>; + hasPreviousPage: () => Promise>; + startCursor: () => Promise>; + endCursor: () => Promise>; +} + +export interface UserEdge { + node: User; + cursor: String; +} + +export interface UserEdgePromise extends Promise, Fragmentable { + node: () => T; + cursor: () => Promise; +} + +export interface UserEdgeSubscription + extends Promise>, + Fragmentable { + node: () => T; + cursor: () => Promise>; +} + +export interface CommentConnection { + pageInfo: PageInfo; + edges: CommentEdge[]; +} + +export interface CommentConnectionPromise + extends Promise, + Fragmentable { + pageInfo: () => T; + edges: >() => T; + aggregate: () => T; +} + +export interface CommentConnectionSubscription + extends Promise>, + Fragmentable { + pageInfo: () => T; + edges: >>() => T; + aggregate: () => T; +} + +export interface PostSubscriptionPayload { + mutation: MutationType; + node: Post; + updatedFields: String[]; + previousValues: PostPreviousValues; +} + +export interface PostSubscriptionPayloadPromise + extends Promise, + Fragmentable { + mutation: () => Promise; + node: () => T; + updatedFields: () => Promise; + previousValues: () => T; +} + +export interface PostSubscriptionPayloadSubscription + extends Promise>, + Fragmentable { + mutation: () => Promise>; + node: () => T; + updatedFields: () => Promise>; + previousValues: () => T; +} + +export interface PostEdge { + node: Post; + cursor: String; +} + +export interface PostEdgePromise extends Promise, Fragmentable { + node: () => T; + cursor: () => Promise; +} + +export interface PostEdgeSubscription + extends Promise>, + Fragmentable { + node: () => T; + cursor: () => Promise>; +} + +export interface CommentPreviousValues { + id: ID_Output; + text: String; +} + +export interface CommentPreviousValuesPromise + extends Promise, + Fragmentable { + id: () => Promise; + text: () => Promise; +} + +export interface CommentPreviousValuesSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + text: () => Promise>; +} + +export interface CommentSubscriptionPayload { + mutation: MutationType; + node: Comment; + updatedFields: String[]; + previousValues: CommentPreviousValues; +} + +export interface CommentSubscriptionPayloadPromise + extends Promise, + Fragmentable { + mutation: () => Promise; + node: () => T; + updatedFields: () => Promise; + previousValues: () => T; +} + +export interface CommentSubscriptionPayloadSubscription + extends Promise>, + Fragmentable { + mutation: () => Promise>; + node: () => T; + updatedFields: () => Promise>; + previousValues: () => T; +} + +export interface Comment { + id: ID_Output; + text: String; +} + +export interface CommentPromise extends Promise, Fragmentable { + id: () => Promise; + text: () => Promise; + writtenBy: () => T; +} + +export interface CommentSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + text: () => Promise>; + writtenBy: () => T; +} + +export interface User { + id: ID_Output; + email: String; + name?: String; +} + +export interface UserPromise extends Promise, Fragmentable { + id: () => Promise; + email: () => Promise; + name: () => Promise; + posts: >( + args?: { + where?: PostWhereInput; + orderBy?: PostOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; + comments: >( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; +} + +export interface UserSubscription + extends Promise>, + Fragmentable { + id: () => Promise>; + email: () => Promise>; + name: () => Promise>; + posts: >>( + args?: { + where?: PostWhereInput; + orderBy?: PostOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; + comments: >>( + args?: { + where?: CommentWhereInput; + orderBy?: CommentOrderByInput; + skip?: Int; + after?: String; + before?: String; + first?: Int; + last?: Int; + } + ) => T; +} + +export interface UserSubscriptionPayload { + mutation: MutationType; + node: User; + updatedFields: String[]; + previousValues: UserPreviousValues; +} + +export interface UserSubscriptionPayloadPromise + extends Promise, + Fragmentable { + mutation: () => Promise; + node: () => T; + updatedFields: () => Promise; + previousValues: () => T; +} + +export interface UserSubscriptionPayloadSubscription + extends Promise>, + Fragmentable { + mutation: () => Promise>; + node: () => T; + updatedFields: () => Promise>; + previousValues: () => T; +} + +export interface AggregatePost { + count: Int; +} + +export interface AggregatePostPromise + extends Promise, + Fragmentable { + count: () => Promise; +} + +export interface AggregatePostSubscription + extends Promise>, + Fragmentable { + count: () => Promise>; +} + +export interface UserConnection { + pageInfo: PageInfo; + edges: UserEdge[]; +} + +export interface UserConnectionPromise + extends Promise, + Fragmentable { + pageInfo: () => T; + edges: >() => T; + aggregate: () => T; +} + +export interface UserConnectionSubscription + extends Promise>, + Fragmentable { + pageInfo: () => T; + edges: >>() => T; + aggregate: () => T; +} + +export interface AggregateUser { + count: Int; +} + +export interface AggregateUserPromise + extends Promise, + Fragmentable { + count: () => Promise; +} + +export interface AggregateUserSubscription + extends Promise>, + Fragmentable { + count: () => Promise>; +} + +/* +DateTime scalar input type, allowing Date +*/ +export type DateTimeInput = Date | string; + +/* +DateTime scalar output type, which is always a string +*/ +export type DateTimeOutput = string; + +export type Long = string; + +/* +The `Boolean` scalar type represents `true` or `false`. +*/ +export type Boolean = boolean; + +/* +The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. +*/ +export type Int = number; + +/* +The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID. +*/ +export type ID_Input = string | number; +export type ID_Output = string; + +/* +The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text. +*/ +export type String = string; + +/** + * Model Metadata + */ + +export const models: Model[] = [ + { + name: "Comment", + embedded: false + }, + { + name: "Post", + embedded: false + }, + { + name: "User", + embedded: false + } +]; + +/** + * Type Defs + */ + +export const Prisma = makePrismaClientClass>({ + typeDefs, + models, + endpoint: `http://localhost:4466` +}); +export const prisma = new Prisma(); diff --git a/typescript/docker-postgres/src/generated/prisma-client/prisma-schema.ts b/typescript/docker-postgres/src/generated/prisma-client/prisma-schema.ts new file mode 100644 index 000000000000..4d61e9d208c6 --- /dev/null +++ b/typescript/docker-postgres/src/generated/prisma-client/prisma-schema.ts @@ -0,0 +1,761 @@ +export const typeDefs = /* GraphQL */ `type AggregateComment { + count: Int! +} + +type AggregatePost { + count: Int! +} + +type AggregateUser { + count: Int! +} + +type BatchPayload { + count: Long! +} + +type Comment { + id: ID! + text: String! + writtenBy: User! +} + +type CommentConnection { + pageInfo: PageInfo! + edges: [CommentEdge]! + aggregate: AggregateComment! +} + +input CommentCreateInput { + text: String! + writtenBy: UserCreateOneWithoutCommentsInput! +} + +input CommentCreateManyInput { + create: [CommentCreateInput!] + connect: [CommentWhereUniqueInput!] +} + +input CommentCreateManyWithoutWrittenByInput { + create: [CommentCreateWithoutWrittenByInput!] + connect: [CommentWhereUniqueInput!] +} + +input CommentCreateWithoutWrittenByInput { + text: String! +} + +type CommentEdge { + node: Comment! + cursor: String! +} + +enum CommentOrderByInput { + id_ASC + id_DESC + text_ASC + text_DESC + createdAt_ASC + createdAt_DESC + updatedAt_ASC + updatedAt_DESC +} + +type CommentPreviousValues { + id: ID! + text: String! +} + +input CommentScalarWhereInput { + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + text: String + text_not: String + text_in: [String!] + text_not_in: [String!] + text_lt: String + text_lte: String + text_gt: String + text_gte: String + text_contains: String + text_not_contains: String + text_starts_with: String + text_not_starts_with: String + text_ends_with: String + text_not_ends_with: String + AND: [CommentScalarWhereInput!] + OR: [CommentScalarWhereInput!] + NOT: [CommentScalarWhereInput!] +} + +type CommentSubscriptionPayload { + mutation: MutationType! + node: Comment + updatedFields: [String!] + previousValues: CommentPreviousValues +} + +input CommentSubscriptionWhereInput { + mutation_in: [MutationType!] + updatedFields_contains: String + updatedFields_contains_every: [String!] + updatedFields_contains_some: [String!] + node: CommentWhereInput + AND: [CommentSubscriptionWhereInput!] + OR: [CommentSubscriptionWhereInput!] + NOT: [CommentSubscriptionWhereInput!] +} + +input CommentUpdateDataInput { + text: String + writtenBy: UserUpdateOneRequiredWithoutCommentsInput +} + +input CommentUpdateInput { + text: String + writtenBy: UserUpdateOneRequiredWithoutCommentsInput +} + +input CommentUpdateManyDataInput { + text: String +} + +input CommentUpdateManyInput { + create: [CommentCreateInput!] + update: [CommentUpdateWithWhereUniqueNestedInput!] + upsert: [CommentUpsertWithWhereUniqueNestedInput!] + delete: [CommentWhereUniqueInput!] + connect: [CommentWhereUniqueInput!] + disconnect: [CommentWhereUniqueInput!] + deleteMany: [CommentScalarWhereInput!] + updateMany: [CommentUpdateManyWithWhereNestedInput!] +} + +input CommentUpdateManyMutationInput { + text: String +} + +input CommentUpdateManyWithoutWrittenByInput { + create: [CommentCreateWithoutWrittenByInput!] + delete: [CommentWhereUniqueInput!] + connect: [CommentWhereUniqueInput!] + disconnect: [CommentWhereUniqueInput!] + update: [CommentUpdateWithWhereUniqueWithoutWrittenByInput!] + upsert: [CommentUpsertWithWhereUniqueWithoutWrittenByInput!] + deleteMany: [CommentScalarWhereInput!] + updateMany: [CommentUpdateManyWithWhereNestedInput!] +} + +input CommentUpdateManyWithWhereNestedInput { + where: CommentScalarWhereInput! + data: CommentUpdateManyDataInput! +} + +input CommentUpdateWithoutWrittenByDataInput { + text: String +} + +input CommentUpdateWithWhereUniqueNestedInput { + where: CommentWhereUniqueInput! + data: CommentUpdateDataInput! +} + +input CommentUpdateWithWhereUniqueWithoutWrittenByInput { + where: CommentWhereUniqueInput! + data: CommentUpdateWithoutWrittenByDataInput! +} + +input CommentUpsertWithWhereUniqueNestedInput { + where: CommentWhereUniqueInput! + update: CommentUpdateDataInput! + create: CommentCreateInput! +} + +input CommentUpsertWithWhereUniqueWithoutWrittenByInput { + where: CommentWhereUniqueInput! + update: CommentUpdateWithoutWrittenByDataInput! + create: CommentCreateWithoutWrittenByInput! +} + +input CommentWhereInput { + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + text: String + text_not: String + text_in: [String!] + text_not_in: [String!] + text_lt: String + text_lte: String + text_gt: String + text_gte: String + text_contains: String + text_not_contains: String + text_starts_with: String + text_not_starts_with: String + text_ends_with: String + text_not_ends_with: String + writtenBy: UserWhereInput + AND: [CommentWhereInput!] + OR: [CommentWhereInput!] + NOT: [CommentWhereInput!] +} + +input CommentWhereUniqueInput { + id: ID +} + +scalar DateTime + +scalar Long + +type Mutation { + createComment(data: CommentCreateInput!): Comment! + updateComment(data: CommentUpdateInput!, where: CommentWhereUniqueInput!): Comment + updateManyComments(data: CommentUpdateManyMutationInput!, where: CommentWhereInput): BatchPayload! + upsertComment(where: CommentWhereUniqueInput!, create: CommentCreateInput!, update: CommentUpdateInput!): Comment! + deleteComment(where: CommentWhereUniqueInput!): Comment + deleteManyComments(where: CommentWhereInput): BatchPayload! + createPost(data: PostCreateInput!): Post! + updatePost(data: PostUpdateInput!, where: PostWhereUniqueInput!): Post + updateManyPosts(data: PostUpdateManyMutationInput!, where: PostWhereInput): BatchPayload! + upsertPost(where: PostWhereUniqueInput!, create: PostCreateInput!, update: PostUpdateInput!): Post! + deletePost(where: PostWhereUniqueInput!): Post + deleteManyPosts(where: PostWhereInput): BatchPayload! + createUser(data: UserCreateInput!): User! + updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User + updateManyUsers(data: UserUpdateManyMutationInput!, where: UserWhereInput): BatchPayload! + upsertUser(where: UserWhereUniqueInput!, create: UserCreateInput!, update: UserUpdateInput!): User! + deleteUser(where: UserWhereUniqueInput!): User + deleteManyUsers(where: UserWhereInput): BatchPayload! +} + +enum MutationType { + CREATED + UPDATED + DELETED +} + +interface Node { + id: ID! +} + +type PageInfo { + hasNextPage: Boolean! + hasPreviousPage: Boolean! + startCursor: String + endCursor: String +} + +type Post { + id: ID! + createdAt: DateTime! + updatedAt: DateTime! + title: String! + content: String + published: Boolean! + author: User! + comments(where: CommentWhereInput, orderBy: CommentOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Comment!] +} + +type PostConnection { + pageInfo: PageInfo! + edges: [PostEdge]! + aggregate: AggregatePost! +} + +input PostCreateInput { + title: String! + content: String + published: Boolean + author: UserCreateOneWithoutPostsInput! + comments: CommentCreateManyInput +} + +input PostCreateManyWithoutAuthorInput { + create: [PostCreateWithoutAuthorInput!] + connect: [PostWhereUniqueInput!] +} + +input PostCreateWithoutAuthorInput { + title: String! + content: String + published: Boolean + comments: CommentCreateManyInput +} + +type PostEdge { + node: Post! + cursor: String! +} + +enum PostOrderByInput { + id_ASC + id_DESC + createdAt_ASC + createdAt_DESC + updatedAt_ASC + updatedAt_DESC + title_ASC + title_DESC + content_ASC + content_DESC + published_ASC + published_DESC +} + +type PostPreviousValues { + id: ID! + createdAt: DateTime! + updatedAt: DateTime! + title: String! + content: String + published: Boolean! +} + +input PostScalarWhereInput { + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + createdAt: DateTime + createdAt_not: DateTime + createdAt_in: [DateTime!] + createdAt_not_in: [DateTime!] + createdAt_lt: DateTime + createdAt_lte: DateTime + createdAt_gt: DateTime + createdAt_gte: DateTime + updatedAt: DateTime + updatedAt_not: DateTime + updatedAt_in: [DateTime!] + updatedAt_not_in: [DateTime!] + updatedAt_lt: DateTime + updatedAt_lte: DateTime + updatedAt_gt: DateTime + updatedAt_gte: DateTime + title: String + title_not: String + title_in: [String!] + title_not_in: [String!] + title_lt: String + title_lte: String + title_gt: String + title_gte: String + title_contains: String + title_not_contains: String + title_starts_with: String + title_not_starts_with: String + title_ends_with: String + title_not_ends_with: String + content: String + content_not: String + content_in: [String!] + content_not_in: [String!] + content_lt: String + content_lte: String + content_gt: String + content_gte: String + content_contains: String + content_not_contains: String + content_starts_with: String + content_not_starts_with: String + content_ends_with: String + content_not_ends_with: String + published: Boolean + published_not: Boolean + AND: [PostScalarWhereInput!] + OR: [PostScalarWhereInput!] + NOT: [PostScalarWhereInput!] +} + +type PostSubscriptionPayload { + mutation: MutationType! + node: Post + updatedFields: [String!] + previousValues: PostPreviousValues +} + +input PostSubscriptionWhereInput { + mutation_in: [MutationType!] + updatedFields_contains: String + updatedFields_contains_every: [String!] + updatedFields_contains_some: [String!] + node: PostWhereInput + AND: [PostSubscriptionWhereInput!] + OR: [PostSubscriptionWhereInput!] + NOT: [PostSubscriptionWhereInput!] +} + +input PostUpdateInput { + title: String + content: String + published: Boolean + author: UserUpdateOneRequiredWithoutPostsInput + comments: CommentUpdateManyInput +} + +input PostUpdateManyDataInput { + title: String + content: String + published: Boolean +} + +input PostUpdateManyMutationInput { + title: String + content: String + published: Boolean +} + +input PostUpdateManyWithoutAuthorInput { + create: [PostCreateWithoutAuthorInput!] + delete: [PostWhereUniqueInput!] + connect: [PostWhereUniqueInput!] + disconnect: [PostWhereUniqueInput!] + update: [PostUpdateWithWhereUniqueWithoutAuthorInput!] + upsert: [PostUpsertWithWhereUniqueWithoutAuthorInput!] + deleteMany: [PostScalarWhereInput!] + updateMany: [PostUpdateManyWithWhereNestedInput!] +} + +input PostUpdateManyWithWhereNestedInput { + where: PostScalarWhereInput! + data: PostUpdateManyDataInput! +} + +input PostUpdateWithoutAuthorDataInput { + title: String + content: String + published: Boolean + comments: CommentUpdateManyInput +} + +input PostUpdateWithWhereUniqueWithoutAuthorInput { + where: PostWhereUniqueInput! + data: PostUpdateWithoutAuthorDataInput! +} + +input PostUpsertWithWhereUniqueWithoutAuthorInput { + where: PostWhereUniqueInput! + update: PostUpdateWithoutAuthorDataInput! + create: PostCreateWithoutAuthorInput! +} + +input PostWhereInput { + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + createdAt: DateTime + createdAt_not: DateTime + createdAt_in: [DateTime!] + createdAt_not_in: [DateTime!] + createdAt_lt: DateTime + createdAt_lte: DateTime + createdAt_gt: DateTime + createdAt_gte: DateTime + updatedAt: DateTime + updatedAt_not: DateTime + updatedAt_in: [DateTime!] + updatedAt_not_in: [DateTime!] + updatedAt_lt: DateTime + updatedAt_lte: DateTime + updatedAt_gt: DateTime + updatedAt_gte: DateTime + title: String + title_not: String + title_in: [String!] + title_not_in: [String!] + title_lt: String + title_lte: String + title_gt: String + title_gte: String + title_contains: String + title_not_contains: String + title_starts_with: String + title_not_starts_with: String + title_ends_with: String + title_not_ends_with: String + content: String + content_not: String + content_in: [String!] + content_not_in: [String!] + content_lt: String + content_lte: String + content_gt: String + content_gte: String + content_contains: String + content_not_contains: String + content_starts_with: String + content_not_starts_with: String + content_ends_with: String + content_not_ends_with: String + published: Boolean + published_not: Boolean + author: UserWhereInput + comments_every: CommentWhereInput + comments_some: CommentWhereInput + comments_none: CommentWhereInput + AND: [PostWhereInput!] + OR: [PostWhereInput!] + NOT: [PostWhereInput!] +} + +input PostWhereUniqueInput { + id: ID +} + +type Query { + comment(where: CommentWhereUniqueInput!): Comment + comments(where: CommentWhereInput, orderBy: CommentOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Comment]! + commentsConnection(where: CommentWhereInput, orderBy: CommentOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): CommentConnection! + post(where: PostWhereUniqueInput!): Post + posts(where: PostWhereInput, orderBy: PostOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Post]! + postsConnection(where: PostWhereInput, orderBy: PostOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): PostConnection! + user(where: UserWhereUniqueInput!): User + users(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [User]! + usersConnection(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): UserConnection! + node(id: ID!): Node +} + +type Subscription { + comment(where: CommentSubscriptionWhereInput): CommentSubscriptionPayload + post(where: PostSubscriptionWhereInput): PostSubscriptionPayload + user(where: UserSubscriptionWhereInput): UserSubscriptionPayload +} + +type User { + id: ID! + email: String! + name: String + posts(where: PostWhereInput, orderBy: PostOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Post!] + comments(where: CommentWhereInput, orderBy: CommentOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Comment!] +} + +type UserConnection { + pageInfo: PageInfo! + edges: [UserEdge]! + aggregate: AggregateUser! +} + +input UserCreateInput { + email: String! + name: String + posts: PostCreateManyWithoutAuthorInput + comments: CommentCreateManyWithoutWrittenByInput +} + +input UserCreateOneWithoutCommentsInput { + create: UserCreateWithoutCommentsInput + connect: UserWhereUniqueInput +} + +input UserCreateOneWithoutPostsInput { + create: UserCreateWithoutPostsInput + connect: UserWhereUniqueInput +} + +input UserCreateWithoutCommentsInput { + email: String! + name: String + posts: PostCreateManyWithoutAuthorInput +} + +input UserCreateWithoutPostsInput { + email: String! + name: String + comments: CommentCreateManyWithoutWrittenByInput +} + +type UserEdge { + node: User! + cursor: String! +} + +enum UserOrderByInput { + id_ASC + id_DESC + email_ASC + email_DESC + name_ASC + name_DESC + createdAt_ASC + createdAt_DESC + updatedAt_ASC + updatedAt_DESC +} + +type UserPreviousValues { + id: ID! + email: String! + name: String +} + +type UserSubscriptionPayload { + mutation: MutationType! + node: User + updatedFields: [String!] + previousValues: UserPreviousValues +} + +input UserSubscriptionWhereInput { + mutation_in: [MutationType!] + updatedFields_contains: String + updatedFields_contains_every: [String!] + updatedFields_contains_some: [String!] + node: UserWhereInput + AND: [UserSubscriptionWhereInput!] + OR: [UserSubscriptionWhereInput!] + NOT: [UserSubscriptionWhereInput!] +} + +input UserUpdateInput { + email: String + name: String + posts: PostUpdateManyWithoutAuthorInput + comments: CommentUpdateManyWithoutWrittenByInput +} + +input UserUpdateManyMutationInput { + email: String + name: String +} + +input UserUpdateOneRequiredWithoutCommentsInput { + create: UserCreateWithoutCommentsInput + update: UserUpdateWithoutCommentsDataInput + upsert: UserUpsertWithoutCommentsInput + connect: UserWhereUniqueInput +} + +input UserUpdateOneRequiredWithoutPostsInput { + create: UserCreateWithoutPostsInput + update: UserUpdateWithoutPostsDataInput + upsert: UserUpsertWithoutPostsInput + connect: UserWhereUniqueInput +} + +input UserUpdateWithoutCommentsDataInput { + email: String + name: String + posts: PostUpdateManyWithoutAuthorInput +} + +input UserUpdateWithoutPostsDataInput { + email: String + name: String + comments: CommentUpdateManyWithoutWrittenByInput +} + +input UserUpsertWithoutCommentsInput { + update: UserUpdateWithoutCommentsDataInput! + create: UserCreateWithoutCommentsInput! +} + +input UserUpsertWithoutPostsInput { + update: UserUpdateWithoutPostsDataInput! + create: UserCreateWithoutPostsInput! +} + +input UserWhereInput { + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + email: String + email_not: String + email_in: [String!] + email_not_in: [String!] + email_lt: String + email_lte: String + email_gt: String + email_gte: String + email_contains: String + email_not_contains: String + email_starts_with: String + email_not_starts_with: String + email_ends_with: String + email_not_ends_with: String + name: String + name_not: String + name_in: [String!] + name_not_in: [String!] + name_lt: String + name_lte: String + name_gt: String + name_gte: String + name_contains: String + name_not_contains: String + name_starts_with: String + name_not_starts_with: String + name_ends_with: String + name_not_ends_with: String + posts_every: PostWhereInput + posts_some: PostWhereInput + posts_none: PostWhereInput + comments_every: CommentWhereInput + comments_some: CommentWhereInput + comments_none: CommentWhereInput + AND: [UserWhereInput!] + OR: [UserWhereInput!] + NOT: [UserWhereInput!] +} + +input UserWhereUniqueInput { + id: ID + email: String +} +` \ No newline at end of file diff --git a/typescript/docker-postgres/src/script.ts b/typescript/docker-postgres/src/script.ts new file mode 100644 index 000000000000..83d0b1f63571 --- /dev/null +++ b/typescript/docker-postgres/src/script.ts @@ -0,0 +1,67 @@ +import { prisma } from './generated/prisma-client' + +// A `main` function so that we can use async/await +async function main() { + // Retrieve all published posts + const allPosts = await prisma.posts({ + where: { published: true }, + }) + console.log(`Retrieved all published posts: `, allPosts) + + // Create a new post (written by an already existing user with email alice@prisma.io) + const newPost = await prisma.createPost({ + title: 'Join the Prisma Slack community', + content: 'http://slack.prisma.io', + author: { + connect: { + email: 'alice@prisma.io', // Should have been created during initial seeding + }, + }, + }) + console.log(`Created a new post: `, newPost) + + // Publish the new post + const updatedPost = await prisma.updatePost({ + where: { + id: newPost.id, + }, + data: { + published: true, + }, + }) + console.log(`Published the newly created post: `, updatedPost) + + // Write a comment + const postWithComment = await prisma.updatePost({ + where: { + id: newPost.id, + }, + data: { + comments: { + create: { + text: 'Wow, there are so many active members on the Prisma Slack!', + writtenBy: { + connect: { + email: 'bob@prisma.io', + }, + }, + }, + }, + }, + }) + console.log(`Wrote a comment for the new post: `, postWithComment) + + // Retrieve all posts by user with email alice@prisma.io + const postsByUser = await prisma + .user({ + email: 'alice@prisma.io', + }) + .posts() + console.log(`Retrieved all posts from a specific user: `, postsByUser) +} + +main() + .then(() => { + process.exit(0) + }) + .catch(e => console.error(e)) diff --git a/typescript/docker-postgres/tsconfig.json b/typescript/docker-postgres/tsconfig.json new file mode 100644 index 000000000000..669f46efc390 --- /dev/null +++ b/typescript/docker-postgres/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "sourceMap": true, + "outDir": "dist", + "strict": true, + "lib": ["esnext", "dom"] + } +} \ No newline at end of file