Skip to content

Commit 29dedf1

Browse files
authored
Merge pull request #1 from howtographql/chapter-7
Finish Chapter 7
2 parents 4226df8 + ab7bfa4 commit 29dedf1

File tree

12 files changed

+353
-10
lines changed

12 files changed

+353
-10
lines changed

nexus-typegen.ts

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,23 @@
55

66

77
import type { Context } from "./src/context"
8-
9-
8+
import type { core } from "nexus"
9+
declare global {
10+
interface NexusGenCustomInputMethods<TypeName extends string> {
11+
/**
12+
* A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.
13+
*/
14+
dateTime<FieldName extends string>(fieldName: FieldName, opts?: core.CommonInputFieldConfig<TypeName, FieldName>): void // "DateTime";
15+
}
16+
}
17+
declare global {
18+
interface NexusGenCustomOutputMethods<TypeName extends string> {
19+
/**
20+
* A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.
21+
*/
22+
dateTime<FieldName extends string>(fieldName: FieldName, ...opts: core.ScalarOutSpread<TypeName, FieldName>): void // "DateTime";
23+
}
24+
}
1025

1126

1227
declare global {
@@ -25,6 +40,7 @@ export interface NexusGenScalars {
2540
Float: number
2641
Boolean: boolean
2742
ID: string
43+
DateTime: any
2844
}
2945

3046
export interface NexusGenObjects {
@@ -33,6 +49,7 @@ export interface NexusGenObjects {
3349
user: NexusGenRootTypes['User']; // User!
3450
}
3551
Link: { // root type
52+
createdAt: NexusGenScalars['DateTime']; // DateTime!
3653
description: string; // String!
3754
id: number; // Int!
3855
url: string; // String!
@@ -44,6 +61,10 @@ export interface NexusGenObjects {
4461
id: number; // Int!
4562
name: string; // String!
4663
}
64+
Vote: { // root type
65+
link: NexusGenRootTypes['Link']; // Link!
66+
user: NexusGenRootTypes['User']; // User!
67+
}
4768
}
4869

4970
export interface NexusGenInterfaces {
@@ -62,15 +83,18 @@ export interface NexusGenFieldTypes {
6283
user: NexusGenRootTypes['User']; // User!
6384
}
6485
Link: { // field return type
86+
createdAt: NexusGenScalars['DateTime']; // DateTime!
6587
description: string; // String!
6688
id: number; // Int!
6789
postedBy: NexusGenRootTypes['User'] | null; // User
6890
url: string; // String!
91+
voters: NexusGenRootTypes['User'][]; // [User!]!
6992
}
7093
Mutation: { // field return type
7194
login: NexusGenRootTypes['AuthPayload']; // AuthPayload!
7295
post: NexusGenRootTypes['Link']; // Link!
7396
signup: NexusGenRootTypes['AuthPayload']; // AuthPayload!
97+
vote: NexusGenRootTypes['Vote'] | null; // Vote
7498
}
7599
Query: { // field return type
76100
feed: NexusGenRootTypes['Link'][]; // [Link!]!
@@ -80,6 +104,11 @@ export interface NexusGenFieldTypes {
80104
id: number; // Int!
81105
links: NexusGenRootTypes['Link'][]; // [Link!]!
82106
name: string; // String!
107+
votes: NexusGenRootTypes['Link'][]; // [Link!]!
108+
}
109+
Vote: { // field return type
110+
link: NexusGenRootTypes['Link']; // Link!
111+
user: NexusGenRootTypes['User']; // User!
83112
}
84113
}
85114

@@ -89,15 +118,18 @@ export interface NexusGenFieldTypeNames {
89118
user: 'User'
90119
}
91120
Link: { // field return type name
121+
createdAt: 'DateTime'
92122
description: 'String'
93123
id: 'Int'
94124
postedBy: 'User'
95125
url: 'String'
126+
voters: 'User'
96127
}
97128
Mutation: { // field return type name
98129
login: 'AuthPayload'
99130
post: 'Link'
100131
signup: 'AuthPayload'
132+
vote: 'Vote'
101133
}
102134
Query: { // field return type name
103135
feed: 'Link'
@@ -107,6 +139,11 @@ export interface NexusGenFieldTypeNames {
107139
id: 'Int'
108140
links: 'Link'
109141
name: 'String'
142+
votes: 'Link'
143+
}
144+
Vote: { // field return type name
145+
link: 'Link'
146+
user: 'User'
110147
}
111148
}
112149

@@ -125,6 +162,9 @@ export interface NexusGenArgTypes {
125162
name: string; // String!
126163
password: string; // String!
127164
}
165+
vote: { // args
166+
linkId: number; // Int!
167+
}
128168
}
129169
}
130170

package-lock.json

Lines changed: 198 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"devDependencies": {
1616
"@types/bcryptjs": "~2.4.0",
1717
"@types/express": "^4.17.13",
18+
"@types/express-graphql": "^0.9.0",
1819
"@types/jsonwebtoken": "~8.5.0",
1920
"prettier": "^2.4.1",
2021
"prisma": "^3.5.0",
@@ -26,6 +27,7 @@
2627
"apollo-server": "^3.5.0",
2728
"bcryptjs": "~2.4.0",
2829
"graphql": "^15.7.2",
30+
"graphql-scalars": "^1.14.1",
2931
"jsonwebtoken": "~8.5.0",
3032
"nexus": "^1.1.0"
3133
},

prisma/dev.db

12 KB
Binary file not shown.

0 commit comments

Comments
 (0)