---
This commit is contained in:
@@ -0,0 +1,456 @@
|
||||
### Repository:
|
||||
|
||||
https://gitea.elliot-at-zuri.ch/admin/TKT20009-Course-Project-I
|
||||
|
||||
### Installation:
|
||||
|
||||
The application can be directly accessed via a web browser at the following addresses, without requiring any installation:
|
||||
\- Frontend: https://wreckit-frontend.elliot-at-zuri.ch
|
||||
\- Backend: https://wreckit-backend.elliot-at-zuri.ch/graphql
|
||||
|
||||
### Idea:
|
||||
|
||||
I had actually built this app prior to this course, according to this tutorial: https://youtube.com/watch?v=I6ypD7qv3Z8/. The app took inspiration from the tutorial, but was built using my own custom tech stack ([Prisma ORM](https://www.prisma.io/orm) instead of [TypeORM](https://typeorm.io/), and [Apollo Client](https://www.apollographql.com/docs/react/) instead of [URQL](https://commerce.nearform.com/open-source/urql/)). I then added 5 OWASP flaws to the app to satisfy the course's requirements.
|
||||
|
||||
The application is a simple web app that allows users to sign up and create/edit/delete/upvote/downvote posts.
|
||||
|
||||
The frontend of the application was built with [Next.js](https://nextjs.org/), while the backend is essentially a [GraphQL](https://graphql.org/) API server built using [Apollo](https://www.apollographql.com/docs/apollo-server/). Both the frontend and backend are written in TypeScript. Don't worry if you are not familiar with these technologies; we are only going to focus on specific parts of the application that contain OWASP flaws. The flaws of the application all reside in the backend, i.e., in the `backend` folder, so you can safely ignore the `frontend` folder. Feel free to look inside the frontend if you are interested, but our focus is on the `backend` folder.
|
||||
|
||||
I'm using the [2021 OWASP Top 10 list](https://owasp.org/Top10/).
|
||||
|
||||
### Flaws:
|
||||
|
||||
#### FLAW 1: [A01:2021-Broken Access Control](https://owasp.org/Top10/A01_2021-Broken_Access_Control/)
|
||||
|
||||
The specific CWE of this flaw is **[CWE-200 Exposure of Sensitive Information to an Unauthorized Actor](https://cwe.mitre.org/data/definitions/200.html)**, and the information being exposed is users' emails and passwords.
|
||||
|
||||
1\. Demonstrating the flaw:
|
||||
\- Visit the frontend of the application in your web browser. You will see that there are quite a few posts created by different users, each with their own username. Copy any username to your clipboard.
|
||||
\- Then, visit [Apollo Sandbox](https://studio.apollographql.com/sandbox/explorer/) to make GraphQL requests to our backend. Change the sandbox address from http://localhost:4000 to https://wreckit-backend.elliot-at-zuri.ch/graphql. Also, click on the settings button next to the url and set `include cookies` to `true`.
|
||||
\- In the `Operation` tab, paste in the following query:
|
||||
|
||||
```graphql
|
||||
query GetUser($username: String!) {
|
||||
getUser(username: $username) {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
username
|
||||
email
|
||||
password
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
\- In the `Variables` tab, paste in the following JSON:
|
||||
|
||||
```json
|
||||
{
|
||||
"username": "<username>"
|
||||
}
|
||||
```
|
||||
|
||||
Replace `<username>` with the username you previously copied.
|
||||
\- In GraphQL, a [Query](https://graphql.org/learn/queries/) is simply a request for data from the server, with some inputs from the client. Here, we are giving the server the `username` of a user and requesting that the server return the `id`, `createdAt`, `updatedAt`, `username`, `email`, and `password` fields corresponding to that username. Click on the `GetUser` button to run this query.
|
||||
\- You will see that the server returns some data back that might look like the following:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"getUser": [
|
||||
{
|
||||
"id": "4c84d5e6-312b-473a-b046-7c8ee2b133f3",
|
||||
"createdAt": "2022-11-25T00:00:00.000Z",
|
||||
"updatedAt": "1990-07-13T00:00:00.000Z",
|
||||
"username": "adigg0",
|
||||
"email": "acathesyed0@adobe.com",
|
||||
"password": "tT5(dgR8+`"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
\- Here, lots of personal information about that user is returned to us, even though we are not logged in! The `password` field shouldn't have been returned at all, while the `email` field should only be returned if we are logged in as that user.
|
||||
|
||||
2\. Identifying the flaw:
|
||||
This issue is happening because we are using the [TypeGraphQL](https://prisma.typegraphql.com/) library to directly generate the `server schema` using the [`Prisma schema`](./backend/prisma/schema.prisma). The `server schema` determines which fields are returned by our GraphQL API server, while the `Prisma schema` reflects the structure of our database. In other words, we are returning whichever fields are present in the backend's database to any client, which is a very bad security practice. The problematic code is at [`L32-L40`](./backend/prisma/schema.prisma#L32-L40).
|
||||
|
||||
3\. Fixing the flaw:
|
||||
\- Open [`schema.prisma`](./backend/prisma/schema.prisma) and add a few `/// @TypeGraphQL.omit(output: true)` lines to the `User` model:
|
||||
|
||||
```prisma
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
/// @TypeGraphQL.omit(output: true)
|
||||
createdAt DateTime @default(now())
|
||||
/// @TypeGraphQL.omit(output: true)
|
||||
updatedAt DateTime @updatedAt
|
||||
username String @unique
|
||||
/// @TypeGraphQL.omit(output: true)
|
||||
password String
|
||||
email String? @unique
|
||||
Posts Post[]
|
||||
}
|
||||
```
|
||||
|
||||
We added `/// @TypeGraphQL.omit(output: true)` above `createdAt`, `updatedAt`, and `password`, so these fields will no longer be returned by the server.
|
||||
\- Next, we are going to configure our server to only return the `email` of the requested user if we are logged in as that user. Open [`user.ts`](./backend/src/resolvers/user.ts) and add the following to the `UserResolver` class:
|
||||
|
||||
```ts
|
||||
@FieldResolver(() => String)
|
||||
async email(
|
||||
@Root() user: User,
|
||||
@Ctx() { req }: Context
|
||||
) {
|
||||
if (req.session.userID != user.id) {
|
||||
return ''
|
||||
}
|
||||
else {
|
||||
return user.email || ''
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This function determines what gets returned by the server when the `email` field of a user is requested. `req.session.userID` is the `id` of the user that is currently logged in and making the request, while `user.id` is the id of the user whose information is being requested. If these two IDs are not the same, it means the user making the request is requesting the email of another user, in which case we return an empty string. If the current user is not logged in, `req.session.userID` would be undefined, which would also cause an emptry string to be returned. On the other hand, if the IDs are the same, we can safely return the requested `email`, or an emptry string in the case it is undefined.
|
||||
|
||||
#### FLAW 2: [A03:2021 – Injection](https://owasp.org/Top10/A03_2021-Injection/)
|
||||
|
||||
1\. Demonstrating the flaw:
|
||||
This one is a classic **[SQL Injection](https://cwe.mitre.org/data/definitions/89.html)** flaw. Again, open [Apollo Sandbox](https://studio.apollographql.com/sandbox/explorer/) and run the `getUser` query, but this time with the following variable:
|
||||
|
||||
```json
|
||||
{
|
||||
"username": "<username>' UNION SELECT * FROM \"User\" UNION SELECT * FROM \"User\" WHERE username='"
|
||||
}
|
||||
```
|
||||
|
||||
Again, replace `<username>` with the username you copied in the previous part. In fact, you can replace `username` with whatever you want, and this query is going to return every single user in the database.
|
||||
|
||||
2\. Identifying the flaw:
|
||||
The issue is with the `getUser` function inside the `UserResolver` class in the [`user.ts`](./backend/src/resolvers/user.ts) file:
|
||||
|
||||
```ts
|
||||
@Query(() => [User])
|
||||
async getUser(
|
||||
@Ctx() { prisma }: Context,
|
||||
@Arg('username', () => String) username: string
|
||||
): Promise<User[]> {
|
||||
return (await prisma.$queryRawUnsafe(`SELECT * FROM "User" WHERE username = '${username}'`)) as User[]
|
||||
}
|
||||
```
|
||||
|
||||
You can find the code here: ./backend/src/resolvers/user.ts#L13-L19
|
||||
|
||||
Notice that the server is constructing a query directly using user input. Therefore, when we pass `<username>' UNION SELECT * FROM "User" UNION SELECT * FROM "User" WHERE username='` as `username`, the following query is constructed:
|
||||
|
||||
```sql
|
||||
SELECT * FROM "User" WHERE username = '<username>' UNION SELECT * FROM "User" UNION SELECT * FROM "User" WHERE username=''
|
||||
```
|
||||
|
||||
This maliciously constructed query unions the results of three `SELECT` statements. The first statement, `SELECT * FROM "User" WHERE username = '<username>'`, might return one user if `<username>` matches an existing username. The second statement, `SELECT * FROM "User"`, returns every single row in the `"User"` table, i.e., every single user. The third statement, `SELECT * FROM "User" WHERE username=''`, doesn't return anything, since no user has an empty username. The union of these three statements returns every single user in the database.
|
||||
|
||||
3\. Fixing the flaw:
|
||||
Modify the `getUser` function as follows:
|
||||
|
||||
```ts
|
||||
@Query(() => User, { nullable: true })
|
||||
async getUser(
|
||||
@Ctx() { prisma }: Context,
|
||||
@Arg('username', () => String) username: string
|
||||
): Promise<User | null> {
|
||||
return await prisma.user.findUnique({ where: { username } })
|
||||
}
|
||||
```
|
||||
|
||||
This time, we are using [Prisma ORM](https://www.prisma.io/orm)'s `findUnique` TypeScript API to find exactly one user whose `username` matches the provided input. Prisma automatically constructs the SQL statement under the hood and sanitises the input for us. This mean that whatever we inputs for `username` is treated as an input string and not used to construct the underlying SQL query, so now running the same `GetUser` query would return null.
|
||||
|
||||
#### FLAW 3: [A04:2021 – Insecure Design](https://owasp.org/Top10/A04_2021-Insecure_Design/)
|
||||
The specific CWE of this flaw is **[CWE-256: Plaintext Storage of a Password](https://cwe.mitre.org/data/definitions/256.html)**.
|
||||
1\. Demonstrating the flaw:
|
||||
Back in Flaw 1, we already saw that the `getUser` query returned the plain text password of the user. Even though we have stopped our `GraphQL` server from returning user's passwords by adding `/// @TypeGraphQL.omit(output: true)` to our Prisma schema, under the hood we are still saving the password in plain text to the database.
|
||||
|
||||
2\. Identifying the flaw:
|
||||
The cause of the error is the `register` mutation inside the `UserResolver` class in the [`user.ts`](./backend/src/resolvers/user.ts) file:
|
||||
|
||||
```ts
|
||||
@Mutation(() => UserResponse)
|
||||
async register(
|
||||
@Ctx() { req, prisma }: Context,
|
||||
@Arg('input', () => UsernamePasswordInput) { email, username, password }: UsernamePasswordInput
|
||||
): Promise<UserResponse> {
|
||||
|
||||
const errors = []
|
||||
|
||||
if (username.length < 8) {
|
||||
errors.push({
|
||||
field: 'username',
|
||||
message: 'Length must be at least 8.'
|
||||
})
|
||||
}
|
||||
else if (await prisma.user.findUnique({ where: { username } }) ? true : false) {
|
||||
errors.push({
|
||||
field: 'username',
|
||||
message: 'Username already exists!'
|
||||
})
|
||||
}
|
||||
|
||||
if (email) {
|
||||
if (!validateEmail(email)) {
|
||||
errors.push({
|
||||
field: 'email',
|
||||
message: 'Invalid email!'
|
||||
})
|
||||
}
|
||||
else if (await prisma.user.findUnique({ where: { email } }) ? true : false) {
|
||||
errors.push({
|
||||
field: 'email',
|
||||
message: 'Email already in use!'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (password.length < 8) {
|
||||
errors.push({
|
||||
field: 'password',
|
||||
message: 'Length must be at least 8.'
|
||||
})
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
return { errors }
|
||||
}
|
||||
|
||||
const user = await prisma.user.create({ data: { username, password } })
|
||||
|
||||
// Logs in after successfully registering
|
||||
req.session.userID = user.id
|
||||
return { user }
|
||||
}
|
||||
```
|
||||
|
||||
You can find the code here: ./backend/src/resolvers/user.ts#L22-L74
|
||||
|
||||
In GraphQL, a [Mutation](https://graphql.com/learn/mutations/) is a request, similar to a Query. However, instead of just asking that the server returns some data, it also asks the server to create/modify/delete data in the backend. Here, the `register` mutation takes in `username`, `email`, and `password` as inputs, performs some validation of those inputs, and creates a new user in the database. The line that is causing trouble is the `const user = await prisma.user.create({ data: { username, password } })` line, where we are storing the user's password in plain text to the database.
|
||||
|
||||
3\. Fixing the flaw:
|
||||
To address this issue, we are going to hash the password using the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm before saving the password to the database. Replace the `const user = await prisma.user.create({ data: { username, password } })` line with the following:
|
||||
|
||||
```ts
|
||||
const hashedPassword = await argon2.hash(password)
|
||||
const user = await prisma.user.create({
|
||||
data: { username, password: hashedPassword },
|
||||
})
|
||||
```
|
||||
|
||||
Under the hood, the `argon2` function from the [`node-argon2`](https://www.npmjs.com/package//argon2) library automatically uses `Argon2id` with settings that satisfy [OWASP Password Storage Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html) by default.
|
||||
|
||||
Then, in the `login` mutation in the same file as the `register` mutation:
|
||||
|
||||
```ts
|
||||
@Mutation(() => UserResponse)
|
||||
async login(
|
||||
@Ctx() { req, prisma }: Context,
|
||||
@Arg('input', () => UsernamePasswordInput) { username, password }: UsernamePasswordInput
|
||||
): Promise<UserResponse> {
|
||||
const user = await prisma.user.findUnique({ where: { username } })
|
||||
if (!user) {
|
||||
return {
|
||||
errors: [{
|
||||
field: 'username',
|
||||
message: 'That username doesn\'t exist.'
|
||||
}]
|
||||
}
|
||||
}
|
||||
if (user.password == password) {
|
||||
req.session.userID = user.id
|
||||
return { user }
|
||||
}
|
||||
else {
|
||||
return {
|
||||
errors: [{
|
||||
field: 'password',
|
||||
message: 'That password is incorrect!'
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We are going to modify the login mutation to make sure that it checks whether the user inputted password matches the hash in the database. Change the `user.password == password` line to `await argon2.verify(user.password, password)`.
|
||||
|
||||
#### FLAW 4: [A07:2021 – Identification and Authentication Failures](https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/)
|
||||
The specific CWE of this flaw is **[CWE-306 Missing Authentication for Critical Function](https://cwe.mitre.org/data/definitions/306.html)**.
|
||||
1\. Demonstrating the flaw:
|
||||
\- Go to [frontend](https://wreckit-frontend.elliot-at-zuri.ch/) again. Click on the title of any post. You are going to be redirected to the url of that post, e.g., https://wreckit-frontend.elliot-at-zuri.ch/post/81b089dc-6924-4e0b-97b1-18ed74f2ab28. Here, `81b089dc-6924-4e0b-97b1-18ed74f2ab28` is the `id` of the post. Copy that `id` to the clipboard.
|
||||
\- Visit [Apollo Sandbox](https://studio.apollographql.com/sandbox/explorer/) again. Paste in the following mutation in the `Operation` tab:
|
||||
|
||||
```graphql
|
||||
mutation UpdatePost($id: String!, $title: String!, $content: String!) {
|
||||
updatePost(id: $id, title: $title, content: $content) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
}
|
||||
post {
|
||||
id
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then, paste in the following in the `Variables` tab:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "<id>",
|
||||
"title": "<whatever-you-want>",
|
||||
"content": "<whatever-you-want>"
|
||||
}
|
||||
```
|
||||
|
||||
Replace `<id>` with the id you previously copied. Note that it should be a number and so shouldn't be surrounded by quotation marks. Replace `<whatever-you-want>` with, well, whatever you want. Click on the `Update Post` button to run the mutation. Notice that we have successfully updated the title and content of the post, even when we are not logged in as its author (or logged in at all). Now, go back to the frontend and reload the `https://wreckit-frontend.elliot-at-zuri.ch/post/<id>` page, and you should see that the changes have been reflected.
|
||||
|
||||
2\. Identifying the flaw:
|
||||
This is the `updatePost` mutation in the `PostResolver` class in [`post.ts`](./backend/src/resolvers/post.ts):
|
||||
|
||||
```ts
|
||||
@Mutation(() => PostResponse)
|
||||
async updatePost(
|
||||
@Ctx() { req, prisma }: Context,
|
||||
@Arg('id', () => Int) id: number,
|
||||
@Arg('title', () => String) title: string,
|
||||
@Arg('content', () => String) content: string,
|
||||
): Promise<PostResponse> {
|
||||
|
||||
const post = await prisma.post.findUnique({ where: { id } })
|
||||
if (!post) {
|
||||
return {
|
||||
errors: [{
|
||||
field: 'id',
|
||||
message: 'Post doesn\'t exist!'
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
if (!title) {
|
||||
return {
|
||||
errors: [{
|
||||
field: 'title',
|
||||
message: 'Title cannot be empty!'
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
return {
|
||||
errors: [{
|
||||
field: 'content',
|
||||
message: 'Content cannot be empty!'
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
return { post: await prisma.post.update({ where: { id }, data: { title, content } }) }
|
||||
}
|
||||
```
|
||||
|
||||
You can find the code here: ./backend/src/resolvers/post.ts#L119-L156
|
||||
|
||||
We can see that the mutation doesn't do anything to verify that a request actually comes from the post's author before updating the post in the database.
|
||||
|
||||
3\. Fixing the flaw:
|
||||
Modify the `updatePost` function as follows:
|
||||
```ts
|
||||
@UseMiddleware(isAuth)
|
||||
@Mutation(() => PostResponse)
|
||||
async updatePost(
|
||||
@Ctx() { req, prisma }: Context,
|
||||
@Arg('id', () => Int) id: number,
|
||||
@Arg('title', () => String) title: string,
|
||||
@Arg('content', () => String) content: string,
|
||||
): Promise<PostResponse> {
|
||||
|
||||
const post = await prisma.post.findUnique({ where: { id } })
|
||||
if (!post) {
|
||||
return {
|
||||
errors: [{
|
||||
field: 'id',
|
||||
message: 'Post doesn\'t exist!'
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
if (post.authorID != req.session.userID!) {
|
||||
throw new Error('Unauthorised!')
|
||||
}
|
||||
|
||||
if (!title) {
|
||||
return {
|
||||
errors: [{
|
||||
field: 'title',
|
||||
message: 'Title cannot be empty!'
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
return {
|
||||
errors: [{
|
||||
field: 'content',
|
||||
message: 'Content cannot be empty!'
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
return { post: await prisma.post.update({ where: { id }, data: { title, content } }) }
|
||||
}
|
||||
```
|
||||
`@UseMiddleware(isAuth)` would ensure that only logged in users can call the `updatePost` mutation, and the following part ensures that only the post's author can update it:
|
||||
```ts
|
||||
if (post.authorID != req.session.userID!) {
|
||||
throw new Error('Unauthorised!')
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### FLAW 5: [A05:2021 – Security Misconfiguration](https://owasp.org/Top10/A05_2021-Security_Misconfiguration/)
|
||||
The specific CWE of this flaw is **[CWE-1004 Sensitive Cookie Without 'HttpOnly' Flag](https://cwe.mitre.org/data/definitions/1004.html)**.
|
||||
1\. Demonstrating the flaw:
|
||||
Go to https://wreckit-frontend.elliot-at-zuri.ch/login using Chrome and login with the following credentials:
|
||||
```
|
||||
username: adigg0
|
||||
password: tT5(dgR8+`
|
||||
```
|
||||
Press `Ctrl+Shift+I` to open `Chrome DevTools`. Open the `Application` tab. In the bar on the left, go to `Storage > Cookies > https://wreckit-frontend.elliot-at-zuri.ch`. You should see a cookie named `qid`. If you don't see it, refresh the page while keeping the `Chrome DevTools` open and you should see the cookie. This is the session cookie that's used to identify the user, and you can see that the `HttpOnly` attribute is not set.
|
||||
|
||||
2\. Identifying the flaw:
|
||||
The following code inside [`index.ts`](./backend/src/index.ts) is responsible:
|
||||
```ts
|
||||
app.use(
|
||||
session({
|
||||
name: SESSION_COOKIE_NAME, // This is the name of the cookie that will be stored on the client (usually a browser) when a new session is created, i.e., when the user logs in.
|
||||
store: new RedisStore({ // This is the key-value database where active user sessions will be stored.
|
||||
client: redis,
|
||||
disableTouch: true // This ensures that the session cookies have no TTL, i.e., they will not automatically expire.
|
||||
}),
|
||||
cookie: {
|
||||
httpOnly: false,
|
||||
sameSite: 'none',
|
||||
secure: true
|
||||
},
|
||||
secret: process.env.SESSION_SECRET,
|
||||
saveUninitialized: false, // Officially recommended setting
|
||||
resave: false // Officially recommended setting
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
You can find the code here: ./backend/src/index.ts#L32-L48
|
||||
|
||||
One can see that we're setting `httpOnly` to `false`.
|
||||
|
||||
3\. Fixing the flaw:
|
||||
Simply changing `httpOnly` to true should fix the problem.
|
||||
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
Dockerfile
|
||||
.env
|
||||
@@ -0,0 +1,10 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
[*.{js,json,yml}]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
@@ -0,0 +1,11 @@
|
||||
DATABASE_URL=
|
||||
REDIS_URL=
|
||||
SESSION_SECRET=
|
||||
API_PORT=
|
||||
FRONTEND_ORIGIN=
|
||||
BACKEND_ORIGIN=
|
||||
SMTP_HOST=
|
||||
SMTP_PORT=
|
||||
SMTP_SECURE=
|
||||
SMTP_USER=
|
||||
SMTP_PASS=
|
||||
@@ -0,0 +1,2 @@
|
||||
.env
|
||||
node_modules
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM node:24.7.0-trixie-slim
|
||||
WORKDIR /usr/src/app
|
||||
COPY . .
|
||||
RUN npm install
|
||||
CMD npm run prisma:deploy && npm run start
|
||||
@@ -0,0 +1 @@
|
||||
# Backend for WreckIt ⚒️
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
interface ProcessEnv {
|
||||
DATABASE_URL: string;
|
||||
REDIS_URL: string;
|
||||
SESSION_SECRET: string;
|
||||
API_PORT: string;
|
||||
FRONTEND_ORIGIN: string;
|
||||
BACKEND_ORIGIN: string;
|
||||
SMTP_HOST: string;
|
||||
SMTP_PORT: string;
|
||||
SMTP_SECURE: string;
|
||||
SMTP_USER: string;
|
||||
SMTP_PASS: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {}
|
||||
Generated
+5603
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "wreckit-backend",
|
||||
"scripts": {
|
||||
"dev:nodemon": "nodemon --watch . src/index.ts",
|
||||
"dev:postgres": "docker run --name postgres-dev -p 5432:5432 -e POSTGRES_PASSWORD=YWpBaqN3QvQhRHxYfhuxfv4CYzY5nKg4MjtyVKWzxFfcAtW86SPX5CUQ0sKtqa6B -d postgres:17.5-alpine3.22",
|
||||
"dev:redis": "docker run --name redis-dev -p 6379:6379 -d redis:8.2.1-alpine3.22",
|
||||
"start": "ts-node src/index.ts",
|
||||
"env:generate": "gen-env-types .env -o env.d.ts -e .",
|
||||
"prisma:generate": "prisma generate",
|
||||
"prisma:create-migration": "prisma migrate dev --create-only --migrations-path",
|
||||
"prisma:migrate": "prisma migrate dev",
|
||||
"prisma:deploy": "prisma migrate deploy"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apollo/server": "^4.10.4",
|
||||
"@prisma/client": "5.22.0",
|
||||
"argon2": "^0.40.3",
|
||||
"class-validator": "^0.14.2",
|
||||
"connect-redis": "^7.1.1",
|
||||
"cors": "^2.8.5",
|
||||
"dataloader": "^2.2.2",
|
||||
"dotenv-safe": "^9.1.0",
|
||||
"express-session": "^1.18.0",
|
||||
"graphql": "^16.9.0",
|
||||
"nodemailer": "^6.9.14",
|
||||
"redis": "^4.6.15",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"regenerator-runtime": "^0.14.1",
|
||||
"tsconfig-paths": "^4.2.0",
|
||||
"type-graphql": "^2.0.0-rc.1",
|
||||
"uuid": "^10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@prisma/generator-helper": "5.22.0",
|
||||
"@prisma/internals": "5.22.0",
|
||||
"@swc/core": "^1.12.4",
|
||||
"@swc/helpers": "^0.5.17",
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/dotenv-safe": "^8.1.6",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/express-session": "^1.18.0",
|
||||
"@types/node": "^20.14.10",
|
||||
"@types/nodemailer": "^6.4.15",
|
||||
"@types/regenerator-runtime": "^0.13.8",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"esbuild": "0.25.9",
|
||||
"gen-env-types": "^1.3.4",
|
||||
"nodemon": "^3.1.4",
|
||||
"prisma": "5.22.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"typegraphql-prisma": "^0.28.0",
|
||||
"typescript": "^5.9.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,638 @@
|
||||
import { ClassType } from "type-graphql";
|
||||
import * as tslib from "tslib";
|
||||
import * as crudResolvers from "./resolvers/crud/resolvers-crud.index";
|
||||
import * as argsTypes from "./resolvers/crud/args.index";
|
||||
import * as actionResolvers from "./resolvers/crud/resolvers-actions.index";
|
||||
import * as relationResolvers from "./resolvers/relations/resolvers.index";
|
||||
import * as models from "./models";
|
||||
import * as outputTypes from "./resolvers/outputs";
|
||||
import * as inputTypes from "./resolvers/inputs";
|
||||
|
||||
export type MethodDecoratorOverrideFn = (decorators: MethodDecorator[]) => MethodDecorator[];
|
||||
|
||||
const crudResolversMap = {
|
||||
Post: crudResolvers.PostCrudResolver,
|
||||
User: crudResolvers.UserCrudResolver,
|
||||
Upvote: crudResolvers.UpvoteCrudResolver,
|
||||
Downvote: crudResolvers.DownvoteCrudResolver,
|
||||
ResetPasswordToken: crudResolvers.ResetPasswordTokenCrudResolver
|
||||
};
|
||||
const actionResolversMap = {
|
||||
Post: {
|
||||
aggregatePost: actionResolvers.AggregatePostResolver,
|
||||
createManyPost: actionResolvers.CreateManyPostResolver,
|
||||
createManyAndReturnPost: actionResolvers.CreateManyAndReturnPostResolver,
|
||||
createOnePost: actionResolvers.CreateOnePostResolver,
|
||||
deleteManyPost: actionResolvers.DeleteManyPostResolver,
|
||||
deleteOnePost: actionResolvers.DeleteOnePostResolver,
|
||||
findFirstPost: actionResolvers.FindFirstPostResolver,
|
||||
findFirstPostOrThrow: actionResolvers.FindFirstPostOrThrowResolver,
|
||||
posts: actionResolvers.FindManyPostResolver,
|
||||
post: actionResolvers.FindUniquePostResolver,
|
||||
getPost: actionResolvers.FindUniquePostOrThrowResolver,
|
||||
groupByPost: actionResolvers.GroupByPostResolver,
|
||||
updateManyPost: actionResolvers.UpdateManyPostResolver,
|
||||
updateOnePost: actionResolvers.UpdateOnePostResolver,
|
||||
upsertOnePost: actionResolvers.UpsertOnePostResolver
|
||||
},
|
||||
User: {
|
||||
aggregateUser: actionResolvers.AggregateUserResolver,
|
||||
createManyUser: actionResolvers.CreateManyUserResolver,
|
||||
createManyAndReturnUser: actionResolvers.CreateManyAndReturnUserResolver,
|
||||
createOneUser: actionResolvers.CreateOneUserResolver,
|
||||
deleteManyUser: actionResolvers.DeleteManyUserResolver,
|
||||
deleteOneUser: actionResolvers.DeleteOneUserResolver,
|
||||
findFirstUser: actionResolvers.FindFirstUserResolver,
|
||||
findFirstUserOrThrow: actionResolvers.FindFirstUserOrThrowResolver,
|
||||
users: actionResolvers.FindManyUserResolver,
|
||||
user: actionResolvers.FindUniqueUserResolver,
|
||||
getUser: actionResolvers.FindUniqueUserOrThrowResolver,
|
||||
groupByUser: actionResolvers.GroupByUserResolver,
|
||||
updateManyUser: actionResolvers.UpdateManyUserResolver,
|
||||
updateOneUser: actionResolvers.UpdateOneUserResolver,
|
||||
upsertOneUser: actionResolvers.UpsertOneUserResolver
|
||||
},
|
||||
Upvote: {
|
||||
aggregateUpvote: actionResolvers.AggregateUpvoteResolver,
|
||||
createManyUpvote: actionResolvers.CreateManyUpvoteResolver,
|
||||
createManyAndReturnUpvote: actionResolvers.CreateManyAndReturnUpvoteResolver,
|
||||
createOneUpvote: actionResolvers.CreateOneUpvoteResolver,
|
||||
deleteManyUpvote: actionResolvers.DeleteManyUpvoteResolver,
|
||||
deleteOneUpvote: actionResolvers.DeleteOneUpvoteResolver,
|
||||
findFirstUpvote: actionResolvers.FindFirstUpvoteResolver,
|
||||
findFirstUpvoteOrThrow: actionResolvers.FindFirstUpvoteOrThrowResolver,
|
||||
upvotes: actionResolvers.FindManyUpvoteResolver,
|
||||
upvote: actionResolvers.FindUniqueUpvoteResolver,
|
||||
getUpvote: actionResolvers.FindUniqueUpvoteOrThrowResolver,
|
||||
groupByUpvote: actionResolvers.GroupByUpvoteResolver,
|
||||
updateManyUpvote: actionResolvers.UpdateManyUpvoteResolver,
|
||||
updateOneUpvote: actionResolvers.UpdateOneUpvoteResolver,
|
||||
upsertOneUpvote: actionResolvers.UpsertOneUpvoteResolver
|
||||
},
|
||||
Downvote: {
|
||||
aggregateDownvote: actionResolvers.AggregateDownvoteResolver,
|
||||
createManyDownvote: actionResolvers.CreateManyDownvoteResolver,
|
||||
createManyAndReturnDownvote: actionResolvers.CreateManyAndReturnDownvoteResolver,
|
||||
createOneDownvote: actionResolvers.CreateOneDownvoteResolver,
|
||||
deleteManyDownvote: actionResolvers.DeleteManyDownvoteResolver,
|
||||
deleteOneDownvote: actionResolvers.DeleteOneDownvoteResolver,
|
||||
findFirstDownvote: actionResolvers.FindFirstDownvoteResolver,
|
||||
findFirstDownvoteOrThrow: actionResolvers.FindFirstDownvoteOrThrowResolver,
|
||||
downvotes: actionResolvers.FindManyDownvoteResolver,
|
||||
downvote: actionResolvers.FindUniqueDownvoteResolver,
|
||||
getDownvote: actionResolvers.FindUniqueDownvoteOrThrowResolver,
|
||||
groupByDownvote: actionResolvers.GroupByDownvoteResolver,
|
||||
updateManyDownvote: actionResolvers.UpdateManyDownvoteResolver,
|
||||
updateOneDownvote: actionResolvers.UpdateOneDownvoteResolver,
|
||||
upsertOneDownvote: actionResolvers.UpsertOneDownvoteResolver
|
||||
},
|
||||
ResetPasswordToken: {
|
||||
aggregateResetPasswordToken: actionResolvers.AggregateResetPasswordTokenResolver,
|
||||
createManyResetPasswordToken: actionResolvers.CreateManyResetPasswordTokenResolver,
|
||||
createManyAndReturnResetPasswordToken: actionResolvers.CreateManyAndReturnResetPasswordTokenResolver,
|
||||
createOneResetPasswordToken: actionResolvers.CreateOneResetPasswordTokenResolver,
|
||||
deleteManyResetPasswordToken: actionResolvers.DeleteManyResetPasswordTokenResolver,
|
||||
deleteOneResetPasswordToken: actionResolvers.DeleteOneResetPasswordTokenResolver,
|
||||
findFirstResetPasswordToken: actionResolvers.FindFirstResetPasswordTokenResolver,
|
||||
findFirstResetPasswordTokenOrThrow: actionResolvers.FindFirstResetPasswordTokenOrThrowResolver,
|
||||
resetPasswordTokens: actionResolvers.FindManyResetPasswordTokenResolver,
|
||||
resetPasswordToken: actionResolvers.FindUniqueResetPasswordTokenResolver,
|
||||
getResetPasswordToken: actionResolvers.FindUniqueResetPasswordTokenOrThrowResolver,
|
||||
groupByResetPasswordToken: actionResolvers.GroupByResetPasswordTokenResolver,
|
||||
updateManyResetPasswordToken: actionResolvers.UpdateManyResetPasswordTokenResolver,
|
||||
updateOneResetPasswordToken: actionResolvers.UpdateOneResetPasswordTokenResolver,
|
||||
upsertOneResetPasswordToken: actionResolvers.UpsertOneResetPasswordTokenResolver
|
||||
}
|
||||
};
|
||||
const crudResolversInfo = {
|
||||
Post: ["aggregatePost", "createManyPost", "createManyAndReturnPost", "createOnePost", "deleteManyPost", "deleteOnePost", "findFirstPost", "findFirstPostOrThrow", "posts", "post", "getPost", "groupByPost", "updateManyPost", "updateOnePost", "upsertOnePost"],
|
||||
User: ["aggregateUser", "createManyUser", "createManyAndReturnUser", "createOneUser", "deleteManyUser", "deleteOneUser", "findFirstUser", "findFirstUserOrThrow", "users", "user", "getUser", "groupByUser", "updateManyUser", "updateOneUser", "upsertOneUser"],
|
||||
Upvote: ["aggregateUpvote", "createManyUpvote", "createManyAndReturnUpvote", "createOneUpvote", "deleteManyUpvote", "deleteOneUpvote", "findFirstUpvote", "findFirstUpvoteOrThrow", "upvotes", "upvote", "getUpvote", "groupByUpvote", "updateManyUpvote", "updateOneUpvote", "upsertOneUpvote"],
|
||||
Downvote: ["aggregateDownvote", "createManyDownvote", "createManyAndReturnDownvote", "createOneDownvote", "deleteManyDownvote", "deleteOneDownvote", "findFirstDownvote", "findFirstDownvoteOrThrow", "downvotes", "downvote", "getDownvote", "groupByDownvote", "updateManyDownvote", "updateOneDownvote", "upsertOneDownvote"],
|
||||
ResetPasswordToken: ["aggregateResetPasswordToken", "createManyResetPasswordToken", "createManyAndReturnResetPasswordToken", "createOneResetPasswordToken", "deleteManyResetPasswordToken", "deleteOneResetPasswordToken", "findFirstResetPasswordToken", "findFirstResetPasswordTokenOrThrow", "resetPasswordTokens", "resetPasswordToken", "getResetPasswordToken", "groupByResetPasswordToken", "updateManyResetPasswordToken", "updateOneResetPasswordToken", "upsertOneResetPasswordToken"]
|
||||
};
|
||||
const argsInfo = {
|
||||
AggregatePostArgs: ["where", "orderBy", "cursor", "take", "skip"],
|
||||
CreateManyPostArgs: ["data", "skipDuplicates"],
|
||||
CreateManyAndReturnPostArgs: ["data", "skipDuplicates"],
|
||||
CreateOnePostArgs: ["data"],
|
||||
DeleteManyPostArgs: ["where"],
|
||||
DeleteOnePostArgs: ["where"],
|
||||
FindFirstPostArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindFirstPostOrThrowArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindManyPostArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindUniquePostArgs: ["where"],
|
||||
FindUniquePostOrThrowArgs: ["where"],
|
||||
GroupByPostArgs: ["where", "orderBy", "by", "having", "take", "skip"],
|
||||
UpdateManyPostArgs: ["data", "where"],
|
||||
UpdateOnePostArgs: ["data", "where"],
|
||||
UpsertOnePostArgs: ["where", "create", "update"],
|
||||
AggregateUserArgs: ["where", "orderBy", "cursor", "take", "skip"],
|
||||
CreateManyUserArgs: ["data", "skipDuplicates"],
|
||||
CreateManyAndReturnUserArgs: ["data", "skipDuplicates"],
|
||||
CreateOneUserArgs: ["data"],
|
||||
DeleteManyUserArgs: ["where"],
|
||||
DeleteOneUserArgs: ["where"],
|
||||
FindFirstUserArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindFirstUserOrThrowArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindManyUserArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindUniqueUserArgs: ["where"],
|
||||
FindUniqueUserOrThrowArgs: ["where"],
|
||||
GroupByUserArgs: ["where", "orderBy", "by", "having", "take", "skip"],
|
||||
UpdateManyUserArgs: ["data", "where"],
|
||||
UpdateOneUserArgs: ["data", "where"],
|
||||
UpsertOneUserArgs: ["where", "create", "update"],
|
||||
AggregateUpvoteArgs: ["where", "orderBy", "cursor", "take", "skip"],
|
||||
CreateManyUpvoteArgs: ["data", "skipDuplicates"],
|
||||
CreateManyAndReturnUpvoteArgs: ["data", "skipDuplicates"],
|
||||
CreateOneUpvoteArgs: ["data"],
|
||||
DeleteManyUpvoteArgs: ["where"],
|
||||
DeleteOneUpvoteArgs: ["where"],
|
||||
FindFirstUpvoteArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindFirstUpvoteOrThrowArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindManyUpvoteArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindUniqueUpvoteArgs: ["where"],
|
||||
FindUniqueUpvoteOrThrowArgs: ["where"],
|
||||
GroupByUpvoteArgs: ["where", "orderBy", "by", "having", "take", "skip"],
|
||||
UpdateManyUpvoteArgs: ["data", "where"],
|
||||
UpdateOneUpvoteArgs: ["data", "where"],
|
||||
UpsertOneUpvoteArgs: ["where", "create", "update"],
|
||||
AggregateDownvoteArgs: ["where", "orderBy", "cursor", "take", "skip"],
|
||||
CreateManyDownvoteArgs: ["data", "skipDuplicates"],
|
||||
CreateManyAndReturnDownvoteArgs: ["data", "skipDuplicates"],
|
||||
CreateOneDownvoteArgs: ["data"],
|
||||
DeleteManyDownvoteArgs: ["where"],
|
||||
DeleteOneDownvoteArgs: ["where"],
|
||||
FindFirstDownvoteArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindFirstDownvoteOrThrowArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindManyDownvoteArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindUniqueDownvoteArgs: ["where"],
|
||||
FindUniqueDownvoteOrThrowArgs: ["where"],
|
||||
GroupByDownvoteArgs: ["where", "orderBy", "by", "having", "take", "skip"],
|
||||
UpdateManyDownvoteArgs: ["data", "where"],
|
||||
UpdateOneDownvoteArgs: ["data", "where"],
|
||||
UpsertOneDownvoteArgs: ["where", "create", "update"],
|
||||
AggregateResetPasswordTokenArgs: ["where", "orderBy", "cursor", "take", "skip"],
|
||||
CreateManyResetPasswordTokenArgs: ["data", "skipDuplicates"],
|
||||
CreateManyAndReturnResetPasswordTokenArgs: ["data", "skipDuplicates"],
|
||||
CreateOneResetPasswordTokenArgs: ["data"],
|
||||
DeleteManyResetPasswordTokenArgs: ["where"],
|
||||
DeleteOneResetPasswordTokenArgs: ["where"],
|
||||
FindFirstResetPasswordTokenArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindFirstResetPasswordTokenOrThrowArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindManyResetPasswordTokenArgs: ["where", "orderBy", "cursor", "take", "skip", "distinct"],
|
||||
FindUniqueResetPasswordTokenArgs: ["where"],
|
||||
FindUniqueResetPasswordTokenOrThrowArgs: ["where"],
|
||||
GroupByResetPasswordTokenArgs: ["where", "orderBy", "by", "having", "take", "skip"],
|
||||
UpdateManyResetPasswordTokenArgs: ["data", "where"],
|
||||
UpdateOneResetPasswordTokenArgs: ["data", "where"],
|
||||
UpsertOneResetPasswordTokenArgs: ["where", "create", "update"]
|
||||
};
|
||||
|
||||
type ResolverModelNames = keyof typeof crudResolversMap;
|
||||
|
||||
type ModelResolverActionNames<
|
||||
TModel extends ResolverModelNames
|
||||
> = keyof typeof crudResolversMap[TModel]["prototype"];
|
||||
|
||||
export type ResolverActionsConfig<
|
||||
TModel extends ResolverModelNames
|
||||
> = Partial<Record<ModelResolverActionNames<TModel>, MethodDecorator[] | MethodDecoratorOverrideFn>>
|
||||
& {
|
||||
_all?: MethodDecorator[];
|
||||
_query?: MethodDecorator[];
|
||||
_mutation?: MethodDecorator[];
|
||||
};
|
||||
|
||||
export type ResolversEnhanceMap = {
|
||||
[TModel in ResolverModelNames]?: ResolverActionsConfig<TModel>;
|
||||
};
|
||||
|
||||
export function applyResolversEnhanceMap(
|
||||
resolversEnhanceMap: ResolversEnhanceMap,
|
||||
) {
|
||||
const mutationOperationPrefixes = [
|
||||
"createOne", "createMany", "createManyAndReturn", "deleteOne", "updateOne", "deleteMany", "updateMany", "upsertOne"
|
||||
];
|
||||
for (const resolversEnhanceMapKey of Object.keys(resolversEnhanceMap)) {
|
||||
const modelName = resolversEnhanceMapKey as keyof typeof resolversEnhanceMap;
|
||||
const crudTarget = crudResolversMap[modelName].prototype;
|
||||
const resolverActionsConfig = resolversEnhanceMap[modelName]!;
|
||||
const actionResolversConfig = actionResolversMap[modelName];
|
||||
const allActionsDecorators = resolverActionsConfig._all;
|
||||
const resolverActionNames = crudResolversInfo[modelName as keyof typeof crudResolversInfo];
|
||||
for (const resolverActionName of resolverActionNames) {
|
||||
const maybeDecoratorsOrFn = resolverActionsConfig[
|
||||
resolverActionName as keyof typeof resolverActionsConfig
|
||||
] as MethodDecorator[] | MethodDecoratorOverrideFn | undefined;
|
||||
const isWriteOperation = mutationOperationPrefixes.some(prefix => resolverActionName.startsWith(prefix));
|
||||
const operationKindDecorators = isWriteOperation ? resolverActionsConfig._mutation : resolverActionsConfig._query;
|
||||
const mainDecorators = [
|
||||
...allActionsDecorators ?? [],
|
||||
...operationKindDecorators ?? [],
|
||||
]
|
||||
let decorators: MethodDecorator[];
|
||||
if (typeof maybeDecoratorsOrFn === "function") {
|
||||
decorators = maybeDecoratorsOrFn(mainDecorators);
|
||||
} else {
|
||||
decorators = [...mainDecorators, ...maybeDecoratorsOrFn ?? []];
|
||||
}
|
||||
const actionTarget = (actionResolversConfig[
|
||||
resolverActionName as keyof typeof actionResolversConfig
|
||||
] as Function).prototype;
|
||||
tslib.__decorate(decorators, crudTarget, resolverActionName, null);
|
||||
tslib.__decorate(decorators, actionTarget, resolverActionName, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type ArgsTypesNames = keyof typeof argsTypes;
|
||||
|
||||
type ArgFieldNames<TArgsType extends ArgsTypesNames> = Exclude<
|
||||
keyof typeof argsTypes[TArgsType]["prototype"],
|
||||
number | symbol
|
||||
>;
|
||||
|
||||
type ArgFieldsConfig<
|
||||
TArgsType extends ArgsTypesNames
|
||||
> = FieldsConfig<ArgFieldNames<TArgsType>>;
|
||||
|
||||
export type ArgConfig<TArgsType extends ArgsTypesNames> = {
|
||||
class?: ClassDecorator[];
|
||||
fields?: ArgFieldsConfig<TArgsType>;
|
||||
};
|
||||
|
||||
export type ArgsTypesEnhanceMap = {
|
||||
[TArgsType in ArgsTypesNames]?: ArgConfig<TArgsType>;
|
||||
};
|
||||
|
||||
export function applyArgsTypesEnhanceMap(
|
||||
argsTypesEnhanceMap: ArgsTypesEnhanceMap,
|
||||
) {
|
||||
for (const argsTypesEnhanceMapKey of Object.keys(argsTypesEnhanceMap)) {
|
||||
const argsTypeName = argsTypesEnhanceMapKey as keyof typeof argsTypesEnhanceMap;
|
||||
const typeConfig = argsTypesEnhanceMap[argsTypeName]!;
|
||||
const typeClass = argsTypes[argsTypeName];
|
||||
const typeTarget = typeClass.prototype;
|
||||
applyTypeClassEnhanceConfig(
|
||||
typeConfig,
|
||||
typeClass,
|
||||
typeTarget,
|
||||
argsInfo[argsTypeName as keyof typeof argsInfo],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const relationResolversMap = {
|
||||
Post: relationResolvers.PostRelationsResolver,
|
||||
User: relationResolvers.UserRelationsResolver
|
||||
};
|
||||
const relationResolversInfo = {
|
||||
Post: ["author"],
|
||||
User: ["Posts"]
|
||||
};
|
||||
|
||||
type RelationResolverModelNames = keyof typeof relationResolversMap;
|
||||
|
||||
type RelationResolverActionNames<
|
||||
TModel extends RelationResolverModelNames
|
||||
> = keyof typeof relationResolversMap[TModel]["prototype"];
|
||||
|
||||
export type RelationResolverActionsConfig<TModel extends RelationResolverModelNames>
|
||||
= Partial<Record<RelationResolverActionNames<TModel>, MethodDecorator[] | MethodDecoratorOverrideFn>>
|
||||
& { _all?: MethodDecorator[] };
|
||||
|
||||
export type RelationResolversEnhanceMap = {
|
||||
[TModel in RelationResolverModelNames]?: RelationResolverActionsConfig<TModel>;
|
||||
};
|
||||
|
||||
export function applyRelationResolversEnhanceMap(
|
||||
relationResolversEnhanceMap: RelationResolversEnhanceMap,
|
||||
) {
|
||||
for (const relationResolversEnhanceMapKey of Object.keys(relationResolversEnhanceMap)) {
|
||||
const modelName = relationResolversEnhanceMapKey as keyof typeof relationResolversEnhanceMap;
|
||||
const relationResolverTarget = relationResolversMap[modelName].prototype;
|
||||
const relationResolverActionsConfig = relationResolversEnhanceMap[modelName]!;
|
||||
const allActionsDecorators = relationResolverActionsConfig._all ?? [];
|
||||
const relationResolverActionNames = relationResolversInfo[modelName as keyof typeof relationResolversInfo];
|
||||
for (const relationResolverActionName of relationResolverActionNames) {
|
||||
const maybeDecoratorsOrFn = relationResolverActionsConfig[
|
||||
relationResolverActionName as keyof typeof relationResolverActionsConfig
|
||||
] as MethodDecorator[] | MethodDecoratorOverrideFn | undefined;
|
||||
let decorators: MethodDecorator[];
|
||||
if (typeof maybeDecoratorsOrFn === "function") {
|
||||
decorators = maybeDecoratorsOrFn(allActionsDecorators);
|
||||
} else {
|
||||
decorators = [...allActionsDecorators, ...maybeDecoratorsOrFn ?? []];
|
||||
}
|
||||
tslib.__decorate(decorators, relationResolverTarget, relationResolverActionName, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type TypeConfig = {
|
||||
class?: ClassDecorator[];
|
||||
fields?: FieldsConfig;
|
||||
};
|
||||
|
||||
export type PropertyDecoratorOverrideFn = (decorators: PropertyDecorator[]) => PropertyDecorator[];
|
||||
|
||||
type FieldsConfig<TTypeKeys extends string = string> = Partial<
|
||||
Record<TTypeKeys, PropertyDecorator[] | PropertyDecoratorOverrideFn>
|
||||
> & { _all?: PropertyDecorator[] };
|
||||
|
||||
function applyTypeClassEnhanceConfig<
|
||||
TEnhanceConfig extends TypeConfig,
|
||||
TType extends object
|
||||
>(
|
||||
enhanceConfig: TEnhanceConfig,
|
||||
typeClass: ClassType<TType>,
|
||||
typePrototype: TType,
|
||||
typeFieldNames: string[]
|
||||
) {
|
||||
if (enhanceConfig.class) {
|
||||
tslib.__decorate(enhanceConfig.class, typeClass);
|
||||
}
|
||||
if (enhanceConfig.fields) {
|
||||
const allFieldsDecorators = enhanceConfig.fields._all ?? [];
|
||||
for (const typeFieldName of typeFieldNames) {
|
||||
const maybeDecoratorsOrFn = enhanceConfig.fields[
|
||||
typeFieldName
|
||||
] as PropertyDecorator[] | PropertyDecoratorOverrideFn | undefined;
|
||||
let decorators: PropertyDecorator[];
|
||||
if (typeof maybeDecoratorsOrFn === "function") {
|
||||
decorators = maybeDecoratorsOrFn(allFieldsDecorators);
|
||||
} else {
|
||||
decorators = [...allFieldsDecorators, ...maybeDecoratorsOrFn ?? []];
|
||||
}
|
||||
tslib.__decorate(decorators, typePrototype, typeFieldName, void 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const modelsInfo = {
|
||||
Post: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points"],
|
||||
User: ["id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
Upvote: ["userID", "postID"],
|
||||
Downvote: ["userID", "postID"],
|
||||
ResetPasswordToken: ["id", "userID", "value"]
|
||||
};
|
||||
|
||||
type ModelNames = keyof typeof models;
|
||||
|
||||
type ModelFieldNames<TModel extends ModelNames> = Exclude<
|
||||
keyof typeof models[TModel]["prototype"],
|
||||
number | symbol
|
||||
>;
|
||||
|
||||
type ModelFieldsConfig<TModel extends ModelNames> = FieldsConfig<
|
||||
ModelFieldNames<TModel>
|
||||
>;
|
||||
|
||||
export type ModelConfig<TModel extends ModelNames> = {
|
||||
class?: ClassDecorator[];
|
||||
fields?: ModelFieldsConfig<TModel>;
|
||||
};
|
||||
|
||||
export type ModelsEnhanceMap = {
|
||||
[TModel in ModelNames]?: ModelConfig<TModel>;
|
||||
};
|
||||
|
||||
export function applyModelsEnhanceMap(modelsEnhanceMap: ModelsEnhanceMap) {
|
||||
for (const modelsEnhanceMapKey of Object.keys(modelsEnhanceMap)) {
|
||||
const modelName = modelsEnhanceMapKey as keyof typeof modelsEnhanceMap;
|
||||
const modelConfig = modelsEnhanceMap[modelName]!;
|
||||
const modelClass = models[modelName];
|
||||
const modelTarget = modelClass.prototype;
|
||||
applyTypeClassEnhanceConfig(
|
||||
modelConfig,
|
||||
modelClass,
|
||||
modelTarget,
|
||||
modelsInfo[modelName as keyof typeof modelsInfo],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const outputsInfo = {
|
||||
AggregatePost: ["_count", "_avg", "_sum", "_min", "_max"],
|
||||
PostGroupBy: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points", "_count", "_avg", "_sum", "_min", "_max"],
|
||||
AggregateUser: ["_count", "_min", "_max"],
|
||||
UserGroupBy: ["id", "createdAt", "updatedAt", "username", "password", "email", "_count", "_min", "_max"],
|
||||
AggregateUpvote: ["_count", "_min", "_max"],
|
||||
UpvoteGroupBy: ["userID", "postID", "_count", "_min", "_max"],
|
||||
AggregateDownvote: ["_count", "_min", "_max"],
|
||||
DownvoteGroupBy: ["userID", "postID", "_count", "_min", "_max"],
|
||||
AggregateResetPasswordToken: ["_count", "_min", "_max"],
|
||||
ResetPasswordTokenGroupBy: ["id", "userID", "value", "_count", "_min", "_max"],
|
||||
AffectedRowsOutput: ["count"],
|
||||
PostCountAggregate: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points", "_all"],
|
||||
PostAvgAggregate: ["points"],
|
||||
PostSumAggregate: ["points"],
|
||||
PostMinAggregate: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points"],
|
||||
PostMaxAggregate: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points"],
|
||||
UserCount: ["Posts"],
|
||||
UserCountAggregate: ["id", "createdAt", "updatedAt", "username", "password", "email", "_all"],
|
||||
UserMinAggregate: ["id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
UserMaxAggregate: ["id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
UpvoteCountAggregate: ["userID", "postID", "_all"],
|
||||
UpvoteMinAggregate: ["userID", "postID"],
|
||||
UpvoteMaxAggregate: ["userID", "postID"],
|
||||
DownvoteCountAggregate: ["userID", "postID", "_all"],
|
||||
DownvoteMinAggregate: ["userID", "postID"],
|
||||
DownvoteMaxAggregate: ["userID", "postID"],
|
||||
ResetPasswordTokenCountAggregate: ["id", "userID", "value", "_all"],
|
||||
ResetPasswordTokenMinAggregate: ["id", "userID", "value"],
|
||||
ResetPasswordTokenMaxAggregate: ["id", "userID", "value"],
|
||||
CreateManyAndReturnPost: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points", "author"],
|
||||
CreateManyAndReturnUser: ["id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
CreateManyAndReturnUpvote: ["userID", "postID"],
|
||||
CreateManyAndReturnDownvote: ["userID", "postID"],
|
||||
CreateManyAndReturnResetPasswordToken: ["id", "userID", "value"]
|
||||
};
|
||||
|
||||
type OutputTypesNames = keyof typeof outputTypes;
|
||||
|
||||
type OutputTypeFieldNames<TOutput extends OutputTypesNames> = Exclude<
|
||||
keyof typeof outputTypes[TOutput]["prototype"],
|
||||
number | symbol
|
||||
>;
|
||||
|
||||
type OutputTypeFieldsConfig<
|
||||
TOutput extends OutputTypesNames
|
||||
> = FieldsConfig<OutputTypeFieldNames<TOutput>>;
|
||||
|
||||
export type OutputTypeConfig<TOutput extends OutputTypesNames> = {
|
||||
class?: ClassDecorator[];
|
||||
fields?: OutputTypeFieldsConfig<TOutput>;
|
||||
};
|
||||
|
||||
export type OutputTypesEnhanceMap = {
|
||||
[TOutput in OutputTypesNames]?: OutputTypeConfig<TOutput>;
|
||||
};
|
||||
|
||||
export function applyOutputTypesEnhanceMap(
|
||||
outputTypesEnhanceMap: OutputTypesEnhanceMap,
|
||||
) {
|
||||
for (const outputTypeEnhanceMapKey of Object.keys(outputTypesEnhanceMap)) {
|
||||
const outputTypeName = outputTypeEnhanceMapKey as keyof typeof outputTypesEnhanceMap;
|
||||
const typeConfig = outputTypesEnhanceMap[outputTypeName]!;
|
||||
const typeClass = outputTypes[outputTypeName];
|
||||
const typeTarget = typeClass.prototype;
|
||||
applyTypeClassEnhanceConfig(
|
||||
typeConfig,
|
||||
typeClass,
|
||||
typeTarget,
|
||||
outputsInfo[outputTypeName as keyof typeof outputsInfo],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const inputsInfo = {
|
||||
PostWhereInput: ["AND", "OR", "NOT", "id", "createdAt", "updatedAt", "title", "content", "authorID", "points", "author"],
|
||||
PostOrderByWithRelationInput: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points", "author"],
|
||||
PostWhereUniqueInput: ["id", "createdAt", "updatedAt", "AND", "OR", "NOT", "title", "content", "authorID", "points", "author"],
|
||||
PostOrderByWithAggregationInput: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points", "_count", "_avg", "_max", "_min", "_sum"],
|
||||
PostScalarWhereWithAggregatesInput: ["AND", "OR", "NOT", "id", "createdAt", "updatedAt", "title", "content", "authorID", "points"],
|
||||
UserWhereInput: ["AND", "OR", "NOT", "id", "createdAt", "updatedAt", "username", "password", "email", "Posts"],
|
||||
UserOrderByWithRelationInput: ["id", "createdAt", "updatedAt", "username", "password", "email", "Posts"],
|
||||
UserWhereUniqueInput: ["id", "username", "email", "AND", "OR", "NOT", "createdAt", "updatedAt", "password", "Posts"],
|
||||
UserOrderByWithAggregationInput: ["id", "createdAt", "updatedAt", "username", "password", "email", "_count", "_max", "_min"],
|
||||
UserScalarWhereWithAggregatesInput: ["AND", "OR", "NOT", "id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
UpvoteWhereInput: ["AND", "OR", "NOT", "userID", "postID"],
|
||||
UpvoteOrderByWithRelationInput: ["userID", "postID"],
|
||||
UpvoteWhereUniqueInput: ["userID_postID", "AND", "OR", "NOT", "userID", "postID"],
|
||||
UpvoteOrderByWithAggregationInput: ["userID", "postID", "_count", "_max", "_min"],
|
||||
UpvoteScalarWhereWithAggregatesInput: ["AND", "OR", "NOT", "userID", "postID"],
|
||||
DownvoteWhereInput: ["AND", "OR", "NOT", "userID", "postID"],
|
||||
DownvoteOrderByWithRelationInput: ["userID", "postID"],
|
||||
DownvoteWhereUniqueInput: ["userID_postID", "AND", "OR", "NOT", "userID", "postID"],
|
||||
DownvoteOrderByWithAggregationInput: ["userID", "postID", "_count", "_max", "_min"],
|
||||
DownvoteScalarWhereWithAggregatesInput: ["AND", "OR", "NOT", "userID", "postID"],
|
||||
ResetPasswordTokenWhereInput: ["AND", "OR", "NOT", "id", "userID", "value"],
|
||||
ResetPasswordTokenOrderByWithRelationInput: ["id", "userID", "value"],
|
||||
ResetPasswordTokenWhereUniqueInput: ["id", "value", "userID_value", "AND", "OR", "NOT", "userID"],
|
||||
ResetPasswordTokenOrderByWithAggregationInput: ["id", "userID", "value", "_count", "_max", "_min"],
|
||||
ResetPasswordTokenScalarWhereWithAggregatesInput: ["AND", "OR", "NOT", "id", "userID", "value"],
|
||||
PostCreateInput: ["id", "createdAt", "updatedAt", "title", "content", "points", "author"],
|
||||
PostUpdateInput: ["id", "createdAt", "updatedAt", "title", "content", "points", "author"],
|
||||
PostCreateManyInput: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points"],
|
||||
PostUpdateManyMutationInput: ["id", "createdAt", "updatedAt", "title", "content", "points"],
|
||||
UserCreateInput: ["id", "createdAt", "updatedAt", "username", "password", "email", "Posts"],
|
||||
UserUpdateInput: ["id", "createdAt", "updatedAt", "username", "password", "email", "Posts"],
|
||||
UserCreateManyInput: ["id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
UserUpdateManyMutationInput: ["id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
UpvoteCreateInput: ["userID", "postID"],
|
||||
UpvoteUpdateInput: ["userID", "postID"],
|
||||
UpvoteCreateManyInput: ["userID", "postID"],
|
||||
UpvoteUpdateManyMutationInput: ["userID", "postID"],
|
||||
DownvoteCreateInput: ["userID", "postID"],
|
||||
DownvoteUpdateInput: ["userID", "postID"],
|
||||
DownvoteCreateManyInput: ["userID", "postID"],
|
||||
DownvoteUpdateManyMutationInput: ["userID", "postID"],
|
||||
ResetPasswordTokenCreateInput: ["id", "userID", "value"],
|
||||
ResetPasswordTokenUpdateInput: ["id", "userID", "value"],
|
||||
ResetPasswordTokenCreateManyInput: ["id", "userID", "value"],
|
||||
ResetPasswordTokenUpdateManyMutationInput: ["id", "userID", "value"],
|
||||
StringFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "contains", "startsWith", "endsWith", "mode", "not"],
|
||||
DateTimeFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "not"],
|
||||
StringNullableFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "contains", "startsWith", "endsWith", "mode", "not"],
|
||||
IntFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "not"],
|
||||
UserRelationFilter: ["is", "isNot"],
|
||||
SortOrderInput: ["sort", "nulls"],
|
||||
PostCountOrderByAggregateInput: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points"],
|
||||
PostAvgOrderByAggregateInput: ["points"],
|
||||
PostMaxOrderByAggregateInput: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points"],
|
||||
PostMinOrderByAggregateInput: ["id", "createdAt", "updatedAt", "title", "content", "authorID", "points"],
|
||||
PostSumOrderByAggregateInput: ["points"],
|
||||
StringWithAggregatesFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "contains", "startsWith", "endsWith", "mode", "not", "_count", "_min", "_max"],
|
||||
DateTimeWithAggregatesFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "not", "_count", "_min", "_max"],
|
||||
StringNullableWithAggregatesFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "contains", "startsWith", "endsWith", "mode", "not", "_count", "_min", "_max"],
|
||||
IntWithAggregatesFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "not", "_count", "_avg", "_sum", "_min", "_max"],
|
||||
PostListRelationFilter: ["every", "some", "none"],
|
||||
PostOrderByRelationAggregateInput: ["_count"],
|
||||
UserCountOrderByAggregateInput: ["id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
UserMaxOrderByAggregateInput: ["id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
UserMinOrderByAggregateInput: ["id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
UpvoteUserIDPostIDCompoundUniqueInput: ["userID", "postID"],
|
||||
UpvoteCountOrderByAggregateInput: ["userID", "postID"],
|
||||
UpvoteMaxOrderByAggregateInput: ["userID", "postID"],
|
||||
UpvoteMinOrderByAggregateInput: ["userID", "postID"],
|
||||
DownvoteUserIDPostIDCompoundUniqueInput: ["userID", "postID"],
|
||||
DownvoteCountOrderByAggregateInput: ["userID", "postID"],
|
||||
DownvoteMaxOrderByAggregateInput: ["userID", "postID"],
|
||||
DownvoteMinOrderByAggregateInput: ["userID", "postID"],
|
||||
ResetPasswordTokenUserIDValueCompoundUniqueInput: ["userID", "value"],
|
||||
ResetPasswordTokenCountOrderByAggregateInput: ["id", "userID", "value"],
|
||||
ResetPasswordTokenMaxOrderByAggregateInput: ["id", "userID", "value"],
|
||||
ResetPasswordTokenMinOrderByAggregateInput: ["id", "userID", "value"],
|
||||
UserCreateNestedOneWithoutPostsInput: ["create", "connectOrCreate", "connect"],
|
||||
StringFieldUpdateOperationsInput: ["set"],
|
||||
DateTimeFieldUpdateOperationsInput: ["set"],
|
||||
NullableStringFieldUpdateOperationsInput: ["set"],
|
||||
IntFieldUpdateOperationsInput: ["set", "increment", "decrement", "multiply", "divide"],
|
||||
UserUpdateOneRequiredWithoutPostsNestedInput: ["create", "connectOrCreate", "upsert", "connect", "update"],
|
||||
PostCreateNestedManyWithoutAuthorInput: ["create", "connectOrCreate", "createMany", "connect"],
|
||||
PostUpdateManyWithoutAuthorNestedInput: ["create", "connectOrCreate", "upsert", "createMany", "set", "disconnect", "delete", "connect", "update", "updateMany", "deleteMany"],
|
||||
NestedStringFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "contains", "startsWith", "endsWith", "not"],
|
||||
NestedDateTimeFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "not"],
|
||||
NestedStringNullableFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "contains", "startsWith", "endsWith", "not"],
|
||||
NestedIntFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "not"],
|
||||
NestedStringWithAggregatesFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "contains", "startsWith", "endsWith", "not", "_count", "_min", "_max"],
|
||||
NestedDateTimeWithAggregatesFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "not", "_count", "_min", "_max"],
|
||||
NestedStringNullableWithAggregatesFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "contains", "startsWith", "endsWith", "not", "_count", "_min", "_max"],
|
||||
NestedIntNullableFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "not"],
|
||||
NestedIntWithAggregatesFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "not", "_count", "_avg", "_sum", "_min", "_max"],
|
||||
NestedFloatFilter: ["equals", "in", "notIn", "lt", "lte", "gt", "gte", "not"],
|
||||
UserCreateWithoutPostsInput: ["id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
UserCreateOrConnectWithoutPostsInput: ["where", "create"],
|
||||
UserUpsertWithoutPostsInput: ["update", "create", "where"],
|
||||
UserUpdateToOneWithWhereWithoutPostsInput: ["where", "data"],
|
||||
UserUpdateWithoutPostsInput: ["id", "createdAt", "updatedAt", "username", "password", "email"],
|
||||
PostCreateWithoutAuthorInput: ["id", "createdAt", "updatedAt", "title", "content", "points"],
|
||||
PostCreateOrConnectWithoutAuthorInput: ["where", "create"],
|
||||
PostCreateManyAuthorInputEnvelope: ["data", "skipDuplicates"],
|
||||
PostUpsertWithWhereUniqueWithoutAuthorInput: ["where", "update", "create"],
|
||||
PostUpdateWithWhereUniqueWithoutAuthorInput: ["where", "data"],
|
||||
PostUpdateManyWithWhereWithoutAuthorInput: ["where", "data"],
|
||||
PostScalarWhereInput: ["AND", "OR", "NOT", "id", "createdAt", "updatedAt", "title", "content", "authorID", "points"],
|
||||
PostCreateManyAuthorInput: ["id", "createdAt", "updatedAt", "title", "content", "points"],
|
||||
PostUpdateWithoutAuthorInput: ["id", "createdAt", "updatedAt", "title", "content", "points"]
|
||||
};
|
||||
|
||||
type InputTypesNames = keyof typeof inputTypes;
|
||||
|
||||
type InputTypeFieldNames<TInput extends InputTypesNames> = Exclude<
|
||||
keyof typeof inputTypes[TInput]["prototype"],
|
||||
number | symbol
|
||||
>;
|
||||
|
||||
type InputTypeFieldsConfig<
|
||||
TInput extends InputTypesNames
|
||||
> = FieldsConfig<InputTypeFieldNames<TInput>>;
|
||||
|
||||
export type InputTypeConfig<TInput extends InputTypesNames> = {
|
||||
class?: ClassDecorator[];
|
||||
fields?: InputTypeFieldsConfig<TInput>;
|
||||
};
|
||||
|
||||
export type InputTypesEnhanceMap = {
|
||||
[TInput in InputTypesNames]?: InputTypeConfig<TInput>;
|
||||
};
|
||||
|
||||
export function applyInputTypesEnhanceMap(
|
||||
inputTypesEnhanceMap: InputTypesEnhanceMap,
|
||||
) {
|
||||
for (const inputTypeEnhanceMapKey of Object.keys(inputTypesEnhanceMap)) {
|
||||
const inputTypeName = inputTypeEnhanceMapKey as keyof typeof inputTypesEnhanceMap;
|
||||
const typeConfig = inputTypesEnhanceMap[inputTypeName]!;
|
||||
const typeClass = inputTypes[inputTypeName];
|
||||
const typeTarget = typeClass.prototype;
|
||||
applyTypeClassEnhanceConfig(
|
||||
typeConfig,
|
||||
typeClass,
|
||||
typeTarget,
|
||||
inputsInfo[inputTypeName as keyof typeof inputsInfo],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
|
||||
export enum DownvoteScalarFieldEnum {
|
||||
userID = "userID",
|
||||
postID = "postID"
|
||||
}
|
||||
TypeGraphQL.registerEnumType(DownvoteScalarFieldEnum, {
|
||||
name: "DownvoteScalarFieldEnum",
|
||||
description: undefined,
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
|
||||
export enum NullsOrder {
|
||||
first = "first",
|
||||
last = "last"
|
||||
}
|
||||
TypeGraphQL.registerEnumType(NullsOrder, {
|
||||
name: "NullsOrder",
|
||||
description: undefined,
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
|
||||
export enum PostScalarFieldEnum {
|
||||
id = "id",
|
||||
createdAt = "createdAt",
|
||||
updatedAt = "updatedAt",
|
||||
title = "title",
|
||||
content = "content",
|
||||
authorID = "authorID",
|
||||
points = "points"
|
||||
}
|
||||
TypeGraphQL.registerEnumType(PostScalarFieldEnum, {
|
||||
name: "PostScalarFieldEnum",
|
||||
description: undefined,
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
|
||||
export enum QueryMode {
|
||||
"default" = "default",
|
||||
insensitive = "insensitive"
|
||||
}
|
||||
TypeGraphQL.registerEnumType(QueryMode, {
|
||||
name: "QueryMode",
|
||||
description: undefined,
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
|
||||
export enum ResetPasswordTokenScalarFieldEnum {
|
||||
id = "id",
|
||||
userID = "userID",
|
||||
value = "value"
|
||||
}
|
||||
TypeGraphQL.registerEnumType(ResetPasswordTokenScalarFieldEnum, {
|
||||
name: "ResetPasswordTokenScalarFieldEnum",
|
||||
description: undefined,
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
|
||||
export enum SortOrder {
|
||||
asc = "asc",
|
||||
desc = "desc"
|
||||
}
|
||||
TypeGraphQL.registerEnumType(SortOrder, {
|
||||
name: "SortOrder",
|
||||
description: undefined,
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
|
||||
export enum TransactionIsolationLevel {
|
||||
ReadUncommitted = "ReadUncommitted",
|
||||
ReadCommitted = "ReadCommitted",
|
||||
RepeatableRead = "RepeatableRead",
|
||||
Serializable = "Serializable"
|
||||
}
|
||||
TypeGraphQL.registerEnumType(TransactionIsolationLevel, {
|
||||
name: "TransactionIsolationLevel",
|
||||
description: undefined,
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
|
||||
export enum UpvoteScalarFieldEnum {
|
||||
userID = "userID",
|
||||
postID = "postID"
|
||||
}
|
||||
TypeGraphQL.registerEnumType(UpvoteScalarFieldEnum, {
|
||||
name: "UpvoteScalarFieldEnum",
|
||||
description: undefined,
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
|
||||
export enum UserScalarFieldEnum {
|
||||
id = "id",
|
||||
createdAt = "createdAt",
|
||||
updatedAt = "updatedAt",
|
||||
username = "username",
|
||||
password = "password",
|
||||
email = "email"
|
||||
}
|
||||
TypeGraphQL.registerEnumType(UserScalarFieldEnum, {
|
||||
name: "UserScalarFieldEnum",
|
||||
description: undefined,
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
export { DownvoteScalarFieldEnum } from "./DownvoteScalarFieldEnum";
|
||||
export { NullsOrder } from "./NullsOrder";
|
||||
export { PostScalarFieldEnum } from "./PostScalarFieldEnum";
|
||||
export { QueryMode } from "./QueryMode";
|
||||
export { ResetPasswordTokenScalarFieldEnum } from "./ResetPasswordTokenScalarFieldEnum";
|
||||
export { SortOrder } from "./SortOrder";
|
||||
export { TransactionIsolationLevel } from "./TransactionIsolationLevel";
|
||||
export { UpvoteScalarFieldEnum } from "./UpvoteScalarFieldEnum";
|
||||
export { UserScalarFieldEnum } from "./UserScalarFieldEnum";
|
||||
@@ -0,0 +1,61 @@
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import graphqlFields from "graphql-fields";
|
||||
|
||||
export function transformInfoIntoPrismaArgs(info: GraphQLResolveInfo): Record<string, any> {
|
||||
const fields: Record<string, any> = graphqlFields(
|
||||
// suppress GraphQLResolveInfo types issue
|
||||
info as any,
|
||||
{},
|
||||
{
|
||||
excludedFields: ['__typename'],
|
||||
processArguments: true,
|
||||
}
|
||||
);
|
||||
return transformFields(fields);
|
||||
}
|
||||
|
||||
function transformFields(fields: Record<string, any>): Record<string, any> {
|
||||
return Object.fromEntries(
|
||||
Object.entries(fields)
|
||||
.map<[string, any]>(([key, value]) => {
|
||||
if (Object.keys(value).length === 0) {
|
||||
return [key, true];
|
||||
}
|
||||
if ("__arguments" in value) {
|
||||
return [key, Object.fromEntries(
|
||||
value.__arguments.map((argument: object) => {
|
||||
const [[key, { value }]] = Object.entries(argument);
|
||||
return [key, value];
|
||||
})
|
||||
)];
|
||||
}
|
||||
return [key, transformFields(value)];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function getPrismaFromContext(context: any) {
|
||||
const prismaClient = context["prisma"];
|
||||
if (!prismaClient) {
|
||||
throw new Error("Unable to find Prisma Client in GraphQL context. Please provide it under the `context[\"prisma\"]` key.");
|
||||
}
|
||||
return prismaClient;
|
||||
}
|
||||
|
||||
export function transformCountFieldIntoSelectRelationsCount(_count: object) {
|
||||
return {
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
...Object.fromEntries(
|
||||
Object.entries(_count).filter(([_, v]) => v != null)
|
||||
),
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import * as crudResolversImport from "./resolvers/crud/resolvers-crud.index";
|
||||
import * as relationResolversImport from "./resolvers/relations/resolvers.index";
|
||||
import { NonEmptyArray } from "type-graphql";
|
||||
|
||||
export * from "./enums";
|
||||
export * from "./models";
|
||||
export * from "./resolvers/crud";
|
||||
|
||||
export const crudResolvers = Object.values(crudResolversImport) as unknown as NonEmptyArray<Function>;
|
||||
|
||||
export * from "./resolvers/relations";
|
||||
|
||||
export const relationResolvers = Object.values(relationResolversImport) as unknown as NonEmptyArray<Function>;
|
||||
|
||||
export * from "./resolvers/inputs";
|
||||
export * from "./resolvers/outputs";
|
||||
export * from "./enhance";
|
||||
export * from "./scalars";
|
||||
|
||||
export const resolvers = [
|
||||
...crudResolvers,
|
||||
...relationResolvers,
|
||||
] as unknown as NonEmptyArray<Function>;
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { DecimalJSScalar } from "../scalars";
|
||||
|
||||
@TypeGraphQL.ObjectType("Downvote", {})
|
||||
export class Downvote {
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
userID!: string;
|
||||
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
postID!: string;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { DecimalJSScalar } from "../scalars";
|
||||
import { User } from "../models/User";
|
||||
|
||||
@TypeGraphQL.ObjectType("Post", {})
|
||||
export class Post {
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
id!: string;
|
||||
|
||||
@TypeGraphQL.Field(_type => Date, {
|
||||
nullable: false
|
||||
})
|
||||
createdAt!: Date;
|
||||
|
||||
@TypeGraphQL.Field(_type => Date, {
|
||||
nullable: false
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: true
|
||||
})
|
||||
title?: string | null;
|
||||
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
content!: string;
|
||||
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
authorID!: string;
|
||||
|
||||
author?: User;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: false
|
||||
})
|
||||
points!: number;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { DecimalJSScalar } from "../scalars";
|
||||
|
||||
@TypeGraphQL.ObjectType("ResetPasswordToken", {})
|
||||
export class ResetPasswordToken {
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
id!: string;
|
||||
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
userID!: string;
|
||||
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
value!: string;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { DecimalJSScalar } from "../scalars";
|
||||
|
||||
@TypeGraphQL.ObjectType("Upvote", {})
|
||||
export class Upvote {
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
userID!: string;
|
||||
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
postID!: string;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { DecimalJSScalar } from "../scalars";
|
||||
import { Post } from "../models/Post";
|
||||
import { UserCount } from "../resolvers/outputs/UserCount";
|
||||
|
||||
@TypeGraphQL.ObjectType("User", {})
|
||||
export class User {
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
id!: string;
|
||||
|
||||
@TypeGraphQL.Field(_type => Date, {
|
||||
nullable: false
|
||||
})
|
||||
createdAt!: Date;
|
||||
|
||||
@TypeGraphQL.Field(_type => Date, {
|
||||
nullable: false
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
username!: string;
|
||||
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: false
|
||||
})
|
||||
password!: string;
|
||||
|
||||
@TypeGraphQL.Field(_type => String, {
|
||||
nullable: true
|
||||
})
|
||||
email?: string | null;
|
||||
|
||||
Posts?: Post[];
|
||||
|
||||
@TypeGraphQL.Field(_type => UserCount, {
|
||||
nullable: true
|
||||
})
|
||||
_count?: UserCount | null;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export { Downvote } from "./Downvote";
|
||||
export { Post } from "./Post";
|
||||
export { ResetPasswordToken } from "./ResetPasswordToken";
|
||||
export { Upvote } from "./Upvote";
|
||||
export { User } from "./User";
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { AggregateDownvoteArgs } from "./args/AggregateDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { AggregateDownvote } from "../../outputs/AggregateDownvote";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class AggregateDownvoteResolver {
|
||||
@TypeGraphQL.Query(_returns => AggregateDownvote, {
|
||||
nullable: false
|
||||
})
|
||||
async aggregateDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: AggregateDownvoteArgs): Promise<AggregateDownvote> {
|
||||
return getPrismaFromContext(ctx).downvote.aggregate({
|
||||
...args,
|
||||
...transformInfoIntoPrismaArgs(info),
|
||||
});
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { CreateManyAndReturnDownvoteArgs } from "./args/CreateManyAndReturnDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { CreateManyAndReturnDownvote } from "../../outputs/CreateManyAndReturnDownvote";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class CreateManyAndReturnDownvoteResolver {
|
||||
@TypeGraphQL.Mutation(_returns => [CreateManyAndReturnDownvote], {
|
||||
nullable: false
|
||||
})
|
||||
async createManyAndReturnDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateManyAndReturnDownvoteArgs): Promise<CreateManyAndReturnDownvote[]> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.createManyAndReturn({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { CreateManyDownvoteArgs } from "./args/CreateManyDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { AffectedRowsOutput } from "../../outputs/AffectedRowsOutput";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class CreateManyDownvoteResolver {
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async createManyDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateManyDownvoteArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.createMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { CreateOneDownvoteArgs } from "./args/CreateOneDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class CreateOneDownvoteResolver {
|
||||
@TypeGraphQL.Mutation(_returns => Downvote, {
|
||||
nullable: false
|
||||
})
|
||||
async createOneDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateOneDownvoteArgs): Promise<Downvote> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.create({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { DeleteManyDownvoteArgs } from "./args/DeleteManyDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { AffectedRowsOutput } from "../../outputs/AffectedRowsOutput";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class DeleteManyDownvoteResolver {
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async deleteManyDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteManyDownvoteArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.deleteMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { DeleteOneDownvoteArgs } from "./args/DeleteOneDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class DeleteOneDownvoteResolver {
|
||||
@TypeGraphQL.Mutation(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async deleteOneDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteOneDownvoteArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.delete({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { AggregateDownvoteArgs } from "./args/AggregateDownvoteArgs";
|
||||
import { CreateManyAndReturnDownvoteArgs } from "./args/CreateManyAndReturnDownvoteArgs";
|
||||
import { CreateManyDownvoteArgs } from "./args/CreateManyDownvoteArgs";
|
||||
import { CreateOneDownvoteArgs } from "./args/CreateOneDownvoteArgs";
|
||||
import { DeleteManyDownvoteArgs } from "./args/DeleteManyDownvoteArgs";
|
||||
import { DeleteOneDownvoteArgs } from "./args/DeleteOneDownvoteArgs";
|
||||
import { FindFirstDownvoteArgs } from "./args/FindFirstDownvoteArgs";
|
||||
import { FindFirstDownvoteOrThrowArgs } from "./args/FindFirstDownvoteOrThrowArgs";
|
||||
import { FindManyDownvoteArgs } from "./args/FindManyDownvoteArgs";
|
||||
import { FindUniqueDownvoteArgs } from "./args/FindUniqueDownvoteArgs";
|
||||
import { FindUniqueDownvoteOrThrowArgs } from "./args/FindUniqueDownvoteOrThrowArgs";
|
||||
import { GroupByDownvoteArgs } from "./args/GroupByDownvoteArgs";
|
||||
import { UpdateManyDownvoteArgs } from "./args/UpdateManyDownvoteArgs";
|
||||
import { UpdateOneDownvoteArgs } from "./args/UpdateOneDownvoteArgs";
|
||||
import { UpsertOneDownvoteArgs } from "./args/UpsertOneDownvoteArgs";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { AffectedRowsOutput } from "../../outputs/AffectedRowsOutput";
|
||||
import { AggregateDownvote } from "../../outputs/AggregateDownvote";
|
||||
import { CreateManyAndReturnDownvote } from "../../outputs/CreateManyAndReturnDownvote";
|
||||
import { DownvoteGroupBy } from "../../outputs/DownvoteGroupBy";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class DownvoteCrudResolver {
|
||||
@TypeGraphQL.Query(_returns => AggregateDownvote, {
|
||||
nullable: false
|
||||
})
|
||||
async aggregateDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: AggregateDownvoteArgs): Promise<AggregateDownvote> {
|
||||
return getPrismaFromContext(ctx).downvote.aggregate({
|
||||
...args,
|
||||
...transformInfoIntoPrismaArgs(info),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async createManyDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateManyDownvoteArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.createMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => [CreateManyAndReturnDownvote], {
|
||||
nullable: false
|
||||
})
|
||||
async createManyAndReturnDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateManyAndReturnDownvoteArgs): Promise<CreateManyAndReturnDownvote[]> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.createManyAndReturn({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => Downvote, {
|
||||
nullable: false
|
||||
})
|
||||
async createOneDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateOneDownvoteArgs): Promise<Downvote> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.create({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async deleteManyDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteManyDownvoteArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.deleteMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async deleteOneDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteOneDownvoteArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.delete({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async findFirstDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstDownvoteArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.findFirst({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async findFirstDownvoteOrThrow(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstDownvoteOrThrowArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.findFirstOrThrow({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => [Downvote], {
|
||||
nullable: false
|
||||
})
|
||||
async downvotes(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindManyDownvoteArgs): Promise<Downvote[]> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.findMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async downvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindUniqueDownvoteArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.findUnique({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async getDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindUniqueDownvoteOrThrowArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.findUniqueOrThrow({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => [DownvoteGroupBy], {
|
||||
nullable: false
|
||||
})
|
||||
async groupByDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: GroupByDownvoteArgs): Promise<DownvoteGroupBy[]> {
|
||||
const { _count, _avg, _sum, _min, _max } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.groupBy({
|
||||
...args,
|
||||
...Object.fromEntries(
|
||||
Object.entries({ _count, _avg, _sum, _min, _max }).filter(([_, v]) => v != null)
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async updateManyDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpdateManyDownvoteArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.updateMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async updateOneDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpdateOneDownvoteArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.update({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => Downvote, {
|
||||
nullable: false
|
||||
})
|
||||
async upsertOneDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpsertOneDownvoteArgs): Promise<Downvote> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.upsert({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { FindFirstDownvoteOrThrowArgs } from "./args/FindFirstDownvoteOrThrowArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class FindFirstDownvoteOrThrowResolver {
|
||||
@TypeGraphQL.Query(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async findFirstDownvoteOrThrow(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstDownvoteOrThrowArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.findFirstOrThrow({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { FindFirstDownvoteArgs } from "./args/FindFirstDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class FindFirstDownvoteResolver {
|
||||
@TypeGraphQL.Query(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async findFirstDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstDownvoteArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.findFirst({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { FindManyDownvoteArgs } from "./args/FindManyDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class FindManyDownvoteResolver {
|
||||
@TypeGraphQL.Query(_returns => [Downvote], {
|
||||
nullable: false
|
||||
})
|
||||
async downvotes(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindManyDownvoteArgs): Promise<Downvote[]> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.findMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { FindUniqueDownvoteOrThrowArgs } from "./args/FindUniqueDownvoteOrThrowArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class FindUniqueDownvoteOrThrowResolver {
|
||||
@TypeGraphQL.Query(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async getDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindUniqueDownvoteOrThrowArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.findUniqueOrThrow({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { FindUniqueDownvoteArgs } from "./args/FindUniqueDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class FindUniqueDownvoteResolver {
|
||||
@TypeGraphQL.Query(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async downvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindUniqueDownvoteArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.findUnique({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { GroupByDownvoteArgs } from "./args/GroupByDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { DownvoteGroupBy } from "../../outputs/DownvoteGroupBy";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class GroupByDownvoteResolver {
|
||||
@TypeGraphQL.Query(_returns => [DownvoteGroupBy], {
|
||||
nullable: false
|
||||
})
|
||||
async groupByDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: GroupByDownvoteArgs): Promise<DownvoteGroupBy[]> {
|
||||
const { _count, _avg, _sum, _min, _max } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.groupBy({
|
||||
...args,
|
||||
...Object.fromEntries(
|
||||
Object.entries({ _count, _avg, _sum, _min, _max }).filter(([_, v]) => v != null)
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { UpdateManyDownvoteArgs } from "./args/UpdateManyDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { AffectedRowsOutput } from "../../outputs/AffectedRowsOutput";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class UpdateManyDownvoteResolver {
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async updateManyDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpdateManyDownvoteArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.updateMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { UpdateOneDownvoteArgs } from "./args/UpdateOneDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class UpdateOneDownvoteResolver {
|
||||
@TypeGraphQL.Mutation(_returns => Downvote, {
|
||||
nullable: true
|
||||
})
|
||||
async updateOneDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpdateOneDownvoteArgs): Promise<Downvote | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.update({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { UpsertOneDownvoteArgs } from "./args/UpsertOneDownvoteArgs";
|
||||
import { Downvote } from "../../../models/Downvote";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Downvote)
|
||||
export class UpsertOneDownvoteResolver {
|
||||
@TypeGraphQL.Mutation(_returns => Downvote, {
|
||||
nullable: false
|
||||
})
|
||||
async upsertOneDownvote(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpsertOneDownvoteArgs): Promise<Downvote> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).downvote.upsert({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteOrderByWithRelationInput } from "../../../inputs/DownvoteOrderByWithRelationInput";
|
||||
import { DownvoteWhereInput } from "../../../inputs/DownvoteWhereInput";
|
||||
import { DownvoteWhereUniqueInput } from "../../../inputs/DownvoteWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class AggregateDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: DownvoteWhereInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [DownvoteOrderByWithRelationInput], {
|
||||
nullable: true
|
||||
})
|
||||
orderBy?: DownvoteOrderByWithRelationInput[] | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereUniqueInput, {
|
||||
nullable: true
|
||||
})
|
||||
cursor?: DownvoteWhereUniqueInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
take?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
skip?: number | undefined;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteCreateManyInput } from "../../../inputs/DownvoteCreateManyInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class CreateManyAndReturnDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => [DownvoteCreateManyInput], {
|
||||
nullable: false
|
||||
})
|
||||
data!: DownvoteCreateManyInput[];
|
||||
|
||||
@TypeGraphQL.Field(_type => Boolean, {
|
||||
nullable: true
|
||||
})
|
||||
skipDuplicates?: boolean | undefined;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteCreateManyInput } from "../../../inputs/DownvoteCreateManyInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class CreateManyDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => [DownvoteCreateManyInput], {
|
||||
nullable: false
|
||||
})
|
||||
data!: DownvoteCreateManyInput[];
|
||||
|
||||
@TypeGraphQL.Field(_type => Boolean, {
|
||||
nullable: true
|
||||
})
|
||||
skipDuplicates?: boolean | undefined;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteCreateInput } from "../../../inputs/DownvoteCreateInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class CreateOneDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteCreateInput, {
|
||||
nullable: false
|
||||
})
|
||||
data!: DownvoteCreateInput;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteWhereInput } from "../../../inputs/DownvoteWhereInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class DeleteManyDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: DownvoteWhereInput | undefined;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteWhereUniqueInput } from "../../../inputs/DownvoteWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class DeleteOneDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereUniqueInput, {
|
||||
nullable: false
|
||||
})
|
||||
where!: DownvoteWhereUniqueInput;
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteOrderByWithRelationInput } from "../../../inputs/DownvoteOrderByWithRelationInput";
|
||||
import { DownvoteWhereInput } from "../../../inputs/DownvoteWhereInput";
|
||||
import { DownvoteWhereUniqueInput } from "../../../inputs/DownvoteWhereUniqueInput";
|
||||
import { DownvoteScalarFieldEnum } from "../../../../enums/DownvoteScalarFieldEnum";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class FindFirstDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: DownvoteWhereInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [DownvoteOrderByWithRelationInput], {
|
||||
nullable: true
|
||||
})
|
||||
orderBy?: DownvoteOrderByWithRelationInput[] | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereUniqueInput, {
|
||||
nullable: true
|
||||
})
|
||||
cursor?: DownvoteWhereUniqueInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
take?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
skip?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [DownvoteScalarFieldEnum], {
|
||||
nullable: true
|
||||
})
|
||||
distinct?: Array<"userID" | "postID"> | undefined;
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteOrderByWithRelationInput } from "../../../inputs/DownvoteOrderByWithRelationInput";
|
||||
import { DownvoteWhereInput } from "../../../inputs/DownvoteWhereInput";
|
||||
import { DownvoteWhereUniqueInput } from "../../../inputs/DownvoteWhereUniqueInput";
|
||||
import { DownvoteScalarFieldEnum } from "../../../../enums/DownvoteScalarFieldEnum";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class FindFirstDownvoteOrThrowArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: DownvoteWhereInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [DownvoteOrderByWithRelationInput], {
|
||||
nullable: true
|
||||
})
|
||||
orderBy?: DownvoteOrderByWithRelationInput[] | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereUniqueInput, {
|
||||
nullable: true
|
||||
})
|
||||
cursor?: DownvoteWhereUniqueInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
take?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
skip?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [DownvoteScalarFieldEnum], {
|
||||
nullable: true
|
||||
})
|
||||
distinct?: Array<"userID" | "postID"> | undefined;
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteOrderByWithRelationInput } from "../../../inputs/DownvoteOrderByWithRelationInput";
|
||||
import { DownvoteWhereInput } from "../../../inputs/DownvoteWhereInput";
|
||||
import { DownvoteWhereUniqueInput } from "../../../inputs/DownvoteWhereUniqueInput";
|
||||
import { DownvoteScalarFieldEnum } from "../../../../enums/DownvoteScalarFieldEnum";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class FindManyDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: DownvoteWhereInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [DownvoteOrderByWithRelationInput], {
|
||||
nullable: true
|
||||
})
|
||||
orderBy?: DownvoteOrderByWithRelationInput[] | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereUniqueInput, {
|
||||
nullable: true
|
||||
})
|
||||
cursor?: DownvoteWhereUniqueInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
take?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
skip?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [DownvoteScalarFieldEnum], {
|
||||
nullable: true
|
||||
})
|
||||
distinct?: Array<"userID" | "postID"> | undefined;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteWhereUniqueInput } from "../../../inputs/DownvoteWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class FindUniqueDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereUniqueInput, {
|
||||
nullable: false
|
||||
})
|
||||
where!: DownvoteWhereUniqueInput;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteWhereUniqueInput } from "../../../inputs/DownvoteWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class FindUniqueDownvoteOrThrowArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereUniqueInput, {
|
||||
nullable: false
|
||||
})
|
||||
where!: DownvoteWhereUniqueInput;
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteOrderByWithAggregationInput } from "../../../inputs/DownvoteOrderByWithAggregationInput";
|
||||
import { DownvoteScalarWhereWithAggregatesInput } from "../../../inputs/DownvoteScalarWhereWithAggregatesInput";
|
||||
import { DownvoteWhereInput } from "../../../inputs/DownvoteWhereInput";
|
||||
import { DownvoteScalarFieldEnum } from "../../../../enums/DownvoteScalarFieldEnum";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class GroupByDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: DownvoteWhereInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [DownvoteOrderByWithAggregationInput], {
|
||||
nullable: true
|
||||
})
|
||||
orderBy?: DownvoteOrderByWithAggregationInput[] | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [DownvoteScalarFieldEnum], {
|
||||
nullable: false
|
||||
})
|
||||
by!: Array<"userID" | "postID">;
|
||||
|
||||
@TypeGraphQL.Field(_type => DownvoteScalarWhereWithAggregatesInput, {
|
||||
nullable: true
|
||||
})
|
||||
having?: DownvoteScalarWhereWithAggregatesInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
take?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
skip?: number | undefined;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteUpdateManyMutationInput } from "../../../inputs/DownvoteUpdateManyMutationInput";
|
||||
import { DownvoteWhereInput } from "../../../inputs/DownvoteWhereInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class UpdateManyDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteUpdateManyMutationInput, {
|
||||
nullable: false
|
||||
})
|
||||
data!: DownvoteUpdateManyMutationInput;
|
||||
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: DownvoteWhereInput | undefined;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteUpdateInput } from "../../../inputs/DownvoteUpdateInput";
|
||||
import { DownvoteWhereUniqueInput } from "../../../inputs/DownvoteWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class UpdateOneDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteUpdateInput, {
|
||||
nullable: false
|
||||
})
|
||||
data!: DownvoteUpdateInput;
|
||||
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereUniqueInput, {
|
||||
nullable: false
|
||||
})
|
||||
where!: DownvoteWhereUniqueInput;
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { DownvoteCreateInput } from "../../../inputs/DownvoteCreateInput";
|
||||
import { DownvoteUpdateInput } from "../../../inputs/DownvoteUpdateInput";
|
||||
import { DownvoteWhereUniqueInput } from "../../../inputs/DownvoteWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class UpsertOneDownvoteArgs {
|
||||
@TypeGraphQL.Field(_type => DownvoteWhereUniqueInput, {
|
||||
nullable: false
|
||||
})
|
||||
where!: DownvoteWhereUniqueInput;
|
||||
|
||||
@TypeGraphQL.Field(_type => DownvoteCreateInput, {
|
||||
nullable: false
|
||||
})
|
||||
create!: DownvoteCreateInput;
|
||||
|
||||
@TypeGraphQL.Field(_type => DownvoteUpdateInput, {
|
||||
nullable: false
|
||||
})
|
||||
update!: DownvoteUpdateInput;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
export { AggregateDownvoteArgs } from "./AggregateDownvoteArgs";
|
||||
export { CreateManyAndReturnDownvoteArgs } from "./CreateManyAndReturnDownvoteArgs";
|
||||
export { CreateManyDownvoteArgs } from "./CreateManyDownvoteArgs";
|
||||
export { CreateOneDownvoteArgs } from "./CreateOneDownvoteArgs";
|
||||
export { DeleteManyDownvoteArgs } from "./DeleteManyDownvoteArgs";
|
||||
export { DeleteOneDownvoteArgs } from "./DeleteOneDownvoteArgs";
|
||||
export { FindFirstDownvoteArgs } from "./FindFirstDownvoteArgs";
|
||||
export { FindFirstDownvoteOrThrowArgs } from "./FindFirstDownvoteOrThrowArgs";
|
||||
export { FindManyDownvoteArgs } from "./FindManyDownvoteArgs";
|
||||
export { FindUniqueDownvoteArgs } from "./FindUniqueDownvoteArgs";
|
||||
export { FindUniqueDownvoteOrThrowArgs } from "./FindUniqueDownvoteOrThrowArgs";
|
||||
export { GroupByDownvoteArgs } from "./GroupByDownvoteArgs";
|
||||
export { UpdateManyDownvoteArgs } from "./UpdateManyDownvoteArgs";
|
||||
export { UpdateOneDownvoteArgs } from "./UpdateOneDownvoteArgs";
|
||||
export { UpsertOneDownvoteArgs } from "./UpsertOneDownvoteArgs";
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { AggregatePostArgs } from "./args/AggregatePostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { AggregatePost } from "../../outputs/AggregatePost";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class AggregatePostResolver {
|
||||
@TypeGraphQL.Query(_returns => AggregatePost, {
|
||||
nullable: false
|
||||
})
|
||||
async aggregatePost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: AggregatePostArgs): Promise<AggregatePost> {
|
||||
return getPrismaFromContext(ctx).post.aggregate({
|
||||
...args,
|
||||
...transformInfoIntoPrismaArgs(info),
|
||||
});
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { CreateManyAndReturnPostArgs } from "./args/CreateManyAndReturnPostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { CreateManyAndReturnPost } from "../../outputs/CreateManyAndReturnPost";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class CreateManyAndReturnPostResolver {
|
||||
@TypeGraphQL.Mutation(_returns => [CreateManyAndReturnPost], {
|
||||
nullable: false
|
||||
})
|
||||
async createManyAndReturnPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateManyAndReturnPostArgs): Promise<CreateManyAndReturnPost[]> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.createManyAndReturn({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { CreateManyPostArgs } from "./args/CreateManyPostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { AffectedRowsOutput } from "../../outputs/AffectedRowsOutput";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class CreateManyPostResolver {
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async createManyPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateManyPostArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.createMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { CreateOnePostArgs } from "./args/CreateOnePostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class CreateOnePostResolver {
|
||||
@TypeGraphQL.Mutation(_returns => Post, {
|
||||
nullable: false
|
||||
})
|
||||
async createOnePost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateOnePostArgs): Promise<Post> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.create({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { DeleteManyPostArgs } from "./args/DeleteManyPostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { AffectedRowsOutput } from "../../outputs/AffectedRowsOutput";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class DeleteManyPostResolver {
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async deleteManyPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteManyPostArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.deleteMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { DeleteOnePostArgs } from "./args/DeleteOnePostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class DeleteOnePostResolver {
|
||||
@TypeGraphQL.Mutation(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async deleteOnePost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteOnePostArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.delete({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { FindFirstPostOrThrowArgs } from "./args/FindFirstPostOrThrowArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class FindFirstPostOrThrowResolver {
|
||||
@TypeGraphQL.Query(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async findFirstPostOrThrow(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstPostOrThrowArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.findFirstOrThrow({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { FindFirstPostArgs } from "./args/FindFirstPostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class FindFirstPostResolver {
|
||||
@TypeGraphQL.Query(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async findFirstPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstPostArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.findFirst({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { FindManyPostArgs } from "./args/FindManyPostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class FindManyPostResolver {
|
||||
@TypeGraphQL.Query(_returns => [Post], {
|
||||
nullable: false
|
||||
})
|
||||
async posts(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindManyPostArgs): Promise<Post[]> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.findMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { FindUniquePostOrThrowArgs } from "./args/FindUniquePostOrThrowArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class FindUniquePostOrThrowResolver {
|
||||
@TypeGraphQL.Query(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async getPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindUniquePostOrThrowArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.findUniqueOrThrow({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { FindUniquePostArgs } from "./args/FindUniquePostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class FindUniquePostResolver {
|
||||
@TypeGraphQL.Query(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async post(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindUniquePostArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.findUnique({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { GroupByPostArgs } from "./args/GroupByPostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { PostGroupBy } from "../../outputs/PostGroupBy";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class GroupByPostResolver {
|
||||
@TypeGraphQL.Query(_returns => [PostGroupBy], {
|
||||
nullable: false
|
||||
})
|
||||
async groupByPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: GroupByPostArgs): Promise<PostGroupBy[]> {
|
||||
const { _count, _avg, _sum, _min, _max } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.groupBy({
|
||||
...args,
|
||||
...Object.fromEntries(
|
||||
Object.entries({ _count, _avg, _sum, _min, _max }).filter(([_, v]) => v != null)
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { AggregatePostArgs } from "./args/AggregatePostArgs";
|
||||
import { CreateManyAndReturnPostArgs } from "./args/CreateManyAndReturnPostArgs";
|
||||
import { CreateManyPostArgs } from "./args/CreateManyPostArgs";
|
||||
import { CreateOnePostArgs } from "./args/CreateOnePostArgs";
|
||||
import { DeleteManyPostArgs } from "./args/DeleteManyPostArgs";
|
||||
import { DeleteOnePostArgs } from "./args/DeleteOnePostArgs";
|
||||
import { FindFirstPostArgs } from "./args/FindFirstPostArgs";
|
||||
import { FindFirstPostOrThrowArgs } from "./args/FindFirstPostOrThrowArgs";
|
||||
import { FindManyPostArgs } from "./args/FindManyPostArgs";
|
||||
import { FindUniquePostArgs } from "./args/FindUniquePostArgs";
|
||||
import { FindUniquePostOrThrowArgs } from "./args/FindUniquePostOrThrowArgs";
|
||||
import { GroupByPostArgs } from "./args/GroupByPostArgs";
|
||||
import { UpdateManyPostArgs } from "./args/UpdateManyPostArgs";
|
||||
import { UpdateOnePostArgs } from "./args/UpdateOnePostArgs";
|
||||
import { UpsertOnePostArgs } from "./args/UpsertOnePostArgs";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { AffectedRowsOutput } from "../../outputs/AffectedRowsOutput";
|
||||
import { AggregatePost } from "../../outputs/AggregatePost";
|
||||
import { CreateManyAndReturnPost } from "../../outputs/CreateManyAndReturnPost";
|
||||
import { PostGroupBy } from "../../outputs/PostGroupBy";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class PostCrudResolver {
|
||||
@TypeGraphQL.Query(_returns => AggregatePost, {
|
||||
nullable: false
|
||||
})
|
||||
async aggregatePost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: AggregatePostArgs): Promise<AggregatePost> {
|
||||
return getPrismaFromContext(ctx).post.aggregate({
|
||||
...args,
|
||||
...transformInfoIntoPrismaArgs(info),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async createManyPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateManyPostArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.createMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => [CreateManyAndReturnPost], {
|
||||
nullable: false
|
||||
})
|
||||
async createManyAndReturnPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateManyAndReturnPostArgs): Promise<CreateManyAndReturnPost[]> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.createManyAndReturn({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => Post, {
|
||||
nullable: false
|
||||
})
|
||||
async createOnePost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateOnePostArgs): Promise<Post> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.create({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async deleteManyPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteManyPostArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.deleteMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async deleteOnePost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteOnePostArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.delete({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async findFirstPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstPostArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.findFirst({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async findFirstPostOrThrow(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstPostOrThrowArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.findFirstOrThrow({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => [Post], {
|
||||
nullable: false
|
||||
})
|
||||
async posts(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindManyPostArgs): Promise<Post[]> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.findMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async post(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindUniquePostArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.findUnique({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async getPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindUniquePostOrThrowArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.findUniqueOrThrow({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Query(_returns => [PostGroupBy], {
|
||||
nullable: false
|
||||
})
|
||||
async groupByPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: GroupByPostArgs): Promise<PostGroupBy[]> {
|
||||
const { _count, _avg, _sum, _min, _max } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.groupBy({
|
||||
...args,
|
||||
...Object.fromEntries(
|
||||
Object.entries({ _count, _avg, _sum, _min, _max }).filter(([_, v]) => v != null)
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async updateManyPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpdateManyPostArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.updateMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async updateOnePost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpdateOnePostArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.update({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
|
||||
@TypeGraphQL.Mutation(_returns => Post, {
|
||||
nullable: false
|
||||
})
|
||||
async upsertOnePost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpsertOnePostArgs): Promise<Post> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.upsert({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { UpdateManyPostArgs } from "./args/UpdateManyPostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { AffectedRowsOutput } from "../../outputs/AffectedRowsOutput";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class UpdateManyPostResolver {
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async updateManyPost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpdateManyPostArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.updateMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { UpdateOnePostArgs } from "./args/UpdateOnePostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class UpdateOnePostResolver {
|
||||
@TypeGraphQL.Mutation(_returns => Post, {
|
||||
nullable: true
|
||||
})
|
||||
async updateOnePost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpdateOnePostArgs): Promise<Post | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.update({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { UpsertOnePostArgs } from "./args/UpsertOnePostArgs";
|
||||
import { Post } from "../../../models/Post";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => Post)
|
||||
export class UpsertOnePostResolver {
|
||||
@TypeGraphQL.Mutation(_returns => Post, {
|
||||
nullable: false
|
||||
})
|
||||
async upsertOnePost(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpsertOnePostArgs): Promise<Post> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).post.upsert({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostOrderByWithRelationInput } from "../../../inputs/PostOrderByWithRelationInput";
|
||||
import { PostWhereInput } from "../../../inputs/PostWhereInput";
|
||||
import { PostWhereUniqueInput } from "../../../inputs/PostWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class AggregatePostArgs {
|
||||
@TypeGraphQL.Field(_type => PostWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: PostWhereInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [PostOrderByWithRelationInput], {
|
||||
nullable: true
|
||||
})
|
||||
orderBy?: PostOrderByWithRelationInput[] | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => PostWhereUniqueInput, {
|
||||
nullable: true
|
||||
})
|
||||
cursor?: PostWhereUniqueInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
take?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
skip?: number | undefined;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostCreateManyInput } from "../../../inputs/PostCreateManyInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class CreateManyAndReturnPostArgs {
|
||||
@TypeGraphQL.Field(_type => [PostCreateManyInput], {
|
||||
nullable: false
|
||||
})
|
||||
data!: PostCreateManyInput[];
|
||||
|
||||
@TypeGraphQL.Field(_type => Boolean, {
|
||||
nullable: true
|
||||
})
|
||||
skipDuplicates?: boolean | undefined;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostCreateManyInput } from "../../../inputs/PostCreateManyInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class CreateManyPostArgs {
|
||||
@TypeGraphQL.Field(_type => [PostCreateManyInput], {
|
||||
nullable: false
|
||||
})
|
||||
data!: PostCreateManyInput[];
|
||||
|
||||
@TypeGraphQL.Field(_type => Boolean, {
|
||||
nullable: true
|
||||
})
|
||||
skipDuplicates?: boolean | undefined;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostCreateInput } from "../../../inputs/PostCreateInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class CreateOnePostArgs {
|
||||
@TypeGraphQL.Field(_type => PostCreateInput, {
|
||||
nullable: false
|
||||
})
|
||||
data!: PostCreateInput;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostWhereInput } from "../../../inputs/PostWhereInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class DeleteManyPostArgs {
|
||||
@TypeGraphQL.Field(_type => PostWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: PostWhereInput | undefined;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostWhereUniqueInput } from "../../../inputs/PostWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class DeleteOnePostArgs {
|
||||
@TypeGraphQL.Field(_type => PostWhereUniqueInput, {
|
||||
nullable: false
|
||||
})
|
||||
where!: PostWhereUniqueInput;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostOrderByWithRelationInput } from "../../../inputs/PostOrderByWithRelationInput";
|
||||
import { PostWhereInput } from "../../../inputs/PostWhereInput";
|
||||
import { PostWhereUniqueInput } from "../../../inputs/PostWhereUniqueInput";
|
||||
import { PostScalarFieldEnum } from "../../../../enums/PostScalarFieldEnum";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class FindFirstPostArgs {
|
||||
@TypeGraphQL.Field(_type => PostWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: PostWhereInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [PostOrderByWithRelationInput], {
|
||||
nullable: true
|
||||
})
|
||||
orderBy?: PostOrderByWithRelationInput[] | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => PostWhereUniqueInput, {
|
||||
nullable: true
|
||||
})
|
||||
cursor?: PostWhereUniqueInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
take?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
skip?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [PostScalarFieldEnum], {
|
||||
nullable: true
|
||||
})
|
||||
distinct?: Array<"id" | "createdAt" | "updatedAt" | "title" | "content" | "authorID" | "points"> | undefined;
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostOrderByWithRelationInput } from "../../../inputs/PostOrderByWithRelationInput";
|
||||
import { PostWhereInput } from "../../../inputs/PostWhereInput";
|
||||
import { PostWhereUniqueInput } from "../../../inputs/PostWhereUniqueInput";
|
||||
import { PostScalarFieldEnum } from "../../../../enums/PostScalarFieldEnum";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class FindFirstPostOrThrowArgs {
|
||||
@TypeGraphQL.Field(_type => PostWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: PostWhereInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [PostOrderByWithRelationInput], {
|
||||
nullable: true
|
||||
})
|
||||
orderBy?: PostOrderByWithRelationInput[] | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => PostWhereUniqueInput, {
|
||||
nullable: true
|
||||
})
|
||||
cursor?: PostWhereUniqueInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
take?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
skip?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [PostScalarFieldEnum], {
|
||||
nullable: true
|
||||
})
|
||||
distinct?: Array<"id" | "createdAt" | "updatedAt" | "title" | "content" | "authorID" | "points"> | undefined;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostOrderByWithRelationInput } from "../../../inputs/PostOrderByWithRelationInput";
|
||||
import { PostWhereInput } from "../../../inputs/PostWhereInput";
|
||||
import { PostWhereUniqueInput } from "../../../inputs/PostWhereUniqueInput";
|
||||
import { PostScalarFieldEnum } from "../../../../enums/PostScalarFieldEnum";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class FindManyPostArgs {
|
||||
@TypeGraphQL.Field(_type => PostWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: PostWhereInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [PostOrderByWithRelationInput], {
|
||||
nullable: true
|
||||
})
|
||||
orderBy?: PostOrderByWithRelationInput[] | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => PostWhereUniqueInput, {
|
||||
nullable: true
|
||||
})
|
||||
cursor?: PostWhereUniqueInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
take?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
skip?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [PostScalarFieldEnum], {
|
||||
nullable: true
|
||||
})
|
||||
distinct?: Array<"id" | "createdAt" | "updatedAt" | "title" | "content" | "authorID" | "points"> | undefined;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostWhereUniqueInput } from "../../../inputs/PostWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class FindUniquePostArgs {
|
||||
@TypeGraphQL.Field(_type => PostWhereUniqueInput, {
|
||||
nullable: false
|
||||
})
|
||||
where!: PostWhereUniqueInput;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostWhereUniqueInput } from "../../../inputs/PostWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class FindUniquePostOrThrowArgs {
|
||||
@TypeGraphQL.Field(_type => PostWhereUniqueInput, {
|
||||
nullable: false
|
||||
})
|
||||
where!: PostWhereUniqueInput;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostOrderByWithAggregationInput } from "../../../inputs/PostOrderByWithAggregationInput";
|
||||
import { PostScalarWhereWithAggregatesInput } from "../../../inputs/PostScalarWhereWithAggregatesInput";
|
||||
import { PostWhereInput } from "../../../inputs/PostWhereInput";
|
||||
import { PostScalarFieldEnum } from "../../../../enums/PostScalarFieldEnum";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class GroupByPostArgs {
|
||||
@TypeGraphQL.Field(_type => PostWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: PostWhereInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [PostOrderByWithAggregationInput], {
|
||||
nullable: true
|
||||
})
|
||||
orderBy?: PostOrderByWithAggregationInput[] | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => [PostScalarFieldEnum], {
|
||||
nullable: false
|
||||
})
|
||||
by!: Array<"id" | "createdAt" | "updatedAt" | "title" | "content" | "authorID" | "points">;
|
||||
|
||||
@TypeGraphQL.Field(_type => PostScalarWhereWithAggregatesInput, {
|
||||
nullable: true
|
||||
})
|
||||
having?: PostScalarWhereWithAggregatesInput | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
take?: number | undefined;
|
||||
|
||||
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
|
||||
nullable: true
|
||||
})
|
||||
skip?: number | undefined;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostUpdateManyMutationInput } from "../../../inputs/PostUpdateManyMutationInput";
|
||||
import { PostWhereInput } from "../../../inputs/PostWhereInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class UpdateManyPostArgs {
|
||||
@TypeGraphQL.Field(_type => PostUpdateManyMutationInput, {
|
||||
nullable: false
|
||||
})
|
||||
data!: PostUpdateManyMutationInput;
|
||||
|
||||
@TypeGraphQL.Field(_type => PostWhereInput, {
|
||||
nullable: true
|
||||
})
|
||||
where?: PostWhereInput | undefined;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostUpdateInput } from "../../../inputs/PostUpdateInput";
|
||||
import { PostWhereUniqueInput } from "../../../inputs/PostWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class UpdateOnePostArgs {
|
||||
@TypeGraphQL.Field(_type => PostUpdateInput, {
|
||||
nullable: false
|
||||
})
|
||||
data!: PostUpdateInput;
|
||||
|
||||
@TypeGraphQL.Field(_type => PostWhereUniqueInput, {
|
||||
nullable: false
|
||||
})
|
||||
where!: PostWhereUniqueInput;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import * as GraphQLScalars from "graphql-scalars";
|
||||
import { PostCreateInput } from "../../../inputs/PostCreateInput";
|
||||
import { PostUpdateInput } from "../../../inputs/PostUpdateInput";
|
||||
import { PostWhereUniqueInput } from "../../../inputs/PostWhereUniqueInput";
|
||||
|
||||
@TypeGraphQL.ArgsType()
|
||||
export class UpsertOnePostArgs {
|
||||
@TypeGraphQL.Field(_type => PostWhereUniqueInput, {
|
||||
nullable: false
|
||||
})
|
||||
where!: PostWhereUniqueInput;
|
||||
|
||||
@TypeGraphQL.Field(_type => PostCreateInput, {
|
||||
nullable: false
|
||||
})
|
||||
create!: PostCreateInput;
|
||||
|
||||
@TypeGraphQL.Field(_type => PostUpdateInput, {
|
||||
nullable: false
|
||||
})
|
||||
update!: PostUpdateInput;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
export { AggregatePostArgs } from "./AggregatePostArgs";
|
||||
export { CreateManyAndReturnPostArgs } from "./CreateManyAndReturnPostArgs";
|
||||
export { CreateManyPostArgs } from "./CreateManyPostArgs";
|
||||
export { CreateOnePostArgs } from "./CreateOnePostArgs";
|
||||
export { DeleteManyPostArgs } from "./DeleteManyPostArgs";
|
||||
export { DeleteOnePostArgs } from "./DeleteOnePostArgs";
|
||||
export { FindFirstPostArgs } from "./FindFirstPostArgs";
|
||||
export { FindFirstPostOrThrowArgs } from "./FindFirstPostOrThrowArgs";
|
||||
export { FindManyPostArgs } from "./FindManyPostArgs";
|
||||
export { FindUniquePostArgs } from "./FindUniquePostArgs";
|
||||
export { FindUniquePostOrThrowArgs } from "./FindUniquePostOrThrowArgs";
|
||||
export { GroupByPostArgs } from "./GroupByPostArgs";
|
||||
export { UpdateManyPostArgs } from "./UpdateManyPostArgs";
|
||||
export { UpdateOnePostArgs } from "./UpdateOnePostArgs";
|
||||
export { UpsertOnePostArgs } from "./UpsertOnePostArgs";
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { AggregateResetPasswordTokenArgs } from "./args/AggregateResetPasswordTokenArgs";
|
||||
import { ResetPasswordToken } from "../../../models/ResetPasswordToken";
|
||||
import { AggregateResetPasswordToken } from "../../outputs/AggregateResetPasswordToken";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => ResetPasswordToken)
|
||||
export class AggregateResetPasswordTokenResolver {
|
||||
@TypeGraphQL.Query(_returns => AggregateResetPasswordToken, {
|
||||
nullable: false
|
||||
})
|
||||
async aggregateResetPasswordToken(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: AggregateResetPasswordTokenArgs): Promise<AggregateResetPasswordToken> {
|
||||
return getPrismaFromContext(ctx).resetPasswordToken.aggregate({
|
||||
...args,
|
||||
...transformInfoIntoPrismaArgs(info),
|
||||
});
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { CreateManyAndReturnResetPasswordTokenArgs } from "./args/CreateManyAndReturnResetPasswordTokenArgs";
|
||||
import { ResetPasswordToken } from "../../../models/ResetPasswordToken";
|
||||
import { CreateManyAndReturnResetPasswordToken } from "../../outputs/CreateManyAndReturnResetPasswordToken";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => ResetPasswordToken)
|
||||
export class CreateManyAndReturnResetPasswordTokenResolver {
|
||||
@TypeGraphQL.Mutation(_returns => [CreateManyAndReturnResetPasswordToken], {
|
||||
nullable: false
|
||||
})
|
||||
async createManyAndReturnResetPasswordToken(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateManyAndReturnResetPasswordTokenArgs): Promise<CreateManyAndReturnResetPasswordToken[]> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).resetPasswordToken.createManyAndReturn({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { CreateManyResetPasswordTokenArgs } from "./args/CreateManyResetPasswordTokenArgs";
|
||||
import { ResetPasswordToken } from "../../../models/ResetPasswordToken";
|
||||
import { AffectedRowsOutput } from "../../outputs/AffectedRowsOutput";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => ResetPasswordToken)
|
||||
export class CreateManyResetPasswordTokenResolver {
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async createManyResetPasswordToken(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateManyResetPasswordTokenArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).resetPasswordToken.createMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { CreateOneResetPasswordTokenArgs } from "./args/CreateOneResetPasswordTokenArgs";
|
||||
import { ResetPasswordToken } from "../../../models/ResetPasswordToken";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => ResetPasswordToken)
|
||||
export class CreateOneResetPasswordTokenResolver {
|
||||
@TypeGraphQL.Mutation(_returns => ResetPasswordToken, {
|
||||
nullable: false
|
||||
})
|
||||
async createOneResetPasswordToken(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateOneResetPasswordTokenArgs): Promise<ResetPasswordToken> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).resetPasswordToken.create({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { DeleteManyResetPasswordTokenArgs } from "./args/DeleteManyResetPasswordTokenArgs";
|
||||
import { ResetPasswordToken } from "../../../models/ResetPasswordToken";
|
||||
import { AffectedRowsOutput } from "../../outputs/AffectedRowsOutput";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => ResetPasswordToken)
|
||||
export class DeleteManyResetPasswordTokenResolver {
|
||||
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
||||
nullable: false
|
||||
})
|
||||
async deleteManyResetPasswordToken(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteManyResetPasswordTokenArgs): Promise<AffectedRowsOutput> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).resetPasswordToken.deleteMany({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { DeleteOneResetPasswordTokenArgs } from "./args/DeleteOneResetPasswordTokenArgs";
|
||||
import { ResetPasswordToken } from "../../../models/ResetPasswordToken";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => ResetPasswordToken)
|
||||
export class DeleteOneResetPasswordTokenResolver {
|
||||
@TypeGraphQL.Mutation(_returns => ResetPasswordToken, {
|
||||
nullable: true
|
||||
})
|
||||
async deleteOneResetPasswordToken(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteOneResetPasswordTokenArgs): Promise<ResetPasswordToken | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).resetPasswordToken.delete({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import * as TypeGraphQL from "type-graphql";
|
||||
import type { GraphQLResolveInfo } from "graphql";
|
||||
import { FindFirstResetPasswordTokenOrThrowArgs } from "./args/FindFirstResetPasswordTokenOrThrowArgs";
|
||||
import { ResetPasswordToken } from "../../../models/ResetPasswordToken";
|
||||
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
||||
|
||||
@TypeGraphQL.Resolver(_of => ResetPasswordToken)
|
||||
export class FindFirstResetPasswordTokenOrThrowResolver {
|
||||
@TypeGraphQL.Query(_returns => ResetPasswordToken, {
|
||||
nullable: true
|
||||
})
|
||||
async findFirstResetPasswordTokenOrThrow(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstResetPasswordTokenOrThrowArgs): Promise<ResetPasswordToken | null> {
|
||||
const { _count } = transformInfoIntoPrismaArgs(info);
|
||||
return getPrismaFromContext(ctx).resetPasswordToken.findFirstOrThrow({
|
||||
...args,
|
||||
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
||||
});
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user