Skip to content

Commit 3e5c22d

Browse files
committed
initial commit
0 parents  commit 3e5c22d

File tree

9 files changed

+767
-0
lines changed

9 files changed

+767
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

Diff for: .prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"printWidth": 100,
5+
"arrowParens": "avoid"
6+
}

Diff for: README.md

Whitespace-only changes.

Diff for: examples/zeus.graphql

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
"""
2+
The query root
3+
"""
4+
type Query {
5+
""""""
6+
cardById(cardId: String): Card
7+
8+
"""Draw a card<br>"""
9+
drawCard: Card!
10+
11+
""""""
12+
drawChangeCard: ChangeCard!
13+
14+
"""list All Cards availble<br>"""
15+
listCards: [Card!]!
16+
17+
""""""
18+
myStacks: [CardStack!]
19+
20+
""""""
21+
nameables: [Nameable!]!
22+
}
23+
24+
"""Stack of cards"""
25+
type CardStack implements Nameable {
26+
"""The list of cards"""
27+
cards: [Card!]
28+
29+
"""The card name"""
30+
name: String!
31+
}
32+
33+
""""""
34+
enum SpecialSkills {
35+
"""Lower enemy defense -5<br>"""
36+
THUNDER
37+
38+
"""Attack multiple Cards at once<br>"""
39+
RAIN
40+
41+
"""50% chance to avoid any attack<br>"""
42+
FIRE
43+
}
44+
45+
"""Aws S3 File"""
46+
type S3Object {
47+
""""""
48+
bucket: String!
49+
50+
""""""
51+
key: String!
52+
53+
""""""
54+
region: String!
55+
}
56+
57+
""""""
58+
scalar JSON
59+
60+
""""""
61+
union ChangeCard = SpecialCard | EffectCard
62+
63+
""""""
64+
interface Nameable {
65+
""""""
66+
name: String!
67+
}
68+
69+
"""Card used in card game<br>"""
70+
type Card implements Nameable {
71+
"""The attack power<br>"""
72+
Attack: Int!
73+
74+
"""<div>How many children the greek god had</div>"""
75+
Children: Int
76+
77+
"""The defense power<br>"""
78+
Defense: Int!
79+
80+
"""Attack other cards on the table , returns Cards after attack<br>"""
81+
attack(
82+
"""Attacked card/card ids<br>"""
83+
cardID: [String!]!
84+
): [Card!]
85+
86+
"""Put your description here"""
87+
cardImage: S3Object
88+
89+
"""Description of a card<br>"""
90+
description: String!
91+
92+
""""""
93+
id: ID!
94+
95+
""""""
96+
image: String!
97+
98+
""""""
99+
info: JSON!
100+
101+
"""The name of a card<br>"""
102+
name: String!
103+
104+
""""""
105+
skills: [SpecialSkills!]
106+
}
107+
108+
""""""
109+
type Mutation {
110+
"""add Card to Cards database<br>"""
111+
addCard(card: createCard!): Card!
112+
}
113+
114+
""""""
115+
type Subscription {
116+
""""""
117+
deck: [Card!]
118+
}
119+
120+
""""""
121+
type SpecialCard implements Nameable {
122+
""""""
123+
effect: String!
124+
125+
""""""
126+
name: String!
127+
}
128+
129+
""""""
130+
type EffectCard implements Nameable {
131+
""""""
132+
effectSize: Float!
133+
134+
""""""
135+
name: String!
136+
}
137+
138+
"""create card inputs<br>"""
139+
input createCard {
140+
"""input skills"""
141+
skills: [SpecialSkills!]
142+
143+
"""The name of a card<br>"""
144+
name: String!
145+
146+
"""Description of a card<br>"""
147+
description: String!
148+
149+
"""<div>How many children the greek god had</div>"""
150+
Children: Int
151+
152+
"""The attack power<br>"""
153+
Attack: Int!
154+
155+
"""The defense power<br>"""
156+
Defense: Int!
157+
}
158+
159+
schema{
160+
query: Query,
161+
mutation: Mutation,
162+
subscription: Subscription
163+
}

Diff for: examples/zeus.ts

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/**
2+
* The query root
3+
*/
4+
export type Query = {
5+
cardById: [
6+
{
7+
cardId: string | undefined
8+
},
9+
Card | undefined
10+
]
11+
drawCard: Card
12+
drawChangeCard: ChangeCard
13+
listCards: Array<Card>
14+
myStacks: Array<CardStack> | undefined
15+
nameables: Array<Nameable>
16+
}
17+
18+
/**
19+
* Stack of cards
20+
*/
21+
export type CardStack = {
22+
cards: Array<Card> | undefined
23+
name: string
24+
}
25+
26+
export enum SpecialSkills {
27+
/**
28+
* Lower enemy defense -5<br>
29+
*/
30+
THUNDER = 'THUNDER',
31+
/**
32+
* Attack multiple Cards at once<br>
33+
*/
34+
RAIN = 'RAIN',
35+
/**
36+
* 50% chance to avoid any attack<br>
37+
*/
38+
FIRE = 'FIRE',
39+
}
40+
41+
/**
42+
* Aws S3 File
43+
*/
44+
export type S3Object = {
45+
bucket: string
46+
key: string
47+
region: string
48+
}
49+
50+
export type JSON = unknown
51+
52+
export type ChangeCard = SpecialCard | undefined | EffectCard | undefined
53+
54+
export type Nameable = {
55+
name: string
56+
}
57+
58+
/**
59+
* Card used in card game<br>
60+
*/
61+
export type Card = {
62+
Attack: number
63+
Children: number | undefined
64+
Defense: number
65+
attack: [
66+
{
67+
cardID: Array<string>
68+
},
69+
Array<Card> | undefined
70+
]
71+
cardImage: S3Object | undefined
72+
description: string
73+
id: string
74+
image: string
75+
info: JSON
76+
name: string
77+
skills: Array<SpecialSkills> | undefined
78+
}
79+
80+
export type Mutation = {
81+
addCard: [
82+
{
83+
card: createCard
84+
},
85+
Card
86+
]
87+
}
88+
89+
export type Subscription = {
90+
deck: Array<Card> | undefined
91+
}
92+
93+
export type SpecialCard = {
94+
effect: string
95+
name: string
96+
}
97+
98+
export type EffectCard = {
99+
effectSize: number
100+
name: string
101+
}
102+
103+
/**
104+
* create card inputs<br>
105+
*/
106+
export type createCard = {
107+
skills: Array<SpecialSkills> | undefined
108+
name: string
109+
description: string
110+
Children: number | undefined
111+
Attack: number
112+
Defense: number
113+
}
114+
115+
export type Result<Obj> = Obj extends [any, infer Output]
116+
? Result<Output>
117+
: Obj extends Array<infer Item>
118+
? Array<Result<Item>>
119+
: Obj extends {}
120+
? { [K in keyof Obj]: Result<Obj[K]> }
121+
: Obj
122+
123+
type Test = Result<Card>
124+
125+
declare let x: Test

Diff for: package.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "typed-graphql-builder",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"devDependencies": {
7+
"@swc-node/register": "^1.4.2",
8+
"@types/node": "^17.0.25",
9+
"typescript": "^4.6.3"
10+
},
11+
"dependencies": {
12+
"graphql": "^16.3.0"
13+
}
14+
}

0 commit comments

Comments
 (0)