Skip to content

Commit 6d92ee0

Browse files
committed
update sdk
1 parent d7fe676 commit 6d92ee0

Some content is hidden

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

52 files changed

+6152
-4587
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

33
.idea
4-
.wundergraph/generated/bundle
5-
.wundergraph/generated/prisma
4+
.wundergraph/generated
65

76
# dependencies
87
node_modules

.graphqlconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"projects": {
3-
"app": {
4-
"name": "app",
5-
"schemaPath": ".wundergraph/generated/wundergraph.app.schema.graphql",
3+
"api": {
4+
"name": "api",
5+
"schemaPath": ".wundergraph/generated/wundergraph.api.schema.graphql",
66
"extensions": {
77
"endpoints": {
8-
"app": {
8+
"api": {
99
"introspect": false,
10-
"url": "http://localhost:9991/app/main/graphql",
10+
"url": "http://localhost:9991/api/main/graphql",
1111
"headers": {
1212
"user-agent": "WunderGraph Client"
1313
}

.wundergraph/generated/CONFIGURE_AUTH_PROVIDERS.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# Follow this guide to configure your Authentication Providers
23

34
## Provider: github (GitHub)
@@ -11,4 +12,16 @@ It's not handled on the server that's hosting the frontend.
1112

1213
```
1314
http://localhost:9991/api/main/auth/cookie/callback/github
14-
```
15+
16+
## Provider: test (OpenID Connect)
17+
18+
### Authorization Callback URL
19+
20+
Make sure to register this URL on your Authentication Provider.
21+
If you don't or misspell the URL, you'll get an invalid callback URL error when trying to log in a user.
22+
Remember that the authentication flow is handled server-side, on the WunderNode.
23+
It's not handled on the server that's hosting the frontend.
24+
25+
```
26+
http://localhost:9991/api/main/auth/cookie/callback/test
27+
```

.wundergraph/generated/forms.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Code generated by wunderctl. DO NOT EDIT.
22

33
import React, { useEffect, useState } from "react";
4-
import { Response } from "./client";
4+
import type { Response } from "@wundergraph/sdk";
55
import {
66
AddMessageInput,
77
AddMessageResponse,

.wundergraph/generated/hooks.ts

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22

33
import { useCallback, useContext, useEffect, useMemo, useState } from "react";
44
import { WunderGraphContext } from "./provider";
5-
import { RequestOptions, MutateRequestOptions, SubscriptionRequestOptions, Response } from "./client";
5+
import { RequestOptions, MutateRequestOptions, SubscriptionRequestOptions, Response } from "@wundergraph/sdk";
66
import {
77
AddMessageInput,
88
AllUsersInput,
99
ChangeUserNameInput,
1010
DeleteAllMessagesByUserEmailInput,
1111
UpdateUserInput,
1212
AllUsersResponse,
13+
CountriesResponse,
14+
GermanyResponse,
1315
MessagesResponse,
1416
MockQueryResponse,
17+
QueryResponse,
18+
UsResponse,
1519
UserInfoResponse,
1620
} from "./models";
1721

@@ -47,8 +51,17 @@ const Query = <R extends {}, I extends {}>(
4751
const [shouldFetch, setShouldFetch] = useState<boolean>(options === undefined || options.initialState === undefined);
4852
const refetch = useCallback((options?: RequestOptions<I, R>) => {
4953
if (options !== undefined) {
50-
_setOptions(options);
54+
_setOptions({
55+
...options,
56+
lazy: false,
57+
});
58+
} else if (_options && _options.lazy === true) {
59+
_setOptions({
60+
..._options,
61+
lazy: false,
62+
});
5163
}
64+
setResponse({ status: "loading" });
5265
setShouldFetch(true);
5366
}, []);
5467
useEffect(() => {
@@ -62,6 +75,8 @@ const Query = <R extends {}, I extends {}>(
6275
status: "ok",
6376
body: options.initialState,
6477
}
78+
: _options && _options.lazy === true
79+
? { status: "lazy" }
6580
: { status: "loading" }
6681
);
6782
useEffect(() => {
@@ -75,6 +90,9 @@ const Query = <R extends {}, I extends {}>(
7590
if (!shouldFetch) {
7691
return;
7792
}
93+
if (_options && _options.lazy === true) {
94+
return;
95+
}
7896
const abortController = new AbortController();
7997
if (response.status === "ok") {
8098
setResponse({ status: "ok", refetching: true, body: response.body });
@@ -136,6 +154,7 @@ const Mutation = <R extends {}, I extends {}>(
136154
abortSignal:
137155
options !== undefined && options.abortSignal !== undefined ? options.abortSignal : _options?.abortSignal,
138156
};
157+
setResponse({ status: "loading" });
139158
const result = await promiseFactory(combinedOptions);
140159
setResponse(result);
141160
if (result.status === "ok" && combinedOptions.refetchMountedQueriesOnSuccess === true) {
@@ -204,11 +223,28 @@ const Subscription = <R, I>(
204223
};
205224
};
206225

226+
export const useLoadingComplete = (...responses: Response<any>[]) => {
227+
const [loading, setLoading] = useState(true);
228+
useEffect(() => {
229+
const isLoading = responses.some((r) => r.status === "loading");
230+
if (isLoading !== loading) setLoading(isLoading);
231+
}, responses);
232+
return loading;
233+
};
234+
207235
export const useQuery = {
208236
AllUsers: (options: RequestOptions<AllUsersInput, AllUsersResponse>) => {
209237
const { client } = useWunderGraph();
210238
return Query(client.query.AllUsers, { requiresAuthentication: false }, options);
211239
},
240+
Countries: (options?: RequestOptions<never, CountriesResponse>) => {
241+
const { client } = useWunderGraph();
242+
return Query(client.query.Countries, { requiresAuthentication: false }, options);
243+
},
244+
Germany: (options?: RequestOptions<never, GermanyResponse>) => {
245+
const { client } = useWunderGraph();
246+
return Query(client.query.Germany, { requiresAuthentication: false }, options);
247+
},
212248
Messages: (options?: RequestOptions<never, MessagesResponse>) => {
213249
const { client } = useWunderGraph();
214250
return Query(client.query.Messages, { requiresAuthentication: false }, options);
@@ -217,6 +253,14 @@ export const useQuery = {
217253
const { client } = useWunderGraph();
218254
return Query(client.query.MockQuery, { requiresAuthentication: false }, options);
219255
},
256+
Query: (options?: RequestOptions<never, QueryResponse>) => {
257+
const { client } = useWunderGraph();
258+
return Query(client.query.Query, { requiresAuthentication: false }, options);
259+
},
260+
Us: (options?: RequestOptions<never, UsResponse>) => {
261+
const { client } = useWunderGraph();
262+
return Query(client.query.Us, { requiresAuthentication: false }, options);
263+
},
220264
UserInfo: (options?: RequestOptions<never, UserInfoResponse>) => {
221265
const { client } = useWunderGraph();
222266
return Query(client.query.UserInfo, { requiresAuthentication: true }, options);
@@ -247,6 +291,14 @@ export const useLiveQuery = {
247291
const { client } = useWunderGraph();
248292
return Subscription(client.liveQuery.AllUsers, { requiresAuthentication: false }, options);
249293
},
294+
Countries: (options?: SubscriptionRequestOptions) => {
295+
const { client } = useWunderGraph();
296+
return Subscription(client.liveQuery.Countries, { requiresAuthentication: false }, options);
297+
},
298+
Germany: (options?: SubscriptionRequestOptions) => {
299+
const { client } = useWunderGraph();
300+
return Subscription(client.liveQuery.Germany, { requiresAuthentication: false }, options);
301+
},
250302
Messages: (options?: SubscriptionRequestOptions) => {
251303
const { client } = useWunderGraph();
252304
return Subscription(client.liveQuery.Messages, { requiresAuthentication: false }, options);
@@ -255,6 +307,14 @@ export const useLiveQuery = {
255307
const { client } = useWunderGraph();
256308
return Subscription(client.liveQuery.MockQuery, { requiresAuthentication: false }, options);
257309
},
310+
Query: (options?: SubscriptionRequestOptions) => {
311+
const { client } = useWunderGraph();
312+
return Subscription(client.liveQuery.Query, { requiresAuthentication: false }, options);
313+
},
314+
Us: (options?: SubscriptionRequestOptions) => {
315+
const { client } = useWunderGraph();
316+
return Subscription(client.liveQuery.Us, { requiresAuthentication: false }, options);
317+
},
258318
UserInfo: (options?: SubscriptionRequestOptions) => {
259319
const { client } = useWunderGraph();
260320
return Subscription(client.liveQuery.UserInfo, { requiresAuthentication: true }, options);

0 commit comments

Comments
 (0)