- Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwundergraph.nextjs.integration.ts
195 lines (183 loc) · 5.77 KB
/
wundergraph.nextjs.integration.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// Code generated by wunderctl. DO NOT EDIT.
importtype{
AddMessageResponse,
AddMessageInput,
AddMessageResponseData,
AllUsersResponse,
AllUsersInput,
AllUsersResponseData,
ChangeUserNameResponse,
ChangeUserNameInput,
ChangeUserNameResponseData,
CountriesResponse,
CountriesResponseData,
DeleteAllMessagesByUserEmailResponse,
DeleteAllMessagesByUserEmailInput,
DeleteAllMessagesByUserEmailResponseData,
GermanyResponse,
GermanyResponseData,
HelloResponse,
HelloResponseData,
MessagesResponse,
MessagesResponseData,
QueryResponse,
QueryResponseData,
UpdateUserResponse,
UpdateUserInput,
UpdateUserResponseData,
UsResponse,
UsResponseData,
UserInfoResponse,
UserInfoResponseData,
}from"./models";
import{createContext}from"react";
import{
QueryArgsWithInput,
SubscriptionArgs,
SubscriptionArgsWithInput,
hooks,
WunderGraphContextProperties,
Client,
User,
}from"@wundergraph/sdk/dist/nextjs";
exporttypeRole="user"|"superadmin";
exportenumAuthProvider{
"github"="github",
}
exportconstAuthProviders={
github: AuthProvider.github,
};
constdefaultWunderGraphContextProperties: WunderGraphContextProperties<Role>={
ssrCache: {},
client: newClient({
applicationHash: "b70be929",
applicationPath: "api/main",
baseURL: "http://localhost:9991",
sdkVersion: "1.0.0-next.25",
}),
user: null,
setUser: (value)=>{},
isWindowFocused: "pristine",
setIsWindowFocused: (value)=>{},
refetchMountedOperations: 0,
setRefetchMountedOperations: (value)=>{},
};
exportconstWunderGraphContext=createContext<WunderGraphContextProperties<Role>>(
defaultWunderGraphContextProperties
);
exportconstwithWunderGraph=hooks.withWunderGraphContextWrapper(
WunderGraphContext,
defaultWunderGraphContextProperties
);
exportconstuseWunderGraph=hooks.useWunderGraph(WunderGraphContext);
exportconstuseQuery={
AllUsers: (args: QueryArgsWithInput<AllUsersInput>)=>
hooks.useQueryWithInput<AllUsersInput,AllUsersResponseData,Role>(WunderGraphContext,{
operationName: "AllUsers",
requiresAuthentication: false,
})(args),
Countries: hooks.useQueryWithoutInput<CountriesResponseData,Role>(WunderGraphContext,{
operationName: "Countries",
requiresAuthentication: false,
}),
Germany: hooks.useQueryWithoutInput<GermanyResponseData,Role>(WunderGraphContext,{
operationName: "Germany",
requiresAuthentication: false,
}),
Hello: hooks.useQueryWithoutInput<HelloResponseData,Role>(WunderGraphContext,{
operationName: "Hello",
requiresAuthentication: false,
}),
Messages: hooks.useQueryWithoutInput<MessagesResponseData,Role>(WunderGraphContext,{
operationName: "Messages",
requiresAuthentication: false,
}),
Query: hooks.useQueryWithoutInput<QueryResponseData,Role>(WunderGraphContext,{
operationName: "Query",
requiresAuthentication: false,
}),
Us: hooks.useQueryWithoutInput<UsResponseData,Role>(WunderGraphContext,{
operationName: "Us",
requiresAuthentication: false,
}),
UserInfo: hooks.useQueryWithoutInput<UserInfoResponseData,Role>(WunderGraphContext,{
operationName: "UserInfo",
requiresAuthentication: true,
}),
};
exportconstuseMutation={
AddMessage: ()=>
hooks.useMutationWithInput<AddMessageInput,AddMessageResponseData,Role>(WunderGraphContext,{
operationName: "AddMessage",
requiresAuthentication: true,
}),
ChangeUserName: ()=>
hooks.useMutationWithInput<ChangeUserNameInput,ChangeUserNameResponseData,Role>(WunderGraphContext,{
operationName: "ChangeUserName",
requiresAuthentication: true,
}),
DeleteAllMessagesByUserEmail: ()=>
hooks.useMutationWithInput<DeleteAllMessagesByUserEmailInput,DeleteAllMessagesByUserEmailResponseData,Role>(
WunderGraphContext,
{
operationName: "DeleteAllMessagesByUserEmail",
requiresAuthentication: true,
}
),
UpdateUser: ()=>
hooks.useMutationWithInput<UpdateUserInput,UpdateUserResponseData,Role>(WunderGraphContext,{
operationName: "UpdateUser",
requiresAuthentication: false,
}),
};
exportconstuseSubscription={};
exportconstuseLiveQuery={
AllUsers: (args: SubscriptionArgsWithInput<AllUsersInput>)=>
hooks.useSubscriptionWithInput<AllUsersInput,AllUsersResponseData,Role>(WunderGraphContext,{
operationName: "AllUsers",
isLiveQuery: true,
requiresAuthentication: false,
})(args),
Countries: (args?: SubscriptionArgs)=>
hooks.useSubscriptionWithoutInput<CountriesResponseData,Role>(WunderGraphContext,{
operationName: "Countries",
isLiveQuery: true,
requiresAuthentication: false,
})(args),
Germany: (args?: SubscriptionArgs)=>
hooks.useSubscriptionWithoutInput<GermanyResponseData,Role>(WunderGraphContext,{
operationName: "Germany",
isLiveQuery: true,
requiresAuthentication: false,
})(args),
Hello: (args?: SubscriptionArgs)=>
hooks.useSubscriptionWithoutInput<HelloResponseData,Role>(WunderGraphContext,{
operationName: "Hello",
isLiveQuery: true,
requiresAuthentication: false,
})(args),
Messages: (args?: SubscriptionArgs)=>
hooks.useSubscriptionWithoutInput<MessagesResponseData,Role>(WunderGraphContext,{
operationName: "Messages",
isLiveQuery: true,
requiresAuthentication: false,
})(args),
Query: (args?: SubscriptionArgs)=>
hooks.useSubscriptionWithoutInput<QueryResponseData,Role>(WunderGraphContext,{
operationName: "Query",
isLiveQuery: true,
requiresAuthentication: false,
})(args),
Us: (args?: SubscriptionArgs)=>
hooks.useSubscriptionWithoutInput<UsResponseData,Role>(WunderGraphContext,{
operationName: "Us",
isLiveQuery: true,
requiresAuthentication: false,
})(args),
UserInfo: (args?: SubscriptionArgs)=>
hooks.useSubscriptionWithoutInput<UserInfoResponseData,Role>(WunderGraphContext,{
operationName: "UserInfo",
isLiveQuery: true,
requiresAuthentication: true,
})(args),
};