Skip to content

Commit 0fb028f

Browse files
committed
🐛 Fixed a bug in schemas without subscriptions
1 parent 6eddc4e commit 0fb028f

File tree

8 files changed

+1098
-65
lines changed

8 files changed

+1098
-65
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* eslint-disable */
2+
3+
import { Zeus, GraphQLTypes, InputType, ValueTypes } from './index';
4+
import { gql, useQuery, useLazyQuery, useSubscription, useMutation } from '@apollo/client';
5+
import type { QueryHookOptions, LazyQueryHookOptions, SubscriptionHookOptions, MutationHookOptions } from '@apollo/client';
6+
7+
8+
export function useTypedQuery<Z, O extends "Query">(
9+
query: Z | ValueTypes[O],
10+
options?: QueryHookOptions<InputType<GraphQLTypes[O], Z>>,
11+
) {
12+
return useQuery<InputType<GraphQLTypes[O], Z>>(gql(Zeus("query",query)), options);
13+
}
14+
export function useTypedLazyQuery<Z, O extends "Query">(
15+
LazyQuery: Z | ValueTypes[O],
16+
options?: LazyQueryHookOptions<InputType<GraphQLTypes[O], Z>>,
17+
) {
18+
return useLazyQuery<InputType<GraphQLTypes[O], Z>>(gql(Zeus("query",LazyQuery)), options);
19+
}
20+
export function useTypedSubscription<Z, O extends "Subscription">(
21+
subscription: Z | ValueTypes[O],
22+
options?: SubscriptionHookOptions<InputType<GraphQLTypes[O], Z>>,
23+
) {
24+
return useSubscription<InputType<GraphQLTypes[O], Z>>(gql(Zeus("subscription",subscription)), options);
25+
}
26+
export function useTypedMutation<Z, O extends "Mutation">(
27+
mutation: Z | ValueTypes[O],
28+
options?: MutationHookOptions<InputType<GraphQLTypes[O], Z>>,
29+
) {
30+
return useMutation<InputType<GraphQLTypes[O], Z>>(gql(Zeus("mutation",mutation)), options);
31+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/* eslint-disable */
2+
3+
export const AllTypesProps: Record<string,any> = {
4+
Query:{
5+
cardById:{
6+
cardId:{
7+
type:"String",
8+
array:false,
9+
arrayRequired:false,
10+
required:false
11+
}
12+
}
13+
},
14+
Card:{
15+
attack:{
16+
cardID:{
17+
type:"String",
18+
array:true,
19+
arrayRequired:true,
20+
required:true
21+
}
22+
}
23+
},
24+
Mutation:{
25+
addCard:{
26+
card:{
27+
type:"createCard",
28+
array:false,
29+
arrayRequired:false,
30+
required:true
31+
}
32+
}
33+
},
34+
SpecialSkills: "enum",
35+
createCard:{
36+
Attack:{
37+
type:"Int",
38+
array:false,
39+
arrayRequired:false,
40+
required:true
41+
},
42+
Defense:{
43+
type:"Int",
44+
array:false,
45+
arrayRequired:false,
46+
required:true
47+
},
48+
skills:{
49+
type:"SpecialSkills",
50+
array:true,
51+
arrayRequired:false,
52+
required:true
53+
},
54+
name:{
55+
type:"String",
56+
array:false,
57+
arrayRequired:false,
58+
required:true
59+
},
60+
description:{
61+
type:"String",
62+
array:false,
63+
arrayRequired:false,
64+
required:true
65+
},
66+
Children:{
67+
type:"Int",
68+
array:false,
69+
arrayRequired:false,
70+
required:false
71+
}
72+
}
73+
}
74+
75+
export const ReturnTypes: Record<string,any> = {
76+
CardStack:{
77+
cards:"Card",
78+
name:"String"
79+
},
80+
Query:{
81+
cardById:"Card",
82+
drawCard:"Card",
83+
drawChangeCard:"ChangeCard",
84+
listCards:"Card",
85+
myStacks:"CardStack",
86+
nameables:"Nameable"
87+
},
88+
Subscription:{
89+
deck:"Card"
90+
},
91+
Card:{
92+
Attack:"Int",
93+
Children:"Int",
94+
Defense:"Int",
95+
attack:"Card",
96+
cardImage:"S3Object",
97+
description:"String",
98+
id:"ID",
99+
image:"String",
100+
name:"String",
101+
skills:"SpecialSkills"
102+
},
103+
Mutation:{
104+
addCard:"Card"
105+
},
106+
SpecialCard:{
107+
effect:"String",
108+
name:"String"
109+
},
110+
Nameable:{
111+
"...on CardStack": "CardStack",
112+
"...on Card": "Card",
113+
"...on SpecialCard": "SpecialCard",
114+
"...on EffectCard": "EffectCard",
115+
name:"String"
116+
},
117+
EffectCard:{
118+
effectSize:"Float",
119+
name:"String"
120+
},
121+
S3Object:{
122+
bucket:"String",
123+
key:"String",
124+
region:"String"
125+
},
126+
ChangeCard:{
127+
"...on SpecialCard":"SpecialCard",
128+
"...on EffectCard":"EffectCard"
129+
}
130+
}

0 commit comments

Comments
 (0)