@smartive/graphql-magic 16.3.6 → 16.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/testing.yml +1 -1
- package/CHANGELOG.md +2 -2
- package/dist/bin/gqm.cjs +37 -35
- package/dist/cjs/index.cjs +51 -48
- package/dist/esm/api/execute.d.ts +1 -5
- package/dist/esm/api/execute.js.map +1 -1
- package/dist/esm/client/queries.d.ts +4 -4
- package/dist/esm/client/queries.js.map +1 -1
- package/dist/esm/db/generate.js +2 -0
- package/dist/esm/db/generate.js.map +1 -1
- package/dist/esm/migrations/generate.js +1 -1
- package/dist/esm/migrations/generate.js.map +1 -1
- package/dist/esm/models/models.d.ts +1 -1
- package/dist/esm/models/models.js.map +1 -1
- package/dist/esm/models/utils.d.ts +8 -12
- package/dist/esm/models/utils.js +3 -5
- package/dist/esm/models/utils.js.map +1 -1
- package/dist/esm/permissions/check.js +0 -15
- package/dist/esm/permissions/check.js.map +1 -1
- package/dist/esm/permissions/generate.d.ts +5 -19
- package/dist/esm/permissions/generate.js.map +1 -1
- package/dist/esm/resolvers/arguments.js.map +1 -1
- package/dist/esm/resolvers/filters.js +0 -2
- package/dist/esm/resolvers/filters.js.map +1 -1
- package/dist/esm/resolvers/mutations.js +5 -4
- package/dist/esm/resolvers/mutations.js.map +1 -1
- package/dist/esm/resolvers/node.js.map +1 -1
- package/dist/esm/resolvers/resolver.d.ts +2 -2
- package/dist/esm/resolvers/resolver.js +1 -1
- package/dist/esm/resolvers/resolver.js.map +1 -1
- package/dist/esm/resolvers/selects.js.map +1 -1
- package/dist/esm/resolvers/utils.d.ts +2 -6
- package/dist/esm/resolvers/utils.js +4 -2
- package/dist/esm/resolvers/utils.js.map +1 -1
- package/dist/esm/schema/utils.d.ts +4 -4
- package/dist/esm/schema/utils.js +31 -30
- package/dist/esm/schema/utils.js.map +1 -1
- package/dist/esm/utils/dates.d.ts +2 -4
- package/dist/esm/utils/dates.js +1 -3
- package/dist/esm/utils/dates.js.map +1 -1
- package/docs/docs/1-tutorial.md +1 -1
- package/docs/package-lock.json +1675 -893
- package/docs/package.json +4 -4
- package/eslint.config.mjs +42 -0
- package/migrations/20230912185644_setup.ts +3 -3
- package/package.json +8 -13
- package/src/api/execute.ts +1 -0
- package/src/bin/gqm/codegen.ts +1 -1
- package/src/client/gql.ts +1 -1
- package/src/client/mutations.ts +8 -8
- package/src/client/queries.ts +15 -14
- package/src/db/generate.ts +8 -5
- package/src/migrations/generate.ts +26 -22
- package/src/models/models.ts +24 -9
- package/src/models/mutation-hook.ts +1 -1
- package/src/models/utils.ts +8 -7
- package/src/permissions/check.ts +22 -30
- package/src/permissions/generate.ts +8 -25
- package/src/resolvers/arguments.ts +7 -2
- package/src/resolvers/filters.ts +8 -10
- package/src/resolvers/mutations.ts +19 -16
- package/src/resolvers/node.ts +3 -2
- package/src/resolvers/resolver.ts +11 -10
- package/src/resolvers/selects.ts +4 -3
- package/src/resolvers/utils.ts +15 -10
- package/src/schema/generate.ts +11 -11
- package/src/schema/utils.ts +84 -82
- package/src/utils/dates.ts +3 -3
- package/tests/generated/api/index.ts +2 -2
- package/tests/generated/client/index.ts +1 -193
- package/tests/generated/db/index.ts +4 -4
- package/tests/generated/models.json +2 -1
- package/tests/generated/schema.graphql +1 -1
- package/tests/utils/graphql-client.ts +49 -0
- package/tests/utils/models.ts +1 -0
- package/tests/utils/server.ts +4 -5
- package/tsconfig.eslint.json +18 -3
- package/tsconfig.json +11 -2
- package/.eslintrc +0 -13
package/src/schema/utils.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
ConstArgumentNode,
|
|
4
|
+
ConstDirectiveNode,
|
|
5
|
+
ConstObjectFieldNode,
|
|
6
|
+
ConstValueNode,
|
|
4
7
|
DefinitionNode,
|
|
5
8
|
DirectiveDefinitionNode,
|
|
6
|
-
DirectiveNode,
|
|
7
9
|
DocumentNode,
|
|
8
10
|
EnumTypeDefinitionNode,
|
|
9
11
|
EnumValueDefinitionNode,
|
|
@@ -11,16 +13,15 @@ import {
|
|
|
11
13
|
InputObjectTypeDefinitionNode,
|
|
12
14
|
InputValueDefinitionNode,
|
|
13
15
|
InterfaceTypeDefinitionNode,
|
|
16
|
+
Kind,
|
|
14
17
|
ListTypeNode,
|
|
15
18
|
NamedTypeNode,
|
|
16
19
|
NameNode,
|
|
17
20
|
NonNullTypeNode,
|
|
18
|
-
ObjectFieldNode,
|
|
19
21
|
ObjectTypeDefinitionNode,
|
|
20
22
|
ScalarTypeDefinitionNode,
|
|
21
23
|
StringValueNode,
|
|
22
24
|
TypeNode,
|
|
23
|
-
ValueNode,
|
|
24
25
|
} from 'graphql';
|
|
25
26
|
import { DateTime } from 'luxon';
|
|
26
27
|
import { Directive, Value, Values } from '../values';
|
|
@@ -46,71 +47,71 @@ export type DirectiveLocation =
|
|
|
46
47
|
| 'INPUT_OBJECT';
|
|
47
48
|
|
|
48
49
|
export const document = (definitions: DefinitionNode[]): DocumentNode => ({
|
|
49
|
-
kind:
|
|
50
|
+
kind: Kind.DOCUMENT,
|
|
50
51
|
definitions,
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
export const directive = (nme: string, locations: DirectiveLocation[], fields?: Field[]): DirectiveDefinitionNode => ({
|
|
54
55
|
name: name(nme),
|
|
55
56
|
repeatable: false,
|
|
56
|
-
kind:
|
|
57
|
+
kind: Kind.DIRECTIVE_DEFINITION,
|
|
57
58
|
arguments: fields && inputValues(fields),
|
|
58
59
|
locations: locations.map(name),
|
|
59
60
|
});
|
|
60
61
|
|
|
61
62
|
export const scalar = (nme: string): ScalarTypeDefinitionNode => ({
|
|
62
63
|
name: name(nme),
|
|
63
|
-
kind:
|
|
64
|
+
kind: Kind.SCALAR_TYPE_DEFINITION,
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
export const input = (nme: string, fields: Field[], dvs?: Directive[]): InputObjectTypeDefinitionNode => ({
|
|
67
68
|
name: name(nme),
|
|
68
69
|
fields: inputValues(fields),
|
|
69
|
-
kind:
|
|
70
|
+
kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
70
71
|
directives: directives(dvs),
|
|
71
72
|
});
|
|
72
73
|
|
|
73
74
|
export const object = (nme: string, fds: Field[], interfaces?: string[], dvs?: Directive[]): ObjectTypeDefinitionNode => ({
|
|
74
75
|
name: name(nme),
|
|
75
76
|
fields: fields(fds),
|
|
76
|
-
kind:
|
|
77
|
-
interfaces: interfaces
|
|
77
|
+
kind: Kind.OBJECT_TYPE_DEFINITION,
|
|
78
|
+
interfaces: interfaces?.map((i) => namedType(i)),
|
|
78
79
|
directives: directives(dvs),
|
|
79
80
|
});
|
|
80
81
|
|
|
81
82
|
export const iface = (nme: string, fds: Field[], interfaces?: string[], dvs?: Directive[]): InterfaceTypeDefinitionNode => ({
|
|
82
83
|
name: name(nme),
|
|
83
84
|
fields: fields(fds),
|
|
84
|
-
kind:
|
|
85
|
-
interfaces: interfaces
|
|
85
|
+
kind: Kind.INTERFACE_TYPE_DEFINITION,
|
|
86
|
+
interfaces: interfaces?.map((i) => namedType(i)),
|
|
86
87
|
directives: directives(dvs),
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
export const inputValues = (fields: Field[]): InputValueDefinitionNode[] =>
|
|
90
91
|
fields.map(
|
|
91
92
|
(field): InputValueDefinitionNode => ({
|
|
92
|
-
kind:
|
|
93
|
+
kind: Kind.INPUT_VALUE_DEFINITION,
|
|
93
94
|
name: name(field.name),
|
|
94
95
|
type: fieldType(field),
|
|
95
96
|
defaultValue: field.defaultValue === undefined ? undefined : value(field.defaultValue),
|
|
96
97
|
directives: directives(field.directives),
|
|
97
|
-
})
|
|
98
|
+
}),
|
|
98
99
|
);
|
|
99
100
|
|
|
100
101
|
export const fields = (fields: Field[]): FieldDefinitionNode[] =>
|
|
101
102
|
fields.map(
|
|
102
103
|
(field): FieldDefinitionNode => ({
|
|
103
|
-
kind:
|
|
104
|
+
kind: Kind.FIELD_DEFINITION,
|
|
104
105
|
name: name(field.name),
|
|
105
106
|
type: fieldType(field),
|
|
106
107
|
arguments: field.args?.map((arg) => ({
|
|
107
|
-
kind:
|
|
108
|
+
kind: Kind.INPUT_VALUE_DEFINITION,
|
|
108
109
|
name: name(arg.name),
|
|
109
110
|
type: fieldType(arg),
|
|
110
111
|
defaultValue: arg.defaultValue === undefined ? undefined : value(arg.defaultValue),
|
|
111
112
|
})),
|
|
112
113
|
directives: directives(field.directives),
|
|
113
|
-
})
|
|
114
|
+
}),
|
|
114
115
|
);
|
|
115
116
|
|
|
116
117
|
export const inputValue = (
|
|
@@ -118,62 +119,62 @@ export const inputValue = (
|
|
|
118
119
|
type: TypeNode,
|
|
119
120
|
dvs?: Directive[],
|
|
120
121
|
description?: string,
|
|
121
|
-
defaultValue?: Value
|
|
122
|
+
defaultValue?: Value,
|
|
122
123
|
): InputValueDefinitionNode => ({
|
|
123
124
|
name: name(nme),
|
|
124
125
|
type,
|
|
125
|
-
kind:
|
|
126
|
+
kind: Kind.INPUT_VALUE_DEFINITION,
|
|
126
127
|
directives: directives(dvs),
|
|
127
128
|
defaultValue: defaultValue ? value(defaultValue) : undefined,
|
|
128
129
|
description: description ? (value(description) as StringValueNode) : undefined,
|
|
129
130
|
});
|
|
130
131
|
|
|
131
|
-
export const directives = (directives?: Directive[]):
|
|
132
|
+
export const directives = (directives?: Directive[]): ConstDirectiveNode[] | undefined =>
|
|
132
133
|
directives?.map(
|
|
133
|
-
(directive):
|
|
134
|
-
kind:
|
|
134
|
+
(directive): ConstDirectiveNode => ({
|
|
135
|
+
kind: Kind.DIRECTIVE,
|
|
135
136
|
name: name(directive.name),
|
|
136
137
|
arguments: args(directive.values),
|
|
137
|
-
})
|
|
138
|
+
}),
|
|
138
139
|
);
|
|
139
140
|
|
|
140
|
-
export const args = (ags: Values | undefined):
|
|
141
|
+
export const args = (ags: Values | undefined): readonly ConstArgumentNode[] | undefined =>
|
|
141
142
|
ags?.map(
|
|
142
|
-
(argument):
|
|
143
|
-
kind:
|
|
143
|
+
(argument): ConstArgumentNode => ({
|
|
144
|
+
kind: Kind.ARGUMENT,
|
|
144
145
|
name: name(argument.name),
|
|
145
146
|
value: value(argument.values),
|
|
146
|
-
})
|
|
147
|
+
}),
|
|
147
148
|
);
|
|
148
149
|
|
|
149
150
|
export const enm = (nme: string, values: string[]): EnumTypeDefinitionNode => ({
|
|
150
151
|
name: name(nme),
|
|
151
|
-
kind:
|
|
152
|
+
kind: Kind.ENUM_TYPE_DEFINITION,
|
|
152
153
|
values: values.map(
|
|
153
154
|
(v): EnumValueDefinitionNode => ({
|
|
154
|
-
kind:
|
|
155
|
+
kind: Kind.ENUM_VALUE_DEFINITION,
|
|
155
156
|
name: name(v),
|
|
156
|
-
})
|
|
157
|
+
}),
|
|
157
158
|
),
|
|
158
159
|
});
|
|
159
160
|
|
|
160
161
|
export const nonNull = (type: NamedTypeNode | ListTypeNode): NonNullTypeNode => ({
|
|
161
162
|
type,
|
|
162
|
-
kind:
|
|
163
|
+
kind: Kind.NON_NULL_TYPE,
|
|
163
164
|
});
|
|
164
165
|
|
|
165
166
|
export const namedType = (nme: string): NamedTypeNode => ({
|
|
166
|
-
kind:
|
|
167
|
+
kind: Kind.NAMED_TYPE,
|
|
167
168
|
name: name(nme),
|
|
168
169
|
});
|
|
169
170
|
|
|
170
171
|
export const list = (type: TypeNode): ListTypeNode => ({
|
|
171
172
|
type,
|
|
172
|
-
kind:
|
|
173
|
+
kind: Kind.LIST_TYPE,
|
|
173
174
|
});
|
|
174
175
|
|
|
175
176
|
export const name = (name: string): NameNode => ({
|
|
176
|
-
kind:
|
|
177
|
+
kind: Kind.NAME,
|
|
177
178
|
value: name,
|
|
178
179
|
});
|
|
179
180
|
|
|
@@ -185,61 +186,62 @@ export const fieldType = (field: Field) => {
|
|
|
185
186
|
if (field.nonNull) {
|
|
186
187
|
type = nonNull(type);
|
|
187
188
|
}
|
|
189
|
+
|
|
188
190
|
return type;
|
|
189
191
|
};
|
|
190
192
|
|
|
191
|
-
export const value = (val: Value = null):
|
|
193
|
+
export const value = (val: Value = null): ConstValueNode =>
|
|
192
194
|
val === null
|
|
193
195
|
? {
|
|
194
|
-
kind:
|
|
196
|
+
kind: Kind.NULL,
|
|
195
197
|
}
|
|
196
198
|
: typeof val === 'boolean'
|
|
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
|
-
|
|
199
|
+
? {
|
|
200
|
+
kind: Kind.BOOLEAN,
|
|
201
|
+
value: val,
|
|
202
|
+
}
|
|
203
|
+
: typeof val === 'number'
|
|
204
|
+
? {
|
|
205
|
+
kind: Kind.INT,
|
|
206
|
+
value: `${val}`,
|
|
207
|
+
}
|
|
208
|
+
: typeof val === 'string'
|
|
209
|
+
? {
|
|
210
|
+
kind: Kind.STRING,
|
|
211
|
+
value: val,
|
|
212
|
+
}
|
|
213
|
+
: val instanceof Symbol
|
|
214
|
+
? {
|
|
215
|
+
kind: Kind.ENUM,
|
|
216
|
+
value: val.description!,
|
|
217
|
+
}
|
|
218
|
+
: Array.isArray(val)
|
|
219
|
+
? {
|
|
220
|
+
kind: Kind.LIST,
|
|
221
|
+
values: val.map(value),
|
|
222
|
+
}
|
|
223
|
+
: val instanceof DateTime
|
|
224
|
+
? {
|
|
225
|
+
kind: Kind.STRING,
|
|
226
|
+
value: val.toString(),
|
|
227
|
+
}
|
|
228
|
+
: val instanceof Dayjs
|
|
229
|
+
? {
|
|
230
|
+
kind: Kind.STRING,
|
|
231
|
+
value: val.toISOString(),
|
|
232
|
+
}
|
|
233
|
+
: typeof val === 'object'
|
|
234
|
+
? {
|
|
235
|
+
kind: Kind.OBJECT,
|
|
236
|
+
fields: Object.keys(val).map(
|
|
237
|
+
(nme): ConstObjectFieldNode => ({
|
|
238
|
+
kind: Kind.OBJECT_FIELD,
|
|
239
|
+
name: name(nme),
|
|
240
|
+
value: value(val[nme]),
|
|
241
|
+
}),
|
|
242
|
+
),
|
|
243
|
+
}
|
|
244
|
+
: doThrow(`Unsupported value ${val}`);
|
|
243
245
|
|
|
244
246
|
const doThrow = (message: string) => {
|
|
245
247
|
throw new Error(message);
|
package/src/utils/dates.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DateTime } from 'luxon';
|
|
|
3
3
|
|
|
4
4
|
export type DateLibrary = 'luxon' | 'dayjs';
|
|
5
5
|
|
|
6
|
-
export const DATE_CLASS:
|
|
6
|
+
export const DATE_CLASS: Record<DateLibrary, string> = {
|
|
7
7
|
luxon: 'DateTime',
|
|
8
8
|
dayjs: 'Dayjs',
|
|
9
9
|
};
|
|
@@ -19,9 +19,9 @@ export const anyDateToLuxon = (date: unknown, zone: string | undefined, fallback
|
|
|
19
19
|
if (!date) {
|
|
20
20
|
if (fallbackToNow) {
|
|
21
21
|
return DateTime.local({ zone });
|
|
22
|
-
} else {
|
|
23
|
-
return undefined;
|
|
24
22
|
}
|
|
23
|
+
|
|
24
|
+
return undefined;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if (DateTime.isDateTime(date)) {
|
|
@@ -678,7 +678,7 @@ export type User = {
|
|
|
678
678
|
deletedReactions: Array<Reaction>;
|
|
679
679
|
deletedReviews: Array<Review>;
|
|
680
680
|
id: Scalars['ID']['output'];
|
|
681
|
-
role
|
|
681
|
+
role: Role;
|
|
682
682
|
updatedAnswers: Array<Answer>;
|
|
683
683
|
updatedManyObjects: Array<SomeObject>;
|
|
684
684
|
updatedQuestions: Array<Question>;
|
|
@@ -1172,7 +1172,7 @@ export type UserResolvers<ContextType = any, ParentType extends ResolversParentT
|
|
|
1172
1172
|
deletedReactions?: Resolver<Array<ResolversTypes['Reaction']>, ParentType, ContextType, Partial<UserDeletedReactionsArgs>>;
|
|
1173
1173
|
deletedReviews?: Resolver<Array<ResolversTypes['Review']>, ParentType, ContextType, Partial<UserDeletedReviewsArgs>>;
|
|
1174
1174
|
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
|
|
1175
|
-
role?: Resolver<
|
|
1175
|
+
role?: Resolver<ResolversTypes['Role'], ParentType, ContextType>;
|
|
1176
1176
|
updatedAnswers?: Resolver<Array<ResolversTypes['Answer']>, ParentType, ContextType, Partial<UserUpdatedAnswersArgs>>;
|
|
1177
1177
|
updatedManyObjects?: Resolver<Array<ResolversTypes['SomeObject']>, ParentType, ContextType, Partial<UserUpdatedManyObjectsArgs>>;
|
|
1178
1178
|
updatedQuestions?: Resolver<Array<ResolversTypes['Question']>, ParentType, ContextType, Partial<UserUpdatedQuestionsArgs>>;
|
|
@@ -675,7 +675,7 @@ export type User = {
|
|
|
675
675
|
deletedReactions: Array<Reaction>;
|
|
676
676
|
deletedReviews: Array<Review>;
|
|
677
677
|
id: Scalars['ID']['output'];
|
|
678
|
-
role:
|
|
678
|
+
role: Role;
|
|
679
679
|
updatedAnswers: Array<Answer>;
|
|
680
680
|
updatedManyObjects: Array<SomeObject>;
|
|
681
681
|
updatedQuestions: Array<Question>;
|
|
@@ -1025,195 +1025,3 @@ export type RestoreAnswerMutationMutationVariables = Exact<{
|
|
|
1025
1025
|
|
|
1026
1026
|
|
|
1027
1027
|
export type RestoreAnswerMutationMutation = { restoreAnswer: string };
|
|
1028
|
-
|
|
1029
|
-
type DiscriminateUnion<T, U> = T extends U ? T : never;
|
|
1030
|
-
|
|
1031
|
-
export namespace DeleteAnotherObject {
|
|
1032
|
-
export type Variables = DeleteAnotherObjectMutationVariables;
|
|
1033
|
-
export type mutation = DeleteAnotherObjectMutation;
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
export namespace GetAnotherObject {
|
|
1037
|
-
export type Variables = GetAnotherObjectQueryVariables;
|
|
1038
|
-
export type query = GetAnotherObjectQuery;
|
|
1039
|
-
export type anotherObjects = NonNullable<(NonNullable<GetAnotherObjectQuery['anotherObjects']>)[number]>;
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
export namespace GetReactions {
|
|
1043
|
-
export type Variables = GetReactionsQueryVariables;
|
|
1044
|
-
export type query = GetReactionsQuery;
|
|
1045
|
-
export type reactions = NonNullable<(NonNullable<GetReactionsQuery['reactions']>)[number]>;
|
|
1046
|
-
export type ReviewInlineFragment = (DiscriminateUnion<NonNullable<(NonNullable<GetReactionsQuery['reactions']>)[number]>, { __typename: 'Review' }>);
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
export namespace GetReaction {
|
|
1050
|
-
export type Variables = GetReactionQueryVariables;
|
|
1051
|
-
export type query = GetReactionQuery;
|
|
1052
|
-
export type reaction = (NonNullable<GetReactionQuery['reaction']>);
|
|
1053
|
-
export type ReviewInlineFragment = (DiscriminateUnion<(NonNullable<GetReactionQuery['reaction']>), { __typename: 'Review' }>);
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
export namespace GetReviews {
|
|
1057
|
-
export type Variables = GetReviewsQueryVariables;
|
|
1058
|
-
export type query = GetReviewsQuery;
|
|
1059
|
-
export type reviews = NonNullable<(NonNullable<GetReviewsQuery['reviews']>)[number]>;
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
export namespace GetReview {
|
|
1063
|
-
export type Variables = GetReviewQueryVariables;
|
|
1064
|
-
export type query = GetReviewQuery;
|
|
1065
|
-
export type review = (NonNullable<GetReviewQuery['review']>);
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
export namespace CreateReview {
|
|
1069
|
-
export type Variables = CreateReviewMutationVariables;
|
|
1070
|
-
export type mutation = CreateReviewMutation;
|
|
1071
|
-
export type createReview = (NonNullable<CreateReviewMutation['createReview']>);
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
export namespace UpdateReview {
|
|
1075
|
-
export type Variables = UpdateReviewMutationVariables;
|
|
1076
|
-
export type mutation = UpdateReviewMutation;
|
|
1077
|
-
export type updateReview = (NonNullable<UpdateReviewMutation['updateReview']>);
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
export namespace SomeQuery {
|
|
1081
|
-
export type Variables = SomeQueryQueryVariables;
|
|
1082
|
-
export type query = SomeQueryQuery;
|
|
1083
|
-
export type manyObjects = NonNullable<(NonNullable<SomeQueryQuery['manyObjects']>)[number]>;
|
|
1084
|
-
export type another = (NonNullable<NonNullable<(NonNullable<SomeQueryQuery['manyObjects']>)[number]>['another']>);
|
|
1085
|
-
export type _manyObjects = NonNullable<(NonNullable<(NonNullable<NonNullable<(NonNullable<SomeQueryQuery['manyObjects']>)[number]>['another']>)['manyObjects']>)[number]>;
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
export namespace ReverseFiltersQuery {
|
|
1089
|
-
export type Variables = ReverseFiltersQueryQueryVariables;
|
|
1090
|
-
export type query = ReverseFiltersQueryQuery;
|
|
1091
|
-
export type all = NonNullable<(NonNullable<ReverseFiltersQueryQuery['all']>)[number]>;
|
|
1092
|
-
export type manyObjects = NonNullable<(NonNullable<NonNullable<(NonNullable<ReverseFiltersQueryQuery['all']>)[number]>['manyObjects']>)[number]>;
|
|
1093
|
-
export type withFloat0 = NonNullable<(NonNullable<ReverseFiltersQueryQuery['withFloat0']>)[number]>;
|
|
1094
|
-
export type _manyObjects = NonNullable<(NonNullable<NonNullable<(NonNullable<ReverseFiltersQueryQuery['withFloat0']>)[number]>['manyObjects']>)[number]>;
|
|
1095
|
-
export type withFloat0_5 = NonNullable<(NonNullable<ReverseFiltersQueryQuery['withFloat0_5']>)[number]>;
|
|
1096
|
-
export type __manyObjects = NonNullable<(NonNullable<NonNullable<(NonNullable<ReverseFiltersQueryQuery['withFloat0_5']>)[number]>['manyObjects']>)[number]>;
|
|
1097
|
-
export type noneFloat0 = NonNullable<(NonNullable<ReverseFiltersQueryQuery['noneFloat0']>)[number]>;
|
|
1098
|
-
export type ___manyObjects = NonNullable<(NonNullable<NonNullable<(NonNullable<ReverseFiltersQueryQuery['noneFloat0']>)[number]>['manyObjects']>)[number]>;
|
|
1099
|
-
export type noneFloat0_5 = NonNullable<(NonNullable<ReverseFiltersQueryQuery['noneFloat0_5']>)[number]>;
|
|
1100
|
-
export type ____manyObjects = NonNullable<(NonNullable<NonNullable<(NonNullable<ReverseFiltersQueryQuery['noneFloat0_5']>)[number]>['manyObjects']>)[number]>;
|
|
1101
|
-
export type noneFloat2 = NonNullable<(NonNullable<ReverseFiltersQueryQuery['noneFloat2']>)[number]>;
|
|
1102
|
-
export type _____manyObjects = NonNullable<(NonNullable<NonNullable<(NonNullable<ReverseFiltersQueryQuery['noneFloat2']>)[number]>['manyObjects']>)[number]>;
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
export namespace NotQuery {
|
|
1106
|
-
export type Variables = NotQueryQueryVariables;
|
|
1107
|
-
export type query = NotQueryQuery;
|
|
1108
|
-
export type manyObjects = NonNullable<(NonNullable<NotQueryQuery['manyObjects']>)[number]>;
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
export namespace AndQuery {
|
|
1112
|
-
export type Variables = AndQueryQueryVariables;
|
|
1113
|
-
export type query = AndQueryQuery;
|
|
1114
|
-
export type manyObjects = NonNullable<(NonNullable<AndQueryQuery['manyObjects']>)[number]>;
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
export namespace OrQuery {
|
|
1118
|
-
export type Variables = OrQueryQueryVariables;
|
|
1119
|
-
export type query = OrQueryQuery;
|
|
1120
|
-
export type manyObjects = NonNullable<(NonNullable<OrQueryQuery['manyObjects']>)[number]>;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
export namespace DeleteAnotherObjectMutation {
|
|
1124
|
-
export type Variables = DeleteAnotherObjectMutationMutationVariables;
|
|
1125
|
-
export type mutation = DeleteAnotherObjectMutationMutation;
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
export namespace RestoreAnotherObjectMutation {
|
|
1129
|
-
export type Variables = RestoreAnotherObjectMutationMutationVariables;
|
|
1130
|
-
export type mutation = RestoreAnotherObjectMutationMutation;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
export namespace CreateSomeObjectMutation {
|
|
1134
|
-
export type Variables = CreateSomeObjectMutationMutationVariables;
|
|
1135
|
-
export type mutation = CreateSomeObjectMutationMutation;
|
|
1136
|
-
export type createSomeObject = (NonNullable<CreateSomeObjectMutationMutation['createSomeObject']>);
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
export namespace UpdateSomeObjectMutation {
|
|
1140
|
-
export type Variables = UpdateSomeObjectMutationMutationVariables;
|
|
1141
|
-
export type mutation = UpdateSomeObjectMutationMutation;
|
|
1142
|
-
export type updateSomeObject = (NonNullable<UpdateSomeObjectMutationMutation['updateSomeObject']>);
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
export namespace DeleteSomeObjectMutation {
|
|
1146
|
-
export type Variables = DeleteSomeObjectMutationMutationVariables;
|
|
1147
|
-
export type mutation = DeleteSomeObjectMutationMutation;
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
export namespace RestoreSomeObjectMutation {
|
|
1151
|
-
export type Variables = RestoreSomeObjectMutationMutationVariables;
|
|
1152
|
-
export type mutation = RestoreSomeObjectMutationMutation;
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
export namespace CreateReviewMutation {
|
|
1156
|
-
export type Variables = CreateReviewMutationMutationVariables;
|
|
1157
|
-
export type mutation = CreateReviewMutationMutation;
|
|
1158
|
-
export type createReview = (NonNullable<CreateReviewMutationMutation['createReview']>);
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
export namespace UpdateReviewMutation {
|
|
1162
|
-
export type Variables = UpdateReviewMutationMutationVariables;
|
|
1163
|
-
export type mutation = UpdateReviewMutationMutation;
|
|
1164
|
-
export type updateReview = (NonNullable<UpdateReviewMutationMutation['updateReview']>);
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
export namespace DeleteReviewMutation {
|
|
1168
|
-
export type Variables = DeleteReviewMutationMutationVariables;
|
|
1169
|
-
export type mutation = DeleteReviewMutationMutation;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
export namespace RestoreReviewMutation {
|
|
1173
|
-
export type Variables = RestoreReviewMutationMutationVariables;
|
|
1174
|
-
export type mutation = RestoreReviewMutationMutation;
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
export namespace CreateQuestionMutation {
|
|
1178
|
-
export type Variables = CreateQuestionMutationMutationVariables;
|
|
1179
|
-
export type mutation = CreateQuestionMutationMutation;
|
|
1180
|
-
export type createQuestion = (NonNullable<CreateQuestionMutationMutation['createQuestion']>);
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
export namespace UpdateQuestionMutation {
|
|
1184
|
-
export type Variables = UpdateQuestionMutationMutationVariables;
|
|
1185
|
-
export type mutation = UpdateQuestionMutationMutation;
|
|
1186
|
-
export type updateQuestion = (NonNullable<UpdateQuestionMutationMutation['updateQuestion']>);
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
export namespace DeleteQuestionMutation {
|
|
1190
|
-
export type Variables = DeleteQuestionMutationMutationVariables;
|
|
1191
|
-
export type mutation = DeleteQuestionMutationMutation;
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
export namespace RestoreQuestionMutation {
|
|
1195
|
-
export type Variables = RestoreQuestionMutationMutationVariables;
|
|
1196
|
-
export type mutation = RestoreQuestionMutationMutation;
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
export namespace CreateAnswerMutation {
|
|
1200
|
-
export type Variables = CreateAnswerMutationMutationVariables;
|
|
1201
|
-
export type mutation = CreateAnswerMutationMutation;
|
|
1202
|
-
export type createAnswer = (NonNullable<CreateAnswerMutationMutation['createAnswer']>);
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
export namespace UpdateAnswerMutation {
|
|
1206
|
-
export type Variables = UpdateAnswerMutationMutationVariables;
|
|
1207
|
-
export type mutation = UpdateAnswerMutationMutation;
|
|
1208
|
-
export type updateAnswer = (NonNullable<UpdateAnswerMutationMutation['updateAnswer']>);
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
export namespace DeleteAnswerMutation {
|
|
1212
|
-
export type Variables = DeleteAnswerMutationMutationVariables;
|
|
1213
|
-
export type mutation = DeleteAnswerMutationMutation;
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
export namespace RestoreAnswerMutation {
|
|
1217
|
-
export type Variables = RestoreAnswerMutationMutationVariables;
|
|
1218
|
-
export type mutation = RestoreAnswerMutationMutation;
|
|
1219
|
-
}
|
|
@@ -9,25 +9,25 @@ export type ReactionType = 'Review' | 'Question' | 'Answer';
|
|
|
9
9
|
export type User = {
|
|
10
10
|
'id': string;
|
|
11
11
|
'username': string | null;
|
|
12
|
-
'role': Role
|
|
12
|
+
'role': Role;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export type UserInitializer = {
|
|
16
16
|
'id': string;
|
|
17
17
|
'username'?: string | null;
|
|
18
|
-
'role'
|
|
18
|
+
'role': Role;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export type UserMutator = {
|
|
22
22
|
'id'?: string;
|
|
23
23
|
'username'?: string | null;
|
|
24
|
-
'role'?: Role
|
|
24
|
+
'role'?: Role;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export type UserSeed = {
|
|
28
28
|
'id': string;
|
|
29
29
|
'username'?: string | null;
|
|
30
|
-
'role'
|
|
30
|
+
'role': string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export type AnotherObject = {
|
|
@@ -319,7 +319,7 @@ scalar Upload
|
|
|
319
319
|
type User {
|
|
320
320
|
id: ID!
|
|
321
321
|
username: String
|
|
322
|
-
role: Role
|
|
322
|
+
role: Role!
|
|
323
323
|
deletedAnotherObjects(where: AnotherObjectWhere, orderBy: [AnotherObjectOrderBy!], limit: Int, offset: Int): [AnotherObject!]!
|
|
324
324
|
createdManyObjects(where: SomeObjectWhere, search: String, orderBy: [SomeObjectOrderBy!], limit: Int, offset: Int): [SomeObject!]!
|
|
325
325
|
updatedManyObjects(where: SomeObjectWhere, search: String, orderBy: [SomeObjectOrderBy!], limit: Int, offset: Int): [SomeObject!]!
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
type Variables = Record<string, unknown>;
|
|
2
|
+
|
|
3
|
+
interface GraphQLResponse<T = any> {
|
|
4
|
+
data?: T;
|
|
5
|
+
errors?: {
|
|
6
|
+
message: string;
|
|
7
|
+
locations?: { line: number; column: number }[];
|
|
8
|
+
path?: string[];
|
|
9
|
+
extensions?: Record<string, unknown>;
|
|
10
|
+
}[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Simple GraphQL client using native fetch
|
|
15
|
+
*/
|
|
16
|
+
export const graphqlRequest = async <T = any>(
|
|
17
|
+
url: string,
|
|
18
|
+
query: string,
|
|
19
|
+
variables?: Variables,
|
|
20
|
+
headers?: HeadersInit,
|
|
21
|
+
): Promise<T> => {
|
|
22
|
+
const response = await fetch(url, {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
...headers,
|
|
27
|
+
},
|
|
28
|
+
body: JSON.stringify({
|
|
29
|
+
query,
|
|
30
|
+
variables,
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw new Error(`HTTP error! Status: ${response.status}.`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const result = (await response.json()) as GraphQLResponse<T>;
|
|
39
|
+
|
|
40
|
+
if (result.errors?.length) {
|
|
41
|
+
throw new Error(`GraphQL Error: ${result.errors.map((e) => e.message).join(', ')}.`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!result.data) {
|
|
45
|
+
throw new Error('No data returned from GraphQL request.');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return result.data;
|
|
49
|
+
};
|