diff --git a/ent/gql_mutation_input.go b/ent/gql_mutation_input.go index 1a2ad91..c772f68 100644 --- a/ent/gql_mutation_input.go +++ b/ent/gql_mutation_input.go @@ -184,6 +184,7 @@ func (c *QuestionCreate) SetInput(i CreateQuestionInput) *QuestionCreate { // UpdateQuestionInput represents a mutation input for updating questions. type UpdateQuestionInput struct { + Category *string Difficulty *question.Difficulty Title *string Description *string @@ -196,6 +197,9 @@ type UpdateQuestionInput struct { // Mutate applies the UpdateQuestionInput on the QuestionMutation builder. func (i *UpdateQuestionInput) Mutate(m *QuestionMutation) { + if v := i.Category; v != nil { + m.SetCategory(*v) + } if v := i.Difficulty; v != nil { m.SetDifficulty(*v) } diff --git a/ent/internal/schema.go b/ent/internal/schema.go index b41da89..9493b05 100644 --- a/ent/internal/schema.go +++ b/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"github.com/database-playground/backend-v2/ent/schema\",\"Package\":\"github.com/database-playground/backend-v2/ent\",\"Schemas\":[{\"name\":\"Database\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"questions\",\"type\":\"Question\"}],\"fields\":[{\"name\":\"slug\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"schema\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2147483647,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"SQL schema\"},{\"name\":\"relation_figure\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"relation figure\"}],\"annotations\":{\"EntGQL\":{\"MutationInputs\":[{\"IsCreate\":true},{}],\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"database:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]}},\"EntSQL\":{\"increment_start\":12884901888}}},{\"name\":\"Event\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"ref_name\":\"events\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"triggered_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"TRIGGERED_AT\"}}},{\"name\":\"payload\",\"type\":{\"Type\":3,\"Ident\":\"map[string]interface {}\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]interface {}\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"type\"]},{\"fields\":[\"type\",\"user_id\"]}],\"annotations\":{\"EntGQL\":{\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"user:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]},\"RelayConnection\":true},\"EntSQL\":{\"increment_start\":21474836480}}},{\"name\":\"Group\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"scope_sets\",\"type\":\"ScopeSet\"}],\"fields\":[{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}],\"annotations\":{\"EntGQL\":{\"MutationInputs\":[{\"IsCreate\":true},{}],\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"group:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]}},\"EntSQL\":{\"increment_start\":4294967296}}},{\"name\":\"Point\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"ref_name\":\"points\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"points\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"granted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"GRANTED_AT\"}}},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"EntGQL\":{\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"user:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]},\"RelayConnection\":true},\"EntSQL\":{\"increment_start\":25769803776}}},{\"name\":\"Question\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"database\",\"type\":\"Database\",\"ref_name\":\"questions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"submissions\",\"type\":\"Submission\",\"annotations\":{\"EntGQL\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"submission:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}],\"RelayConnection\":true}}}],\"fields\":[{\"name\":\"category\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"CATEGORY\"}},\"comment\":\"Question category, e.g. 'query'\"},{\"name\":\"difficulty\",\"type\":{\"Type\":6,\"Ident\":\"question.Difficulty\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"Unspecified\",\"V\":\"unspecified\"},{\"N\":\"Easy\",\"V\":\"easy\"},{\"N\":\"Medium\",\"V\":\"medium\"},{\"N\":\"Hard\",\"V\":\"hard\"}],\"default\":true,\"default_value\":\"medium\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"DIFFICULTY\"}},\"comment\":\"Question difficulty, e.g. 'easy'\"},{\"name\":\"title\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"Question title\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2147483647,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"Question stem\"},{\"name\":\"reference_answer\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2147483647,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"answer:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]}},\"comment\":\"Reference answer\"}],\"annotations\":{\"EntGQL\":{\"MutationInputs\":[{\"IsCreate\":true},{}],\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"question:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]},\"RelayConnection\":true},\"EntSQL\":{\"increment_start\":17179869184}}},{\"name\":\"ScopeSet\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"groups\",\"type\":\"Group\",\"ref_name\":\"scope_sets\",\"inverse\":true}],\"fields\":[{\"name\":\"slug\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"scopes\",\"type\":{\"Type\":3,\"Ident\":\"[]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"[]string\",\"Kind\":23,\"PkgPath\":\"\",\"Methods\":{}}},\"default\":true,\"default_value\":[],\"default_kind\":23,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"EntGQL\":{\"MutationInputs\":[{\"IsCreate\":true},{}],\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"scopeset:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]}},\"EntSQL\":{\"increment_start\":8589934592}}},{\"name\":\"Submission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"question\",\"type\":\"Question\",\"ref_name\":\"submissions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"user\",\"type\":\"User\",\"ref_name\":\"submissions\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"submitted_code\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"submission.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"pending\",\"V\":\"pending\"},{\"N\":\"success\",\"V\":\"success\"},{\"N\":\"failed\",\"V\":\"failed\"}],\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"query_result\",\"type\":{\"Type\":3,\"Ident\":\"*models.UserSQLExecutionResult\",\"PkgPath\":\"github.com/database-playground/backend-v2/models\",\"PkgName\":\"models\",\"Nillable\":true,\"RType\":{\"Name\":\"UserSQLExecutionResult\",\"Ident\":\"models.UserSQLExecutionResult\",\"Kind\":22,\"PkgPath\":\"github.com/database-playground/backend-v2/models\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"error\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"submitted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"SUBMITTED_AT\"}}}],\"annotations\":{\"EntGQL\":{\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"submissions:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]},\"RelayConnection\":true},\"EntSQL\":{\"increment_start\":30064771072}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"group\",\"type\":\"Group\",\"unique\":true,\"required\":true},{\"name\":\"points\",\"type\":\"Point\",\"annotations\":{\"EntGQL\":{\"RelayConnection\":true}}},{\"name\":\"events\",\"type\":\"Event\",\"annotations\":{\"EntGQL\":{\"RelayConnection\":true}}},{\"name\":\"submissions\",\"type\":\"Submission\",\"annotations\":{\"EntGQL\":{\"RelayConnection\":true}}}],\"fields\":[{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"EMAIL\"}}},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}],\"annotations\":{\"EntGQL\":{\"MutationInputs\":[{\"IsCreate\":true},{}],\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"user:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]},\"RelayConnection\":true},\"EntSQL\":{\"increment_start\":0}}}],\"Features\":[\"namedges\",\"intercept\",\"schema/snapshot\",\"sql/globalid\"]}" +const Schema = "{\"Schema\":\"github.com/database-playground/backend-v2/ent/schema\",\"Package\":\"github.com/database-playground/backend-v2/ent\",\"Schemas\":[{\"name\":\"Database\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"questions\",\"type\":\"Question\"}],\"fields\":[{\"name\":\"slug\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"schema\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2147483647,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"SQL schema\"},{\"name\":\"relation_figure\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"relation figure\"}],\"annotations\":{\"EntGQL\":{\"MutationInputs\":[{\"IsCreate\":true},{}],\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"database:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]}},\"EntSQL\":{\"increment_start\":12884901888}}},{\"name\":\"Event\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"ref_name\":\"events\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"triggered_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"TRIGGERED_AT\"}}},{\"name\":\"payload\",\"type\":{\"Type\":3,\"Ident\":\"map[string]interface {}\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]interface {}\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"type\"]},{\"fields\":[\"type\",\"user_id\"]}],\"annotations\":{\"EntGQL\":{\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"user:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]},\"RelayConnection\":true},\"EntSQL\":{\"increment_start\":21474836480}}},{\"name\":\"Group\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"scope_sets\",\"type\":\"ScopeSet\"}],\"fields\":[{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}],\"annotations\":{\"EntGQL\":{\"MutationInputs\":[{\"IsCreate\":true},{}],\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"group:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]}},\"EntSQL\":{\"increment_start\":4294967296}}},{\"name\":\"Point\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"ref_name\":\"points\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"points\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"granted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"GRANTED_AT\"}}},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"EntGQL\":{\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"user:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]},\"RelayConnection\":true},\"EntSQL\":{\"increment_start\":25769803776}}},{\"name\":\"Question\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"database\",\"type\":\"Database\",\"ref_name\":\"questions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"submissions\",\"type\":\"Submission\",\"annotations\":{\"EntGQL\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"submission:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}],\"RelayConnection\":true}}}],\"fields\":[{\"name\":\"category\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"CATEGORY\"}},\"comment\":\"Question category, e.g. 'query'\"},{\"name\":\"difficulty\",\"type\":{\"Type\":6,\"Ident\":\"question.Difficulty\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"Unspecified\",\"V\":\"unspecified\"},{\"N\":\"Easy\",\"V\":\"easy\"},{\"N\":\"Medium\",\"V\":\"medium\"},{\"N\":\"Hard\",\"V\":\"hard\"}],\"default\":true,\"default_value\":\"medium\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"DIFFICULTY\"}},\"comment\":\"Question difficulty, e.g. 'easy'\"},{\"name\":\"title\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"Question title\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2147483647,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"Question stem\"},{\"name\":\"reference_answer\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2147483647,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"answer:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]}},\"comment\":\"Reference answer\"}],\"annotations\":{\"EntGQL\":{\"MutationInputs\":[{\"IsCreate\":true},{}],\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"question:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]},\"RelayConnection\":true},\"EntSQL\":{\"increment_start\":17179869184}}},{\"name\":\"ScopeSet\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"groups\",\"type\":\"Group\",\"ref_name\":\"scope_sets\",\"inverse\":true}],\"fields\":[{\"name\":\"slug\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"scopes\",\"type\":{\"Type\":3,\"Ident\":\"[]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"[]string\",\"Kind\":23,\"PkgPath\":\"\",\"Methods\":{}}},\"default\":true,\"default_value\":[],\"default_kind\":23,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"EntGQL\":{\"MutationInputs\":[{\"IsCreate\":true},{}],\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"scopeset:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]}},\"EntSQL\":{\"increment_start\":8589934592}}},{\"name\":\"Submission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"question\",\"type\":\"Question\",\"ref_name\":\"submissions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"user\",\"type\":\"User\",\"ref_name\":\"submissions\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"submitted_code\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"submission.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"pending\",\"V\":\"pending\"},{\"N\":\"success\",\"V\":\"success\"},{\"N\":\"failed\",\"V\":\"failed\"}],\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"query_result\",\"type\":{\"Type\":3,\"Ident\":\"*models.UserSQLExecutionResult\",\"PkgPath\":\"github.com/database-playground/backend-v2/models\",\"PkgName\":\"models\",\"Nillable\":true,\"RType\":{\"Name\":\"UserSQLExecutionResult\",\"Ident\":\"models.UserSQLExecutionResult\",\"Kind\":22,\"PkgPath\":\"github.com/database-playground/backend-v2/models\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"error\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"submitted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"SUBMITTED_AT\"}}}],\"annotations\":{\"EntGQL\":{\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"submissions:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]},\"RelayConnection\":true},\"EntSQL\":{\"increment_start\":30064771072}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"group\",\"type\":\"Group\",\"unique\":true,\"required\":true},{\"name\":\"points\",\"type\":\"Point\",\"annotations\":{\"EntGQL\":{\"RelayConnection\":true}}},{\"name\":\"events\",\"type\":\"Event\",\"annotations\":{\"EntGQL\":{\"RelayConnection\":true}}},{\"name\":\"submissions\",\"type\":\"Submission\",\"annotations\":{\"EntGQL\":{\"RelayConnection\":true}}}],\"fields\":[{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"Skip\":48}}},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntGQL\":{\"OrderField\":\"EMAIL\"}}},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}],\"annotations\":{\"EntGQL\":{\"MutationInputs\":[{\"IsCreate\":true},{}],\"QueryField\":{\"Directives\":[{\"arguments\":[{\"Comment\":null,\"Name\":\"scope\",\"Value\":{\"Children\":null,\"Comment\":null,\"Definition\":null,\"ExpectedType\":null,\"Kind\":3,\"Raw\":\"user:read\",\"VariableDefinition\":null}}],\"name\":\"scope\"}]},\"RelayConnection\":true},\"EntSQL\":{\"increment_start\":0}}}],\"Features\":[\"namedges\",\"intercept\",\"schema/snapshot\",\"sql/globalid\"]}" diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 072ab2e..87aaea2 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -97,7 +97,7 @@ var ( // QuestionsColumns holds the columns for the "questions" table. QuestionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "category", Type: field.TypeString, Unique: true}, + {Name: "category", Type: field.TypeString}, {Name: "difficulty", Type: field.TypeEnum, Enums: []string{"unspecified", "easy", "medium", "hard"}, Default: "medium"}, {Name: "title", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Size: 2147483647}, diff --git a/ent/question_update.go b/ent/question_update.go index 32142d1..5c437b0 100644 --- a/ent/question_update.go +++ b/ent/question_update.go @@ -29,6 +29,20 @@ func (_u *QuestionUpdate) Where(ps ...predicate.Question) *QuestionUpdate { return _u } +// SetCategory sets the "category" field. +func (_u *QuestionUpdate) SetCategory(v string) *QuestionUpdate { + _u.mutation.SetCategory(v) + return _u +} + +// SetNillableCategory sets the "category" field if the given value is not nil. +func (_u *QuestionUpdate) SetNillableCategory(v *string) *QuestionUpdate { + if v != nil { + _u.SetCategory(*v) + } + return _u +} + // SetDifficulty sets the "difficulty" field. func (_u *QuestionUpdate) SetDifficulty(v question.Difficulty) *QuestionUpdate { _u.mutation.SetDifficulty(v) @@ -172,6 +186,11 @@ func (_u *QuestionUpdate) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (_u *QuestionUpdate) check() error { + if v, ok := _u.mutation.Category(); ok { + if err := question.CategoryValidator(v); err != nil { + return &ValidationError{Name: "category", err: fmt.Errorf(`ent: validator failed for field "Question.category": %w`, err)} + } + } if v, ok := _u.mutation.Difficulty(); ok { if err := question.DifficultyValidator(v); err != nil { return &ValidationError{Name: "difficulty", err: fmt.Errorf(`ent: validator failed for field "Question.difficulty": %w`, err)} @@ -195,6 +214,9 @@ func (_u *QuestionUpdate) sqlSave(ctx context.Context) (_node int, err error) { } } } + if value, ok := _u.mutation.Category(); ok { + _spec.SetField(question.FieldCategory, field.TypeString, value) + } if value, ok := _u.mutation.Difficulty(); ok { _spec.SetField(question.FieldDifficulty, field.TypeEnum, value) } @@ -301,6 +323,20 @@ type QuestionUpdateOne struct { mutation *QuestionMutation } +// SetCategory sets the "category" field. +func (_u *QuestionUpdateOne) SetCategory(v string) *QuestionUpdateOne { + _u.mutation.SetCategory(v) + return _u +} + +// SetNillableCategory sets the "category" field if the given value is not nil. +func (_u *QuestionUpdateOne) SetNillableCategory(v *string) *QuestionUpdateOne { + if v != nil { + _u.SetCategory(*v) + } + return _u +} + // SetDifficulty sets the "difficulty" field. func (_u *QuestionUpdateOne) SetDifficulty(v question.Difficulty) *QuestionUpdateOne { _u.mutation.SetDifficulty(v) @@ -457,6 +493,11 @@ func (_u *QuestionUpdateOne) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (_u *QuestionUpdateOne) check() error { + if v, ok := _u.mutation.Category(); ok { + if err := question.CategoryValidator(v); err != nil { + return &ValidationError{Name: "category", err: fmt.Errorf(`ent: validator failed for field "Question.category": %w`, err)} + } + } if v, ok := _u.mutation.Difficulty(); ok { if err := question.DifficultyValidator(v); err != nil { return &ValidationError{Name: "difficulty", err: fmt.Errorf(`ent: validator failed for field "Question.difficulty": %w`, err)} @@ -497,6 +538,9 @@ func (_u *QuestionUpdateOne) sqlSave(ctx context.Context) (_node *Question, err } } } + if value, ok := _u.mutation.Category(); ok { + _spec.SetField(question.FieldCategory, field.TypeString, value) + } if value, ok := _u.mutation.Difficulty(); ok { _spec.SetField(question.FieldDifficulty, field.TypeEnum, value) } diff --git a/ent/schema/question.go b/ent/schema/question.go index 44a6984..b9f58e5 100644 --- a/ent/schema/question.go +++ b/ent/schema/question.go @@ -6,6 +6,7 @@ import ( "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" ) type Question struct { @@ -14,7 +15,7 @@ type Question struct { func (Question) Fields() []ent.Field { return []ent.Field{ - field.String("category").NotEmpty().Unique().Immutable().Comment("Question category, e.g. 'query'").Annotations( + field.String("category").NotEmpty().Comment("Question category, e.g. 'query'").Annotations( entgql.OrderField("CATEGORY"), ), field.Enum("difficulty").NamedValues( @@ -48,6 +49,13 @@ func (Question) Edges() []ent.Edge { } } +func (Question) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("category"), + index.Fields("difficulty"), + } +} + func (Question) Annotations() []schema.Annotation { return []schema.Annotation{ entgql.QueryField().Directives( diff --git a/graph/ent.graphqls b/graph/ent.graphqls index 9484831..89a9994 100644 --- a/graph/ent.graphqls +++ b/graph/ent.graphqls @@ -1224,6 +1224,10 @@ UpdateQuestionInput is used for update Question object. Input was generated by ent. """ input UpdateQuestionInput { + """ + Question category, e.g. 'query' + """ + category: String """ Question difficulty, e.g. 'easy' """