Skip to content

Commit 8aa8ee9

Browse files
committed
feat(recipe,menu): check length of recipes and menu options
1 parent 60c3519 commit 8aa8ee9

File tree

9 files changed

+224
-212
lines changed

9 files changed

+224
-212
lines changed

client/client/gen/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ export type InputRecipe = {
114114
glassType?: InputMaybe<InputGlassType>
115115
name: Scalars["String"]["input"]
116116
recipeType?: InputMaybe<InputRecipeType>
117-
steps?: InputMaybe<Array<InputStep>>
117+
steps: Array<InputStep>
118118
}
119119

120120
export type InputRecipeGroup = {
121121
asMenu?: InputMaybe<InputAsMenuArgs>
122122
imageURL?: InputMaybe<Scalars["String"]["input"]>
123123
name: Scalars["String"]["input"]
124-
recipes?: InputMaybe<Array<InputRecipe>>
124+
recipes: Array<InputRecipe>
125125
}
126126

127127
export type InputRecipeType = {
@@ -153,14 +153,14 @@ export type MenuItem = {
153153
imageURL?: Maybe<Scalars["String"]["output"]>
154154
minPriceYen: Scalars["Float"]["output"]
155155
name: Scalars["String"]["output"]
156-
options?: Maybe<Array<MenuItemOption>>
156+
options: Array<MenuItemOption>
157157
}
158158

159159
export type MenuItemOption = {
160160
__typename?: "MenuItemOption"
161161
category: Scalars["String"]["output"]
162162
imageURL?: Maybe<Scalars["String"]["output"]>
163-
materials?: Maybe<Array<Scalars["String"]["output"]>>
163+
materials: Array<Scalars["String"]["output"]>
164164
name: Scalars["String"]["output"]
165165
outOfStock: Scalars["Boolean"]["output"]
166166
priceYen: Scalars["Float"]["output"]
@@ -253,15 +253,15 @@ export type Recipe = {
253253
category: Scalars["String"]["output"]
254254
glass?: Maybe<GlassType>
255255
name: Scalars["String"]["output"]
256-
steps?: Maybe<Array<Step>>
256+
steps: Array<Step>
257257
type?: Maybe<RecipeType>
258258
}
259259

260260
export type RecipeGroup = {
261261
__typename?: "RecipeGroup"
262262
imageURL?: Maybe<Scalars["String"]["output"]>
263263
name: Scalars["String"]["output"]
264-
recipes?: Maybe<Array<Recipe>>
264+
recipes: Array<Recipe>
265265
}
266266

267267
export type RecipeType = {

client/hackbar-copilot.graphqls

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ type MenuItem {
106106
name: String!
107107
imageURL: String
108108
flavor: String
109-
options: [MenuItemOption!]
109+
options: [MenuItemOption!]!
110110
minPriceYen: Float!
111111
}
112112

113113
type MenuItemOption {
114114
name: String!
115115
category: String!
116116
imageURL: String
117-
materials: [String!]
117+
materials: [String!]!
118118
outOfStock: Boolean!
119119
priceYen: Float!
120120
recipe: Recipe
@@ -185,7 +185,7 @@ extend type Mutation {
185185
input InputRecipeGroup {
186186
name: String!
187187
imageURL: String
188-
recipes: [InputRecipe!]
188+
recipes: [InputRecipe!]!
189189
asMenu: InputAsMenuArgs
190190
}
191191

@@ -194,7 +194,7 @@ input InputRecipe {
194194
category: String!
195195
recipeType: InputRecipeType
196196
glassType: InputGlassType
197-
steps: [InputStep!]
197+
steps: [InputStep!]!
198198
asMenu: InputAsMenuItemArgs
199199
}
200200

@@ -237,7 +237,7 @@ extend type Query {
237237
type RecipeGroup {
238238
name: String!
239239
imageURL: String
240-
recipes: [Recipe!]
240+
recipes: [Recipe!]!
241241
# asMenu: AsMenu
242242
}
243243

@@ -246,7 +246,7 @@ type Recipe {
246246
category: String!
247247
type: RecipeType
248248
glass: GlassType
249-
steps: [Step!]
249+
steps: [Step!]!
250250
# asMenu: AsMenuItem
251251
}
252252

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tingtt/hackbar-copilot",
3-
"version": "0.4.0",
3+
"version": "0.4.4",
44
"publishConfig": {
55
"access": "public"
66
},

internal/domain/recipe/validaterecipegroup.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ func (rg *RecipeGroup) Validate() error {
88
if rg.Name == "" {
99
return fmt.Errorf("name cannot be empty")
1010
}
11+
if len(rg.Recipes) == 0 {
12+
return fmt.Errorf("recipes cannot be empty")
13+
}
1114
for _, r := range rg.Recipes {
1215
if err := r.Validate(); err != nil {
1316
return fmt.Errorf("recipe \"%s\" is invalid: %w", r.Name, err)

0 commit comments

Comments
 (0)