From 8737f3e8ffe0629049284d5ee44b38012f56653d Mon Sep 17 00:00:00 2001 From: Yi-Jyun Pan Date: Thu, 23 Oct 2025 22:39:37 +0800 Subject: [PATCH 1/3] chore: upgrade dependencies --- go.mod | 6 +++--- go.sum | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index f524cfd..cfcee29 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/jackc/pgx/v5 v5.7.6 github.com/joho/godotenv v1.5.1 github.com/mattn/go-sqlite3 v1.14.28 - github.com/posthog/posthog-go v1.6.11 + github.com/posthog/posthog-go v1.6.12 github.com/redis/rueidis v1.0.67 github.com/samber/lo v1.52.0 github.com/stretchr/testify v1.11.1 @@ -23,7 +23,7 @@ require ( github.com/vektah/gqlparser/v2 v2.5.30 go.uber.org/fx v1.24.0 golang.org/x/oauth2 v0.32.0 - google.golang.org/api v0.252.0 + google.golang.org/api v0.253.0 ) require ( @@ -145,7 +145,7 @@ require ( golang.org/x/sys v0.37.0 // indirect golang.org/x/text v0.30.0 // indirect golang.org/x/tools v0.38.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20251020155222-88f65dc88635 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index b84646f..02ed66a 100644 --- a/go.sum +++ b/go.sum @@ -217,8 +217,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posthog/posthog-go v1.6.11 h1:5G8Y3pxnOpc3S4+PK1z1dCmZRuldiWxBsqqvvSfC2+w= -github.com/posthog/posthog-go v1.6.11/go.mod h1:LcC1Nu4AgvV22EndTtrMXTy+7RGVC0MhChSw7Qk5XkY= +github.com/posthog/posthog-go v1.6.12 h1:rsOBL/YdMfLJtOVjKJLgdzYmvaL3aIW6IVbAteSe+aI= +github.com/posthog/posthog-go v1.6.12/go.mod h1:LcC1Nu4AgvV22EndTtrMXTy+7RGVC0MhChSw7Qk5XkY= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= @@ -345,8 +345,8 @@ golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q= golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss= golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= -golang.org/x/time v0.13.0 h1:eUlYslOIt32DgYD6utsuUeHs4d7AsEYLuIAdg7FlYgI= -golang.org/x/time v0.13.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= +golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= +golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= @@ -355,14 +355,14 @@ golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTF golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/api v0.252.0 h1:xfKJeAJaMwb8OC9fesr369rjciQ704AjU/psjkKURSI= -google.golang.org/api v0.252.0/go.mod h1:dnHOv81x5RAmumZ7BWLShB/u7JZNeyalImxHmtTHxqw= +google.golang.org/api v0.253.0 h1:apU86Eq9Q2eQco3NsUYFpVTfy7DwemojL7LmbAj7g/I= +google.golang.org/api v0.253.0/go.mod h1:PX09ad0r/4du83vZVAaGg7OaeyGnaUmT/CYPNvtLCbw= google.golang.org/genproto v0.0.0-20250603155806-513f23925822 h1:rHWScKit0gvAPuOnu87KpaYtjK5zBMLcULh7gxkCXu4= google.golang.org/genproto v0.0.0-20250603155806-513f23925822/go.mod h1:HubltRL7rMh0LfnQPkMH4NPDFEWp0jw3vixw7jEM53s= google.golang.org/genproto/googleapis/api v0.0.0-20250804133106-a7a43d27e69b h1:ULiyYQ0FdsJhwwZUwbaXpZF5yUE3h+RA+gxvBu37ucc= google.golang.org/genproto/googleapis/api v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:oDOGiMSXHL4sDTJvFvIB9nRQCGdLP1o/iVaqQK8zB+M= -google.golang.org/genproto/googleapis/rpc v0.0.0-20251020155222-88f65dc88635 h1:3uycTxukehWrxH4HtPRtn1PDABTU331ViDjyqrUbaog= -google.golang.org/genproto/googleapis/rpc v0.0.0-20251020155222-88f65dc88635/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 h1:M1rk8KBnUsBDg1oPGHNCxG4vc1f49epmTO7xscSajMk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= From 5cb39fda280fc29b767a80572ca6da7aa4a28b32 Mon Sep 17 00:00:00 2001 From: Yi-Jyun Pan Date: Thu, 23 Oct 2025 22:42:54 +0800 Subject: [PATCH 2/3] feat: add create mutation to Point model --- ent/gql_mutation_input.go | 30 ++++++++++++++++++++++++++++++ ent/internal/schema.go | 2 +- ent/schema/point.go | 3 +++ graph/ent.graphqls | 10 ++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/ent/gql_mutation_input.go b/ent/gql_mutation_input.go index c772f68..b364120 100644 --- a/ent/gql_mutation_input.go +++ b/ent/gql_mutation_input.go @@ -3,6 +3,8 @@ package ent import ( + "time" + "github.com/database-playground/backend-v2/ent/question" ) @@ -150,6 +152,34 @@ func (c *GroupUpdateOne) SetInput(i UpdateGroupInput) *GroupUpdateOne { return c } +// CreatePointInput represents a mutation input for creating points. +type CreatePointInput struct { + Points *int + GrantedAt *time.Time + Description *string + UserID int +} + +// Mutate applies the CreatePointInput on the PointMutation builder. +func (i *CreatePointInput) Mutate(m *PointMutation) { + if v := i.Points; v != nil { + m.SetPoints(*v) + } + if v := i.GrantedAt; v != nil { + m.SetGrantedAt(*v) + } + if v := i.Description; v != nil { + m.SetDescription(*v) + } + m.SetUserID(i.UserID) +} + +// SetInput applies the change-set in the CreatePointInput on the PointCreate builder. +func (c *PointCreate) SetInput(i CreatePointInput) *PointCreate { + i.Mutate(c.Mutation()) + return c +} + // CreateQuestionInput represents a mutation input for creating questions. type CreateQuestionInput struct { Category string diff --git a/ent/internal/schema.go b/ent/internal/schema.go index 6170b02..d5d2216 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},\"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\"}],\"indexes\":[{\"fields\":[\"category\"]},{\"fields\":[\"difficulty\"]}],\"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\":{\"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\":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\"}],\"indexes\":[{\"fields\":[\"category\"]},{\"fields\":[\"difficulty\"]}],\"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/schema/point.go b/ent/schema/point.go index e9478fd..0d9f6e8 100644 --- a/ent/schema/point.go +++ b/ent/schema/point.go @@ -39,5 +39,8 @@ func (Point) Annotations() []schema.Annotation { ScopeDirective("user:read"), ), entgql.RelayConnection(), + entgql.Mutations( + entgql.MutationCreate(), + ), } } diff --git a/graph/ent.graphqls b/graph/ent.graphqls index 89a9994..34ae787 100644 --- a/graph/ent.graphqls +++ b/graph/ent.graphqls @@ -27,6 +27,16 @@ input CreateGroupInput { scopeSetIDs: [ID!] } """ +CreatePointInput is used for create Point object. +Input was generated by ent. +""" +input CreatePointInput { + points: Int + grantedAt: Time + description: String + userID: ID! +} +""" CreateQuestionInput is used for create Question object. Input was generated by ent. """ From 80e1c6f09be37382c9e367d59d88e09c3aee6970 Mon Sep 17 00:00:00 2001 From: Yi-Jyun Pan Date: Thu, 23 Oct 2025 22:43:09 +0800 Subject: [PATCH 3/3] feat: add CreatePoint mutation --- docs/scope.md | 1 + graph/user.graphqls | 5 +++++ graph/user.resolvers.go | 12 ++++++++++++ 3 files changed, 18 insertions(+) diff --git a/docs/scope.md b/docs/scope.md index f60d026..948c5ad 100644 --- a/docs/scope.md +++ b/docs/scope.md @@ -11,6 +11,7 @@ - `question`:題庫操作 - `answer`:解答(只有 `read` 動作,`answer:write` 被 `question:write` 涵蓋) - `submission`:提交紀錄操作(做題) +- `point`:點數操作(只有 `write` 操作) ## 動作 diff --git a/graph/user.graphqls b/graph/user.graphqls index 96f6a06..944f898 100644 --- a/graph/user.graphqls +++ b/graph/user.graphqls @@ -105,4 +105,9 @@ extend type Mutation { Logout from all the devices of the current user. """ logoutAll: Boolean! @scope(scope: "me:write") + + """ + Create a new point record for a user. + """ + createPoint(input: CreatePointInput!): Point @scope(scope: "point:write") } diff --git a/graph/user.resolvers.go b/graph/user.resolvers.go index 5b460c2..ae3690f 100644 --- a/graph/user.resolvers.go +++ b/graph/user.resolvers.go @@ -209,6 +209,18 @@ func (r *mutationResolver) LogoutAll(ctx context.Context) (bool, error) { return r.LogoutUser(ctx, user.UserID) } +// CreatePoint is the resolver for the createPoint field. +func (r *mutationResolver) CreatePoint(ctx context.Context, input ent.CreatePointInput) (*ent.Point, error) { + entClient := r.EntClient(ctx) + + point, err := entClient.Point.Create().SetInput(input).Save(ctx) + if err != nil { + return nil, err + } + + return point, nil +} + // Me is the resolver for the me field. func (r *queryResolver) Me(ctx context.Context) (*ent.User, error) { tokenInfo, ok := auth.GetUser(ctx)