Skip to content

Commit 0c34116

Browse files
committed
update enable ts strict
1 parent b8bff64 commit 0c34116

File tree

7 files changed

+81
-28
lines changed

7 files changed

+81
-28
lines changed

.wundergraph/generated/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ export class Client {
129129
};
130130
private extraHeaders?: HeadersInit;
131131
private readonly baseURL: string = "http://localhost:9991";
132-
private readonly applicationHash: string = "edf54fdd";
132+
private readonly applicationHash: string = "e6b49e3f";
133133
private readonly applicationPath: string = "api/main";
134-
private readonly sdkVersion: string = "0.43.1";
134+
private readonly sdkVersion: string = "0.43.3";
135135
private csrfToken: string | undefined;
136136
private user: User | null;
137137
private userListener: UserListener | undefined;

.wundergraph/generated/models.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,52 @@ export interface MockQueryResponse {
7979
};
8080
errors?: ReadonlyArray<GraphQLError>;
8181
}
82+
83+
export interface GraphQLError {
84+
message: string;
85+
path?: ReadonlyArray<string | number>;
86+
}
87+
88+
export interface AddMessageResponseData {
89+
createOnemessages?: {
90+
id: number;
91+
message: string;
92+
};
93+
}
94+
95+
export interface AllUsersResponseData {
96+
findManyusers: {
97+
id: number;
98+
email: string;
99+
name: string;
100+
messages?: {
101+
id: number;
102+
message: string;
103+
}[];
104+
}[];
105+
}
106+
107+
export interface DeleteAllMessagesByUserEmailResponseData {
108+
deleteManymessages?: {
109+
count: number;
110+
};
111+
}
112+
113+
export interface MessagesResponseData {
114+
findManymessages: {
115+
id: number;
116+
message: string;
117+
users: {
118+
id: number;
119+
name: string;
120+
};
121+
}[];
122+
}
123+
124+
export interface MockQueryResponseData {
125+
findFirstusers?: {
126+
id: number;
127+
email: string;
128+
name: string;
129+
};
130+
}

.wundergraph/generated/wundergraph.postman.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
"item": [
33
{
44
"_": {
5-
"postman_id": "3cc3e0c9-15cd-4fbb-ba6e-6ea9dcfc3caf"
5+
"postman_id": "b701d340-52c2-4cdb-942a-80696e8186ea"
66
},
7-
"id": "3cc3e0c9-15cd-4fbb-ba6e-6ea9dcfc3caf",
7+
"id": "b701d340-52c2-4cdb-942a-80696e8186ea",
88
"name": "Queries",
99
"description": {
1010
"content": "All your query operations",
1111
"type": "text/plain"
1212
},
1313
"item": [
1414
{
15-
"id": "9da61559-dcf1-481c-83b0-84eadef098d4",
15+
"id": "80d2d82a-9fe6-4e30-b00e-af99129d582c",
1616
"name": "AllUsers",
1717
"request": {
1818
"url": {
@@ -40,7 +40,7 @@
4040
"event": []
4141
},
4242
{
43-
"id": "025a6451-aaa8-4b1f-b4be-7e13dd60c7cb",
43+
"id": "ea870baa-8240-4473-a314-2ce62ded8d2e",
4444
"name": "Messages",
4545
"request": {
4646
"url": {
@@ -68,7 +68,7 @@
6868
"event": []
6969
},
7070
{
71-
"id": "8691b10f-f827-46c9-a20e-bc2423f094dd",
71+
"id": "4d65e632-8bfa-4084-b85c-c19a7ccb1b38",
7272
"name": "MockQuery",
7373
"request": {
7474
"url": {
@@ -100,17 +100,17 @@
100100
},
101101
{
102102
"_": {
103-
"postman_id": "a4fa0a13-2105-4be5-b848-20043eef879b"
103+
"postman_id": "90cca54d-cfb9-480e-baf1-ebfb082d0f21"
104104
},
105-
"id": "a4fa0a13-2105-4be5-b848-20043eef879b",
105+
"id": "90cca54d-cfb9-480e-baf1-ebfb082d0f21",
106106
"name": "Mutations",
107107
"description": {
108108
"content": "All your mutation operations",
109109
"type": "text/plain"
110110
},
111111
"item": [
112112
{
113-
"id": "7d03e45a-4891-4a3a-8e90-675e339af528",
113+
"id": "0d5427b6-fdb8-4580-ae12-9b2155c63eb9",
114114
"name": "AddMessage",
115115
"request": {
116116
"url": {
@@ -146,7 +146,7 @@
146146
"event": []
147147
},
148148
{
149-
"id": "0ea376c5-1678-48ec-8b0c-ea8ae43c4c2d",
149+
"id": "ca4c8355-0798-4bfe-90c4-99d25c5b92bc",
150150
"name": "DeleteAllMessagesByUserEmail",
151151
"request": {
152152
"url": {
@@ -194,7 +194,7 @@
194194
}
195195
],
196196
"info": {
197-
"_postman_id": "47e4483b-160e-413c-8112-557084ef5745",
197+
"_postman_id": "ce01f95d-b590-4ce7-9e85-9cc556dce497",
198198
"name": "Wundergraph",
199199
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
200200
"description": {

.wundergraph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"license": "ISC",
1010
"dependencies": {
1111
"@types/node": "^14.14.37",
12-
"@wundergraph/sdk": "0.43.1",
12+
"@wundergraph/sdk": "0.43.3",
1313
"concurrently": "^6.0.0",
1414
"ts-node-dev": "^1.1.1",
1515
"typescript": "^4.1.3"

.wundergraph/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@
174174
dependencies:
175175
ts-proto "^1.65.0"
176176

177-
"@wundergraph/sdk@0.43.1":
178-
version "0.43.1"
179-
resolved "https://registry.yarnpkg.com/@wundergraph/sdk/-/sdk-0.43.1.tgz#ee44ee91f52b1d8ab6280ae32001da1fd09ecb77"
180-
integrity sha512-JBKaYNGKcBJrsncxVtAHk2tSfFHPNAQVVThlkeIP+RRaGNtDueiHtcg4e8FkaiVNmY6aYIC103RhaC7aLSawLA==
177+
"@wundergraph/sdk@0.43.3":
178+
version "0.43.3"
179+
resolved "https://registry.yarnpkg.com/@wundergraph/sdk/-/sdk-0.43.3.tgz#f4255156a129c354284456a9ecbff355185d64ad"
180+
integrity sha512-X7IQT4kPEeCiSmsv28dyRPXUBHBBjLYkbwboep2kKFa0JdKWK4ZRKpzUrLQxrkQYX9Uxx8MfFKHg6fomewb+VA==
181181
dependencies:
182182
"@graphql-tools/merge" "^6.2.6"
183183
"@wundergraph/protobuf" "0.34.0"

pages/index.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import styles from '../styles/Home.module.css'
22
import {useLiveQuery, useMutation, useWunderGraph} from "../.wundergraph/generated/hooks";
33
import {useEffect, useState} from "react";
4-
import {MessagesResponse} from "../.wundergraph/generated/models";
4+
import type {MessagesResponseData} from "../.wundergraph/generated/models";
55
import {GetServerSideProps, NextPage} from "next";
66
import {Client, User} from '../.wundergraph/generated/client';
77

8-
type Messages = MessagesResponse["data"]["findManymessages"];
8+
type Messages = MessagesResponseData["findManymessages"];
99

1010
interface Props {
11-
messages?: Messages,
12-
user?: User
11+
messages?: Messages;
12+
user: User | null;
1313
}
1414

1515
const Chat: NextPage<Props> = ({messages: serverSideMessages, user: serverSideUser}) => {
@@ -22,7 +22,7 @@ const Chat: NextPage<Props> = ({messages: serverSideMessages, user: serverSideUs
2222
const [messages, setMessages] = useState<Messages>(user !== undefined && serverSideMessages || []);
2323
useEffect(() => {
2424
if (loadMessages.status === "ok") {
25-
setMessages(loadMessages.body.data.findManymessages.reverse());
25+
setMessages((loadMessages.body.data?.findManymessages || []).reverse());
2626
}
2727
if (loadMessages.status === "requiresAuthentication"){
2828
setMessages([]);
@@ -55,9 +55,13 @@ const Chat: NextPage<Props> = ({messages: serverSideMessages, user: serverSideUs
5555
User
5656
</h3>
5757
<p>
58-
Logged in as: {user.name}, {user.email} , {JSON.stringify(user.roles)}
58+
Logged in as: {user?.name}, {user?.email} , {JSON.stringify(user?.roles)}
5959
</p>
60-
<button onClick={() => logout()}>Logout</button>
60+
<button onClick={async () => {
61+
await logout();
62+
window.location.reload();
63+
}
64+
}>Logout</button>
6165
</div>}
6266
{messages !== null && messages.length !== 0 && (
6367
<div>
@@ -79,7 +83,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
7983
// this way, we can make authenticated requests via SSR
8084
const client = new Client({
8185
extraHeaders: {
82-
cookie: context.req.headers.cookie,
86+
"cookie": context.req.headers.cookie || "",
8387
}
8488
});
8589
// fetch the user so that we can render the UI based on the user name and email
@@ -89,8 +93,8 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
8993
return {
9094
props: {
9195
// pass on the data to the page renderer
92-
user,
93-
messages: messages.status === "ok" && messages.body.data.findManymessages.reverse(),
96+
user: user || null,
97+
messages: messages.status === "ok" && messages.body.data?.findManymessages.reverse() || [],
9498
}
9599
}
96100
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"allowJs": true,
1010
"skipLibCheck": true,
11-
"strict": false,
11+
"strict": true,
1212
"forceConsistentCasingInFileNames": true,
1313
"noEmit": true,
1414
"esModuleInterop": true,

0 commit comments

Comments
 (0)