Skip to content

Commit a57a29e

Browse files
committed
chore: Added example
1 parent 95f217d commit a57a29e

File tree

134 files changed

+811
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+811
-243
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ npx prisma generate
3737

3838
## Resources
3939

40+
- Todo - https://github.com/unlight/prisma-nestjs-graphql/issues/2
4041
- https://ts-ast-viewer.com/
4142
- https://github.com/unlight/nestjs-graphql-prisma-realworld-example-app
4243
- https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/data-model
4344
- JSON type for the code first approach - https://github.com/nestjs/graphql/issues/111#issuecomment-631452899
45+
- https://github.com/paljs/prisma-tools/tree/master/packages/plugins

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
"eslint:w": "watchexec -w src \"npm run eslint\"",
3535
"eslint": "node node_modules/eslint/bin/eslint \"src/**/*.{ts,tsx}\"",
3636
"lint:fix": "npm run eslint -- --fix",
37+
"eslint:fix": "npm run eslint -- --fix",
3738
"build": "sh Taskfile bundle",
3839
"prisma:g": "node node_modules/@prisma/cli/build/index.js generate",
3940
"unused": "no-unused-export \"src/**/*.ts\"",
40-
"prettier:format": "npx prettier src --write"
41+
"prettier:format": "npx prettier src --write",
42+
"start:example": "node -r ts-node/register/transpile-only src/example/main.ts"
4143
},
4244
"husky": {
4345
"hooks": {
@@ -60,7 +62,10 @@
6062
"devDependencies": {
6163
"@commitlint/cli": "^9.1.2",
6264
"@commitlint/config-conventional": "^9.1.2",
65+
"@nestjs/common": "^7.4.2",
66+
"@nestjs/core": "^7.4.2",
6367
"@nestjs/graphql": "^7.6.0",
68+
"@nestjs/platform-express": "^7.4.2",
6469
"@prisma/cli": "^2.4.1",
6570
"@prisma/client": "^2.4.1",
6671
"@semantic-release/changelog": "^5.0.1",
@@ -69,7 +74,10 @@
6974
"@types/node": "^14.0.27",
7075
"@typescript-eslint/eslint-plugin": "^3.9.0",
7176
"@typescript-eslint/parser": "^3.9.0",
77+
"apollo-server-express": "^2.16.1",
7278
"c8": "^7.3.0",
79+
"class-transformer": "^0.3.1",
80+
"class-validator": "^0.12.2",
7381
"eslint": "^7.7.0",
7482
"eslint-import-resolver-node": "^0.3.4",
7583
"eslint-plugin-etc": "0.0.1-beta.40",
@@ -85,12 +93,15 @@
8593
"eslint-plugin-unicorn": "^21.0.0",
8694
"eslint-plugin-wix-editor": "^3.2.0",
8795
"git-branch-is": "^4.0.0",
96+
"graphql": "^15.3.0",
8897
"graphql-type-json": "^0.3.2",
8998
"husky": "^4.2.5",
9099
"mocha": "^8.1.1",
91100
"no-unused-export": "^1.12.2",
92101
"precise-commits": "^1.0.2",
93102
"prettier": "^2.0.5",
103+
"reflect-metadata": "^0.1.13",
104+
"rxjs": "^6.6.2",
94105
"semantic-release": "^17.1.1",
95106
"simplytyped": "^3.3.0",
96107
"ts-node": "^8.10.2",

schema.gql

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
# ------------------------------------------------------
2+
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
3+
# ------------------------------------------------------
4+
5+
type Recipe {
6+
id: ID!
7+
title: String!
8+
description: String
9+
creationDate: String!
10+
ingredients: [String!]!
11+
}
12+
13+
type Tag {
14+
id: ID!
15+
name: String!
16+
articles: [Article!]
17+
}
18+
19+
type Comment {
20+
id: ID!
21+
createdAt: String!
22+
updatedAt: String!
23+
body: String!
24+
author: User!
25+
authorId: String!
26+
article: Article
27+
articleId: String
28+
}
29+
30+
type Article {
31+
id: ID!
32+
slug: String!
33+
title: String!
34+
description: String!
35+
body: String!
36+
tags: [Tag!]
37+
createdAt: String!
38+
updatedAt: String!
39+
favoritesCount: Int!
40+
author: User!
41+
authorId: String!
42+
favoritedBy: [User!]
43+
comments: [Comment!]
44+
active: Boolean
45+
}
46+
47+
type User {
48+
id: ID!
49+
email: String!
50+
51+
"""User's name"""
52+
name: String!
53+
password: String!
54+
bio: String
55+
image: String
56+
following: [User!]
57+
followers: [User!]
58+
favoriteArticles: [Article!]
59+
articles: [Article!]
60+
comments: [Comment!]
61+
}
62+
63+
type Query {
64+
recipe(id: String!): Recipe!
65+
recipes(skip: Int = 0, take: Int = 25): [Recipe!]!
66+
users(where: UserWhereInput!): [User!]!
67+
}
68+
69+
input UserWhereInput {
70+
id: StringFilter
71+
email: StringFilter
72+
name: StringFilter
73+
password: StringFilter
74+
bio: NullableStringFilter
75+
image: NullableStringFilter
76+
following: UserFilter
77+
followers: UserFilter
78+
favoriteArticles: ArticleFilter
79+
articles: ArticleFilter
80+
comments: CommentFilter
81+
AND: [UserWhereInput!]
82+
OR: [UserWhereInput!]
83+
NOT: [UserWhereInput!]
84+
}
85+
86+
input StringFilter {
87+
equals: String
88+
not: StringFilter
89+
in: [String!]
90+
notIn: [String!]
91+
lt: String
92+
lte: String
93+
gt: String
94+
gte: String
95+
contains: String
96+
startsWith: String
97+
endsWith: String
98+
}
99+
100+
input NullableStringFilter {
101+
equals: String
102+
not: NullableStringFilter
103+
in: [String!]
104+
notIn: [String!]
105+
lt: String
106+
lte: String
107+
gt: String
108+
gte: String
109+
contains: String
110+
startsWith: String
111+
endsWith: String
112+
}
113+
114+
input UserFilter {
115+
every: UserWhereInput
116+
some: UserWhereInput
117+
none: UserWhereInput
118+
}
119+
120+
input ArticleFilter {
121+
every: ArticleWhereInput
122+
some: ArticleWhereInput
123+
none: ArticleWhereInput
124+
}
125+
126+
input ArticleWhereInput {
127+
id: StringFilter
128+
slug: StringFilter
129+
title: StringFilter
130+
description: StringFilter
131+
body: StringFilter
132+
tags: TagFilter
133+
createdAt: DateTimeFilter
134+
updatedAt: DateTimeFilter
135+
favoritesCount: IntFilter
136+
authorId: StringFilter
137+
favoritedBy: UserFilter
138+
comments: CommentFilter
139+
active: NullableBooleanFilter
140+
AND: [ArticleWhereInput!]
141+
OR: [ArticleWhereInput!]
142+
NOT: [ArticleWhereInput!]
143+
author: UserWhereInput
144+
}
145+
146+
input TagFilter {
147+
every: TagWhereInput
148+
some: TagWhereInput
149+
none: TagWhereInput
150+
}
151+
152+
input TagWhereInput {
153+
id: StringFilter
154+
name: StringFilter
155+
articles: ArticleFilter
156+
AND: [TagWhereInput!]
157+
OR: [TagWhereInput!]
158+
NOT: [TagWhereInput!]
159+
}
160+
161+
input DateTimeFilter {
162+
equals: String
163+
not: DateTimeFilter
164+
in: [String!]
165+
notIn: [String!]
166+
lt: String
167+
lte: String
168+
gt: String
169+
gte: String
170+
}
171+
172+
input IntFilter {
173+
equals: Int
174+
not: IntFilter
175+
in: [Int!]
176+
notIn: [Int!]
177+
lt: Int
178+
lte: Int
179+
gt: Int
180+
gte: Int
181+
}
182+
183+
input CommentFilter {
184+
every: CommentWhereInput
185+
some: CommentWhereInput
186+
none: CommentWhereInput
187+
}
188+
189+
input CommentWhereInput {
190+
id: StringFilter
191+
createdAt: DateTimeFilter
192+
updatedAt: DateTimeFilter
193+
body: StringFilter
194+
authorId: StringFilter
195+
articleId: NullableStringFilter
196+
AND: [CommentWhereInput!]
197+
OR: [CommentWhereInput!]
198+
NOT: [CommentWhereInput!]
199+
author: UserWhereInput
200+
article: ArticleWhereInput
201+
}
202+
203+
input NullableBooleanFilter {
204+
equals: Boolean
205+
not: NullableBooleanFilter
206+
}
207+
208+
type Mutation {
209+
addRecipe(newRecipeData: NewRecipeInput!): Recipe!
210+
removeRecipe(id: String!): Boolean!
211+
}
212+
213+
input NewRecipeInput {
214+
title: String!
215+
description: String
216+
ingredients: [String!]!
217+
}
218+
219+
type Subscription {
220+
recipeAdded: Recipe!
221+
}

src/@generated/article/article-create-many-without-author.input.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { InputType, Field } from '@nestjs/graphql';
1+
import { Field, InputType } from '@nestjs/graphql';
2+
23
import { ArticleCreateWithoutAuthorInput } from './article-create-without-author.input';
34
import { ArticleWhereUniqueInput } from './article-where-unique.input';
45

src/@generated/article/article-create-many-without-favorited-by.input.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { InputType, Field } from '@nestjs/graphql';
1+
import { Field, InputType } from '@nestjs/graphql';
2+
23
import { ArticleCreateWithoutFavoritedByInput } from './article-create-without-favorited-by.input';
34
import { ArticleWhereUniqueInput } from './article-where-unique.input';
45

src/@generated/article/article-create-many-without-tags.input.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { InputType, Field } from '@nestjs/graphql';
1+
import { Field, InputType } from '@nestjs/graphql';
2+
23
import { ArticleCreateWithoutTagsInput } from './article-create-without-tags.input';
34
import { ArticleWhereUniqueInput } from './article-where-unique.input';
45

src/@generated/article/article-create-one-without-comments.input.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { InputType, Field } from '@nestjs/graphql';
1+
import { Field, InputType } from '@nestjs/graphql';
2+
23
import { ArticleCreateWithoutCommentsInput } from './article-create-without-comments.input';
34
import { ArticleWhereUniqueInput } from './article-where-unique.input';
45

src/@generated/article/article-create-without-author.input.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { InputType, Field, Int } from '@nestjs/graphql';
1+
import { Field, InputType, Int } from '@nestjs/graphql';
2+
3+
import { CommentCreateManyWithoutArticleInput } from '../comment/comment-create-many-without-article.input';
24
import { TagCreateManyWithoutArticlesInput } from '../tag/tag-create-many-without-articles.input';
35
import { UserCreateManyWithoutFavoriteArticlesInput } from '../user/user-create-many-without-favorite-articles.input';
4-
import { CommentCreateManyWithoutArticleInput } from '../comment/comment-create-many-without-article.input';
56

67
@InputType({})
78
export class ArticleCreateWithoutAuthorInput {

src/@generated/article/article-create-without-comments.input.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { InputType, Field, Int } from '@nestjs/graphql';
1+
import { Field, InputType, Int } from '@nestjs/graphql';
2+
23
import { TagCreateManyWithoutArticlesInput } from '../tag/tag-create-many-without-articles.input';
3-
import { UserCreateOneWithoutArticlesInput } from '../user/user-create-one-without-articles.input';
44
import { UserCreateManyWithoutFavoriteArticlesInput } from '../user/user-create-many-without-favorite-articles.input';
5+
import { UserCreateOneWithoutArticlesInput } from '../user/user-create-one-without-articles.input';
56

67
@InputType({})
78
export class ArticleCreateWithoutCommentsInput {

src/@generated/article/article-create-without-favorited-by.input.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { InputType, Field, Int } from '@nestjs/graphql';
1+
import { Field, InputType, Int } from '@nestjs/graphql';
2+
3+
import { CommentCreateManyWithoutArticleInput } from '../comment/comment-create-many-without-article.input';
24
import { TagCreateManyWithoutArticlesInput } from '../tag/tag-create-many-without-articles.input';
35
import { UserCreateOneWithoutArticlesInput } from '../user/user-create-one-without-articles.input';
4-
import { CommentCreateManyWithoutArticleInput } from '../comment/comment-create-many-without-article.input';
56

67
@InputType({})
78
export class ArticleCreateWithoutFavoritedByInput {

0 commit comments

Comments
 (0)