This repository has been archived by the owner on Sep 22, 2021. It is now read-only.
/
auth-graphql.tsx
382 lines (322 loc) · 11.2 KB
/
auth-graphql.tsx
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
import gql from 'graphql-tag';
import * as ApolloReactCommon from '@apollo/react-common';
import * as ApolloReactHooks from '@apollo/react-hooks';
export type Maybe<T> = T | null;
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string,
String: string,
Boolean: boolean,
Int: number,
Float: number,
Upload: any,
};
export enum CacheControlScope {
Public = 'PUBLIC',
Private = 'PRIVATE'
}
export type ChangeResponse = {
__typename?: 'ChangeResponse',
message?: Maybe<Scalars['String']>,
token?: Maybe<Scalars['String']>,
};
export type LoginResponse = {
__typename?: 'LoginResponse',
user?: Maybe<User>,
token?: Maybe<Scalars['String']>,
};
export type Message = {
__typename?: 'Message',
message?: Maybe<Scalars['String']>,
};
export type Mutation = {
__typename?: 'Mutation',
changeUsername?: Maybe<ChangeResponse>,
changeEmail?: Maybe<ChangeResponse>,
changePassword?: Maybe<Message>,
changeName?: Maybe<ChangeResponse>,
login?: Maybe<LoginResponse>,
logout?: Maybe<Message>,
postSubscribe?: Maybe<Message>,
postUnsubscribe?: Maybe<Message>,
requestResetPassword?: Maybe<Message>,
resetPassword?: Maybe<Message>,
signup?: Maybe<LoginResponse>,
undoEmailChange?: Maybe<UndoEmailChangeResponse>,
verifyEmail?: Maybe<ChangeResponse>,
};
export type MutationChangeUsernameArgs = {
username: Scalars['String']
};
export type MutationChangeEmailArgs = {
email: Scalars['String']
};
export type MutationChangePasswordArgs = {
oldPassword: Scalars['String'],
newPassword: Scalars['String']
};
export type MutationChangeNameArgs = {
newName: Scalars['String']
};
export type MutationLoginArgs = {
username: Scalars['String'],
password: Scalars['String']
};
export type MutationPostSubscribeArgs = {
post_id: Scalars['Int']
};
export type MutationPostUnsubscribeArgs = {
post_id: Scalars['Int']
};
export type MutationRequestResetPasswordArgs = {
email: Scalars['String']
};
export type MutationResetPasswordArgs = {
token: Scalars['String'],
newPassword: Scalars['String']
};
export type MutationSignupArgs = {
email?: Maybe<Scalars['String']>,
password: Scalars['String'],
username: Scalars['String'],
name?: Maybe<Scalars['String']>
};
export type MutationUndoEmailChangeArgs = {
token: Scalars['String']
};
export type MutationVerifyEmailArgs = {
token: Scalars['String']
};
export type Query = {
__typename?: 'Query',
subscription?: Maybe<Subscription>,
token?: Maybe<Token>,
user?: Maybe<User>,
users?: Maybe<Array<Maybe<User>>>,
};
export type QuerySubscriptionArgs = {
post_id: Scalars['Int']
};
export type QueryUserArgs = {
id: Scalars['Int']
};
export type QueryUsersArgs = {
limit?: Maybe<Scalars['Int']>,
page?: Maybe<Scalars['Int']>
};
export type Subscription = {
__typename?: 'Subscription',
subscribed?: Maybe<Scalars['Boolean']>,
};
export type Token = {
__typename?: 'Token',
token?: Maybe<Scalars['String']>,
};
export type UndoEmailChangeResponse = {
__typename?: 'UndoEmailChangeResponse',
message?: Maybe<Scalars['String']>,
email?: Maybe<Scalars['String']>,
token?: Maybe<Scalars['String']>,
};
export type User = {
__typename?: 'User',
id?: Maybe<Scalars['Int']>,
username?: Maybe<Scalars['String']>,
name?: Maybe<Scalars['String']>,
email?: Maybe<Scalars['String']>,
email_verified?: Maybe<Scalars['Boolean']>,
};
export type UserFragment = (
{ __typename?: 'User' }
& Pick<User, 'id' | 'name' | 'username' | 'email' | 'email_verified'>
);
export type SignupMutationVariables = {
email?: Maybe<Scalars['String']>,
password: Scalars['String'],
username: Scalars['String'],
name?: Maybe<Scalars['String']>
};
export type SignupMutation = (
{ __typename?: 'Mutation' }
& { signup: Maybe<(
{ __typename?: 'LoginResponse' }
& Pick<LoginResponse, 'token'>
& { user: Maybe<(
{ __typename?: 'User' }
& UserFragment
)> }
)> }
);
export type LoginMutationVariables = {
password: Scalars['String'],
username: Scalars['String']
};
export type LoginMutation = (
{ __typename?: 'Mutation' }
& { login: Maybe<(
{ __typename?: 'LoginResponse' }
& Pick<LoginResponse, 'token'>
& { user: Maybe<(
{ __typename?: 'User' }
& UserFragment
)> }
)> }
);
export type LogoutMutationVariables = {};
export type LogoutMutation = (
{ __typename?: 'Mutation' }
& { logout: Maybe<(
{ __typename?: 'Message' }
& Pick<Message, 'message'>
)> }
);
export type Get_Refresh_TokenQueryVariables = {};
export type Get_Refresh_TokenQuery = (
{ __typename?: 'Query' }
& { token: Maybe<(
{ __typename?: 'Token' }
& Pick<Token, 'token'>
)> }
);
export const UserFragmentDoc = gql`
fragment user on User {
id
name
username
email
email_verified
}
`;
export const SignupDocument = gql`
mutation SIGNUP($email: String, $password: String!, $username: String!, $name: String) {
signup(email: $email, password: $password, username: $username, name: $name) {
user {
...user
}
token
}
}
${UserFragmentDoc}`;
export type SignupMutationFn = ApolloReactCommon.MutationFunction<SignupMutation, SignupMutationVariables>;
/**
* __useSignupMutation__
*
* To run a mutation, you first call `useSignupMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useSignupMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [signupMutation, { data, loading, error }] = useSignupMutation({
* variables: {
* email: // value for 'email'
* password: // value for 'password'
* username: // value for 'username'
* name: // value for 'name'
* },
* });
*/
export function useSignupMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<SignupMutation, SignupMutationVariables>) {
return ApolloReactHooks.useMutation<SignupMutation, SignupMutationVariables>(SignupDocument, baseOptions);
}
export type SignupMutationHookResult = ReturnType<typeof useSignupMutation>;
export type SignupMutationResult = ApolloReactCommon.MutationResult<SignupMutation>;
export type SignupMutationOptions = ApolloReactCommon.BaseMutationOptions<SignupMutation, SignupMutationVariables>;
export const LoginDocument = gql`
mutation LOGIN($password: String!, $username: String!) {
login(password: $password, username: $username) {
user {
...user
}
token
}
}
${UserFragmentDoc}`;
export type LoginMutationFn = ApolloReactCommon.MutationFunction<LoginMutation, LoginMutationVariables>;
/**
* __useLoginMutation__
*
* To run a mutation, you first call `useLoginMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useLoginMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [loginMutation, { data, loading, error }] = useLoginMutation({
* variables: {
* password: // value for 'password'
* username: // value for 'username'
* },
* });
*/
export function useLoginMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<LoginMutation, LoginMutationVariables>) {
return ApolloReactHooks.useMutation<LoginMutation, LoginMutationVariables>(LoginDocument, baseOptions);
}
export type LoginMutationHookResult = ReturnType<typeof useLoginMutation>;
export type LoginMutationResult = ApolloReactCommon.MutationResult<LoginMutation>;
export type LoginMutationOptions = ApolloReactCommon.BaseMutationOptions<LoginMutation, LoginMutationVariables>;
export const LogoutDocument = gql`
mutation LOGOUT {
logout {
message
}
}
`;
export type LogoutMutationFn = ApolloReactCommon.MutationFunction<LogoutMutation, LogoutMutationVariables>;
/**
* __useLogoutMutation__
*
* To run a mutation, you first call `useLogoutMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useLogoutMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [logoutMutation, { data, loading, error }] = useLogoutMutation({
* variables: {
* },
* });
*/
export function useLogoutMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<LogoutMutation, LogoutMutationVariables>) {
return ApolloReactHooks.useMutation<LogoutMutation, LogoutMutationVariables>(LogoutDocument, baseOptions);
}
export type LogoutMutationHookResult = ReturnType<typeof useLogoutMutation>;
export type LogoutMutationResult = ApolloReactCommon.MutationResult<LogoutMutation>;
export type LogoutMutationOptions = ApolloReactCommon.BaseMutationOptions<LogoutMutation, LogoutMutationVariables>;
export const Get_Refresh_TokenDocument = gql`
query GET_REFRESH_TOKEN {
token {
token
}
}
`;
/**
* __useGet_Refresh_TokenQuery__
*
* To run a query within a React component, call `useGet_Refresh_TokenQuery` and pass it any options that fit your needs.
* When your component renders, `useGet_Refresh_TokenQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useGet_Refresh_TokenQuery({
* variables: {
* },
* });
*/
export function useGet_Refresh_TokenQuery(baseOptions?: ApolloReactHooks.QueryHookOptions<Get_Refresh_TokenQuery, Get_Refresh_TokenQueryVariables>) {
return ApolloReactHooks.useQuery<Get_Refresh_TokenQuery, Get_Refresh_TokenQueryVariables>(Get_Refresh_TokenDocument, baseOptions);
}
export function useGet_Refresh_TokenLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions<Get_Refresh_TokenQuery, Get_Refresh_TokenQueryVariables>) {
return ApolloReactHooks.useLazyQuery<Get_Refresh_TokenQuery, Get_Refresh_TokenQueryVariables>(Get_Refresh_TokenDocument, baseOptions);
}
export type Get_Refresh_TokenQueryHookResult = ReturnType<typeof useGet_Refresh_TokenQuery>;
export type Get_Refresh_TokenLazyQueryHookResult = ReturnType<typeof useGet_Refresh_TokenLazyQuery>;
export type Get_Refresh_TokenQueryResult = ApolloReactCommon.QueryResult<Get_Refresh_TokenQuery, Get_Refresh_TokenQueryVariables>;