From 161a66e7385ee49552f913b4ff33b679bd3cc3c1 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Wed, 2 Nov 2022 23:15:32 -0400 Subject: [PATCH 01/29] regenerated schema with new fields --- go.sum | 2 - graph/entity.resolvers.go | 2 + graph/generated/generated.go | 3733 ++++++++++++++++++++++++---------- graph/model/models_gen.go | 144 +- graph/schema.graphqls | 34 + graph/schema.resolvers.go | 12 + 6 files changed, 2792 insertions(+), 1135 deletions(-) diff --git a/go.sum b/go.sum index 8555901..19e84ed 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ github.com/99designs/gqlgen v0.17.13 h1:ETUEqvRg5Zvr1lXtpoRdj026fzVay0ZlJPwI33qX github.com/99designs/gqlgen v0.17.13/go.mod h1:w1brbeOdqVyNJI553BGwtwdVcYu1LKeYE1opLWN9RgQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/KnightHacks/knighthacks_shared v0.0.0-20220701074430-690b99b0cd25 h1:m1DwqDMsPCyubE/NEg4EUoUsUNXzbWUZMS2sJZ5XUxs= -github.com/KnightHacks/knighthacks_shared v0.0.0-20220701074430-690b99b0cd25/go.mod h1:fEEUyCM7yJM0NCAtgRzY3aUf5sPqqMvIK3N9+yNOb2o= github.com/KnightHacks/knighthacks_shared v0.0.0-20221029020239-4248bfa6f0dd h1:y1d0uyNpLbtLjru/ybdfWwmSfz9jDHh9/tk7cDpaGP0= github.com/KnightHacks/knighthacks_shared v0.0.0-20221029020239-4248bfa6f0dd/go.mod h1:W6x/SycHYHMTE51Mo1MZeGQJUTJGME5LF3hdPFdGp4c= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= diff --git a/graph/entity.resolvers.go b/graph/entity.resolvers.go index 3d9108f..6e6bacc 100644 --- a/graph/entity.resolvers.go +++ b/graph/entity.resolvers.go @@ -11,11 +11,13 @@ import ( "github.com/KnightHacks/knighthacks_users/graph/model" ) +// FindUserByID is the resolver for the findUserByID field. func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.User, error) { user, err := r.Resolver.Repository.GetUserByID(ctx, id) return user, err } +// FindUserByOAuthUIDAndOAuthProvider is the resolver for the findUserByOAuthUIDAndOAuthProvider field. func (r *entityResolver) FindUserByOAuthUIDAndOAuthProvider(ctx context.Context, oAuthUID string, oAuthProvider models.Provider) (*model.User, error) { user, err := r.Resolver.Repository.GetUserByOAuthUID(ctx, oAuthUID, oAuthProvider) return user, err diff --git a/graph/generated/generated.go b/graph/generated/generated.go index 9899c37..d2ab85c 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -526,6 +526,14 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputEducationInfoInput, + ec.unmarshalInputMLHTermsInput, + ec.unmarshalInputMailingAddressInput, + ec.unmarshalInputNewUser, + ec.unmarshalInputPronounsInput, + ec.unmarshalInputUpdatedUser, + ) first := true switch rc.Operation.Operation { @@ -535,6 +543,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { return nil } first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) @@ -549,6 +558,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { return nil } first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) data := ec._Mutation(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) @@ -583,7 +593,7 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var sources = []*ast.Source{ - {Name: "graph/schema.graphqls", Input: `directive @goModel(model: String, models: [String!]) on OBJECT + {Name: "../schema.graphqls", Input: `directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM @@ -668,6 +678,35 @@ input PronounsInput { objective: String! } +input MLHTermsInput { + sendMessages: Boolean! + codeOfConduct: Boolean! + shareInfo: Boolean! +} + +input MailingAddressInput { + country: String! + state: String! + city: String! + postalCode: String! + addressLines: [String!]! +} + +input EducationInfoInput { + name: String! + graduationDate: String! + major: String! + level: LevelOfStudy +} + +enum LevelOfStudy { + FRESHMAN, SOPHOMORE, JUNIOR, SENIOR, SUPER_SENIOR, GRADUATE +} + +enum ShirtSize { + XS, S, M, L, XL, XXL, XXXL, XXXXL # idk what sizes, TODO: Look into what shirt sizes we will have +} + input NewUser { firstName: String! lastName: String! @@ -675,6 +714,11 @@ input NewUser { phoneNumber: String! pronouns: PronounsInput age: Int + mailingAddress: MailingAddressInput + mlh: MLHTermsInput! + shirtSize: ShirtSize! + yearsOfExperience: Float + educationInfo: EducationInfoInput! } input UpdatedUser { @@ -728,17 +772,18 @@ type Mutation { } `, BuiltIn: false}, - {Name: "federation/directives.graphql", Input: ` -scalar _Any -scalar _FieldSet - -directive @external on FIELD_DEFINITION -directive @requires(fields: _FieldSet!) on FIELD_DEFINITION -directive @provides(fields: _FieldSet!) on FIELD_DEFINITION -directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE -directive @extends on OBJECT | INTERFACE + {Name: "../../federation/directives.graphql", Input: ` + scalar _Any + scalar _FieldSet + + directive @external on FIELD_DEFINITION + directive @requires(fields: _FieldSet!) on FIELD_DEFINITION + directive @provides(fields: _FieldSet!) on FIELD_DEFINITION + directive @extends on OBJECT | INTERFACE + + directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE `, BuiltIn: true}, - {Name: "federation/entity.graphql", Input: ` + {Name: "../../federation/entity.graphql", Input: ` # a union of all types that use the @key directive union _Entity = User @@ -1101,31 +1146,20 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findUserByID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "Entity", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Entity_findUserByID_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindUserByID(rctx, args["id"].(string)) + return ec.resolvers.Entity().FindUserByID(rctx, fc.Args["id"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -1142,32 +1176,67 @@ func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field grap return ec.marshalNUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) _Entity_findUserByOAuthUIDAndOAuthProvider(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Entity", Field: field, - Args: nil, IsMethod: true, IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "firstName": + return ec.fieldContext_User_firstName(ctx, field) + case "lastName": + return ec.fieldContext_User_lastName(ctx, field) + case "fullName": + return ec.fieldContext_User_fullName(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "pronouns": + return ec.fieldContext_User_pronouns(ctx, field) + case "age": + return ec.fieldContext_User_age(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + case "oAuth": + return ec.fieldContext_User_oAuth(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, } - + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Entity_findUserByOAuthUIDAndOAuthProvider_args(ctx, rawArgs) - if err != nil { + if fc.Args, err = ec.field_Entity_findUserByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Entity_findUserByOAuthUIDAndOAuthProvider(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findUserByOAuthUIDAndOAuthProvider(ctx, field) + if err != nil { return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindUserByOAuthUIDAndOAuthProvider(rctx, args["oAuthUID"].(string), args["oAuthProvider"].(models.Provider)) + return ec.resolvers.Entity().FindUserByOAuthUIDAndOAuthProvider(rctx, fc.Args["oAuthUID"].(string), fc.Args["oAuthProvider"].(models.Provider)) }) if err != nil { ec.Error(ctx, err) @@ -1184,22 +1253,64 @@ func (ec *executionContext) _Entity_findUserByOAuthUIDAndOAuthProvider(ctx conte return ec.marshalNUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) _LoginPayload_accountExists(ctx context.Context, field graphql.CollectedField, obj *model.LoginPayload) (ret graphql.Marshaler) { +func (ec *executionContext) fieldContext_Entity_findUserByOAuthUIDAndOAuthProvider(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "firstName": + return ec.fieldContext_User_firstName(ctx, field) + case "lastName": + return ec.fieldContext_User_lastName(ctx, field) + case "fullName": + return ec.fieldContext_User_fullName(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "pronouns": + return ec.fieldContext_User_pronouns(ctx, field) + case "age": + return ec.fieldContext_User_age(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + case "oAuth": + return ec.fieldContext_User_oAuth(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } defer func() { if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + err = ec.Recover(ctx, r) + ec.Error(ctx, err) } }() - fc := &graphql.FieldContext{ - Object: "LoginPayload", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findUserByOAuthUIDAndOAuthProvider_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return } + return fc, nil +} +func (ec *executionContext) _LoginPayload_accountExists(ctx context.Context, field graphql.CollectedField, obj *model.LoginPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LoginPayload_accountExists(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.AccountExists, nil @@ -1219,22 +1330,31 @@ func (ec *executionContext) _LoginPayload_accountExists(ctx context.Context, fie return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _LoginPayload_user(ctx context.Context, field graphql.CollectedField, obj *model.LoginPayload) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_LoginPayload_accountExists(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "LoginPayload", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) _LoginPayload_user(ctx context.Context, field graphql.CollectedField, obj *model.LoginPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LoginPayload_user(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.User, nil @@ -1251,22 +1371,53 @@ func (ec *executionContext) _LoginPayload_user(ctx context.Context, field graphq return ec.marshalOUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_LoginPayload_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LoginPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "firstName": + return ec.fieldContext_User_firstName(ctx, field) + case "lastName": + return ec.fieldContext_User_lastName(ctx, field) + case "fullName": + return ec.fieldContext_User_fullName(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "pronouns": + return ec.fieldContext_User_pronouns(ctx, field) + case "age": + return ec.fieldContext_User_age(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + case "oAuth": + return ec.fieldContext_User_oAuth(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _LoginPayload_accessToken(ctx context.Context, field graphql.CollectedField, obj *model.LoginPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LoginPayload_accessToken(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "LoginPayload", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.AccessToken, nil @@ -1283,22 +1434,31 @@ func (ec *executionContext) _LoginPayload_accessToken(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _LoginPayload_refreshToken(ctx context.Context, field graphql.CollectedField, obj *model.LoginPayload) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_LoginPayload_accessToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "LoginPayload", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) _LoginPayload_refreshToken(ctx context.Context, field graphql.CollectedField, obj *model.LoginPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LoginPayload_refreshToken(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.RefreshToken, nil @@ -1315,22 +1475,31 @@ func (ec *executionContext) _LoginPayload_refreshToken(ctx context.Context, fiel return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _LoginPayload_encryptedOAuthAccessToken(ctx context.Context, field graphql.CollectedField, obj *model.LoginPayload) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_LoginPayload_refreshToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "LoginPayload", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) _LoginPayload_encryptedOAuthAccessToken(ctx context.Context, field graphql.CollectedField, obj *model.LoginPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LoginPayload_encryptedOAuthAccessToken(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EncryptedOAuthAccessToken, nil @@ -1347,32 +1516,34 @@ func (ec *executionContext) _LoginPayload_encryptedOAuthAccessToken(ctx context. return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_LoginPayload_encryptedOAuthAccessToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LoginPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Mutation_register(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_register(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_register_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().Register(rctx, args["provider"].(models.Provider), args["encryptedOAuthAccessToken"].(string), args["input"].(model.NewUser)) + return ec.resolvers.Mutation().Register(rctx, fc.Args["provider"].(models.Provider), fc.Args["encryptedOAuthAccessToken"].(string), fc.Args["input"].(model.NewUser)) }) if err != nil { ec.Error(ctx, err) @@ -1389,33 +1560,54 @@ func (ec *executionContext) _Mutation_register(ctx context.Context, field graphq return ec.marshalNRegistrationPayload2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRegistrationPayload(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Mutation_register(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Mutation", Field: field, - Args: nil, IsMethod: true, IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "user": + return ec.fieldContext_RegistrationPayload_user(ctx, field) + case "accessToken": + return ec.fieldContext_RegistrationPayload_accessToken(ctx, field) + case "refreshToken": + return ec.fieldContext_RegistrationPayload_refreshToken(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RegistrationPayload", field.Name) + }, } - + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_updateUser_args(ctx, rawArgs) - if err != nil { + if fc.Args, err = ec.field_Mutation_register_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateUser(ctx, field) + if err != nil { return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateUser(rctx, args["id"].(string), args["input"].(model.UpdatedUser)) + return ec.resolvers.Mutation().UpdateUser(rctx, fc.Args["id"].(string), fc.Args["input"].(model.UpdatedUser)) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") @@ -1455,33 +1647,68 @@ func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field grap return ec.marshalNUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Mutation", Field: field, - Args: nil, IsMethod: true, IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "firstName": + return ec.fieldContext_User_firstName(ctx, field) + case "lastName": + return ec.fieldContext_User_lastName(ctx, field) + case "fullName": + return ec.fieldContext_User_fullName(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "pronouns": + return ec.fieldContext_User_pronouns(ctx, field) + case "age": + return ec.fieldContext_User_age(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + case "oAuth": + return ec.fieldContext_User_oAuth(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, } - + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_deleteUser_args(ctx, rawArgs) - if err != nil { + if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteUser(ctx, field) + if err != nil { return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteUser(rctx, args["id"].(string)) + return ec.resolvers.Mutation().DeleteUser(rctx, fc.Args["id"].(string)) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") @@ -1521,22 +1748,42 @@ func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field grap return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _OAuth_provider(ctx context.Context, field graphql.CollectedField, obj *model.OAuth) (ret graphql.Marshaler) { +func (ec *executionContext) fieldContext_Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } defer func() { if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + err = ec.Recover(ctx, r) + ec.Error(ctx, err) } }() - fc := &graphql.FieldContext{ - Object: "OAuth", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_deleteUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return } + return fc, nil +} +func (ec *executionContext) _OAuth_provider(ctx context.Context, field graphql.CollectedField, obj *model.OAuth) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OAuth_provider(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Provider, nil @@ -1556,22 +1803,31 @@ func (ec *executionContext) _OAuth_provider(ctx context.Context, field graphql.C return ec.marshalNProvider2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐProvider(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_OAuth_provider(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OAuth", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Provider does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _OAuth_uid(ctx context.Context, field graphql.CollectedField, obj *model.OAuth) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OAuth_uid(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "OAuth", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.UID, nil @@ -1591,22 +1847,31 @@ func (ec *executionContext) _OAuth_uid(ctx context.Context, field graphql.Collec return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_OAuth_uid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OAuth", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "PageInfo", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.StartCursor, nil @@ -1626,22 +1891,31 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EndCursor, nil @@ -1661,22 +1935,31 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PageInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Pronouns_subjective(ctx context.Context, field graphql.CollectedField, obj *model.Pronouns) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Pronouns_subjective(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "Pronouns", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Subjective, nil @@ -1696,22 +1979,31 @@ func (ec *executionContext) _Pronouns_subjective(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Pronouns_objective(ctx context.Context, field graphql.CollectedField, obj *model.Pronouns) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Pronouns_subjective(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Pronouns", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) _Pronouns_objective(ctx context.Context, field graphql.CollectedField, obj *model.Pronouns) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Pronouns_objective(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Objective, nil @@ -1731,32 +2023,34 @@ func (ec *executionContext) _Pronouns_objective(ctx context.Context, field graph return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_Pronouns_objective(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Pronouns", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Query_getAuthRedirectLink(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getAuthRedirectLink(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_getAuthRedirectLink_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetAuthRedirectLink(rctx, args["provider"].(models.Provider), args["redirect"].(*string)) + return ec.resolvers.Query().GetAuthRedirectLink(rctx, fc.Args["provider"].(models.Provider), fc.Args["redirect"].(*string)) }) if err != nil { ec.Error(ctx, err) @@ -1773,32 +2067,45 @@ func (ec *executionContext) _Query_getAuthRedirectLink(ctx context.Context, fiel return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Query_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Query_getAuthRedirectLink(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Query", Field: field, - Args: nil, IsMethod: true, IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } - + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_login_args(ctx, rawArgs) - if err != nil { + if fc.Args, err = ec.field_Query_getAuthRedirectLink_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Query_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_login(ctx, field) + if err != nil { return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Login(rctx, args["provider"].(models.Provider), args["code"].(string), args["state"].(string)) + return ec.resolvers.Query().Login(rctx, fc.Args["provider"].(models.Provider), fc.Args["code"].(string), fc.Args["state"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -1815,33 +2122,58 @@ func (ec *executionContext) _Query_login(ctx context.Context, field graphql.Coll return ec.marshalNLoginPayload2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐLoginPayload(ctx, field.Selections, res) } -func (ec *executionContext) _Query_refreshJWT(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Query_login(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Query", Field: field, - Args: nil, IsMethod: true, IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "accountExists": + return ec.fieldContext_LoginPayload_accountExists(ctx, field) + case "user": + return ec.fieldContext_LoginPayload_user(ctx, field) + case "accessToken": + return ec.fieldContext_LoginPayload_accessToken(ctx, field) + case "refreshToken": + return ec.fieldContext_LoginPayload_refreshToken(ctx, field) + case "encryptedOAuthAccessToken": + return ec.fieldContext_LoginPayload_encryptedOAuthAccessToken(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type LoginPayload", field.Name) + }, } - + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_refreshJWT_args(ctx, rawArgs) - if err != nil { + if fc.Args, err = ec.field_Query_login_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Query_refreshJWT(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_refreshJWT(ctx, field) + if err != nil { return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().RefreshJwt(rctx, args["refreshToken"].(string)) + return ec.resolvers.Query().RefreshJwt(rctx, fc.Args["refreshToken"].(string)) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") @@ -1881,33 +2213,46 @@ func (ec *executionContext) _Query_refreshJWT(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Query_refreshJWT(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Query", Field: field, - Args: nil, IsMethod: true, IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } - + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_users_args(ctx, rawArgs) - if err != nil { + if fc.Args, err = ec.field_Query_refreshJWT_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_users(ctx, field) + if err != nil { return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Users(rctx, args["first"].(int), args["after"].(*string)) + return ec.resolvers.Query().Users(rctx, fc.Args["first"].(int), fc.Args["after"].(*string)) } directive1 := func(ctx context.Context) (interface{}, error) { maxLength, err := ec.unmarshalNInt2int(ctx, 20) @@ -1957,33 +2302,54 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll return ec.marshalNUsersConnection2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUsersConnection(ctx, field.Selections, res) } -func (ec *executionContext) _Query_getUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Query", Field: field, - Args: nil, IsMethod: true, IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_UsersConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_UsersConnection_pageInfo(ctx, field) + case "users": + return ec.fieldContext_UsersConnection_users(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UsersConnection", field.Name) + }, } - + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_getUser_args(ctx, rawArgs) - if err != nil { + if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Query_getUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getUser(ctx, field) + if err != nil { return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetUser(rctx, args["id"].(string)) + return ec.resolvers.Query().GetUser(rctx, fc.Args["id"].(string)) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") @@ -2020,33 +2386,68 @@ func (ec *executionContext) _Query_getUser(ctx context.Context, field graphql.Co return ec.marshalOUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) _Query_searchUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Query_getUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Query", Field: field, - Args: nil, IsMethod: true, IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "firstName": + return ec.fieldContext_User_firstName(ctx, field) + case "lastName": + return ec.fieldContext_User_lastName(ctx, field) + case "fullName": + return ec.fieldContext_User_fullName(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "pronouns": + return ec.fieldContext_User_pronouns(ctx, field) + case "age": + return ec.fieldContext_User_age(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + case "oAuth": + return ec.fieldContext_User_oAuth(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, } - + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_searchUser_args(ctx, rawArgs) - if err != nil { + if fc.Args, err = ec.field_Query_getUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Query_searchUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_searchUser(ctx, field) + if err != nil { return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().SearchUser(rctx, args["name"].(string)) + return ec.resolvers.Query().SearchUser(rctx, fc.Args["name"].(string)) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") @@ -2086,22 +2487,64 @@ func (ec *executionContext) _Query_searchUser(ctx context.Context, field graphql return ec.marshalNUser2ᚕᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUserᚄ(ctx, field.Selections, res) } -func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Query_searchUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Query", Field: field, - Args: nil, IsMethod: true, IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "firstName": + return ec.fieldContext_User_firstName(ctx, field) + case "lastName": + return ec.fieldContext_User_lastName(ctx, field) + case "fullName": + return ec.fieldContext_User_fullName(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "pronouns": + return ec.fieldContext_User_pronouns(ctx, field) + case "age": + return ec.fieldContext_User_age(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + case "oAuth": + return ec.fieldContext_User_oAuth(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_searchUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return } + return fc, nil +} +func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_me(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2142,32 +2585,56 @@ func (ec *executionContext) _Query_me(ctx context.Context, field graphql.Collect return ec.marshalOUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Query", Field: field, - Args: nil, IsMethod: true, - IsResolver: false, - } + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "firstName": + return ec.fieldContext_User_firstName(ctx, field) + case "lastName": + return ec.fieldContext_User_lastName(ctx, field) + case "fullName": + return ec.fieldContext_User_fullName(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "pronouns": + return ec.fieldContext_User_pronouns(ctx, field) + case "age": + return ec.fieldContext_User_age(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + case "oAuth": + return ec.fieldContext_User_oAuth(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query__entities_args(ctx, rawArgs) +func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__entities(ctx, field) if err != nil { - ec.Error(ctx, err) return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.__resolve_entities(ctx, args["representations"].([]map[string]interface{})), nil + return ec.__resolve_entities(ctx, fc.Args["representations"].([]map[string]interface{})), nil }) if err != nil { ec.Error(ctx, err) @@ -2184,22 +2651,42 @@ func (ec *executionContext) _Query__entities(ctx context.Context, field graphql. return ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) } -func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Query__entities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Query", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type _Entity does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query__entities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return } + return fc, nil +} +func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__service(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.__resolve__service(ctx) @@ -2219,32 +2706,38 @@ func (ec *executionContext) _Query__service(ctx context.Context, field graphql.C return ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Query__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Query", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "sdl": + return ec.fieldContext__Service_sdl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) + }, } + return fc, nil +} - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { - ec.Error(ctx, err) return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) + return ec.introspectType(fc.Args["name"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -2258,22 +2751,64 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "Query", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return } + return fc, nil +} +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -2290,22 +2825,45 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _RegistrationPayload_user(ctx context.Context, field graphql.CollectedField, obj *model.RegistrationPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RegistrationPayload_user(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "RegistrationPayload", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.User, nil @@ -2325,22 +2883,53 @@ func (ec *executionContext) _RegistrationPayload_user(ctx context.Context, field return ec.marshalNUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_RegistrationPayload_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RegistrationPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "firstName": + return ec.fieldContext_User_firstName(ctx, field) + case "lastName": + return ec.fieldContext_User_lastName(ctx, field) + case "fullName": + return ec.fieldContext_User_fullName(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "pronouns": + return ec.fieldContext_User_pronouns(ctx, field) + case "age": + return ec.fieldContext_User_age(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + case "oAuth": + return ec.fieldContext_User_oAuth(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _RegistrationPayload_accessToken(ctx context.Context, field graphql.CollectedField, obj *model.RegistrationPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RegistrationPayload_accessToken(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "RegistrationPayload", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.AccessToken, nil @@ -2360,22 +2949,31 @@ func (ec *executionContext) _RegistrationPayload_accessToken(ctx context.Context return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _RegistrationPayload_refreshToken(ctx context.Context, field graphql.CollectedField, obj *model.RegistrationPayload) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_RegistrationPayload_accessToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "RegistrationPayload", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) _RegistrationPayload_refreshToken(ctx context.Context, field graphql.CollectedField, obj *model.RegistrationPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RegistrationPayload_refreshToken(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.RefreshToken, nil @@ -2395,22 +2993,31 @@ func (ec *executionContext) _RegistrationPayload_refreshToken(ctx context.Contex return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_RegistrationPayload_refreshToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RegistrationPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "User", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -2430,22 +3037,31 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "User", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_firstName(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.FirstName, nil @@ -2465,22 +3081,31 @@ func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.C return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_User_firstName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "User", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_lastName(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.LastName, nil @@ -2500,22 +3125,31 @@ func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.Co return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_User_lastName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _User_fullName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_fullName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "User", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.User().FullName(rctx, obj) @@ -2535,22 +3169,31 @@ func (ec *executionContext) _User_fullName(ctx context.Context, field graphql.Co return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_User_fullName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_email(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "User", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2594,22 +3237,31 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _User_phoneNumber(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_User_email(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "User", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) _User_phoneNumber(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_phoneNumber(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2653,22 +3305,31 @@ func (ec *executionContext) _User_phoneNumber(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_User_phoneNumber(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _User_pronouns(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_pronouns(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "User", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Pronouns, nil @@ -2685,22 +3346,37 @@ func (ec *executionContext) _User_pronouns(ctx context.Context, field graphql.Co return ec.marshalOPronouns2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐPronouns(ctx, field.Selections, res) } -func (ec *executionContext) _User_age(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_User_pronouns(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "User", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "subjective": + return ec.fieldContext_Pronouns_subjective(ctx, field) + case "objective": + return ec.fieldContext_Pronouns_objective(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Pronouns", field.Name) + }, } + return fc, nil +} +func (ec *executionContext) _User_age(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_age(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2741,22 +3417,31 @@ func (ec *executionContext) _User_age(ctx context.Context, field graphql.Collect return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } -func (ec *executionContext) _User_role(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_User_age(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "User", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) _User_role(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_role(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2800,22 +3485,31 @@ func (ec *executionContext) _User_role(ctx context.Context, field graphql.Collec return ec.marshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_User_role(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Role does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _User_oAuth(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_oAuth(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "User", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2859,22 +3553,37 @@ func (ec *executionContext) _User_oAuth(ctx context.Context, field graphql.Colle return ec.marshalNOAuth2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐOAuth(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_User_oAuth(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "provider": + return ec.fieldContext_OAuth_provider(ctx, field) + case "uid": + return ec.fieldContext_OAuth_uid(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OAuth", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _UsersConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.UsersConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UsersConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "UsersConnection", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.TotalCount, nil @@ -2894,22 +3603,31 @@ func (ec *executionContext) _UsersConnection_totalCount(ctx context.Context, fie return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) _UsersConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.UsersConnection) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_UsersConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "UsersConnection", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) _UsersConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.UsersConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UsersConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PageInfo, nil @@ -2929,22 +3647,37 @@ func (ec *executionContext) _UsersConnection_pageInfo(ctx context.Context, field return ec.marshalNPageInfo2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) _UsersConnection_users(ctx context.Context, field graphql.CollectedField, obj *model.UsersConnection) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext_UsersConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "UsersConnection", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, } + return fc, nil +} +func (ec *executionContext) _UsersConnection_users(ctx context.Context, field graphql.CollectedField, obj *model.UsersConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UsersConnection_users(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Users, nil @@ -2964,22 +3697,53 @@ func (ec *executionContext) _UsersConnection_users(ctx context.Context, field gr return ec.marshalNUser2ᚕᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUserᚄ(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext_UsersConnection_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UsersConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "firstName": + return ec.fieldContext_User_firstName(ctx, field) + case "lastName": + return ec.fieldContext_User_lastName(ctx, field) + case "fullName": + return ec.fieldContext_User_fullName(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "pronouns": + return ec.fieldContext_User_pronouns(ctx, field) + case "age": + return ec.fieldContext_User_age(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + case "oAuth": + return ec.fieldContext_User_oAuth(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { + fc, err := ec.fieldContext__Service_sdl(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "_Service", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SDL, nil @@ -2996,22 +3760,31 @@ func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.Col return ec.marshalOString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext__Service_sdl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "_Service", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -3031,22 +3804,31 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -3063,22 +3845,31 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil @@ -3098,22 +3889,31 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Directive", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -3133,22 +3933,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Directive", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, } + return fc, nil +} +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsRepeatable, nil @@ -3168,22 +3987,31 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field return ec.marshalNBoolean2bool(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -3203,22 +4031,31 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -3235,22 +4072,31 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__EnumValue", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -3270,22 +4116,31 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__EnumValue", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -3302,22 +4157,31 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -3337,22 +4201,31 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -3369,22 +4242,31 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -3404,22 +4286,41 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Field", Field: field, - Args: nil, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, } + return fc, nil +} +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -3439,22 +4340,53 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -3474,22 +4406,31 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Field", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -3506,22 +4447,31 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -3541,22 +4491,31 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -3573,22 +4532,31 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -3608,22 +4576,53 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -3640,22 +4639,31 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -3672,32 +4680,41 @@ func (ec *executionContext) ___Schema_description(ctx context.Context, field gra return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Schema", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), nil - }) +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) if err != nil { - ec.Error(ctx, err) return graphql.Null } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -3707,22 +4724,53 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil @@ -3742,22 +4790,53 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -3774,22 +4853,53 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -3806,22 +4916,53 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil @@ -3841,22 +4982,43 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil @@ -3876,22 +5038,31 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Type", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -3908,22 +5079,31 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Type", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -3940,32 +5120,34 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Type", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) if err != nil { - ec.Error(ctx, err) return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil }) if err != nil { ec.Error(ctx, err) @@ -3979,22 +5161,56 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Type", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return } + return fc, nil +} +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -4011,22 +5227,53 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -4043,32 +5290,56 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Type", Field: field, - Args: nil, IsMethod: true, IsResolver: false, - } + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) if err != nil { - ec.Error(ctx, err) return graphql.Null } - fc.Args = args + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil }) if err != nil { ec.Error(ctx, err) @@ -4082,22 +5353,52 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Type", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -4114,22 +5415,41 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ Object: "__Type", Field: field, - Args: nil, IsMethod: true, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, } + return fc, nil +} +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -4146,22 +5466,53 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SpecifiedByURL(), nil @@ -4178,10 +5529,179 @@ func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field gr return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** +func (ec *executionContext) unmarshalInputEducationInfoInput(ctx context.Context, obj interface{}) (model.EducationInfoInput, error) { + var it model.EducationInfoInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "graduationDate", "major", "level"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.Name, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "graduationDate": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("graduationDate")) + it.GraduationDate, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "major": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("major")) + it.Major, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "level": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("level")) + it.Level, err = ec.unmarshalOLevelOfStudy2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐLevelOfStudy(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMLHTermsInput(ctx context.Context, obj interface{}) (model.MLHTermsInput, error) { + var it model.MLHTermsInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"sendMessages", "codeOfConduct", "shareInfo"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "sendMessages": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sendMessages")) + it.SendMessages, err = ec.unmarshalNBoolean2bool(ctx, v) + if err != nil { + return it, err + } + case "codeOfConduct": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("codeOfConduct")) + it.CodeOfConduct, err = ec.unmarshalNBoolean2bool(ctx, v) + if err != nil { + return it, err + } + case "shareInfo": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("shareInfo")) + it.ShareInfo, err = ec.unmarshalNBoolean2bool(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMailingAddressInput(ctx context.Context, obj interface{}) (model.MailingAddressInput, error) { + var it model.MailingAddressInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"country", "state", "city", "postalCode", "addressLines"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "country": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("country")) + it.Country, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "state": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("state")) + it.State, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "city": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("city")) + it.City, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "postalCode": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("postalCode")) + it.PostalCode, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "addressLines": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressLines")) + it.AddressLines, err = ec.unmarshalNString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputNewUser(ctx context.Context, obj interface{}) (model.NewUser, error) { var it model.NewUser asMap := map[string]interface{}{} @@ -4189,7 +5709,12 @@ func (ec *executionContext) unmarshalInputNewUser(ctx context.Context, obj inter asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age", "mailingAddress", "mlh", "shirtSize", "yearsOfExperience", "educationInfo"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "firstName": var err error @@ -4199,43 +5724,83 @@ func (ec *executionContext) unmarshalInputNewUser(ctx context.Context, obj inter if err != nil { return it, err } - case "lastName": + case "lastName": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastName")) + it.LastName, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "email": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) + it.Email, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "phoneNumber": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("phoneNumber")) + it.PhoneNumber, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "pronouns": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pronouns")) + it.Pronouns, err = ec.unmarshalOPronounsInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐPronounsInput(ctx, v) + if err != nil { + return it, err + } + case "age": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("age")) + it.Age, err = ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + case "mailingAddress": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastName")) - it.LastName, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mailingAddress")) + it.MailingAddress, err = ec.unmarshalOMailingAddressInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMailingAddressInput(ctx, v) if err != nil { return it, err } - case "email": + case "mlh": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) - it.Email, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mlh")) + it.Mlh, err = ec.unmarshalNMLHTermsInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTermsInput(ctx, v) if err != nil { return it, err } - case "phoneNumber": + case "shirtSize": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("phoneNumber")) - it.PhoneNumber, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("shirtSize")) + it.ShirtSize, err = ec.unmarshalNShirtSize2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐShirtSize(ctx, v) if err != nil { return it, err } - case "pronouns": + case "yearsOfExperience": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pronouns")) - it.Pronouns, err = ec.unmarshalOPronounsInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐPronounsInput(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("yearsOfExperience")) + it.YearsOfExperience, err = ec.unmarshalOFloat2ᚖfloat64(ctx, v) if err != nil { return it, err } - case "age": + case "educationInfo": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("age")) - it.Age, err = ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("educationInfo")) + it.EducationInfo, err = ec.unmarshalNEducationInfoInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfoInput(ctx, v) if err != nil { return it, err } @@ -4252,7 +5817,12 @@ func (ec *executionContext) unmarshalInputPronounsInput(ctx context.Context, obj asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"subjective", "objective"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "subjective": var err error @@ -4283,7 +5853,12 @@ func (ec *executionContext) unmarshalInputUpdatedUser(ctx context.Context, obj i asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "firstName": var err error @@ -4466,42 +6041,27 @@ func (ec *executionContext) _LoginPayload(ctx context.Context, sel ast.Selection case "__typename": out.Values[i] = graphql.MarshalString("LoginPayload") case "accountExists": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._LoginPayload_accountExists(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._LoginPayload_accountExists(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "user": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._LoginPayload_user(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._LoginPayload_user(ctx, field, obj) case "accessToken": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._LoginPayload_accessToken(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._LoginPayload_accessToken(ctx, field, obj) case "refreshToken": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._LoginPayload_refreshToken(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._LoginPayload_refreshToken(ctx, field, obj) case "encryptedOAuthAccessToken": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._LoginPayload_encryptedOAuthAccessToken(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._LoginPayload_encryptedOAuthAccessToken(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) @@ -4534,31 +6094,28 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "register": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_register(ctx, field) - } - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_register(ctx, field) + }) if out.Values[i] == graphql.Null { invalids++ } case "updateUser": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateUser(ctx, field) - } - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateUser(ctx, field) + }) if out.Values[i] == graphql.Null { invalids++ } case "deleteUser": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_deleteUser(ctx, field) - } - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteUser(ctx, field) + }) if out.Values[i] == graphql.Null { invalids++ @@ -4585,21 +6142,15 @@ func (ec *executionContext) _OAuth(ctx context.Context, sel ast.SelectionSet, ob case "__typename": out.Values[i] = graphql.MarshalString("OAuth") case "provider": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._OAuth_provider(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._OAuth_provider(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "uid": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._OAuth_uid(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._OAuth_uid(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ @@ -4626,21 +6177,15 @@ func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, case "__typename": out.Values[i] = graphql.MarshalString("PageInfo") case "startCursor": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._PageInfo_startCursor(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "endCursor": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._PageInfo_endCursor(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ @@ -4667,21 +6212,15 @@ func (ec *executionContext) _Pronouns(ctx context.Context, sel ast.SelectionSet, case "__typename": out.Values[i] = graphql.MarshalString("Pronouns") case "subjective": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Pronouns_subjective(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._Pronouns_subjective(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "objective": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Pronouns_objective(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._Pronouns_objective(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ @@ -4918,18 +6457,16 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr return rrm(innerCtx) }) case "__type": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___type(ctx, field) - } - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) case "__schema": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___schema(ctx, field) - } - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) default: panic("unknown field " + strconv.Quote(field.Name)) @@ -4953,31 +6490,22 @@ func (ec *executionContext) _RegistrationPayload(ctx context.Context, sel ast.Se case "__typename": out.Values[i] = graphql.MarshalString("RegistrationPayload") case "user": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._RegistrationPayload_user(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._RegistrationPayload_user(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "accessToken": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._RegistrationPayload_accessToken(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._RegistrationPayload_accessToken(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "refreshToken": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._RegistrationPayload_refreshToken(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._RegistrationPayload_refreshToken(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ @@ -5004,31 +6532,22 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._User_id(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._User_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "firstName": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._User_firstName(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._User_firstName(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "lastName": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._User_lastName(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._User_lastName(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) @@ -5054,45 +6573,30 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj }) case "email": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._User_email(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._User_email(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "phoneNumber": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._User_phoneNumber(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._User_phoneNumber(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "pronouns": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._User_pronouns(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._User_pronouns(ctx, field, obj) case "age": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._User_age(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._User_age(ctx, field, obj) case "role": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._User_role(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._User_role(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) @@ -5139,31 +6643,22 @@ func (ec *executionContext) _UsersConnection(ctx context.Context, sel ast.Select case "__typename": out.Values[i] = graphql.MarshalString("UsersConnection") case "totalCount": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._UsersConnection_totalCount(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._UsersConnection_totalCount(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "pageInfo": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._UsersConnection_pageInfo(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._UsersConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "users": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._UsersConnection_users(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec._UsersConnection_users(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ @@ -5190,11 +6685,8 @@ func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, case "__typename": out.Values[i] = graphql.MarshalString("_Service") case "sdl": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.__Service_sdl(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.__Service_sdl(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) @@ -5218,48 +6710,33 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Directive_name(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Directive_description(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Directive_description(ctx, field, obj) case "locations": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Directive_locations(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Directive_locations(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "args": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Directive_args(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Directive_args(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "isRepeatable": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Directive_isRepeatable(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ @@ -5286,38 +6763,26 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") case "name": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___EnumValue_name(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___EnumValue_description(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) case "isDeprecated": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___EnumValue_isDeprecated(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "deprecationReason": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___EnumValue_deprecationReason(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) @@ -5341,58 +6806,40 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, case "__typename": out.Values[i] = graphql.MarshalString("__Field") case "name": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_name(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Field_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_description(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Field_description(ctx, field, obj) case "args": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_args(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Field_args(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "type": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_type(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Field_type(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "isDeprecated": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_isDeprecated(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "deprecationReason": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_deprecationReason(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) @@ -5416,38 +6863,26 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") case "name": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___InputValue_name(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___InputValue_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___InputValue_description(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___InputValue_description(ctx, field, obj) case "type": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___InputValue_type(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___InputValue_type(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "defaultValue": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___InputValue_defaultValue(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) @@ -5471,52 +6906,34 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, case "__typename": out.Values[i] = graphql.MarshalString("__Schema") case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_description(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Schema_description(ctx, field, obj) case "types": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_types(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Schema_types(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "queryType": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_queryType(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "mutationType": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_mutationType(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) case "subscriptionType": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_subscriptionType(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) case "directives": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_directives(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Schema_directives(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ @@ -5543,77 +6960,47 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o case "__typename": out.Values[i] = graphql.MarshalString("__Type") case "kind": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_kind(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Type_kind(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "name": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_name(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Type_name(ctx, field, obj) case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_description(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Type_description(ctx, field, obj) case "fields": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_fields(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Type_fields(ctx, field, obj) case "interfaces": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_interfaces(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) case "possibleTypes": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_possibleTypes(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) case "enumValues": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_enumValues(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) case "inputFields": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_inputFields(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) case "ofType": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_ofType(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Type_ofType(ctx, field, obj) case "specifiedByURL": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_specifiedByURL(ctx, field, obj) - } - out.Values[i] = innerFunc(ctx) + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) @@ -5639,12 +7026,17 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res } +func (ec *executionContext) unmarshalNEducationInfoInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfoInput(ctx context.Context, v interface{}) (*model.EducationInfoInput, error) { + res, err := ec.unmarshalInputEducationInfoInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalID(v) return res, graphql.ErrorOnPath(ctx, err) @@ -5654,7 +7046,7 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res @@ -5669,7 +7061,7 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res @@ -5682,13 +7074,18 @@ func (ec *executionContext) marshalNLoginPayload2githubᚗcomᚋKnightHacksᚋkn func (ec *executionContext) marshalNLoginPayload2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐLoginPayload(ctx context.Context, sel ast.SelectionSet, v *model.LoginPayload) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._LoginPayload(ctx, sel, v) } +func (ec *executionContext) unmarshalNMLHTermsInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTermsInput(ctx context.Context, v interface{}) (*model.MLHTermsInput, error) { + res, err := ec.unmarshalInputMLHTermsInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNNewUser2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐNewUser(ctx context.Context, v interface{}) (model.NewUser, error) { res, err := ec.unmarshalInputNewUser(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -5701,7 +7098,7 @@ func (ec *executionContext) marshalNOAuth2githubᚗcomᚋKnightHacksᚋknighthac func (ec *executionContext) marshalNOAuth2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐOAuth(ctx context.Context, sel ast.SelectionSet, v *model.OAuth) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } @@ -5711,7 +7108,7 @@ func (ec *executionContext) marshalNOAuth2ᚖgithubᚗcomᚋKnightHacksᚋknight func (ec *executionContext) marshalNPageInfo2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v *models.PageInfo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } @@ -5735,7 +7132,7 @@ func (ec *executionContext) marshalNRegistrationPayload2githubᚗcomᚋKnightHac func (ec *executionContext) marshalNRegistrationPayload2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRegistrationPayload(ctx context.Context, sel ast.SelectionSet, v *model.RegistrationPayload) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } @@ -5752,6 +7149,16 @@ func (ec *executionContext) marshalNRole2githubᚗcomᚋKnightHacksᚋknighthack return v } +func (ec *executionContext) unmarshalNShirtSize2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐShirtSize(ctx context.Context, v interface{}) (model.ShirtSize, error) { + var res model.ShirtSize + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNShirtSize2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐShirtSize(ctx context.Context, sel ast.SelectionSet, v model.ShirtSize) graphql.Marshaler { + return v +} + func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) @@ -5761,12 +7168,44 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res } +func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNString2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + func (ec *executionContext) unmarshalNUpdatedUser2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUpdatedUser(ctx context.Context, v interface{}) (model.UpdatedUser, error) { res, err := ec.unmarshalInputUpdatedUser(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -5823,7 +7262,7 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋKnightHacksᚋknig func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } @@ -5837,7 +7276,7 @@ func (ec *executionContext) marshalNUsersConnection2githubᚗcomᚋKnightHacks func (ec *executionContext) marshalNUsersConnection2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUsersConnection(ctx context.Context, sel ast.SelectionSet, v *model.UsersConnection) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } @@ -5852,14 +7291,14 @@ func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{ func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } res := graphql.MarshalMap(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res @@ -5944,7 +7383,7 @@ func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel as res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res @@ -6011,7 +7450,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res @@ -6185,7 +7624,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } @@ -6201,7 +7640,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res @@ -6233,6 +7672,22 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } +func (ec *executionContext) unmarshalOFloat2ᚖfloat64(ctx context.Context, v interface{}) (*float64, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalFloatContext(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOFloat2ᚖfloat64(ctx context.Context, sel ast.SelectionSet, v *float64) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalFloatContext(*v) + return graphql.WrapContextMarshaler(ctx, res) +} + func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { if v == nil { return nil, nil @@ -6249,6 +7704,30 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele return res } +func (ec *executionContext) unmarshalOLevelOfStudy2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐLevelOfStudy(ctx context.Context, v interface{}) (*model.LevelOfStudy, error) { + if v == nil { + return nil, nil + } + var res = new(model.LevelOfStudy) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOLevelOfStudy2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐLevelOfStudy(ctx context.Context, sel ast.SelectionSet, v *model.LevelOfStudy) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOMailingAddressInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMailingAddressInput(ctx context.Context, v interface{}) (*model.MailingAddressInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMailingAddressInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOPronouns2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐPronouns(ctx context.Context, sel ast.SelectionSet, v *model.Pronouns) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/graph/model/models_gen.go b/graph/model/models_gen.go index 1c76592..66c5de5 100644 --- a/graph/model/models_gen.go +++ b/graph/model/models_gen.go @@ -3,6 +3,10 @@ package model import ( + "fmt" + "io" + "strconv" + "github.com/KnightHacks/knighthacks_shared/models" ) @@ -10,6 +14,13 @@ type Connection interface { IsConnection() } +type EducationInfoInput struct { + Name string `json:"name"` + GraduationDate string `json:"graduationDate"` + Major string `json:"major"` + Level *LevelOfStudy `json:"level"` +} + type LoginPayload struct { // If false then you must register immediately following this. Else, you are logged in and have access to your own user. AccountExists bool `json:"accountExists"` @@ -19,13 +30,32 @@ type LoginPayload struct { EncryptedOAuthAccessToken *string `json:"encryptedOAuthAccessToken"` } +type MLHTermsInput struct { + SendMessages bool `json:"sendMessages"` + CodeOfConduct bool `json:"codeOfConduct"` + ShareInfo bool `json:"shareInfo"` +} + +type MailingAddressInput struct { + Country string `json:"country"` + State string `json:"state"` + City string `json:"city"` + PostalCode string `json:"postalCode"` + AddressLines []string `json:"addressLines"` +} + type NewUser struct { - FirstName string `json:"firstName"` - LastName string `json:"lastName"` - Email string `json:"email"` - PhoneNumber string `json:"phoneNumber"` - Pronouns *PronounsInput `json:"pronouns"` - Age *int `json:"age"` + FirstName string `json:"firstName"` + LastName string `json:"lastName"` + Email string `json:"email"` + PhoneNumber string `json:"phoneNumber"` + Pronouns *PronounsInput `json:"pronouns"` + Age *int `json:"age"` + MailingAddress *MailingAddressInput `json:"mailingAddress"` + Mlh *MLHTermsInput `json:"mlh"` + ShirtSize ShirtSize `json:"shirtSize"` + YearsOfExperience *float64 `json:"yearsOfExperience"` + EducationInfo *EducationInfoInput `json:"educationInfo"` } type OAuth struct { @@ -83,3 +113,105 @@ type UsersConnection struct { } func (UsersConnection) IsConnection() {} + +type LevelOfStudy string + +const ( + LevelOfStudyFreshman LevelOfStudy = "FRESHMAN" + LevelOfStudySophomore LevelOfStudy = "SOPHOMORE" + LevelOfStudyJunior LevelOfStudy = "JUNIOR" + LevelOfStudySenior LevelOfStudy = "SENIOR" + LevelOfStudySuperSenior LevelOfStudy = "SUPER_SENIOR" + LevelOfStudyGraduate LevelOfStudy = "GRADUATE" +) + +var AllLevelOfStudy = []LevelOfStudy{ + LevelOfStudyFreshman, + LevelOfStudySophomore, + LevelOfStudyJunior, + LevelOfStudySenior, + LevelOfStudySuperSenior, + LevelOfStudyGraduate, +} + +func (e LevelOfStudy) IsValid() bool { + switch e { + case LevelOfStudyFreshman, LevelOfStudySophomore, LevelOfStudyJunior, LevelOfStudySenior, LevelOfStudySuperSenior, LevelOfStudyGraduate: + return true + } + return false +} + +func (e LevelOfStudy) String() string { + return string(e) +} + +func (e *LevelOfStudy) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = LevelOfStudy(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid LevelOfStudy", str) + } + return nil +} + +func (e LevelOfStudy) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type ShirtSize string + +const ( + ShirtSizeXs ShirtSize = "XS" + ShirtSizeS ShirtSize = "S" + ShirtSizeM ShirtSize = "M" + ShirtSizeL ShirtSize = "L" + ShirtSizeXl ShirtSize = "XL" + ShirtSizeXxl ShirtSize = "XXL" + ShirtSizeXxxl ShirtSize = "XXXL" + ShirtSizeXxxxl ShirtSize = "XXXXL" +) + +var AllShirtSize = []ShirtSize{ + ShirtSizeXs, + ShirtSizeS, + ShirtSizeM, + ShirtSizeL, + ShirtSizeXl, + ShirtSizeXxl, + ShirtSizeXxxl, + ShirtSizeXxxxl, +} + +func (e ShirtSize) IsValid() bool { + switch e { + case ShirtSizeXs, ShirtSizeS, ShirtSizeM, ShirtSizeL, ShirtSizeXl, ShirtSizeXxl, ShirtSizeXxxl, ShirtSizeXxxxl: + return true + } + return false +} + +func (e ShirtSize) String() string { + return string(e) +} + +func (e *ShirtSize) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = ShirtSize(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid ShirtSize", str) + } + return nil +} + +func (e ShirtSize) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/graph/schema.graphqls b/graph/schema.graphqls index 4a7638f..1d5cb87 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -83,6 +83,35 @@ input PronounsInput { objective: String! } +input MLHTermsInput { + sendMessages: Boolean! + codeOfConduct: Boolean! + shareInfo: Boolean! +} + +input MailingAddressInput { + country: String! + state: String! + city: String! + postalCode: String! + addressLines: [String!]! +} + +input EducationInfoInput { + name: String! + graduationDate: String! + major: String! + level: LevelOfStudy +} + +enum LevelOfStudy { + FRESHMAN, SOPHOMORE, JUNIOR, SENIOR, SUPER_SENIOR, GRADUATE +} + +enum ShirtSize { + XS, S, M, L, XL, XXL, XXXL, XXXXL # idk what sizes, TODO: Look into what shirt sizes we will have +} + input NewUser { firstName: String! lastName: String! @@ -90,6 +119,11 @@ input NewUser { phoneNumber: String! pronouns: PronounsInput age: Int + mailingAddress: MailingAddressInput + mlh: MLHTermsInput! + shirtSize: ShirtSize! + yearsOfExperience: Float + educationInfo: EducationInfoInput! } input UpdatedUser { diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index a4e5be9..0be2cca 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -21,6 +21,7 @@ import ( "github.com/KnightHacks/knighthacks_users/repository" ) +// Register is the resolver for the register field. func (r *mutationResolver) Register(ctx context.Context, provider models.Provider, encryptedOauthAccessToken string, input model.NewUser) (*model.RegistrationPayload, error) { // Decode the encrypted OAuth AccessToken from base64 b, err := base64.URLEncoding.DecodeString(encryptedOauthAccessToken) @@ -56,6 +57,7 @@ func (r *mutationResolver) Register(ctx context.Context, provider models.Provide return payload, nil } +// UpdateUser is the resolver for the updateUser field. func (r *mutationResolver) UpdateUser(ctx context.Context, id string, input model.UpdatedUser) (*model.User, error) { if input.FirstName == nil && input.LastName == nil && input.Email == nil && input.PhoneNumber == nil && input.Pronouns == nil && input.Age == nil { return nil, fmt.Errorf("no field has been updated") @@ -72,6 +74,7 @@ func (r *mutationResolver) UpdateUser(ctx context.Context, id string, input mode return r.Repository.UpdateUser(ctx, id, &input) } +// DeleteUser is the resolver for the deleteUser field. func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (bool, error) { claims, ok := ctx.Value("AuthorizationUserClaims").(*auth.UserClaims) if !ok { @@ -83,6 +86,7 @@ func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (bool, err return r.Repository.DeleteUser(ctx, id) } +// GetAuthRedirectLink is the resolver for the getAuthRedirectLink field. func (r *queryResolver) GetAuthRedirectLink(ctx context.Context, provider models.Provider, redirect *string) (string, error) { ginContext, err := utils.GinContextFromContext(ctx) if err != nil { @@ -103,6 +107,7 @@ func (r *queryResolver) GetAuthRedirectLink(ctx context.Context, provider models return r.Auth.GetAuthCodeURL(provider, state, redirect), nil } +// Login is the resolver for the login field. func (r *queryResolver) Login(ctx context.Context, provider models.Provider, code string, state string) (*model.LoginPayload, error) { // todo: this should probably be cleaned up, been at this shit for hours, please god.. no more ginContext, err := utils.GinContextFromContext(ctx) @@ -165,6 +170,7 @@ func (r *queryResolver) Login(ctx context.Context, provider models.Provider, cod return &payload, nil } +// RefreshJwt is the resolver for the refreshJWT field. func (r *queryResolver) RefreshJwt(ctx context.Context, refreshToken string) (string, error) { refreshTokenUserClaims, err := r.Auth.ParseJWT(refreshToken, auth.RefreshTokenType) if err != nil { @@ -179,6 +185,7 @@ func (r *queryResolver) RefreshJwt(ctx context.Context, refreshToken string) (st return token, nil } +// Users is the resolver for the users field. func (r *queryResolver) Users(ctx context.Context, first int, after *string) (*model.UsersConnection, error) { a, err := pagination.DecodeCursor(after) if err != nil { @@ -196,10 +203,12 @@ func (r *queryResolver) Users(ctx context.Context, first int, after *string) (*m }, nil } +// GetUser is the resolver for the getUser field. func (r *queryResolver) GetUser(ctx context.Context, id string) (*model.User, error) { return r.Repository.GetUserByID(ctx, id) } +// SearchUser is the resolver for the searchUser field. func (r *queryResolver) SearchUser(ctx context.Context, name string) ([]*model.User, error) { if !utils.IsASCII(name) { // TODO: how to handle non ascii names? do they exist? idk @@ -209,6 +218,7 @@ func (r *queryResolver) SearchUser(ctx context.Context, name string) ([]*model.U return r.Repository.SearchUser(ctx, name) } +// Me is the resolver for the me field. func (r *queryResolver) Me(ctx context.Context) (*model.User, error) { userClaims, err := auth.UserClaimsFromContext(ctx) if err != nil { @@ -218,10 +228,12 @@ func (r *queryResolver) Me(ctx context.Context) (*model.User, error) { return r.Entity().FindUserByID(ctx, userClaims.UserID) } +// FullName is the resolver for the fullName field. func (r *userResolver) FullName(ctx context.Context, obj *model.User) (string, error) { return fmt.Sprintf("%s %s", obj.FirstName, obj.LastName), nil } +// OAuth is the resolver for the oAuth field. func (r *userResolver) OAuth(ctx context.Context, obj *model.User) (*model.OAuth, error) { return r.Repository.GetOAuth(ctx, obj.ID) } From 85264950cc41cabc9601a09308bcd7552826751e Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Wed, 2 Nov 2022 23:26:57 -0400 Subject: [PATCH 02/29] added update/get types and fields relating to the previous commit --- graph/generated/generated.go | 2423 +++++++++++++++++++++++++++------- graph/model/models_gen.go | 63 +- graph/schema.graphqls | 35 +- graph/schema.resolvers.go | 25 + 4 files changed, 2071 insertions(+), 475 deletions(-) diff --git a/graph/generated/generated.go b/graph/generated/generated.go index d2ab85c..c4e0dda 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -50,6 +50,13 @@ type DirectiveRoot struct { } type ComplexityRoot struct { + EducationInfo struct { + GraduationDate func(childComplexity int) int + Level func(childComplexity int) int + Major func(childComplexity int) int + Name func(childComplexity int) int + } + Entity struct { FindUserByID func(childComplexity int, id string) int FindUserByOAuthUIDAndOAuthProvider func(childComplexity int, oAuthUID string, oAuthProvider models.Provider) int @@ -63,6 +70,20 @@ type ComplexityRoot struct { User func(childComplexity int) int } + MLHTerms struct { + CodeOfConduct func(childComplexity int) int + SendMessages func(childComplexity int) int + ShareInfo func(childComplexity int) int + } + + MailingAddress struct { + AddressLines func(childComplexity int) int + City func(childComplexity int) int + Country func(childComplexity int) int + PostalCode func(childComplexity int) int + State func(childComplexity int) int + } + Mutation struct { DeleteUser func(childComplexity int, id string) int Register func(childComplexity int, provider models.Provider, encryptedOauthAccessToken string, input model.NewUser) int @@ -103,16 +124,21 @@ type ComplexityRoot struct { } User struct { - Age func(childComplexity int) int - Email func(childComplexity int) int - FirstName func(childComplexity int) int - FullName func(childComplexity int) int - ID func(childComplexity int) int - LastName func(childComplexity int) int - OAuth func(childComplexity int) int - PhoneNumber func(childComplexity int) int - Pronouns func(childComplexity int) int - Role func(childComplexity int) int + Age func(childComplexity int) int + EducationInfo func(childComplexity int) int + Email func(childComplexity int) int + FirstName func(childComplexity int) int + FullName func(childComplexity int) int + ID func(childComplexity int) int + LastName func(childComplexity int) int + MailingAddress func(childComplexity int) int + Mlh func(childComplexity int) int + OAuth func(childComplexity int) int + PhoneNumber func(childComplexity int) int + Pronouns func(childComplexity int) int + Role func(childComplexity int) int + ShirtSize func(childComplexity int) int + YearsOfExperience func(childComplexity int) int } UsersConnection struct { @@ -148,6 +174,11 @@ type UserResolver interface { FullName(ctx context.Context, obj *model.User) (string, error) OAuth(ctx context.Context, obj *model.User) (*model.OAuth, error) + MailingAddress(ctx context.Context, obj *model.User) (*model.MailingAddress, error) + Mlh(ctx context.Context, obj *model.User) (*model.MLHTerms, error) + ShirtSize(ctx context.Context, obj *model.User) (model.ShirtSize, error) + YearsOfExperience(ctx context.Context, obj *model.User) (*float64, error) + EducationInfo(ctx context.Context, obj *model.User) (*model.EducationInfo, error) } type executableSchema struct { @@ -165,6 +196,34 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { + case "EducationInfo.graduationDate": + if e.complexity.EducationInfo.GraduationDate == nil { + break + } + + return e.complexity.EducationInfo.GraduationDate(childComplexity), true + + case "EducationInfo.level": + if e.complexity.EducationInfo.Level == nil { + break + } + + return e.complexity.EducationInfo.Level(childComplexity), true + + case "EducationInfo.major": + if e.complexity.EducationInfo.Major == nil { + break + } + + return e.complexity.EducationInfo.Major(childComplexity), true + + case "EducationInfo.name": + if e.complexity.EducationInfo.Name == nil { + break + } + + return e.complexity.EducationInfo.Name(childComplexity), true + case "Entity.findUserByID": if e.complexity.Entity.FindUserByID == nil { break @@ -224,6 +283,62 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.LoginPayload.User(childComplexity), true + case "MLHTerms.codeOfConduct": + if e.complexity.MLHTerms.CodeOfConduct == nil { + break + } + + return e.complexity.MLHTerms.CodeOfConduct(childComplexity), true + + case "MLHTerms.sendMessages": + if e.complexity.MLHTerms.SendMessages == nil { + break + } + + return e.complexity.MLHTerms.SendMessages(childComplexity), true + + case "MLHTerms.shareInfo": + if e.complexity.MLHTerms.ShareInfo == nil { + break + } + + return e.complexity.MLHTerms.ShareInfo(childComplexity), true + + case "MailingAddress.addressLines": + if e.complexity.MailingAddress.AddressLines == nil { + break + } + + return e.complexity.MailingAddress.AddressLines(childComplexity), true + + case "MailingAddress.city": + if e.complexity.MailingAddress.City == nil { + break + } + + return e.complexity.MailingAddress.City(childComplexity), true + + case "MailingAddress.country": + if e.complexity.MailingAddress.Country == nil { + break + } + + return e.complexity.MailingAddress.Country(childComplexity), true + + case "MailingAddress.postalCode": + if e.complexity.MailingAddress.PostalCode == nil { + break + } + + return e.complexity.MailingAddress.PostalCode(childComplexity), true + + case "MailingAddress.state": + if e.complexity.MailingAddress.State == nil { + break + } + + return e.complexity.MailingAddress.State(childComplexity), true + case "Mutation.deleteUser": if e.complexity.Mutation.DeleteUser == nil { break @@ -428,6 +543,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Age(childComplexity), true + case "User.educationInfo": + if e.complexity.User.EducationInfo == nil { + break + } + + return e.complexity.User.EducationInfo(childComplexity), true + case "User.email": if e.complexity.User.Email == nil { break @@ -463,6 +585,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.LastName(childComplexity), true + case "User.mailingAddress": + if e.complexity.User.MailingAddress == nil { + break + } + + return e.complexity.User.MailingAddress(childComplexity), true + + case "User.mlh": + if e.complexity.User.Mlh == nil { + break + } + + return e.complexity.User.Mlh(childComplexity), true + case "User.oAuth": if e.complexity.User.OAuth == nil { break @@ -491,6 +627,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Role(childComplexity), true + case "User.shirtSize": + if e.complexity.User.ShirtSize == nil { + break + } + + return e.complexity.User.ShirtSize(childComplexity), true + + case "User.yearsOfExperience": + if e.complexity.User.YearsOfExperience == nil { + break + } + + return e.complexity.User.YearsOfExperience(childComplexity), true + case "UsersConnection.pageInfo": if e.complexity.UsersConnection.PageInfo == nil { break @@ -641,6 +791,12 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { role: Role! @hasRole(role: OWNS) oAuth: OAuth! @goField(forceResolver: true) @hasRole(role: OWNS) + + mailingAddress: MailingAddress @goField(forceResolver: true) @hasRole(role: OWNS) + mlh: MLHTerms! @goField(forceResolver: true) @hasRole(role: OWNS) + shirtSize: ShirtSize! @goField(forceResolver: true) @hasRole(role: OWNS) + yearsOfExperience: Float @goField(forceResolver: true) @hasRole(role: OWNS) + educationInfo: EducationInfo! @goField(forceResolver: true) @hasRole(role: OWNS) } """ @@ -678,12 +834,26 @@ input PronounsInput { objective: String! } +type MLHTerms { + sendMessages: Boolean! + codeOfConduct: Boolean! + shareInfo: Boolean! +} + input MLHTermsInput { sendMessages: Boolean! codeOfConduct: Boolean! shareInfo: Boolean! } +type MailingAddress { + country: String! + state: String! + city: String! + postalCode: String! + addressLines: [String!]! +} + input MailingAddressInput { country: String! state: String! @@ -692,6 +862,13 @@ input MailingAddressInput { addressLines: [String!]! } +type EducationInfo { + name: String! + graduationDate: String! + major: String! + level: LevelOfStudy +} + input EducationInfoInput { name: String! graduationDate: String! @@ -728,6 +905,12 @@ input UpdatedUser { phoneNumber: String pronouns: PronounsInput age: Int + + mailingAddress: MailingAddressInput + mlh: MLHTermsInput + shirtSize: ShirtSize + yearsOfExperience: Float + educationInfo: EducationInfoInput } type LoginPayload { @@ -758,7 +941,7 @@ type Query { refreshJWT(refreshToken: String!): String! @hasRole(role: NORMAL) users(first: Int!, after: String): UsersConnection! @pagination(maxLength: 20) @hasRole(role: ADMIN) getUser(id: ID!): User @hasRole(role: NORMAL) - searchUser(name: String!): [User!]! @hasRole(role: NORMAL) + searchUser(name: String!): [User!]! @hasRole(role: ADMIN) me: User @hasRole(role: NORMAL) } @@ -1145,6 +1328,179 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** +func (ec *executionContext) _EducationInfo_name(ctx context.Context, field graphql.CollectedField, obj *model.EducationInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EducationInfo_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_EducationInfo_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EducationInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EducationInfo_graduationDate(ctx context.Context, field graphql.CollectedField, obj *model.EducationInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EducationInfo_graduationDate(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.GraduationDate, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_EducationInfo_graduationDate(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EducationInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EducationInfo_major(ctx context.Context, field graphql.CollectedField, obj *model.EducationInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EducationInfo_major(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Major, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_EducationInfo_major(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EducationInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EducationInfo_level(ctx context.Context, field graphql.CollectedField, obj *model.EducationInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EducationInfo_level(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Level, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.LevelOfStudy) + fc.Result = res + return ec.marshalOLevelOfStudy2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐLevelOfStudy(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_EducationInfo_level(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EducationInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type LevelOfStudy does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Entity_findUserByID(ctx, field) if err != nil { @@ -1204,6 +1560,16 @@ func (ec *executionContext) fieldContext_Entity_findUserByID(ctx context.Context return ec.fieldContext_User_role(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) + case "mailingAddress": + return ec.fieldContext_User_mailingAddress(ctx, field) + case "mlh": + return ec.fieldContext_User_mlh(ctx, field) + case "shirtSize": + return ec.fieldContext_User_shirtSize(ctx, field) + case "yearsOfExperience": + return ec.fieldContext_User_yearsOfExperience(ctx, field) + case "educationInfo": + return ec.fieldContext_User_educationInfo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -1281,6 +1647,16 @@ func (ec *executionContext) fieldContext_Entity_findUserByOAuthUIDAndOAuthProvid return ec.fieldContext_User_role(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) + case "mailingAddress": + return ec.fieldContext_User_mailingAddress(ctx, field) + case "mlh": + return ec.fieldContext_User_mlh(ctx, field) + case "shirtSize": + return ec.fieldContext_User_shirtSize(ctx, field) + case "yearsOfExperience": + return ec.fieldContext_User_yearsOfExperience(ctx, field) + case "educationInfo": + return ec.fieldContext_User_educationInfo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -1399,6 +1775,16 @@ func (ec *executionContext) fieldContext_LoginPayload_user(ctx context.Context, return ec.fieldContext_User_role(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) + case "mailingAddress": + return ec.fieldContext_User_mailingAddress(ctx, field) + case "mlh": + return ec.fieldContext_User_mlh(ctx, field) + case "shirtSize": + return ec.fieldContext_User_shirtSize(ctx, field) + case "yearsOfExperience": + return ec.fieldContext_User_yearsOfExperience(ctx, field) + case "educationInfo": + return ec.fieldContext_User_educationInfo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -1529,8 +1915,8 @@ func (ec *executionContext) fieldContext_LoginPayload_encryptedOAuthAccessToken( return fc, nil } -func (ec *executionContext) _Mutation_register(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_register(ctx, field) +func (ec *executionContext) _MLHTerms_sendMessages(ctx context.Context, field graphql.CollectedField, obj *model.MLHTerms) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MLHTerms_sendMessages(ctx, field) if err != nil { return graphql.Null } @@ -1543,7 +1929,7 @@ func (ec *executionContext) _Mutation_register(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().Register(rctx, fc.Args["provider"].(models.Provider), fc.Args["encryptedOAuthAccessToken"].(string), fc.Args["input"].(model.NewUser)) + return obj.SendMessages, nil }) if err != nil { ec.Error(ctx, err) @@ -1555,146 +1941,26 @@ func (ec *executionContext) _Mutation_register(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(*model.RegistrationPayload) + res := resTmp.(bool) fc.Result = res - return ec.marshalNRegistrationPayload2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRegistrationPayload(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_register(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MLHTerms_sendMessages(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "MLHTerms", Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "user": - return ec.fieldContext_RegistrationPayload_user(ctx, field) - case "accessToken": - return ec.fieldContext_RegistrationPayload_accessToken(ctx, field) - case "refreshToken": - return ec.fieldContext_RegistrationPayload_refreshToken(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type RegistrationPayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_register_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateUser(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateUser(rctx, fc.Args["id"].(string), fc.Args["input"].(model.UpdatedUser)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") - if err != nil { - return nil, err - } - if ec.directives.HasRole == nil { - return nil, errors.New("directive hasRole is not implemented") - } - return ec.directives.HasRole(ctx, nil, directive0, role) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*model.User); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/KnightHacks/knighthacks_users/graph/model.User`, tmp) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*model.User) - fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "firstName": - return ec.fieldContext_User_firstName(ctx, field) - case "lastName": - return ec.fieldContext_User_lastName(ctx, field) - case "fullName": - return ec.fieldContext_User_fullName(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "phoneNumber": - return ec.fieldContext_User_phoneNumber(ctx, field) - case "pronouns": - return ec.fieldContext_User_pronouns(ctx, field) - case "age": - return ec.fieldContext_User_age(ctx, field) - case "role": - return ec.fieldContext_User_role(ctx, field) - case "oAuth": - return ec.fieldContext_User_oAuth(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } return fc, nil } -func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteUser(ctx, field) +func (ec *executionContext) _MLHTerms_codeOfConduct(ctx context.Context, field graphql.CollectedField, obj *model.MLHTerms) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MLHTerms_codeOfConduct(ctx, field) if err != nil { return graphql.Null } @@ -1706,32 +1972,8 @@ func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteUser(rctx, fc.Args["id"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") - if err != nil { - return nil, err - } - if ec.directives.HasRole == nil { - return nil, errors.New("directive hasRole is not implemented") - } - return ec.directives.HasRole(ctx, nil, directive0, role) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.CodeOfConduct, nil }) if err != nil { ec.Error(ctx, err) @@ -1748,32 +1990,21 @@ func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field grap return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MLHTerms_codeOfConduct(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "MLHTerms", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } return fc, nil } -func (ec *executionContext) _OAuth_provider(ctx context.Context, field graphql.CollectedField, obj *model.OAuth) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_OAuth_provider(ctx, field) +func (ec *executionContext) _MLHTerms_shareInfo(ctx context.Context, field graphql.CollectedField, obj *model.MLHTerms) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MLHTerms_shareInfo(ctx, field) if err != nil { return graphql.Null } @@ -1786,7 +2017,7 @@ func (ec *executionContext) _OAuth_provider(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Provider, nil + return obj.ShareInfo, nil }) if err != nil { ec.Error(ctx, err) @@ -1798,26 +2029,26 @@ func (ec *executionContext) _OAuth_provider(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(models.Provider) + res := resTmp.(bool) fc.Result = res - return ec.marshalNProvider2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐProvider(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_OAuth_provider(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MLHTerms_shareInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "OAuth", + Object: "MLHTerms", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Provider does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _OAuth_uid(ctx context.Context, field graphql.CollectedField, obj *model.OAuth) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_OAuth_uid(ctx, field) +func (ec *executionContext) _MailingAddress_country(ctx context.Context, field graphql.CollectedField, obj *model.MailingAddress) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MailingAddress_country(ctx, field) if err != nil { return graphql.Null } @@ -1830,7 +2061,7 @@ func (ec *executionContext) _OAuth_uid(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.UID, nil + return obj.Country, nil }) if err != nil { ec.Error(ctx, err) @@ -1847,9 +2078,9 @@ func (ec *executionContext) _OAuth_uid(ctx context.Context, field graphql.Collec return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_OAuth_uid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MailingAddress_country(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "OAuth", + Object: "MailingAddress", Field: field, IsMethod: false, IsResolver: false, @@ -1860,8 +2091,8 @@ func (ec *executionContext) fieldContext_OAuth_uid(ctx context.Context, field gr return fc, nil } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) +func (ec *executionContext) _MailingAddress_state(ctx context.Context, field graphql.CollectedField, obj *model.MailingAddress) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MailingAddress_state(ctx, field) if err != nil { return graphql.Null } @@ -1874,7 +2105,7 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.StartCursor, nil + return obj.State, nil }) if err != nil { ec.Error(ctx, err) @@ -1891,9 +2122,9 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MailingAddress_state(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "MailingAddress", Field: field, IsMethod: false, IsResolver: false, @@ -1904,8 +2135,8 @@ func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Contex return fc, nil } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) +func (ec *executionContext) _MailingAddress_city(ctx context.Context, field graphql.CollectedField, obj *model.MailingAddress) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MailingAddress_city(ctx, field) if err != nil { return graphql.Null } @@ -1918,7 +2149,7 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EndCursor, nil + return obj.City, nil }) if err != nil { ec.Error(ctx, err) @@ -1935,9 +2166,9 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MailingAddress_city(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "MailingAddress", Field: field, IsMethod: false, IsResolver: false, @@ -1948,8 +2179,8 @@ func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, return fc, nil } -func (ec *executionContext) _Pronouns_subjective(ctx context.Context, field graphql.CollectedField, obj *model.Pronouns) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Pronouns_subjective(ctx, field) +func (ec *executionContext) _MailingAddress_postalCode(ctx context.Context, field graphql.CollectedField, obj *model.MailingAddress) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MailingAddress_postalCode(ctx, field) if err != nil { return graphql.Null } @@ -1962,7 +2193,7 @@ func (ec *executionContext) _Pronouns_subjective(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Subjective, nil + return obj.PostalCode, nil }) if err != nil { ec.Error(ctx, err) @@ -1979,9 +2210,9 @@ func (ec *executionContext) _Pronouns_subjective(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Pronouns_subjective(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MailingAddress_postalCode(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Pronouns", + Object: "MailingAddress", Field: field, IsMethod: false, IsResolver: false, @@ -1992,8 +2223,8 @@ func (ec *executionContext) fieldContext_Pronouns_subjective(ctx context.Context return fc, nil } -func (ec *executionContext) _Pronouns_objective(ctx context.Context, field graphql.CollectedField, obj *model.Pronouns) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Pronouns_objective(ctx, field) +func (ec *executionContext) _MailingAddress_addressLines(ctx context.Context, field graphql.CollectedField, obj *model.MailingAddress) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MailingAddress_addressLines(ctx, field) if err != nil { return graphql.Null } @@ -2006,7 +2237,7 @@ func (ec *executionContext) _Pronouns_objective(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Objective, nil + return obj.AddressLines, nil }) if err != nil { ec.Error(ctx, err) @@ -2018,14 +2249,14 @@ func (ec *executionContext) _Pronouns_objective(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Pronouns_objective(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MailingAddress_addressLines(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Pronouns", + Object: "MailingAddress", Field: field, IsMethod: false, IsResolver: false, @@ -2036,8 +2267,8 @@ func (ec *executionContext) fieldContext_Pronouns_objective(ctx context.Context, return fc, nil } -func (ec *executionContext) _Query_getAuthRedirectLink(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getAuthRedirectLink(ctx, field) +func (ec *executionContext) _Mutation_register(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_register(ctx, field) if err != nil { return graphql.Null } @@ -2050,7 +2281,7 @@ func (ec *executionContext) _Query_getAuthRedirectLink(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetAuthRedirectLink(rctx, fc.Args["provider"].(models.Provider), fc.Args["redirect"].(*string)) + return ec.resolvers.Mutation().Register(rctx, fc.Args["provider"].(models.Provider), fc.Args["encryptedOAuthAccessToken"].(string), fc.Args["input"].(model.NewUser)) }) if err != nil { ec.Error(ctx, err) @@ -2062,19 +2293,27 @@ func (ec *executionContext) _Query_getAuthRedirectLink(ctx context.Context, fiel } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.RegistrationPayload) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNRegistrationPayload2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRegistrationPayload(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getAuthRedirectLink(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_register(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "user": + return ec.fieldContext_RegistrationPayload_user(ctx, field) + case "accessToken": + return ec.fieldContext_RegistrationPayload_accessToken(ctx, field) + case "refreshToken": + return ec.fieldContext_RegistrationPayload_refreshToken(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RegistrationPayload", field.Name) }, } defer func() { @@ -2084,15 +2323,15 @@ func (ec *executionContext) fieldContext_Query_getAuthRedirectLink(ctx context.C } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getAuthRedirectLink_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_register_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return } return fc, nil } -func (ec *executionContext) _Query_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_login(ctx, field) +func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateUser(ctx, field) if err != nil { return graphql.Null } @@ -2104,19 +2343,528 @@ func (ec *executionContext) _Query_login(ctx context.Context, field graphql.Coll } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Login(rctx, fc.Args["provider"].(models.Provider), fc.Args["code"].(string), fc.Args["state"].(string)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateUser(rctx, fc.Args["id"].(string), fc.Args["input"].(model.UpdatedUser)) } - return graphql.Null - } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.User); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/KnightHacks/knighthacks_users/graph/model.User`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "firstName": + return ec.fieldContext_User_firstName(ctx, field) + case "lastName": + return ec.fieldContext_User_lastName(ctx, field) + case "fullName": + return ec.fieldContext_User_fullName(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "pronouns": + return ec.fieldContext_User_pronouns(ctx, field) + case "age": + return ec.fieldContext_User_age(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + case "oAuth": + return ec.fieldContext_User_oAuth(ctx, field) + case "mailingAddress": + return ec.fieldContext_User_mailingAddress(ctx, field) + case "mlh": + return ec.fieldContext_User_mlh(ctx, field) + case "shirtSize": + return ec.fieldContext_User_shirtSize(ctx, field) + case "yearsOfExperience": + return ec.fieldContext_User_yearsOfExperience(ctx, field) + case "educationInfo": + return ec.fieldContext_User_educationInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteUser(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteUser(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_deleteUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _OAuth_provider(ctx context.Context, field graphql.CollectedField, obj *model.OAuth) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OAuth_provider(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Provider, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(models.Provider) + fc.Result = res + return ec.marshalNProvider2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐProvider(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_OAuth_provider(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OAuth", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Provider does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _OAuth_uid(ctx context.Context, field graphql.CollectedField, obj *model.OAuth) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OAuth_uid(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.UID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_OAuth_uid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OAuth", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.StartCursor, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PageInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EndCursor, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PageInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Pronouns_subjective(ctx context.Context, field graphql.CollectedField, obj *model.Pronouns) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Pronouns_subjective(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Subjective, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Pronouns_subjective(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Pronouns", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Pronouns_objective(ctx context.Context, field graphql.CollectedField, obj *model.Pronouns) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Pronouns_objective(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Objective, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Pronouns_objective(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Pronouns", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_getAuthRedirectLink(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getAuthRedirectLink(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetAuthRedirectLink(rctx, fc.Args["provider"].(models.Provider), fc.Args["redirect"].(*string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getAuthRedirectLink(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getAuthRedirectLink_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Query_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_login(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Login(rctx, fc.Args["provider"].(models.Provider), fc.Args["code"].(string), fc.Args["state"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } res := resTmp.(*model.LoginPayload) fc.Result = res return ec.marshalNLoginPayload2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐLoginPayload(ctx, field.Selections, res) @@ -2414,6 +3162,16 @@ func (ec *executionContext) fieldContext_Query_getUser(ctx context.Context, fiel return ec.fieldContext_User_role(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) + case "mailingAddress": + return ec.fieldContext_User_mailingAddress(ctx, field) + case "mlh": + return ec.fieldContext_User_mlh(ctx, field) + case "shirtSize": + return ec.fieldContext_User_shirtSize(ctx, field) + case "yearsOfExperience": + return ec.fieldContext_User_yearsOfExperience(ctx, field) + case "educationInfo": + return ec.fieldContext_User_educationInfo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -2450,7 +3208,7 @@ func (ec *executionContext) _Query_searchUser(ctx context.Context, field graphql return ec.resolvers.Query().SearchUser(rctx, fc.Args["name"].(string)) } directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "ADMIN") if err != nil { return nil, err } @@ -2515,6 +3273,16 @@ func (ec *executionContext) fieldContext_Query_searchUser(ctx context.Context, f return ec.fieldContext_User_role(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) + case "mailingAddress": + return ec.fieldContext_User_mailingAddress(ctx, field) + case "mlh": + return ec.fieldContext_User_mlh(ctx, field) + case "shirtSize": + return ec.fieldContext_User_shirtSize(ctx, field) + case "yearsOfExperience": + return ec.fieldContext_User_yearsOfExperience(ctx, field) + case "educationInfo": + return ec.fieldContext_User_educationInfo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -2613,6 +3381,16 @@ func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field gra return ec.fieldContext_User_role(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) + case "mailingAddress": + return ec.fieldContext_User_mailingAddress(ctx, field) + case "mlh": + return ec.fieldContext_User_mlh(ctx, field) + case "shirtSize": + return ec.fieldContext_User_shirtSize(ctx, field) + case "yearsOfExperience": + return ec.fieldContext_User_yearsOfExperience(ctx, field) + case "educationInfo": + return ec.fieldContext_User_educationInfo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -2797,8 +3575,271 @@ func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _RegistrationPayload_user(ctx context.Context, field graphql.CollectedField, obj *model.RegistrationPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RegistrationPayload_user(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.User, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_RegistrationPayload_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RegistrationPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "firstName": + return ec.fieldContext_User_firstName(ctx, field) + case "lastName": + return ec.fieldContext_User_lastName(ctx, field) + case "fullName": + return ec.fieldContext_User_fullName(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "pronouns": + return ec.fieldContext_User_pronouns(ctx, field) + case "age": + return ec.fieldContext_User_age(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + case "oAuth": + return ec.fieldContext_User_oAuth(ctx, field) + case "mailingAddress": + return ec.fieldContext_User_mailingAddress(ctx, field) + case "mlh": + return ec.fieldContext_User_mlh(ctx, field) + case "shirtSize": + return ec.fieldContext_User_shirtSize(ctx, field) + case "yearsOfExperience": + return ec.fieldContext_User_yearsOfExperience(ctx, field) + case "educationInfo": + return ec.fieldContext_User_educationInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _RegistrationPayload_accessToken(ctx context.Context, field graphql.CollectedField, obj *model.RegistrationPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RegistrationPayload_accessToken(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AccessToken, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_RegistrationPayload_accessToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RegistrationPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _RegistrationPayload_refreshToken(ctx context.Context, field graphql.CollectedField, obj *model.RegistrationPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RegistrationPayload_refreshToken(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.RefreshToken, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_RegistrationPayload_refreshToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RegistrationPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_firstName(ctx, field) if err != nil { return graphql.Null } @@ -2811,49 +3852,38 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.FirstName, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_firstName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "User", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _RegistrationPayload_user(ctx context.Context, field graphql.CollectedField, obj *model.RegistrationPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_RegistrationPayload_user(ctx, field) +func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_lastName(ctx, field) if err != nil { return graphql.Null } @@ -2866,7 +3896,7 @@ func (ec *executionContext) _RegistrationPayload_user(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.User, nil + return obj.LastName, nil }) if err != nil { ec.Error(ctx, err) @@ -2878,48 +3908,26 @@ func (ec *executionContext) _RegistrationPayload_user(ctx context.Context, field } return graphql.Null } - res := resTmp.(*model.User) + res := resTmp.(string) fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_RegistrationPayload_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_lastName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RegistrationPayload", + Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "firstName": - return ec.fieldContext_User_firstName(ctx, field) - case "lastName": - return ec.fieldContext_User_lastName(ctx, field) - case "fullName": - return ec.fieldContext_User_fullName(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "phoneNumber": - return ec.fieldContext_User_phoneNumber(ctx, field) - case "pronouns": - return ec.fieldContext_User_pronouns(ctx, field) - case "age": - return ec.fieldContext_User_age(ctx, field) - case "role": - return ec.fieldContext_User_role(ctx, field) - case "oAuth": - return ec.fieldContext_User_oAuth(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _RegistrationPayload_accessToken(ctx context.Context, field graphql.CollectedField, obj *model.RegistrationPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_RegistrationPayload_accessToken(ctx, field) +func (ec *executionContext) _User_fullName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_fullName(ctx, field) if err != nil { return graphql.Null } @@ -2932,7 +3940,7 @@ func (ec *executionContext) _RegistrationPayload_accessToken(ctx context.Context }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.AccessToken, nil + return ec.resolvers.User().FullName(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -2949,12 +3957,12 @@ func (ec *executionContext) _RegistrationPayload_accessToken(ctx context.Context return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_RegistrationPayload_accessToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_fullName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RegistrationPayload", + Object: "User", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, @@ -2962,8 +3970,8 @@ func (ec *executionContext) fieldContext_RegistrationPayload_accessToken(ctx con return fc, nil } -func (ec *executionContext) _RegistrationPayload_refreshToken(ctx context.Context, field graphql.CollectedField, obj *model.RegistrationPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_RegistrationPayload_refreshToken(ctx, field) +func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_email(ctx, field) if err != nil { return graphql.Null } @@ -2975,8 +3983,32 @@ func (ec *executionContext) _RegistrationPayload_refreshToken(ctx context.Contex } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.RefreshToken, nil + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Email, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, obj, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -2993,9 +4025,9 @@ func (ec *executionContext) _RegistrationPayload_refreshToken(ctx context.Contex return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_RegistrationPayload_refreshToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_email(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RegistrationPayload", + Object: "User", Field: field, IsMethod: false, IsResolver: false, @@ -3006,8 +4038,8 @@ func (ec *executionContext) fieldContext_RegistrationPayload_refreshToken(ctx co return fc, nil } -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_id(ctx, field) +func (ec *executionContext) _User_phoneNumber(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_phoneNumber(ctx, field) if err != nil { return graphql.Null } @@ -3019,8 +4051,32 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PhoneNumber, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, obj, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -3034,24 +4090,24 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte } res := resTmp.(string) fc.Result = res - return ec.marshalNID2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_phoneNumber(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_firstName(ctx, field) +func (ec *executionContext) _User_pronouns(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_pronouns(ctx, field) if err != nil { return graphql.Null } @@ -3064,38 +4120,41 @@ func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.FirstName, nil + return obj.Pronouns, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.Pronouns) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOPronouns2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐPronouns(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_firstName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_pronouns(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "subjective": + return ec.fieldContext_Pronouns_subjective(ctx, field) + case "objective": + return ec.fieldContext_Pronouns_objective(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Pronouns", field.Name) }, } return fc, nil } -func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_lastName(ctx, field) +func (ec *executionContext) _User_age(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_age(ctx, field) if err != nil { return graphql.Null } @@ -3107,52 +4166,97 @@ func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.Co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.LastName, nil + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Age, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, obj, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*int); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*int) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_lastName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_age(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_fullName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_fullName(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null +func (ec *executionContext) _User_role(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_role(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Role, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, obj, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().FullName(rctx, obj) + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(models.Role); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/KnightHacks/knighthacks_shared/models.Role`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -3164,26 +4268,26 @@ func (ec *executionContext) _User_fullName(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(string) + res := resTmp.(models.Role) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_fullName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_role(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Role does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_email(ctx, field) +func (ec *executionContext) _User_oAuth(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_oAuth(ctx, field) if err != nil { return graphql.Null } @@ -3197,7 +4301,7 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Email, nil + return ec.resolvers.User().OAuth(rctx, obj) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") @@ -3217,10 +4321,10 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle if tmp == nil { return nil, nil } - if data, ok := tmp.(string); ok { + if data, ok := tmp.(*model.OAuth); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/KnightHacks/knighthacks_users/graph/model.OAuth`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -3232,26 +4336,32 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.OAuth) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNOAuth2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐOAuth(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_email(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_oAuth(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "provider": + return ec.fieldContext_OAuth_provider(ctx, field) + case "uid": + return ec.fieldContext_OAuth_uid(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OAuth", field.Name) }, } return fc, nil } -func (ec *executionContext) _User_phoneNumber(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_phoneNumber(ctx, field) +func (ec *executionContext) _User_mailingAddress(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_mailingAddress(ctx, field) if err != nil { return graphql.Null } @@ -3265,7 +4375,7 @@ func (ec *executionContext) _User_phoneNumber(ctx context.Context, field graphql resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PhoneNumber, nil + return ec.resolvers.User().MailingAddress(rctx, obj) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") @@ -3285,41 +4395,50 @@ func (ec *executionContext) _User_phoneNumber(ctx context.Context, field graphql if tmp == nil { return nil, nil } - if data, ok := tmp.(string); ok { + if data, ok := tmp.(*model.MailingAddress); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/KnightHacks/knighthacks_users/graph/model.MailingAddress`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.MailingAddress) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOMailingAddress2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMailingAddress(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_phoneNumber(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_mailingAddress(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "country": + return ec.fieldContext_MailingAddress_country(ctx, field) + case "state": + return ec.fieldContext_MailingAddress_state(ctx, field) + case "city": + return ec.fieldContext_MailingAddress_city(ctx, field) + case "postalCode": + return ec.fieldContext_MailingAddress_postalCode(ctx, field) + case "addressLines": + return ec.fieldContext_MailingAddress_addressLines(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MailingAddress", field.Name) }, } return fc, nil } -func (ec *executionContext) _User_pronouns(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_pronouns(ctx, field) +func (ec *executionContext) _User_mlh(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_mlh(ctx, field) if err != nil { return graphql.Null } @@ -3331,42 +4450,71 @@ func (ec *executionContext) _User_pronouns(ctx context.Context, field graphql.Co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Pronouns, nil + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Mlh(rctx, obj) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, obj, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.MLHTerms); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/KnightHacks/knighthacks_users/graph/model.MLHTerms`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*model.Pronouns) + res := resTmp.(*model.MLHTerms) fc.Result = res - return ec.marshalOPronouns2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐPronouns(ctx, field.Selections, res) + return ec.marshalNMLHTerms2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTerms(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_pronouns(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_mlh(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "subjective": - return ec.fieldContext_Pronouns_subjective(ctx, field) - case "objective": - return ec.fieldContext_Pronouns_objective(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Pronouns", field.Name) + case "sendMessages": + return ec.fieldContext_MLHTerms_sendMessages(ctx, field) + case "codeOfConduct": + return ec.fieldContext_MLHTerms_codeOfConduct(ctx, field) + case "shareInfo": + return ec.fieldContext_MLHTerms_shareInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MLHTerms", field.Name) }, } return fc, nil } -func (ec *executionContext) _User_age(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_age(ctx, field) +func (ec *executionContext) _User_shirtSize(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_shirtSize(ctx, field) if err != nil { return graphql.Null } @@ -3380,7 +4528,7 @@ func (ec *executionContext) _User_age(ctx context.Context, field graphql.Collect resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Age, nil + return ec.resolvers.User().ShirtSize(rctx, obj) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") @@ -3400,38 +4548,41 @@ func (ec *executionContext) _User_age(ctx context.Context, field graphql.Collect if tmp == nil { return nil, nil } - if data, ok := tmp.(*int); ok { + if data, ok := tmp.(model.ShirtSize); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/KnightHacks/knighthacks_users/graph/model.ShirtSize`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*int) + res := resTmp.(model.ShirtSize) fc.Result = res - return ec.marshalOInt2ᚖint(ctx, field.Selections, res) + return ec.marshalNShirtSize2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐShirtSize(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_age(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_shirtSize(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type ShirtSize does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_role(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_role(ctx, field) +func (ec *executionContext) _User_yearsOfExperience(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_yearsOfExperience(ctx, field) if err != nil { return graphql.Null } @@ -3445,7 +4596,7 @@ func (ec *executionContext) _User_role(ctx context.Context, field graphql.Collec resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Role, nil + return ec.resolvers.User().YearsOfExperience(rctx, obj) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") @@ -3465,41 +4616,38 @@ func (ec *executionContext) _User_role(ctx context.Context, field graphql.Collec if tmp == nil { return nil, nil } - if data, ok := tmp.(models.Role); ok { + if data, ok := tmp.(*float64); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/KnightHacks/knighthacks_shared/models.Role`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *float64`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(models.Role) + res := resTmp.(*float64) fc.Result = res - return ec.marshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, field.Selections, res) + return ec.marshalOFloat2ᚖfloat64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_role(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_yearsOfExperience(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Role does not have child fields") + return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_oAuth(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_oAuth(ctx, field) +func (ec *executionContext) _User_educationInfo(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_educationInfo(ctx, field) if err != nil { return graphql.Null } @@ -3513,7 +4661,7 @@ func (ec *executionContext) _User_oAuth(ctx context.Context, field graphql.Colle resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().OAuth(rctx, obj) + return ec.resolvers.User().EducationInfo(rctx, obj) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") @@ -3533,10 +4681,10 @@ func (ec *executionContext) _User_oAuth(ctx context.Context, field graphql.Colle if tmp == nil { return nil, nil } - if data, ok := tmp.(*model.OAuth); ok { + if data, ok := tmp.(*model.EducationInfo); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/KnightHacks/knighthacks_users/graph/model.OAuth`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/KnightHacks/knighthacks_users/graph/model.EducationInfo`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -3548,12 +4696,12 @@ func (ec *executionContext) _User_oAuth(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(*model.OAuth) + res := resTmp.(*model.EducationInfo) fc.Result = res - return ec.marshalNOAuth2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐOAuth(ctx, field.Selections, res) + return ec.marshalNEducationInfo2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_oAuth(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_educationInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, @@ -3561,12 +4709,16 @@ func (ec *executionContext) fieldContext_User_oAuth(ctx context.Context, field g IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "provider": - return ec.fieldContext_OAuth_provider(ctx, field) - case "uid": - return ec.fieldContext_OAuth_uid(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type OAuth", field.Name) + case "name": + return ec.fieldContext_EducationInfo_name(ctx, field) + case "graduationDate": + return ec.fieldContext_EducationInfo_graduationDate(ctx, field) + case "major": + return ec.fieldContext_EducationInfo_major(ctx, field) + case "level": + return ec.fieldContext_EducationInfo_level(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EducationInfo", field.Name) }, } return fc, nil @@ -3725,6 +4877,16 @@ func (ec *executionContext) fieldContext_UsersConnection_users(ctx context.Conte return ec.fieldContext_User_role(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) + case "mailingAddress": + return ec.fieldContext_User_mailingAddress(ctx, field) + case "mlh": + return ec.fieldContext_User_mlh(ctx, field) + case "shirtSize": + return ec.fieldContext_User_shirtSize(ctx, field) + case "yearsOfExperience": + return ec.fieldContext_User_yearsOfExperience(ctx, field) + case "educationInfo": + return ec.fieldContext_User_educationInfo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -5853,7 +7015,7 @@ func (ec *executionContext) unmarshalInputUpdatedUser(ctx context.Context, obj i asMap[k] = v } - fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age"} + fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age", "mailingAddress", "mlh", "shirtSize", "yearsOfExperience", "educationInfo"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -5908,6 +7070,46 @@ func (ec *executionContext) unmarshalInputUpdatedUser(ctx context.Context, obj i if err != nil { return it, err } + case "mailingAddress": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mailingAddress")) + it.MailingAddress, err = ec.unmarshalOMailingAddressInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMailingAddressInput(ctx, v) + if err != nil { + return it, err + } + case "mlh": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mlh")) + it.Mlh, err = ec.unmarshalOMLHTermsInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTermsInput(ctx, v) + if err != nil { + return it, err + } + case "shirtSize": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("shirtSize")) + it.ShirtSize, err = ec.unmarshalOShirtSize2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐShirtSize(ctx, v) + if err != nil { + return it, err + } + case "yearsOfExperience": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("yearsOfExperience")) + it.YearsOfExperience, err = ec.unmarshalOFloat2ᚖfloat64(ctx, v) + if err != nil { + return it, err + } + case "educationInfo": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("educationInfo")) + it.EducationInfo, err = ec.unmarshalOEducationInfoInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfoInput(ctx, v) + if err != nil { + return it, err + } } } @@ -5928,32 +7130,78 @@ func (ec *executionContext) _Connection(ctx context.Context, sel ast.SelectionSe if obj == nil { return graphql.Null } - return ec._UsersConnection(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) + return ec._UsersConnection(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case model.User: + return ec._User(ctx, sel, &obj) + case *model.User: + if obj == nil { + return graphql.Null + } + return ec._User(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var educationInfoImplementors = []string{"EducationInfo"} + +func (ec *executionContext) _EducationInfo(ctx context.Context, sel ast.SelectionSet, obj *model.EducationInfo) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, educationInfoImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EducationInfo") + case "name": + + out.Values[i] = ec._EducationInfo_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "graduationDate": + + out.Values[i] = ec._EducationInfo_graduationDate(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "major": + + out.Values[i] = ec._EducationInfo_major(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "level": + + out.Values[i] = ec._EducationInfo_level(ctx, field, obj) + + default: + panic("unknown field " + strconv.Quote(field.Name)) + } } -} - -func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler { - switch obj := (obj).(type) { - case nil: + out.Dispatch() + if invalids > 0 { return graphql.Null - case model.User: - return ec._User(ctx, sel, &obj) - case *model.User: - if obj == nil { - return graphql.Null - } - return ec._User(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) } + return out } -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - var entityImplementors = []string{"Entity"} func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { @@ -6074,6 +7322,104 @@ func (ec *executionContext) _LoginPayload(ctx context.Context, sel ast.Selection return out } +var mLHTermsImplementors = []string{"MLHTerms"} + +func (ec *executionContext) _MLHTerms(ctx context.Context, sel ast.SelectionSet, obj *model.MLHTerms) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, mLHTermsImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MLHTerms") + case "sendMessages": + + out.Values[i] = ec._MLHTerms_sendMessages(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "codeOfConduct": + + out.Values[i] = ec._MLHTerms_codeOfConduct(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "shareInfo": + + out.Values[i] = ec._MLHTerms_shareInfo(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var mailingAddressImplementors = []string{"MailingAddress"} + +func (ec *executionContext) _MailingAddress(ctx context.Context, sel ast.SelectionSet, obj *model.MailingAddress) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, mailingAddressImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MailingAddress") + case "country": + + out.Values[i] = ec._MailingAddress_country(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "state": + + out.Values[i] = ec._MailingAddress_state(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "city": + + out.Values[i] = ec._MailingAddress_city(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "postalCode": + + out.Values[i] = ec._MailingAddress_postalCode(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "addressLines": + + out.Values[i] = ec._MailingAddress_addressLines(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { @@ -6617,6 +7963,100 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) + + }) + case "mailingAddress": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_mailingAddress(ctx, field, obj) + return res + } + + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) + + }) + case "mlh": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_mlh(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + } + + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) + + }) + case "shirtSize": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_shirtSize(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + } + + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) + + }) + case "yearsOfExperience": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_yearsOfExperience(ctx, field, obj) + return res + } + + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) + + }) + case "educationInfo": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_educationInfo(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + } + out.Concurrently(i, func() graphql.Marshaler { return innerFunc(ctx) @@ -7032,6 +8472,20 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return res } +func (ec *executionContext) marshalNEducationInfo2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfo(ctx context.Context, sel ast.SelectionSet, v model.EducationInfo) graphql.Marshaler { + return ec._EducationInfo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNEducationInfo2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfo(ctx context.Context, sel ast.SelectionSet, v *model.EducationInfo) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._EducationInfo(ctx, sel, v) +} + func (ec *executionContext) unmarshalNEducationInfoInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfoInput(ctx context.Context, v interface{}) (*model.EducationInfoInput, error) { res, err := ec.unmarshalInputEducationInfoInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -7081,6 +8535,20 @@ func (ec *executionContext) marshalNLoginPayload2ᚖgithubᚗcomᚋKnightHacks return ec._LoginPayload(ctx, sel, v) } +func (ec *executionContext) marshalNMLHTerms2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTerms(ctx context.Context, sel ast.SelectionSet, v model.MLHTerms) graphql.Marshaler { + return ec._MLHTerms(ctx, sel, &v) +} + +func (ec *executionContext) marshalNMLHTerms2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTerms(ctx context.Context, sel ast.SelectionSet, v *model.MLHTerms) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._MLHTerms(ctx, sel, v) +} + func (ec *executionContext) unmarshalNMLHTermsInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTermsInput(ctx context.Context, v interface{}) (*model.MLHTermsInput, error) { res, err := ec.unmarshalInputMLHTermsInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -7672,6 +9140,14 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } +func (ec *executionContext) unmarshalOEducationInfoInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfoInput(ctx context.Context, v interface{}) (*model.EducationInfoInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputEducationInfoInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOFloat2ᚖfloat64(ctx context.Context, v interface{}) (*float64, error) { if v == nil { return nil, nil @@ -7720,6 +9196,21 @@ func (ec *executionContext) marshalOLevelOfStudy2ᚖgithubᚗcomᚋKnightHacks return v } +func (ec *executionContext) unmarshalOMLHTermsInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTermsInput(ctx context.Context, v interface{}) (*model.MLHTermsInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMLHTermsInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOMailingAddress2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMailingAddress(ctx context.Context, sel ast.SelectionSet, v *model.MailingAddress) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MailingAddress(ctx, sel, v) +} + func (ec *executionContext) unmarshalOMailingAddressInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMailingAddressInput(ctx context.Context, v interface{}) (*model.MailingAddressInput, error) { if v == nil { return nil, nil @@ -7743,6 +9234,22 @@ func (ec *executionContext) unmarshalOPronounsInput2ᚖgithubᚗcomᚋKnightHack return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalOShirtSize2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐShirtSize(ctx context.Context, v interface{}) (*model.ShirtSize, error) { + if v == nil { + return nil, nil + } + var res = new(model.ShirtSize) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOShirtSize2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐShirtSize(ctx context.Context, sel ast.SelectionSet, v *model.ShirtSize) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) diff --git a/graph/model/models_gen.go b/graph/model/models_gen.go index 66c5de5..4678b0c 100644 --- a/graph/model/models_gen.go +++ b/graph/model/models_gen.go @@ -14,6 +14,13 @@ type Connection interface { IsConnection() } +type EducationInfo struct { + Name string `json:"name"` + GraduationDate string `json:"graduationDate"` + Major string `json:"major"` + Level *LevelOfStudy `json:"level"` +} + type EducationInfoInput struct { Name string `json:"name"` GraduationDate string `json:"graduationDate"` @@ -30,12 +37,26 @@ type LoginPayload struct { EncryptedOAuthAccessToken *string `json:"encryptedOAuthAccessToken"` } +type MLHTerms struct { + SendMessages bool `json:"sendMessages"` + CodeOfConduct bool `json:"codeOfConduct"` + ShareInfo bool `json:"shareInfo"` +} + type MLHTermsInput struct { SendMessages bool `json:"sendMessages"` CodeOfConduct bool `json:"codeOfConduct"` ShareInfo bool `json:"shareInfo"` } +type MailingAddress struct { + Country string `json:"country"` + State string `json:"state"` + City string `json:"city"` + PostalCode string `json:"postalCode"` + AddressLines []string `json:"addressLines"` +} + type MailingAddressInput struct { Country string `json:"country"` State string `json:"state"` @@ -83,25 +104,35 @@ type RegistrationPayload struct { } type UpdatedUser struct { - FirstName *string `json:"firstName"` - LastName *string `json:"lastName"` - Email *string `json:"email"` - PhoneNumber *string `json:"phoneNumber"` - Pronouns *PronounsInput `json:"pronouns"` - Age *int `json:"age"` + FirstName *string `json:"firstName"` + LastName *string `json:"lastName"` + Email *string `json:"email"` + PhoneNumber *string `json:"phoneNumber"` + Pronouns *PronounsInput `json:"pronouns"` + Age *int `json:"age"` + MailingAddress *MailingAddressInput `json:"mailingAddress"` + Mlh *MLHTermsInput `json:"mlh"` + ShirtSize *ShirtSize `json:"shirtSize"` + YearsOfExperience *float64 `json:"yearsOfExperience"` + EducationInfo *EducationInfoInput `json:"educationInfo"` } type User struct { - ID string `json:"id"` - FirstName string `json:"firstName"` - LastName string `json:"lastName"` - FullName string `json:"fullName"` - Email string `json:"email"` - PhoneNumber string `json:"phoneNumber"` - Pronouns *Pronouns `json:"pronouns"` - Age *int `json:"age"` - Role models.Role `json:"role"` - OAuth *OAuth `json:"oAuth"` + ID string `json:"id"` + FirstName string `json:"firstName"` + LastName string `json:"lastName"` + FullName string `json:"fullName"` + Email string `json:"email"` + PhoneNumber string `json:"phoneNumber"` + Pronouns *Pronouns `json:"pronouns"` + Age *int `json:"age"` + Role models.Role `json:"role"` + OAuth *OAuth `json:"oAuth"` + MailingAddress *MailingAddress `json:"mailingAddress"` + Mlh *MLHTerms `json:"mlh"` + ShirtSize ShirtSize `json:"shirtSize"` + YearsOfExperience *float64 `json:"yearsOfExperience"` + EducationInfo *EducationInfo `json:"educationInfo"` } func (User) IsEntity() {} diff --git a/graph/schema.graphqls b/graph/schema.graphqls index 1d5cb87..acbece7 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -46,6 +46,12 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { role: Role! @hasRole(role: OWNS) oAuth: OAuth! @goField(forceResolver: true) @hasRole(role: OWNS) + + mailingAddress: MailingAddress @goField(forceResolver: true) @hasRole(role: OWNS) + mlh: MLHTerms! @goField(forceResolver: true) @hasRole(role: OWNS) + shirtSize: ShirtSize! @goField(forceResolver: true) @hasRole(role: OWNS) + yearsOfExperience: Float @goField(forceResolver: true) @hasRole(role: OWNS) + educationInfo: EducationInfo! @goField(forceResolver: true) @hasRole(role: OWNS) } """ @@ -83,12 +89,26 @@ input PronounsInput { objective: String! } +type MLHTerms { + sendMessages: Boolean! + codeOfConduct: Boolean! + shareInfo: Boolean! +} + input MLHTermsInput { sendMessages: Boolean! codeOfConduct: Boolean! shareInfo: Boolean! } +type MailingAddress { + country: String! + state: String! + city: String! + postalCode: String! + addressLines: [String!]! +} + input MailingAddressInput { country: String! state: String! @@ -97,6 +117,13 @@ input MailingAddressInput { addressLines: [String!]! } +type EducationInfo { + name: String! + graduationDate: String! + major: String! + level: LevelOfStudy +} + input EducationInfoInput { name: String! graduationDate: String! @@ -133,6 +160,12 @@ input UpdatedUser { phoneNumber: String pronouns: PronounsInput age: Int + + mailingAddress: MailingAddressInput + mlh: MLHTermsInput + shirtSize: ShirtSize + yearsOfExperience: Float + educationInfo: EducationInfoInput } type LoginPayload { @@ -163,7 +196,7 @@ type Query { refreshJWT(refreshToken: String!): String! @hasRole(role: NORMAL) users(first: Int!, after: String): UsersConnection! @pagination(maxLength: 20) @hasRole(role: ADMIN) getUser(id: ID!): User @hasRole(role: NORMAL) - searchUser(name: String!): [User!]! @hasRole(role: NORMAL) + searchUser(name: String!): [User!]! @hasRole(role: ADMIN) me: User @hasRole(role: NORMAL) } diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index 0be2cca..3a56edb 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -238,6 +238,31 @@ func (r *userResolver) OAuth(ctx context.Context, obj *model.User) (*model.OAuth return r.Repository.GetOAuth(ctx, obj.ID) } +// MailingAddress is the resolver for the mailingAddress field. +func (r *userResolver) MailingAddress(ctx context.Context, obj *model.User) (*model.MailingAddress, error) { + panic(fmt.Errorf("not implemented")) +} + +// Mlh is the resolver for the mlh field. +func (r *userResolver) Mlh(ctx context.Context, obj *model.User) (*model.MLHTerms, error) { + panic(fmt.Errorf("not implemented")) +} + +// ShirtSize is the resolver for the shirtSize field. +func (r *userResolver) ShirtSize(ctx context.Context, obj *model.User) (model.ShirtSize, error) { + panic(fmt.Errorf("not implemented")) +} + +// YearsOfExperience is the resolver for the yearsOfExperience field. +func (r *userResolver) YearsOfExperience(ctx context.Context, obj *model.User) (*float64, error) { + panic(fmt.Errorf("not implemented")) +} + +// EducationInfo is the resolver for the educationInfo field. +func (r *userResolver) EducationInfo(ctx context.Context, obj *model.User) (*model.EducationInfo, error) { + panic(fmt.Errorf("not implemented")) +} + // Mutation returns generated.MutationResolver implementation. func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } From 881d7c3514ff055f661f722368bb0facc9a477a6 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Thu, 3 Nov 2022 10:47:20 -0400 Subject: [PATCH 03/29] added documentation for encryptedOAuthAccessToken --- graph/schema.graphqls | 3 +++ 1 file changed, 3 insertions(+) diff --git a/graph/schema.graphqls b/graph/schema.graphqls index 4a7638f..63884c6 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -110,6 +110,9 @@ type LoginPayload { accessToken: String refreshToken: String + """ + Not null when accountExists is false, use this in registration + """ encryptedOAuthAccessToken: String } From d4ec7e27a3a85491ac22586dac9b7b85e365a61c Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Sun, 6 Nov 2022 15:24:09 -0500 Subject: [PATCH 04/29] removed force resolver for a few fields on User --- graph/generated/generated.go | 88 +++++++++--------------------------- graph/schema.graphqls | 6 +-- graph/schema.resolvers.go | 15 ------ 3 files changed, 24 insertions(+), 85 deletions(-) diff --git a/graph/generated/generated.go b/graph/generated/generated.go index c4e0dda..3cb25a0 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -176,9 +176,6 @@ type UserResolver interface { OAuth(ctx context.Context, obj *model.User) (*model.OAuth, error) MailingAddress(ctx context.Context, obj *model.User) (*model.MailingAddress, error) Mlh(ctx context.Context, obj *model.User) (*model.MLHTerms, error) - ShirtSize(ctx context.Context, obj *model.User) (model.ShirtSize, error) - YearsOfExperience(ctx context.Context, obj *model.User) (*float64, error) - EducationInfo(ctx context.Context, obj *model.User) (*model.EducationInfo, error) } type executableSchema struct { @@ -794,9 +791,9 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { mailingAddress: MailingAddress @goField(forceResolver: true) @hasRole(role: OWNS) mlh: MLHTerms! @goField(forceResolver: true) @hasRole(role: OWNS) - shirtSize: ShirtSize! @goField(forceResolver: true) @hasRole(role: OWNS) - yearsOfExperience: Float @goField(forceResolver: true) @hasRole(role: OWNS) - educationInfo: EducationInfo! @goField(forceResolver: true) @hasRole(role: OWNS) + shirtSize: ShirtSize! @hasRole(role: OWNS) + yearsOfExperience: Float @hasRole(role: OWNS) + educationInfo: EducationInfo! @hasRole(role: OWNS) } """ @@ -4528,7 +4525,7 @@ func (ec *executionContext) _User_shirtSize(ctx context.Context, field graphql.C resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().ShirtSize(rctx, obj) + return obj.ShirtSize, nil } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") @@ -4572,8 +4569,8 @@ func (ec *executionContext) fieldContext_User_shirtSize(ctx context.Context, fie fc = &graphql.FieldContext{ Object: "User", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ShirtSize does not have child fields") }, @@ -4596,7 +4593,7 @@ func (ec *executionContext) _User_yearsOfExperience(ctx context.Context, field g resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().YearsOfExperience(rctx, obj) + return obj.YearsOfExperience, nil } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") @@ -4637,8 +4634,8 @@ func (ec *executionContext) fieldContext_User_yearsOfExperience(ctx context.Cont fc = &graphql.FieldContext{ Object: "User", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, @@ -4661,7 +4658,7 @@ func (ec *executionContext) _User_educationInfo(ctx context.Context, field graph resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().EducationInfo(rctx, obj) + return obj.EducationInfo, nil } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") @@ -4705,8 +4702,8 @@ func (ec *executionContext) fieldContext_User_educationInfo(ctx context.Context, fc = &graphql.FieldContext{ Object: "User", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": @@ -8005,62 +8002,23 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj }) case "shirtSize": - field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._User_shirtSize(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) - - }) - case "yearsOfExperience": - field := field + out.Values[i] = ec._User_shirtSize(ctx, field, obj) - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._User_yearsOfExperience(ctx, field, obj) - return res + if out.Values[i] == graphql.Null { + atomic.AddUint32(&invalids, 1) } + case "yearsOfExperience": - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + out.Values[i] = ec._User_yearsOfExperience(ctx, field, obj) - }) case "educationInfo": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._User_educationInfo(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + out.Values[i] = ec._User_educationInfo(ctx, field, obj) - }) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&invalids, 1) + } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -8472,10 +8430,6 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return res } -func (ec *executionContext) marshalNEducationInfo2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfo(ctx context.Context, sel ast.SelectionSet, v model.EducationInfo) graphql.Marshaler { - return ec._EducationInfo(ctx, sel, &v) -} - func (ec *executionContext) marshalNEducationInfo2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfo(ctx context.Context, sel ast.SelectionSet, v *model.EducationInfo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { diff --git a/graph/schema.graphqls b/graph/schema.graphqls index acbece7..1897828 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -49,9 +49,9 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { mailingAddress: MailingAddress @goField(forceResolver: true) @hasRole(role: OWNS) mlh: MLHTerms! @goField(forceResolver: true) @hasRole(role: OWNS) - shirtSize: ShirtSize! @goField(forceResolver: true) @hasRole(role: OWNS) - yearsOfExperience: Float @goField(forceResolver: true) @hasRole(role: OWNS) - educationInfo: EducationInfo! @goField(forceResolver: true) @hasRole(role: OWNS) + shirtSize: ShirtSize! @hasRole(role: OWNS) + yearsOfExperience: Float @hasRole(role: OWNS) + educationInfo: EducationInfo! @hasRole(role: OWNS) } """ diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index 3a56edb..2e4e376 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -248,21 +248,6 @@ func (r *userResolver) Mlh(ctx context.Context, obj *model.User) (*model.MLHTerm panic(fmt.Errorf("not implemented")) } -// ShirtSize is the resolver for the shirtSize field. -func (r *userResolver) ShirtSize(ctx context.Context, obj *model.User) (model.ShirtSize, error) { - panic(fmt.Errorf("not implemented")) -} - -// YearsOfExperience is the resolver for the yearsOfExperience field. -func (r *userResolver) YearsOfExperience(ctx context.Context, obj *model.User) (*float64, error) { - panic(fmt.Errorf("not implemented")) -} - -// EducationInfo is the resolver for the educationInfo field. -func (r *userResolver) EducationInfo(ctx context.Context, obj *model.User) (*model.EducationInfo, error) { - panic(fmt.Errorf("not implemented")) -} - // Mutation returns generated.MutationResolver implementation. func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } From 6ecb3b3d23f8361a8d527747e8257d5cc401e07d Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 00:31:29 -0500 Subject: [PATCH 05/29] started splitting database_repository.go into multiple files --- graph/schema.resolvers.go | 2 +- main.go | 8 +++--- repository/consts.go | 8 ++++++ .../{ => database}/database_repository.go | 26 ++++++++----------- 4 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 repository/consts.go rename repository/{ => database}/database_repository.go (97%) diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index 2e4e376..08f27be 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -9,6 +9,7 @@ import ( "encoding/base64" "errors" "fmt" + "github.com/KnightHacks/knighthacks_users/repository" "net/http" "net/url" @@ -18,7 +19,6 @@ import ( "github.com/KnightHacks/knighthacks_shared/utils" "github.com/KnightHacks/knighthacks_users/graph/generated" "github.com/KnightHacks/knighthacks_users/graph/model" - "github.com/KnightHacks/knighthacks_users/repository" ) // Register is the resolver for the register field. diff --git a/main.go b/main.go index bbb33ce..d4dc47c 100644 --- a/main.go +++ b/main.go @@ -6,11 +6,11 @@ import ( "fmt" "github.com/99designs/gqlgen/graphql" "github.com/KnightHacks/knighthacks_shared/auth" - "github.com/KnightHacks/knighthacks_shared/database" + databaseUtils "github.com/KnightHacks/knighthacks_shared/database" "github.com/KnightHacks/knighthacks_shared/pagination" "github.com/KnightHacks/knighthacks_shared/utils" "github.com/KnightHacks/knighthacks_users/graph/model" - "github.com/KnightHacks/knighthacks_users/repository" + "github.com/KnightHacks/knighthacks_users/repository/database" "github.com/gin-gonic/gin" "github.com/jackc/pgx/v4/pgxpool" "github.com/vektah/gqlparser/v2/gqlerror" @@ -33,7 +33,7 @@ func main() { port = defaultPort } - pool, err := database.ConnectWithRetries(utils.GetEnvOrDie("DATABASE_URI")) + pool, err := databaseUtils.ConnectWithRetries(utils.GetEnvOrDie("DATABASE_URI")) if err != nil { log.Fatalf("Unable to connect to database: %v\n", err) } @@ -65,7 +65,7 @@ func graphqlHandler(a *auth.Auth, pool *pgxpool.Pool) gin.HandlerFunc { config := generated.Config{ Resolvers: &graph.Resolver{ - Repository: repository.NewDatabaseRepository(pool), + Repository: database.NewDatabaseRepository(pool), Auth: a, }, Directives: generated.DirectiveRoot{ diff --git a/repository/consts.go b/repository/consts.go new file mode 100644 index 0000000..af9a86a --- /dev/null +++ b/repository/consts.go @@ -0,0 +1,8 @@ +package repository + +import "errors" + +var ( + UserNotFound = errors.New("user not found") + UserAlreadyExists = errors.New("user with id already exists") +) diff --git a/repository/database_repository.go b/repository/database/database_repository.go similarity index 97% rename from repository/database_repository.go rename to repository/database/database_repository.go index 468ae11..5d3ba8f 100644 --- a/repository/database_repository.go +++ b/repository/database/database_repository.go @@ -1,20 +1,16 @@ -package repository +package database import ( "context" "errors" sharedModels "github.com/KnightHacks/knighthacks_shared/models" "github.com/KnightHacks/knighthacks_users/graph/model" + "github.com/KnightHacks/knighthacks_users/repository" "github.com/jackc/pgx/v4" "github.com/jackc/pgx/v4/pgxpool" "strconv" ) -var ( - UserNotFound = errors.New("user not found") - UserAlreadyExists = errors.New("user with id already exists") -) - // DatabaseRepository // Implements the Repository interface's functions // @@ -87,7 +83,7 @@ func (r *DatabaseRepository) getUserWithTx(ctx context.Context, query string, tx if err != nil { if errors.Is(err, pgx.ErrNoRows) { - return nil, UserNotFound + return nil, repository.UserNotFound } return nil, err } @@ -159,7 +155,7 @@ func (r *DatabaseRepository) CreateUser(ctx context.Context, oAuth *model.OAuth, var discoveredId = new(int) err := tx.QueryRow(ctx, "SELECT id FROM users WHERE oauth_uid=$1 AND oauth_provider=$2 LIMIT 1", oAuth.UID, oAuth.Provider.String()).Scan(discoveredId) if err == nil && discoveredId != nil { - return UserAlreadyExists + return repository.UserAlreadyExists } if err != nil && !errors.Is(err, pgx.ErrNoRows) { return err @@ -387,7 +383,7 @@ func (r *DatabaseRepository) DeleteUser(ctx context.Context, id string) (bool, e //there should be one row affected, if not throw error if commandTag.RowsAffected() != 1 { - return false, UserNotFound + return false, repository.UserNotFound } // then no error @@ -401,7 +397,7 @@ func (r *DatabaseRepository) UpdateFirstName(ctx context.Context, id string, fir return err } if commandTag.RowsAffected() != 1 { - return UserNotFound + return repository.UserNotFound } return nil } @@ -413,7 +409,7 @@ func (r *DatabaseRepository) UpdateLastName(ctx context.Context, id string, last return err } if commandTag.RowsAffected() != 1 { - return UserNotFound + return repository.UserNotFound } // then no error return nil @@ -426,7 +422,7 @@ func (r *DatabaseRepository) UpdateEmail(ctx context.Context, id string, email s return err } if commandTag.RowsAffected() != 1 { - return UserNotFound + return repository.UserNotFound } // then no error return nil @@ -439,7 +435,7 @@ func (r *DatabaseRepository) UpdatePhoneNumber(ctx context.Context, id string, n return err } if commandTag.RowsAffected() != 1 { - return UserNotFound + return repository.UserNotFound } // then no error return nil @@ -496,7 +492,7 @@ func (r *DatabaseRepository) UpdatePronouns(ctx context.Context, id string, pron return err } if commandTag.RowsAffected() != 1 { - return UserNotFound + return repository.UserNotFound } // then no error return nil @@ -509,7 +505,7 @@ func (r *DatabaseRepository) UpdateAge(ctx context.Context, id string, age *int, return err } if commandTag.RowsAffected() != 1 { - return UserNotFound + return repository.UserNotFound } // then no error return nil From 0f194a65190af2651a8d62ddde4647861888a01e Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 01:36:09 -0500 Subject: [PATCH 06/29] split database_repository into get_user, pronouns, and update_user --- repository/database/database_repository.go | 445 ++------------------- repository/database/get_user.go | 161 ++++++++ repository/database/pronouns.go | 93 +++++ repository/database/update_user.go | 205 ++++++++++ 4 files changed, 491 insertions(+), 413 deletions(-) create mode 100644 repository/database/get_user.go create mode 100644 repository/database/pronouns.go create mode 100644 repository/database/update_user.go diff --git a/repository/database/database_repository.go b/repository/database/database_repository.go index 5d3ba8f..9f3c4c2 100644 --- a/repository/database/database_repository.go +++ b/repository/database/database_repository.go @@ -3,6 +3,7 @@ package database import ( "context" "errors" + "github.com/KnightHacks/knighthacks_shared/database" sharedModels "github.com/KnightHacks/knighthacks_shared/models" "github.com/KnightHacks/knighthacks_users/graph/model" "github.com/KnightHacks/knighthacks_users/repository" @@ -30,108 +31,6 @@ func NewDatabaseRepository(databasePool *pgxpool.Pool) *DatabaseRepository { } } -// GetByPronouns gets the sql row id for the pronouns associated with the input -func (r *DatabaseRepository) GetByPronouns(pronouns model.Pronouns) (int, bool) { - id, exist := r.PronounReverseMap[pronouns] - return id, exist -} - -// GetById gets the pronouns by the sql row id -func (r *DatabaseRepository) GetById(id int) (model.Pronouns, bool) { - pronouns, exist := r.PronounMap[id] - return pronouns, exist -} - -// Set inputs the pronouns into the bidirectional map -func (r *DatabaseRepository) Set(id int, pronouns model.Pronouns) { - r.PronounMap[id] = pronouns - r.PronounReverseMap[pronouns] = id -} - -// GetUserByID returns the user by their id -func (r *DatabaseRepository) GetUserByID(ctx context.Context, id string) (*model.User, error) { - return r.getUser( - ctx, - `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE id = $1 LIMIT 1`, - id, - ) -} - -// GetUserByOAuthUID returns the user by their oauth auth token -func (r *DatabaseRepository) GetUserByOAuthUID(ctx context.Context, oAuthUID string, provider sharedModels.Provider) (*model.User, error) { - return r.getUser( - ctx, - `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE oauth_uid=cast($1 as varchar) AND oauth_provider=$2 LIMIT 1`, - oAuthUID, - provider, - ) -} - -func (r *DatabaseRepository) getUserWithTx(ctx context.Context, query string, tx pgx.Tx, args ...interface{}) (*model.User, error) { - var user model.User - - if tx == nil { - var err error - tx, err = r.DatabasePool.Begin(ctx) - if err != nil { - return nil, err - } - defer tx.Commit(ctx) - } - - pronounId, err := ScanUser(&user, tx.QueryRow(ctx, query, args...)) - - if err != nil { - if errors.Is(err, pgx.ErrNoRows) { - return nil, repository.UserNotFound - } - return nil, err - } - - // if the user has their pronouns set - if err = getPronouns(ctx, tx, pronounId, r, &user); err != nil { - return nil, err - } - return &user, nil -} - -func (r *DatabaseRepository) getUser(ctx context.Context, query string, args ...interface{}) (*model.User, error) { - return r.getUserWithTx(ctx, query, nil, args...) -} - -// GetOAuth returns the model.OAuth object that is associated with the user's id -// Used by the OAuth force resolver, this is not a common operation so making this -// a force resolver is a good idea -func (r *DatabaseRepository) GetOAuth(ctx context.Context, id string) (*model.OAuth, error) { - var oAuth model.OAuth - err := r.DatabasePool.QueryRow(ctx, "SELECT oauth_uid, oauth_provider FROM users WHERE id = $1", id).Scan(&oAuth.UID, &oAuth.Provider) - if err != nil { - return nil, err - } - return &oAuth, err -} - -func getPronouns(ctx context.Context, tx pgx.Tx, pronounId *int32, r *DatabaseRepository, user *model.User) error { - if pronounId != nil { - pronouns, exists := r.GetById(int(*pronounId)) - // does the pronoun not exist in the local cache? - if !exists { - // retrieve the pronoun from the database - err := tx.QueryRow(ctx, "SELECT subjective, objective FROM pronouns WHERE id = $1", pronounId).Scan( - &pronouns.Subjective, - &pronouns.Objective, - ) - if err != nil { - return err - } - // set the pronoun in the local cache - r.Set(int(*pronounId), pronouns) - } - user.Pronouns = &pronouns - } - return nil -} - // CreateUser Creates a user in the database and returns the new user struct // // The NewUser input struct contains all nillable fields so the following function @@ -139,10 +38,10 @@ func getPronouns(ctx context.Context, tx pgx.Tx, pronounId *int32, r *DatabaseRe // lot of pointers for nil safety purposes func (r *DatabaseRepository) CreateUser(ctx context.Context, oAuth *model.OAuth, input *model.NewUser) (*model.User, error) { var userId string - var pronounsPtr *model.Pronouns + var pronouns model.Pronouns if input.Pronouns != nil { // input.Pronouns is a PronounsInput struct which a direct copy of the Pronouns struct, so we need to copy its fields - pronounsPtr = &model.Pronouns{ + pronouns = model.Pronouns{ Subjective: input.Pronouns.Subjective, Objective: input.Pronouns.Objective, } @@ -150,7 +49,7 @@ func (r *DatabaseRepository) CreateUser(ctx context.Context, oAuth *model.OAuth, // Begins the database transaction err := r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { - // Detects whether or not the user with the oauth_uid, for github that is their github ID already exists, if + // Detects whether the user with the oauth_uid, for GitHub that is their github ID already exists, if // the use already exists we return an UserAlreadyExists error var discoveredId = new(int) err := tx.QueryRow(ctx, "SELECT id FROM users WHERE oauth_uid=$1 AND oauth_provider=$2 LIMIT 1", oAuth.UID, oAuth.Provider.String()).Scan(discoveredId) @@ -161,61 +60,13 @@ func (r *DatabaseRepository) CreateUser(ctx context.Context, oAuth *model.OAuth, return err } - var pronounIdPtr *int - - // is pronoun being set? - if pronounsPtr != nil { - pronouns := *pronounsPtr - pronounId, exists := r.GetByPronouns(pronouns) - // if the pronoun does not exist in the local cache - if !exists { - // check if the pronoun exists in the database - err = tx.QueryRow(ctx, "SELECT id FROM pronouns WHERE subjective=$1 AND objective=$2", - input.Pronouns.Subjective, - input.Pronouns.Objective, - ).Scan(&pronounId) - - pronounExist := true - if err != nil { - if errors.Is(err, pgx.ErrNoRows) { - // pronoun does not exist in the database - pronounExist = false - } else { - return err - } - } - if !pronounExist { - // since the new pronoun does not exist in the database, we insert it - err = tx.QueryRow(ctx, "INSERT INTO pronouns (subjective, objective) VALUES ($1, $2) RETURNING id", - input.Pronouns.Subjective, - input.Pronouns.Objective, - ).Scan(&pronounId) - } - - if err != nil { - return err - } - // set the pronoun cache - r.Set(pronounId, pronouns) - } - - pronounIdPtr = &pronounId + // Get pronouns + pronounIdPtr, err := r.GetOrCreatePronoun(ctx, tx, pronouns, input) + if err != nil { + return err } - // TODO: Possibly change ID type to int to stop this hacky fix? - // insert user into database and return their ID - var userIdInt int - err = tx.QueryRow(ctx, "INSERT INTO users (first_name, last_name, email, phone_number, age, pronoun_id, oauth_uid, oauth_provider, role) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id", - input.FirstName, - input.LastName, - input.Email, - input.PhoneNumber, - input.Age, - pronounIdPtr, - oAuth.UID, - oAuth.Provider.String(), - sharedModels.RoleNormal, - ).Scan(&userIdInt) + userIdInt, err := r.InsertUser(ctx, tx, input, pronounIdPtr, oAuth) if err != nil { return err } @@ -232,143 +83,28 @@ func (r *DatabaseRepository) CreateUser(ctx context.Context, oAuth *model.OAuth, LastName: input.LastName, Email: input.Email, PhoneNumber: input.PhoneNumber, - Pronouns: pronounsPtr, + Pronouns: &pronouns, Age: input.Age, OAuth: oAuth, }, nil } -// update user add multiple parts go off of create user -// we will check whether the values in input are nil or empty strings, if not, we execute the update statement -func (r *DatabaseRepository) UpdateUser(ctx context.Context, id string, input *model.UpdatedUser) (*model.User, error) { - var user *model.User - var err error - // checking to see if input is empty first - if input.FirstName == nil && input.LastName == nil && input.Email == nil && input.PhoneNumber == nil && input.Pronouns == nil && input.Age == nil { - return nil, errors.New("empty user field") - } - err = r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { - if input.FirstName != nil { - err = r.UpdateFirstName(ctx, id, *input.FirstName, tx) - if err != nil { - return err - } - } - if input.LastName != nil { - err = r.UpdateLastName(ctx, id, *input.LastName, tx) - if err != nil { - return err - } - } - if input.Email != nil { - err = r.UpdateEmail(ctx, id, *input.Email, tx) - if err != nil { - return err - } - } - if input.PhoneNumber != nil { - err = r.UpdatePhoneNumber(ctx, id, *input.PhoneNumber, tx) - if err != nil { - return err - } - } - if input.Pronouns != nil { - err = r.UpdatePronouns(ctx, id, input.Pronouns, tx) - if err != nil { - return err - } - } - if input.Age != nil { - err = r.UpdateAge(ctx, id, input.Age, tx) - if err != nil { - return err - } - } - - user, err = r.getUserWithTx(ctx, - `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE id = $1 LIMIT 1`, - tx, - id) - - if err != nil { - return err - } - return nil - }) - if err != nil { - return nil, err - } - return user, nil -} - -func (r *DatabaseRepository) GetUsers(ctx context.Context, first int, after string) ([]*model.User, int, error) { - users := make([]*model.User, 0, first) - var totalCount int - err := r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { - rows, err := tx.Query( - ctx, - "SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE id > $1 ORDER BY `id` DESC LIMIT $2", - after, - first, - ) - if err != nil { - return err - } - for rows.Next() { - var user model.User - - pronounId, err := ScanUser(&user, rows) - if err != nil { - return err - } - err = getPronouns(ctx, tx, pronounId, r, &user) - if err != nil { - return err - } - users = append(users, &user) - } - - if err = rows.Err(); err != nil { - return err - } - row := tx.QueryRow(ctx, "SELECT COUNT(*) FROM users") - if err != nil { - return err - } - - return row.Scan(&totalCount) - }) - return users, totalCount, err -} - -func (r *DatabaseRepository) SearchUser(ctx context.Context, name string) ([]*model.User, error) { - const limit int = 10 - users := make([]*model.User, 0, limit) - - err := r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { - rows, err := tx.Query(ctx, "SELECT * from users WHERE to_tsvector(first_name || ' ' || last_name) @@ to_tsquery('$1:*') LIMIT $2", name, limit) - if err != nil { - return err - } - for rows.Next() { - var user model.User - - pronounId, err := ScanUser(&user, rows) - if err != nil { - return err - } - err = getPronouns(ctx, tx, pronounId, r, &user) - if err != nil { - return err - } - users = append(users, &user) - } - return rows.Err() - }) - if err != nil { - return nil, err - } - return users, nil +func (r *DatabaseRepository) InsertUser(ctx context.Context, queryable database.Queryable, input *model.NewUser, pronounIdPtr *int, oAuth *model.OAuth) (int, error) { + // TODO: Possibly change ID type to int to stop this hacky fix? + // insert user into database and return their ID + var userIdInt int + err := queryable.QueryRow(ctx, "INSERT INTO users (first_name, last_name, email, phone_number, age, pronoun_id, oauth_uid, oauth_provider, role) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id", + input.FirstName, + input.LastName, + input.Email, + input.PhoneNumber, + input.Age, + pronounIdPtr, + oAuth.UID, + oAuth.Provider.String(), + sharedModels.RoleNormal, + ).Scan(&userIdInt) + return userIdInt, err } func (r *DatabaseRepository) DeleteUser(ctx context.Context, id string) (bool, error) { @@ -390,132 +126,11 @@ func (r *DatabaseRepository) DeleteUser(ctx context.Context, id string) (bool, e return true, nil } -// this will update first name -func (r *DatabaseRepository) UpdateFirstName(ctx context.Context, id string, first string, tx pgx.Tx) error { - commandTag, err := tx.Exec(ctx, "UPDATE users SET first_name = $1 WHERE id = $2", first, id) - if err != nil { - return err - } - if commandTag.RowsAffected() != 1 { - return repository.UserNotFound - } - return nil -} - -// this function will update last name -func (r *DatabaseRepository) UpdateLastName(ctx context.Context, id string, last string, tx pgx.Tx) error { - commandTag, err := tx.Exec(ctx, "UPDATE users SET last_name = $1 WHERE id = $2", last, id) - if err != nil { - return err - } - if commandTag.RowsAffected() != 1 { - return repository.UserNotFound - } - // then no error - return nil -} - -// updates email -func (r *DatabaseRepository) UpdateEmail(ctx context.Context, id string, email string, tx pgx.Tx) error { - commandTag, err := tx.Exec(ctx, "UPDATE users SET email = $1 WHERE id = $2", email, id) - if err != nil { - return err - } - if commandTag.RowsAffected() != 1 { - return repository.UserNotFound - } - // then no error - return nil -} - -// updates user phone number -func (r *DatabaseRepository) UpdatePhoneNumber(ctx context.Context, id string, number string, tx pgx.Tx) error { - commandTag, err := tx.Exec(ctx, "UPDATE users SET phone_number = $1 WHERE id = $2", number, id) - if err != nil { - return err - } - if commandTag.RowsAffected() != 1 { - return repository.UserNotFound - } - // then no error - return nil -} - -// updates user Pronouns -func (r *DatabaseRepository) UpdatePronouns(ctx context.Context, id string, pronoun *model.PronounsInput, tx pgx.Tx) error { - // first find pronouns, if it doesnt exist this will add to database and then update user pronoun in database - // copied from createUser - var pronounsPtr *model.Pronouns - pronounsPtr = &model.Pronouns{ - Subjective: pronoun.Subjective, - Objective: pronoun.Objective, - } - var pronounIdPtr *int - pronouns := *pronounsPtr - pronounId, exists := r.GetByPronouns(pronouns) - - if !exists { - // check if the pronoun exists in the database - err := tx.QueryRow(ctx, "SELECT id FROM pronouns WHERE subjective=$1 AND objective=$2", - pronoun.Subjective, - pronoun.Objective, - ).Scan(&pronounId) - - pronounExist := true - if err != nil { - if errors.Is(err, pgx.ErrNoRows) { - // pronoun does not exist in the database - pronounExist = false - } else { - return err - } - } - if !pronounExist { - // since the new pronoun does not exist in the database, we insert it - err = tx.QueryRow(ctx, "INSERT INTO pronouns (subjective, objective) VALUES ($1, $2) RETURNING id", - pronoun.Subjective, - pronoun.Objective, - ).Scan(&pronounId) - } - - if err != nil { - return err - } - // set the pronoun cache - r.Set(pronounId, pronouns) - } - - pronounIdPtr = &pronounId - - commandTag, err := tx.Exec(ctx, "UPDATE users SET pronoun_id = $1 WHERE id = $2", pronounIdPtr, id) - if err != nil { - return err - } - if commandTag.RowsAffected() != 1 { - return repository.UserNotFound - } - // then no error - return nil -} - -// updates user age -func (r *DatabaseRepository) UpdateAge(ctx context.Context, id string, age *int, tx pgx.Tx) error { - commandTag, err := tx.Exec(ctx, "UPDATE users SET age = $1 WHERE id = $2", *age, id) - if err != nil { - return err - } - if commandTag.RowsAffected() != 1 { - return repository.UserNotFound - } - // then no error - return nil -} - type Scannable interface { Scan(dest ...interface{}) error } -func ScanUser[T Scannable](user *model.User, scannable T) (*int32, error) { +func ScanUser[T Scannable](user *model.User, scannable T) (*int, error) { var pronounId *int32 var userIdInt int err := scannable.Scan( @@ -532,5 +147,9 @@ func ScanUser[T Scannable](user *model.User, scannable T) (*int32, error) { return nil, err } user.ID = strconv.Itoa(userIdInt) - return pronounId, nil + if pronounId != nil { + i := int(*pronounId) + return &i, nil + } + return nil, nil } diff --git a/repository/database/get_user.go b/repository/database/get_user.go new file mode 100644 index 0000000..6d9bee9 --- /dev/null +++ b/repository/database/get_user.go @@ -0,0 +1,161 @@ +package database + +import ( + "context" + "errors" + sharedModels "github.com/KnightHacks/knighthacks_shared/models" + "github.com/KnightHacks/knighthacks_users/graph/model" + "github.com/KnightHacks/knighthacks_users/repository" + "github.com/jackc/pgx/v4" +) + +/* + $$$$$$\ $$\ $$\ $$\ +$$ __$$\ $$ | $$ | $$ | +$$ / \__| $$$$$$\ $$$$$$\ $$ | $$ | $$$$$$$\ $$$$$$\ $$$$$$\ +$$ |$$$$\ $$ __$$\\_$$ _| $$ | $$ |$$ _____|$$ __$$\ $$ __$$\ +$$ |\_$$ |$$$$$$$$ | $$ | $$ | $$ |\$$$$$$\ $$$$$$$$ |$$ | \__| +$$ | $$ |$$ ____| $$ |$$\ $$ | $$ | \____$$\ $$ ____|$$ | +\$$$$$$ |\$$$$$$$\ \$$$$ | \$$$$$$ |$$$$$$$ |\$$$$$$$\ $$ | + \______/ \_______| \____/ \______/ \_______/ \_______|\__| +*/ + +func (r *DatabaseRepository) GetUsers(ctx context.Context, first int, after string) ([]*model.User, int, error) { + users := make([]*model.User, 0, first) + var totalCount int + err := r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { + rows, err := tx.Query( + ctx, + "SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE id > $1 ORDER BY `id` DESC LIMIT $2", + after, + first, + ) + if err != nil { + return err + } + for rows.Next() { + var user model.User + + pronounId, err := ScanUser(&user, rows) + if err != nil { + return err + } + // user has pronouns, but we don't know what they are + if pronounId != nil { + err = r.getPronouns(ctx, tx, *pronounId) + if err != nil { + return err + } + } + users = append(users, &user) + } + + if err = rows.Err(); err != nil { + return err + } + row := tx.QueryRow(ctx, "SELECT COUNT(*) FROM users") + if err != nil { + return err + } + + return row.Scan(&totalCount) + }) + return users, totalCount, err +} + +// GetUserByID returns the user by their id +func (r *DatabaseRepository) GetUserByID(ctx context.Context, id string) (*model.User, error) { + return r.getUser( + ctx, + `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE id = $1 LIMIT 1`, + id, + ) +} + +// GetUserByOAuthUID returns the user by their oauth auth token +func (r *DatabaseRepository) GetUserByOAuthUID(ctx context.Context, oAuthUID string, provider sharedModels.Provider) (*model.User, error) { + return r.getUser( + ctx, + `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE oauth_uid=cast($1 as varchar) AND oauth_provider=$2 LIMIT 1`, + oAuthUID, + provider, + ) +} + +func (r *DatabaseRepository) getUserWithTx(ctx context.Context, query string, tx pgx.Tx, args ...interface{}) (*model.User, error) { + var user model.User + + if tx == nil { + var err error + tx, err = r.DatabasePool.Begin(ctx) + if err != nil { + return nil, err + } + defer tx.Commit(ctx) + } + + pronounId, err := ScanUser(&user, tx.QueryRow(ctx, query, args...)) + + if err != nil { + if errors.Is(err, pgx.ErrNoRows) { + return nil, repository.UserNotFound + } + return nil, err + } + + // if the user has their pronouns set + if pronounId != nil { + if err = r.getPronouns(ctx, tx, *pronounId); err != nil { + return nil, err + } + } + return &user, nil +} + +func (r *DatabaseRepository) getUser(ctx context.Context, query string, args ...interface{}) (*model.User, error) { + return r.getUserWithTx(ctx, query, nil, args...) +} + +func (r *DatabaseRepository) SearchUser(ctx context.Context, name string) ([]*model.User, error) { + const limit int = 10 + users := make([]*model.User, 0, limit) + + err := r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { + rows, err := tx.Query(ctx, "SELECT * from users WHERE to_tsvector(first_name || ' ' || last_name) @@ to_tsquery('$1:*') LIMIT $2", name, limit) + if err != nil { + return err + } + for rows.Next() { + var user model.User + + pronounId, err := ScanUser(&user, rows) + if err != nil { + return err + } + if pronounId != nil { + err = r.getPronouns(ctx, tx, *pronounId) + } + if err != nil { + return err + } + users = append(users, &user) + } + return rows.Err() + }) + if err != nil { + return nil, err + } + return users, nil +} + +// GetOAuth returns the model.OAuth object that is associated with the user's id +// Used by the OAuth force resolver, this is not a common operation so making this +// a force resolver is a good idea +func (r *DatabaseRepository) GetOAuth(ctx context.Context, id string) (*model.OAuth, error) { + var oAuth model.OAuth + err := r.DatabasePool.QueryRow(ctx, "SELECT oauth_uid, oauth_provider FROM users WHERE id = $1", id).Scan(&oAuth.UID, &oAuth.Provider) + if err != nil { + return nil, err + } + return &oAuth, err +} diff --git a/repository/database/pronouns.go b/repository/database/pronouns.go new file mode 100644 index 0000000..b24dcd8 --- /dev/null +++ b/repository/database/pronouns.go @@ -0,0 +1,93 @@ +package database + +import ( + "context" + "errors" + "github.com/KnightHacks/knighthacks_shared/database" + "github.com/KnightHacks/knighthacks_users/graph/model" + "github.com/jackc/pgx/v4" +) + +/* +$$$$$$$\ +$$ __$$\ +$$ | $$ | $$$$$$\ $$$$$$\ $$$$$$$\ $$$$$$\ $$\ $$\ $$$$$$$\ $$$$$$$\ +$$$$$$$ |$$ __$$\ $$ __$$\ $$ __$$\ $$ __$$\ $$ | $$ |$$ __$$\ $$ _____| +$$ ____/ $$ | \__|$$ / $$ |$$ | $$ |$$ / $$ |$$ | $$ |$$ | $$ |\$$$$$$\ +$$ | $$ | $$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ | \____$$\ +$$ | $$ | \$$$$$$ |$$ | $$ |\$$$$$$ |\$$$$$$ |$$ | $$ |$$$$$$$ | +\__| \__| \______/ \__| \__| \______/ \______/ \__| \__|\_______/ +*/ + +// GetByPronouns gets the sql row id for the pronouns associated with the input +func (r *DatabaseRepository) GetByPronouns(pronouns model.Pronouns) (int, bool) { + id, exist := r.PronounReverseMap[pronouns] + return id, exist +} + +// GetById gets the pronouns by the sql row id +func (r *DatabaseRepository) GetById(id int) (model.Pronouns, bool) { + pronouns, exist := r.PronounMap[id] + return pronouns, exist +} + +// Set inputs the pronouns into the bidirectional map +func (r *DatabaseRepository) Set(id int, pronouns model.Pronouns) { + r.PronounMap[id] = pronouns + r.PronounReverseMap[pronouns] = id +} + +func (r *DatabaseRepository) getPronouns(ctx context.Context, queryable database.Queryable, pronounId int) error { + pronouns, exists := r.GetById(pronounId) + // does the pronoun not exist in the local cache? + if !exists { + // retrieve the pronoun from the database + err := queryable.QueryRow(ctx, "SELECT subjective, objective FROM pronouns WHERE id = $1", pronounId).Scan( + &pronouns.Subjective, + &pronouns.Objective, + ) + if err != nil { + return err + } + // set the pronoun in the local cache + r.Set(pronounId, pronouns) + } + return nil +} + +func (r *DatabaseRepository) GetOrCreatePronoun(ctx context.Context, queryable database.Queryable, pronouns model.Pronouns, input *model.NewUser) (*int, error) { + pronounId, exists := r.GetByPronouns(pronouns) + // if the pronoun does not exist in the local cache + if !exists { + // check if the pronoun exists in the database + err := queryable.QueryRow(ctx, "SELECT id FROM pronouns WHERE subjective=$1 AND objective=$2", + input.Pronouns.Subjective, + input.Pronouns.Objective, + ).Scan(&pronounId) + + pronounExist := true + if err != nil { + if errors.Is(err, pgx.ErrNoRows) { + // pronoun does not exist in the database + pronounExist = false + } else { + return nil, err + } + } + + if !pronounExist { + // since the new pronoun does not exist in the database, we insert it + err = queryable.QueryRow(ctx, "INSERT INTO pronouns (subjective, objective) VALUES ($1, $2) RETURNING id", + input.Pronouns.Subjective, + input.Pronouns.Objective, + ).Scan(&pronounId) + } + + if err != nil { + return nil, err + } + // set the pronoun cache + r.Set(pronounId, pronouns) + } + return &pronounId, nil +} diff --git a/repository/database/update_user.go b/repository/database/update_user.go new file mode 100644 index 0000000..1982d2d --- /dev/null +++ b/repository/database/update_user.go @@ -0,0 +1,205 @@ +package database + +import ( + "context" + "errors" + "github.com/KnightHacks/knighthacks_users/graph/model" + "github.com/KnightHacks/knighthacks_users/repository" + "github.com/jackc/pgx/v4" +) + +/* +$$\ $$\ $$\ $$\ $$\ $$\ +$$ | $$ | $$ | $$ | $$ | $$ | +$$ | $$ | $$$$$$\ $$$$$$$ | $$$$$$\ $$$$$$\ $$$$$$\ $$ | $$ | $$$$$$$\ $$$$$$\ $$$$$$\ +$$ | $$ |$$ __$$\ $$ __$$ | \____$$\\_$$ _| $$ __$$\ $$ | $$ |$$ _____|$$ __$$\ $$ __$$\ +$$ | $$ |$$ / $$ |$$ / $$ | $$$$$$$ | $$ | $$$$$$$$ | $$ | $$ |\$$$$$$\ $$$$$$$$ |$$ | \__| +$$ | $$ |$$ | $$ |$$ | $$ |$$ __$$ | $$ |$$\ $$ ____| $$ | $$ | \____$$\ $$ ____|$$ | +\$$$$$$ |$$$$$$$ |\$$$$$$$ |\$$$$$$$ | \$$$$ |\$$$$$$$\ \$$$$$$ |$$$$$$$ |\$$$$$$$\ $$ | + \______/ $$ ____/ \_______| \_______| \____/ \_______| \______/ \_______/ \_______|\__| + $$ | + $$ | + \__| +*/ + +// UpdateUser +// update user add multiple parts go off of create user +// we will check whether the values in input are nil or empty strings, if not, we execute the update statement +func (r *DatabaseRepository) UpdateUser(ctx context.Context, id string, input *model.UpdatedUser) (*model.User, error) { + var user *model.User + var err error + // checking to see if input is empty first + if input.FirstName == nil && input.LastName == nil && input.Email == nil && input.PhoneNumber == nil && input.Pronouns == nil && input.Age == nil { + return nil, errors.New("empty user field") + } + err = r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { + + if input.FirstName != nil { + err = r.UpdateFirstName(ctx, id, *input.FirstName, tx) + if err != nil { + return err + } + } + if input.LastName != nil { + err = r.UpdateLastName(ctx, id, *input.LastName, tx) + if err != nil { + return err + } + } + if input.Email != nil { + err = r.UpdateEmail(ctx, id, *input.Email, tx) + if err != nil { + return err + } + } + if input.PhoneNumber != nil { + err = r.UpdatePhoneNumber(ctx, id, *input.PhoneNumber, tx) + if err != nil { + return err + } + } + if input.Pronouns != nil { + err = r.UpdatePronouns(ctx, id, input.Pronouns, tx) + if err != nil { + return err + } + } + if input.Age != nil { + err = r.UpdateAge(ctx, id, input.Age, tx) + if err != nil { + return err + } + } + + user, err = r.getUserWithTx(ctx, + `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE id = $1 LIMIT 1`, + tx, + id) + + if err != nil { + return err + } + return nil + }) + if err != nil { + return nil, err + } + return user, nil +} + +// UpdateFirstName this will update first name +func (r *DatabaseRepository) UpdateFirstName(ctx context.Context, id string, first string, tx pgx.Tx) error { + + commandTag, err := tx.Exec(ctx, "UPDATE users SET first_name = $1 WHERE id = $2", first, id) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + return nil +} + +// UpdateLastName this function will update last name +func (r *DatabaseRepository) UpdateLastName(ctx context.Context, id string, last string, tx pgx.Tx) error { + commandTag, err := tx.Exec(ctx, "UPDATE users SET last_name = $1 WHERE id = $2", last, id) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} + +// UpdateEmail updates email +func (r *DatabaseRepository) UpdateEmail(ctx context.Context, id string, email string, tx pgx.Tx) error { + commandTag, err := tx.Exec(ctx, "UPDATE users SET email = $1 WHERE id = $2", email, id) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} + +// UpdatePhoneNumber updates user phone number +func (r *DatabaseRepository) UpdatePhoneNumber(ctx context.Context, id string, number string, tx pgx.Tx) error { + commandTag, err := tx.Exec(ctx, "UPDATE users SET phone_number = $1 WHERE id = $2", number, id) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} + +// UpdateAge updates user age +func (r *DatabaseRepository) UpdateAge(ctx context.Context, id string, age *int, tx pgx.Tx) error { + commandTag, err := tx.Exec(ctx, "UPDATE users SET age = $1 WHERE id = $2", *age, id) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} + +// UpdatePronouns updates user Pronouns +func (r *DatabaseRepository) UpdatePronouns(ctx context.Context, id string, pronoun *model.PronounsInput, tx pgx.Tx) error { + // first find pronouns, if it doesn't exist this will add to database and then update user pronoun in database + // copied from createUser + var pronouns = model.Pronouns{ + Subjective: pronoun.Subjective, + Objective: pronoun.Objective, + } + pronounId, exists := r.GetByPronouns(pronouns) + + if !exists { + // check if the pronoun exists in the database + err := tx.QueryRow(ctx, "SELECT id FROM pronouns WHERE subjective=$1 AND objective=$2", + pronoun.Subjective, + pronoun.Objective, + ).Scan(&pronounId) + + pronounExist := true + if err != nil { + if errors.Is(err, pgx.ErrNoRows) { + // pronoun does not exist in the database + pronounExist = false + } else { + return err + } + } + if !pronounExist { + // since the new pronoun does not exist in the database, we insert it + err = tx.QueryRow(ctx, "INSERT INTO pronouns (subjective, objective) VALUES ($1, $2) RETURNING id", + pronoun.Subjective, + pronoun.Objective, + ).Scan(&pronounId) + } + + if err != nil { + return err + } + // set the pronoun cache + r.Set(pronounId, pronouns) + } + + commandTag, err := tx.Exec(ctx, "UPDATE users SET pronoun_id = $1 WHERE id = $2", pronounId, id) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} From b081db2e2aa100ffbb395526cf9eb875ed1d4958 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 02:14:50 -0500 Subject: [PATCH 07/29] cleaned up UpdateUser validation --- repository/database/update_user.go | 55 +++++++++++++----------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/repository/database/update_user.go b/repository/database/update_user.go index 1982d2d..6985ab2 100644 --- a/repository/database/update_user.go +++ b/repository/database/update_user.go @@ -22,6 +22,18 @@ $$ | $$ |$$ | $$ |$$ | $$ |$$ __$$ | $$ |$$\ $$ ____| $$ | $$ | \___ \__| */ +type UpdateFunc[T any] func(ctx context.Context, id string, input T, tx pgx.Tx) error + +func Validate[T any](ctx context.Context, tx pgx.Tx, id string, input *T, updateFunc UpdateFunc[T]) error { + if input != nil { + err := updateFunc(ctx, id, *input, tx) + if err != nil { + return err + } + } + return nil +} + // UpdateUser // update user add multiple parts go off of create user // we will check whether the values in input are nil or empty strings, if not, we execute the update statement @@ -33,42 +45,23 @@ func (r *DatabaseRepository) UpdateUser(ctx context.Context, id string, input *m return nil, errors.New("empty user field") } err = r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { - - if input.FirstName != nil { - err = r.UpdateFirstName(ctx, id, *input.FirstName, tx) - if err != nil { - return err - } + if err = Validate(ctx, tx, id, input.FirstName, r.UpdateFirstName); err != nil { + return err } - if input.LastName != nil { - err = r.UpdateLastName(ctx, id, *input.LastName, tx) - if err != nil { - return err - } + if err = Validate(ctx, tx, id, input.LastName, r.UpdateLastName); err != nil { + return err } - if input.Email != nil { - err = r.UpdateEmail(ctx, id, *input.Email, tx) - if err != nil { - return err - } + if err = Validate(ctx, tx, id, input.Email, r.UpdateEmail); err != nil { + return err } - if input.PhoneNumber != nil { - err = r.UpdatePhoneNumber(ctx, id, *input.PhoneNumber, tx) - if err != nil { - return err - } + if err = Validate(ctx, tx, id, input.PhoneNumber, r.UpdatePhoneNumber); err != nil { + return err } - if input.Pronouns != nil { - err = r.UpdatePronouns(ctx, id, input.Pronouns, tx) - if err != nil { - return err - } + if err = Validate(ctx, tx, id, &input.Pronouns, r.UpdatePronouns); err != nil { + return err } - if input.Age != nil { - err = r.UpdateAge(ctx, id, input.Age, tx) - if err != nil { - return err - } + if err = Validate(ctx, tx, id, &input.Age, r.UpdateAge); err != nil { + return err } user, err = r.getUserWithTx(ctx, From 006c5d83805f833cb08ad5f090bb3f4ca016a7eb Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 02:38:05 -0500 Subject: [PATCH 08/29] added missing import --- graph/schema.resolvers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index 08f27be..2e4e376 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -9,7 +9,6 @@ import ( "encoding/base64" "errors" "fmt" - "github.com/KnightHacks/knighthacks_users/repository" "net/http" "net/url" @@ -19,6 +18,7 @@ import ( "github.com/KnightHacks/knighthacks_shared/utils" "github.com/KnightHacks/knighthacks_users/graph/generated" "github.com/KnightHacks/knighthacks_users/graph/model" + "github.com/KnightHacks/knighthacks_users/repository" ) // Register is the resolver for the register field. From fe3e427676cc789a667b7035bd0db0e720de71f6 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 02:38:30 -0500 Subject: [PATCH 09/29] fixed "graduationDate" type --- graph/generated/generated.go | 32 +++++++++++++++++++++++++------- graph/model/models_gen.go | 5 +++-- graph/schema.graphqls | 6 ++++-- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/graph/generated/generated.go b/graph/generated/generated.go index 3cb25a0..6306a53 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -10,6 +10,7 @@ import ( "strconv" "sync" "sync/atomic" + "time" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" @@ -740,7 +741,9 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var sources = []*ast.Source{ - {Name: "../schema.graphqls", Input: `directive @goModel(model: String, models: [String!]) on OBJECT + {Name: "../schema.graphqls", Input: `scalar Time + +directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM @@ -861,14 +864,14 @@ input MailingAddressInput { type EducationInfo { name: String! - graduationDate: String! + graduationDate: Time! major: String! level: LevelOfStudy } input EducationInfoInput { name: String! - graduationDate: String! + graduationDate: Time! major: String! level: LevelOfStudy } @@ -1395,9 +1398,9 @@ func (ec *executionContext) _EducationInfo_graduationDate(ctx context.Context, f } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_EducationInfo_graduationDate(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -1407,7 +1410,7 @@ func (ec *executionContext) fieldContext_EducationInfo_graduationDate(ctx contex IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil @@ -6731,7 +6734,7 @@ func (ec *executionContext) unmarshalInputEducationInfoInput(ctx context.Context var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("graduationDate")) - it.GraduationDate, err = ec.unmarshalNString2string(ctx, v) + it.GraduationDate, err = ec.unmarshalNTime2timeᚐTime(ctx, v) if err != nil { return it, err } @@ -8628,6 +8631,21 @@ func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel return ret } +func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { + res, err := graphql.UnmarshalTime(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + res := graphql.MarshalTime(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + func (ec *executionContext) unmarshalNUpdatedUser2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUpdatedUser(ctx context.Context, v interface{}) (model.UpdatedUser, error) { res, err := ec.unmarshalInputUpdatedUser(ctx, v) return res, graphql.ErrorOnPath(ctx, err) diff --git a/graph/model/models_gen.go b/graph/model/models_gen.go index 4678b0c..a83c843 100644 --- a/graph/model/models_gen.go +++ b/graph/model/models_gen.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "strconv" + "time" "github.com/KnightHacks/knighthacks_shared/models" ) @@ -16,14 +17,14 @@ type Connection interface { type EducationInfo struct { Name string `json:"name"` - GraduationDate string `json:"graduationDate"` + GraduationDate time.Time `json:"graduationDate"` Major string `json:"major"` Level *LevelOfStudy `json:"level"` } type EducationInfoInput struct { Name string `json:"name"` - GraduationDate string `json:"graduationDate"` + GraduationDate time.Time `json:"graduationDate"` Major string `json:"major"` Level *LevelOfStudy `json:"level"` } diff --git a/graph/schema.graphqls b/graph/schema.graphqls index 1897828..639629d 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -1,3 +1,5 @@ +scalar Time + directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR @@ -119,14 +121,14 @@ input MailingAddressInput { type EducationInfo { name: String! - graduationDate: String! + graduationDate: Time! major: String! level: LevelOfStudy } input EducationInfoInput { name: String! - graduationDate: String! + graduationDate: Time! major: String! level: LevelOfStudy } From e07b5ab8e24a7e09e6b364eed8b94573cec6e464 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 02:39:00 -0500 Subject: [PATCH 10/29] moved create user into its own file --- repository/database/create_user.go | 138 +++++++++++++++++++++ repository/database/database_repository.go | 80 ------------ 2 files changed, 138 insertions(+), 80 deletions(-) create mode 100644 repository/database/create_user.go diff --git a/repository/database/create_user.go b/repository/database/create_user.go new file mode 100644 index 0000000..25d3ee1 --- /dev/null +++ b/repository/database/create_user.go @@ -0,0 +1,138 @@ +package database + +import ( + "context" + "errors" + "github.com/KnightHacks/knighthacks_shared/database" + sharedModels "github.com/KnightHacks/knighthacks_shared/models" + "github.com/KnightHacks/knighthacks_users/graph/model" + "github.com/KnightHacks/knighthacks_users/repository" + "github.com/jackc/pgx/v4" + "strconv" +) + +// CreateUser Creates a user in the database and returns the new user struct +// +// The NewUser input struct contains all nillable fields so the following function +// must be able to run regardless of whether of it's input, that is why there is a +// lot of pointers for nil safety purposes +func (r *DatabaseRepository) CreateUser(ctx context.Context, oAuth *model.OAuth, input *model.NewUser) (*model.User, error) { + var userId string + var pronouns model.Pronouns + if input.Pronouns != nil { + // input.Pronouns is a PronounsInput struct which a direct copy of the Pronouns struct, so we need to copy its fields + pronouns = model.Pronouns{ + Subjective: input.Pronouns.Subjective, + Objective: input.Pronouns.Objective, + } + } + + // Begins the database transaction + err := r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { + // Detects whether the user with the oauth_uid, for GitHub that is their github ID already exists, if + // the use already exists we return an UserAlreadyExists error + var discoveredId = new(int) + err := tx.QueryRow(ctx, "SELECT id FROM users WHERE oauth_uid=$1 AND oauth_provider=$2 LIMIT 1", oAuth.UID, oAuth.Provider.String()).Scan(discoveredId) + if err == nil && discoveredId != nil { + return repository.UserAlreadyExists + } + if err != nil && !errors.Is(err, pgx.ErrNoRows) { + return err + } + + // Get pronouns + pronounIdPtr, err := r.GetOrCreatePronoun(ctx, tx, pronouns, input) + if err != nil { + return err + } + + // Insert new user into database + userIdInt, err := r.InsertUser(ctx, tx, input, pronounIdPtr, oAuth) + if err != nil { + return err + } + + // Insert MLH Terms + if err = r.InsertMLHTerms(ctx, tx, userIdInt, input.Mlh); err != nil { + return err + } + + // Insert Education Info + if err = r.InsertEducationInfo(ctx, tx, userIdInt, input.EducationInfo); err != nil { + return err + } + + // Insert Mailing Address Data + if err = r.InsertMailingAddress(ctx, tx, userIdInt, input.MailingAddress); err != nil { + return err + } + + userId = strconv.Itoa(userIdInt) + return nil + }) + if err != nil { + return nil, err + } + // TODO: look into the case where the userId is not scanned in + return &model.User{ + ID: userId, + FirstName: input.FirstName, + LastName: input.LastName, + Email: input.Email, + PhoneNumber: input.PhoneNumber, + Pronouns: &pronouns, + Age: input.Age, + OAuth: oAuth, + }, nil +} + +func (r *DatabaseRepository) InsertUser(ctx context.Context, queryable database.Queryable, input *model.NewUser, pronounIdPtr *int, oAuth *model.OAuth) (int, error) { + // TODO: Possibly change ID type to int to stop this hacky fix? + // insert user into database and return their ID + var userIdInt int + err := queryable.QueryRow(ctx, "INSERT INTO users (first_name, last_name, email, phone_number, age, pronoun_id, oauth_uid, oauth_provider, role) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id", + input.FirstName, + input.LastName, + input.Email, + input.PhoneNumber, + input.Age, + pronounIdPtr, + oAuth.UID, + oAuth.Provider.String(), + sharedModels.RoleNormal, + ).Scan(&userIdInt) + return userIdInt, err +} + +func (r *DatabaseRepository) InsertMLHTerms(ctx context.Context, queryable database.Queryable, userId int, input *model.MLHTermsInput) error { + _, err := queryable.Exec(ctx, "INSERT INTO mlh_terms (user_id, send_messages, share_info, code_of_conduct) VALUES ($1, $2, $3, $4)", + userId, + input.SendMessages, + input.ShareInfo, + input.CodeOfConduct, + ) + return err +} + +func (r *DatabaseRepository) InsertEducationInfo(ctx context.Context, queryable database.Queryable, userId int, input *model.EducationInfoInput) error { + _, err := queryable.Exec(ctx, "INSERT INTO education_info (user_id, name, major, graduation_date, level) VALUES ($1, $2, $3, $4)", + userId, + input.Name, + input.Major, + input.GraduationDate.UTC(), + input.Level, + ) + return err +} + +func (r *DatabaseRepository) InsertMailingAddress(ctx context.Context, queryable database.Queryable, userId int, input *model.MailingAddressInput) error { + _, err := queryable.Exec(ctx, "INSERT INTO mailing_addresses (user_id, country, state, city, postal_code, address_lines) VALUES ($1, $2, $3, $4, $5, $6)", + userId, + input.Country, + input.State, + input.City, + input.PostalCode, + input.AddressLines, + ) + return err +} diff --git a/repository/database/database_repository.go b/repository/database/database_repository.go index 9f3c4c2..d899a6a 100644 --- a/repository/database/database_repository.go +++ b/repository/database/database_repository.go @@ -2,12 +2,8 @@ package database import ( "context" - "errors" - "github.com/KnightHacks/knighthacks_shared/database" - sharedModels "github.com/KnightHacks/knighthacks_shared/models" "github.com/KnightHacks/knighthacks_users/graph/model" "github.com/KnightHacks/knighthacks_users/repository" - "github.com/jackc/pgx/v4" "github.com/jackc/pgx/v4/pgxpool" "strconv" ) @@ -31,82 +27,6 @@ func NewDatabaseRepository(databasePool *pgxpool.Pool) *DatabaseRepository { } } -// CreateUser Creates a user in the database and returns the new user struct -// -// The NewUser input struct contains all nillable fields so the following function -// must be able to run regardless of whether of it's input, that is why there is a -// lot of pointers for nil safety purposes -func (r *DatabaseRepository) CreateUser(ctx context.Context, oAuth *model.OAuth, input *model.NewUser) (*model.User, error) { - var userId string - var pronouns model.Pronouns - if input.Pronouns != nil { - // input.Pronouns is a PronounsInput struct which a direct copy of the Pronouns struct, so we need to copy its fields - pronouns = model.Pronouns{ - Subjective: input.Pronouns.Subjective, - Objective: input.Pronouns.Objective, - } - } - - // Begins the database transaction - err := r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { - // Detects whether the user with the oauth_uid, for GitHub that is their github ID already exists, if - // the use already exists we return an UserAlreadyExists error - var discoveredId = new(int) - err := tx.QueryRow(ctx, "SELECT id FROM users WHERE oauth_uid=$1 AND oauth_provider=$2 LIMIT 1", oAuth.UID, oAuth.Provider.String()).Scan(discoveredId) - if err == nil && discoveredId != nil { - return repository.UserAlreadyExists - } - if err != nil && !errors.Is(err, pgx.ErrNoRows) { - return err - } - - // Get pronouns - pronounIdPtr, err := r.GetOrCreatePronoun(ctx, tx, pronouns, input) - if err != nil { - return err - } - - userIdInt, err := r.InsertUser(ctx, tx, input, pronounIdPtr, oAuth) - if err != nil { - return err - } - userId = strconv.Itoa(userIdInt) - return nil - }) - if err != nil { - return nil, err - } - // TODO: look into the case where the userId is not scanned in - return &model.User{ - ID: userId, - FirstName: input.FirstName, - LastName: input.LastName, - Email: input.Email, - PhoneNumber: input.PhoneNumber, - Pronouns: &pronouns, - Age: input.Age, - OAuth: oAuth, - }, nil -} - -func (r *DatabaseRepository) InsertUser(ctx context.Context, queryable database.Queryable, input *model.NewUser, pronounIdPtr *int, oAuth *model.OAuth) (int, error) { - // TODO: Possibly change ID type to int to stop this hacky fix? - // insert user into database and return their ID - var userIdInt int - err := queryable.QueryRow(ctx, "INSERT INTO users (first_name, last_name, email, phone_number, age, pronoun_id, oauth_uid, oauth_provider, role) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id", - input.FirstName, - input.LastName, - input.Email, - input.PhoneNumber, - input.Age, - pronounIdPtr, - oAuth.UID, - oAuth.Provider.String(), - sharedModels.RoleNormal, - ).Scan(&userIdInt) - return userIdInt, err -} - func (r *DatabaseRepository) DeleteUser(ctx context.Context, id string) (bool, error) { //query the row using the id with a DELETE statment From 3577341fecb2d5751b869d68091ef8796d12071b Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 02:52:46 -0500 Subject: [PATCH 11/29] templated get mlh and get mailing address --- graph/schema.resolvers.go | 4 ++-- repository/database/get_user.go | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index 2e4e376..0acf6b4 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -240,12 +240,12 @@ func (r *userResolver) OAuth(ctx context.Context, obj *model.User) (*model.OAuth // MailingAddress is the resolver for the mailingAddress field. func (r *userResolver) MailingAddress(ctx context.Context, obj *model.User) (*model.MailingAddress, error) { - panic(fmt.Errorf("not implemented")) + return r.Repository.GetUserMailingAddress(ctx, obj.ID) } // Mlh is the resolver for the mlh field. func (r *userResolver) Mlh(ctx context.Context, obj *model.User) (*model.MLHTerms, error) { - panic(fmt.Errorf("not implemented")) + return r.Repository.GetUserMLHTerms(ctx, obj.ID) } // Mutation returns generated.MutationResolver implementation. diff --git a/repository/database/get_user.go b/repository/database/get_user.go index 6d9bee9..42fbc7e 100644 --- a/repository/database/get_user.go +++ b/repository/database/get_user.go @@ -159,3 +159,13 @@ func (r *DatabaseRepository) GetOAuth(ctx context.Context, id string) (*model.OA } return &oAuth, err } + +func (r *DatabaseRepository) GetUserMailingAddress(ctx context.Context, userId string) (*model.MailingAddress, error) { + //TODO implement me + panic("implement me") +} + +func (r *DatabaseRepository) GetUserMLHTerms(ctx context.Context, userId string) (*model.MLHTerms, error) { + //TODO implement me + panic("implement me") +} From b5df043e779cd955ec92a45f23e8cd776b2b256b Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 02:53:14 -0500 Subject: [PATCH 12/29] address update input types for mailing address, mlh terms, and edu info --- graph/generated/generated.go | 224 +++++++++++++++++++++++++++++++++-- graph/model/models_gen.go | 43 +++++-- graph/schema.graphqls | 27 ++++- 3 files changed, 270 insertions(+), 24 deletions(-) diff --git a/graph/generated/generated.go b/graph/generated/generated.go index 6306a53..7d7993f 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -676,8 +676,11 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec := executionContext{rc, e} inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputEducationInfoInput, + ec.unmarshalInputEducationInfoUpdate, ec.unmarshalInputMLHTermsInput, + ec.unmarshalInputMLHTermsUpdate, ec.unmarshalInputMailingAddressInput, + ec.unmarshalInputMailingAddressUpdate, ec.unmarshalInputNewUser, ec.unmarshalInputPronounsInput, ec.unmarshalInputUpdatedUser, @@ -846,6 +849,12 @@ input MLHTermsInput { shareInfo: Boolean! } +input MLHTermsUpdate { + sendMessages: Boolean + codeOfConduct: Boolean + shareInfo: Boolean +} + type MailingAddress { country: String! state: String! @@ -862,6 +871,14 @@ input MailingAddressInput { addressLines: [String!]! } +input MailingAddressUpdate { + country: String + state: String + city: String + postalCode: String + addressLines: [String!] +} + type EducationInfo { name: String! graduationDate: Time! @@ -876,6 +893,13 @@ input EducationInfoInput { level: LevelOfStudy } +input EducationInfoUpdate { + name: String + graduationDate: Time + major: String + level: LevelOfStudy +} + enum LevelOfStudy { FRESHMAN, SOPHOMORE, JUNIOR, SENIOR, SUPER_SENIOR, GRADUATE } @@ -906,11 +930,11 @@ input UpdatedUser { pronouns: PronounsInput age: Int - mailingAddress: MailingAddressInput - mlh: MLHTermsInput + mailingAddress: MailingAddressUpdate + mlh: MLHTermsUpdate shirtSize: ShirtSize yearsOfExperience: Float - educationInfo: EducationInfoInput + educationInfo: EducationInfoUpdate } type LoginPayload { @@ -6760,6 +6784,58 @@ func (ec *executionContext) unmarshalInputEducationInfoInput(ctx context.Context return it, nil } +func (ec *executionContext) unmarshalInputEducationInfoUpdate(ctx context.Context, obj interface{}) (model.EducationInfoUpdate, error) { + var it model.EducationInfoUpdate + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "graduationDate", "major", "level"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "graduationDate": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("graduationDate")) + it.GraduationDate, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + case "major": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("major")) + it.Major, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "level": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("level")) + it.Level, err = ec.unmarshalOLevelOfStudy2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐLevelOfStudy(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputMLHTermsInput(ctx context.Context, obj interface{}) (model.MLHTermsInput, error) { var it model.MLHTermsInput asMap := map[string]interface{}{} @@ -6804,6 +6880,50 @@ func (ec *executionContext) unmarshalInputMLHTermsInput(ctx context.Context, obj return it, nil } +func (ec *executionContext) unmarshalInputMLHTermsUpdate(ctx context.Context, obj interface{}) (model.MLHTermsUpdate, error) { + var it model.MLHTermsUpdate + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"sendMessages", "codeOfConduct", "shareInfo"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "sendMessages": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sendMessages")) + it.SendMessages, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + case "codeOfConduct": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("codeOfConduct")) + it.CodeOfConduct, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + case "shareInfo": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("shareInfo")) + it.ShareInfo, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputMailingAddressInput(ctx context.Context, obj interface{}) (model.MailingAddressInput, error) { var it model.MailingAddressInput asMap := map[string]interface{}{} @@ -6864,6 +6984,66 @@ func (ec *executionContext) unmarshalInputMailingAddressInput(ctx context.Contex return it, nil } +func (ec *executionContext) unmarshalInputMailingAddressUpdate(ctx context.Context, obj interface{}) (model.MailingAddressUpdate, error) { + var it model.MailingAddressUpdate + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"country", "state", "city", "postalCode", "addressLines"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "country": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("country")) + it.Country, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "state": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("state")) + it.State, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "city": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("city")) + it.City, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "postalCode": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("postalCode")) + it.PostalCode, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "addressLines": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressLines")) + it.AddressLines, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputNewUser(ctx context.Context, obj interface{}) (model.NewUser, error) { var it model.NewUser asMap := map[string]interface{}{} @@ -7074,7 +7254,7 @@ func (ec *executionContext) unmarshalInputUpdatedUser(ctx context.Context, obj i var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mailingAddress")) - it.MailingAddress, err = ec.unmarshalOMailingAddressInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMailingAddressInput(ctx, v) + it.MailingAddress, err = ec.unmarshalOMailingAddressUpdate2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMailingAddressUpdate(ctx, v) if err != nil { return it, err } @@ -7082,7 +7262,7 @@ func (ec *executionContext) unmarshalInputUpdatedUser(ctx context.Context, obj i var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mlh")) - it.Mlh, err = ec.unmarshalOMLHTermsInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTermsInput(ctx, v) + it.Mlh, err = ec.unmarshalOMLHTermsUpdate2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTermsUpdate(ctx, v) if err != nil { return it, err } @@ -7106,7 +7286,7 @@ func (ec *executionContext) unmarshalInputUpdatedUser(ctx context.Context, obj i var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("educationInfo")) - it.EducationInfo, err = ec.unmarshalOEducationInfoInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfoInput(ctx, v) + it.EducationInfo, err = ec.unmarshalOEducationInfoUpdate2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfoUpdate(ctx, v) if err != nil { return it, err } @@ -9112,11 +9292,11 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } -func (ec *executionContext) unmarshalOEducationInfoInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfoInput(ctx context.Context, v interface{}) (*model.EducationInfoInput, error) { +func (ec *executionContext) unmarshalOEducationInfoUpdate2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐEducationInfoUpdate(ctx context.Context, v interface{}) (*model.EducationInfoUpdate, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalInputEducationInfoInput(ctx, v) + res, err := ec.unmarshalInputEducationInfoUpdate(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } @@ -9168,11 +9348,11 @@ func (ec *executionContext) marshalOLevelOfStudy2ᚖgithubᚗcomᚋKnightHacks return v } -func (ec *executionContext) unmarshalOMLHTermsInput2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTermsInput(ctx context.Context, v interface{}) (*model.MLHTermsInput, error) { +func (ec *executionContext) unmarshalOMLHTermsUpdate2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMLHTermsUpdate(ctx context.Context, v interface{}) (*model.MLHTermsUpdate, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalInputMLHTermsInput(ctx, v) + res, err := ec.unmarshalInputMLHTermsUpdate(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } @@ -9191,6 +9371,14 @@ func (ec *executionContext) unmarshalOMailingAddressInput2ᚖgithubᚗcomᚋKnig return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalOMailingAddressUpdate2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐMailingAddressUpdate(ctx context.Context, v interface{}) (*model.MailingAddressUpdate, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMailingAddressUpdate(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOPronouns2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐPronouns(ctx context.Context, sel ast.SelectionSet, v *model.Pronouns) graphql.Marshaler { if v == nil { return graphql.Null @@ -9286,6 +9474,22 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as return res } +func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalTime(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalTime(*v) + return res +} + func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/graph/model/models_gen.go b/graph/model/models_gen.go index a83c843..8348291 100644 --- a/graph/model/models_gen.go +++ b/graph/model/models_gen.go @@ -29,6 +29,13 @@ type EducationInfoInput struct { Level *LevelOfStudy `json:"level"` } +type EducationInfoUpdate struct { + Name *string `json:"name"` + GraduationDate *time.Time `json:"graduationDate"` + Major *string `json:"major"` + Level *LevelOfStudy `json:"level"` +} + type LoginPayload struct { // If false then you must register immediately following this. Else, you are logged in and have access to your own user. AccountExists bool `json:"accountExists"` @@ -50,6 +57,12 @@ type MLHTermsInput struct { ShareInfo bool `json:"shareInfo"` } +type MLHTermsUpdate struct { + SendMessages *bool `json:"sendMessages"` + CodeOfConduct *bool `json:"codeOfConduct"` + ShareInfo *bool `json:"shareInfo"` +} + type MailingAddress struct { Country string `json:"country"` State string `json:"state"` @@ -66,6 +79,14 @@ type MailingAddressInput struct { AddressLines []string `json:"addressLines"` } +type MailingAddressUpdate struct { + Country *string `json:"country"` + State *string `json:"state"` + City *string `json:"city"` + PostalCode *string `json:"postalCode"` + AddressLines []string `json:"addressLines"` +} + type NewUser struct { FirstName string `json:"firstName"` LastName string `json:"lastName"` @@ -105,17 +126,17 @@ type RegistrationPayload struct { } type UpdatedUser struct { - FirstName *string `json:"firstName"` - LastName *string `json:"lastName"` - Email *string `json:"email"` - PhoneNumber *string `json:"phoneNumber"` - Pronouns *PronounsInput `json:"pronouns"` - Age *int `json:"age"` - MailingAddress *MailingAddressInput `json:"mailingAddress"` - Mlh *MLHTermsInput `json:"mlh"` - ShirtSize *ShirtSize `json:"shirtSize"` - YearsOfExperience *float64 `json:"yearsOfExperience"` - EducationInfo *EducationInfoInput `json:"educationInfo"` + FirstName *string `json:"firstName"` + LastName *string `json:"lastName"` + Email *string `json:"email"` + PhoneNumber *string `json:"phoneNumber"` + Pronouns *PronounsInput `json:"pronouns"` + Age *int `json:"age"` + MailingAddress *MailingAddressUpdate `json:"mailingAddress"` + Mlh *MLHTermsUpdate `json:"mlh"` + ShirtSize *ShirtSize `json:"shirtSize"` + YearsOfExperience *float64 `json:"yearsOfExperience"` + EducationInfo *EducationInfoUpdate `json:"educationInfo"` } type User struct { diff --git a/graph/schema.graphqls b/graph/schema.graphqls index 639629d..854441c 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -103,6 +103,12 @@ input MLHTermsInput { shareInfo: Boolean! } +input MLHTermsUpdate { + sendMessages: Boolean + codeOfConduct: Boolean + shareInfo: Boolean +} + type MailingAddress { country: String! state: String! @@ -119,6 +125,14 @@ input MailingAddressInput { addressLines: [String!]! } +input MailingAddressUpdate { + country: String + state: String + city: String + postalCode: String + addressLines: [String!] +} + type EducationInfo { name: String! graduationDate: Time! @@ -133,6 +147,13 @@ input EducationInfoInput { level: LevelOfStudy } +input EducationInfoUpdate { + name: String + graduationDate: Time + major: String + level: LevelOfStudy +} + enum LevelOfStudy { FRESHMAN, SOPHOMORE, JUNIOR, SENIOR, SUPER_SENIOR, GRADUATE } @@ -163,11 +184,11 @@ input UpdatedUser { pronouns: PronounsInput age: Int - mailingAddress: MailingAddressInput - mlh: MLHTermsInput + mailingAddress: MailingAddressUpdate + mlh: MLHTermsUpdate shirtSize: ShirtSize yearsOfExperience: Float - educationInfo: EducationInfoInput + educationInfo: EducationInfoUpdate } type LoginPayload { From 52dbc0d85235ea565b1966a08e47c8b875091701 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 02:53:25 -0500 Subject: [PATCH 13/29] more function templating --- repository/repository.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/repository/repository.go b/repository/repository.go index 5bf3009..3d5e264 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -10,6 +10,8 @@ import ( type Repository interface { GetUserByID(ctx context.Context, id string) (*model.User, error) GetUserByOAuthUID(ctx context.Context, oAuthUID string, provider models.Provider) (*model.User, error) + GetUserMailingAddress(ctx context.Context, userId string) (*model.MailingAddress, error) + GetUserMLHTerms(ctx context.Context, userId string) (*model.MLHTerms, error) UpdateUser(ctx context.Context, id string, input *model.UpdatedUser) (*model.User, error) From 78f6f13d82febb9d0e12dccf085bcb9c3e71c060 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 04:06:08 -0500 Subject: [PATCH 14/29] implemented update functions for edu info, mlh terms, mailing address, shirt size, and years of experience --- repository/database/update_user.go | 200 +++++++++++++++++++++++++++-- 1 file changed, 192 insertions(+), 8 deletions(-) diff --git a/repository/database/update_user.go b/repository/database/update_user.go index 6985ab2..ea78a6a 100644 --- a/repository/database/update_user.go +++ b/repository/database/update_user.go @@ -3,6 +3,8 @@ package database import ( "context" "errors" + "fmt" + "github.com/KnightHacks/knighthacks_shared/database" "github.com/KnightHacks/knighthacks_users/graph/model" "github.com/KnightHacks/knighthacks_users/repository" "github.com/jackc/pgx/v4" @@ -22,11 +24,23 @@ $$ | $$ |$$ | $$ |$$ | $$ |$$ __$$ | $$ |$$\ $$ ____| $$ | $$ | \___ \__| */ +// UpdatePronouns(ctx context.Context, id string, pronoun *model.PronounsInput, tx pgx.Tx) error +// func (ctx context.Context, id string, t *T, tx pgx.Tx) type UpdateFunc[T any] func(ctx context.Context, id string, input T, tx pgx.Tx) error -func Validate[T any](ctx context.Context, tx pgx.Tx, id string, input *T, updateFunc UpdateFunc[T]) error { +// Validate Yes, I understand this function is generic hell but there is no other way to do it. +// *any does not work bc when you use *any it passes your generic type into any and not as *any. +// that would make it a double pointer and not a single pointer. +func Validate[T *string | + *float64 | + *model.ShirtSize | + *int | + *model.PronounsInput | + *model.MailingAddressUpdate | + *model.EducationInfoUpdate | + *model.MLHTermsUpdate](ctx context.Context, tx pgx.Tx, id string, input T, updateFunc UpdateFunc[T]) error { if input != nil { - err := updateFunc(ctx, id, *input, tx) + err := updateFunc(ctx, id, input, tx) if err != nil { return err } @@ -57,10 +71,25 @@ func (r *DatabaseRepository) UpdateUser(ctx context.Context, id string, input *m if err = Validate(ctx, tx, id, input.PhoneNumber, r.UpdatePhoneNumber); err != nil { return err } - if err = Validate(ctx, tx, id, &input.Pronouns, r.UpdatePronouns); err != nil { + if err = Validate(ctx, tx, id, input.Pronouns, r.UpdatePronouns); err != nil { return err } - if err = Validate(ctx, tx, id, &input.Age, r.UpdateAge); err != nil { + if err = Validate(ctx, tx, id, input.Age, r.UpdateAge); err != nil { + return err + } + if err = Validate(ctx, tx, id, input.EducationInfo, r.UpdateEducationInfo); err != nil { + return err + } + if err = Validate(ctx, tx, id, input.Mlh, r.UpdateMLHTerms); err != nil { + return err + } + if err = Validate(ctx, tx, id, input.MailingAddress, r.UpdateMailingAddress); err != nil { + return err + } + if err = Validate(ctx, tx, id, input.ShirtSize, r.UpdateShirtSize); err != nil { + return err + } + if err = Validate(ctx, tx, id, input.YearsOfExperience, r.UpdateYearsOfExperience); err != nil { return err } @@ -81,7 +110,7 @@ func (r *DatabaseRepository) UpdateUser(ctx context.Context, id string, input *m } // UpdateFirstName this will update first name -func (r *DatabaseRepository) UpdateFirstName(ctx context.Context, id string, first string, tx pgx.Tx) error { +func (r *DatabaseRepository) UpdateFirstName(ctx context.Context, id string, first *string, tx pgx.Tx) error { commandTag, err := tx.Exec(ctx, "UPDATE users SET first_name = $1 WHERE id = $2", first, id) if err != nil { @@ -94,7 +123,7 @@ func (r *DatabaseRepository) UpdateFirstName(ctx context.Context, id string, fir } // UpdateLastName this function will update last name -func (r *DatabaseRepository) UpdateLastName(ctx context.Context, id string, last string, tx pgx.Tx) error { +func (r *DatabaseRepository) UpdateLastName(ctx context.Context, id string, last *string, tx pgx.Tx) error { commandTag, err := tx.Exec(ctx, "UPDATE users SET last_name = $1 WHERE id = $2", last, id) if err != nil { return err @@ -107,7 +136,7 @@ func (r *DatabaseRepository) UpdateLastName(ctx context.Context, id string, last } // UpdateEmail updates email -func (r *DatabaseRepository) UpdateEmail(ctx context.Context, id string, email string, tx pgx.Tx) error { +func (r *DatabaseRepository) UpdateEmail(ctx context.Context, id string, email *string, tx pgx.Tx) error { commandTag, err := tx.Exec(ctx, "UPDATE users SET email = $1 WHERE id = $2", email, id) if err != nil { return err @@ -120,7 +149,7 @@ func (r *DatabaseRepository) UpdateEmail(ctx context.Context, id string, email s } // UpdatePhoneNumber updates user phone number -func (r *DatabaseRepository) UpdatePhoneNumber(ctx context.Context, id string, number string, tx pgx.Tx) error { +func (r *DatabaseRepository) UpdatePhoneNumber(ctx context.Context, id string, number *string, tx pgx.Tx) error { commandTag, err := tx.Exec(ctx, "UPDATE users SET phone_number = $1 WHERE id = $2", number, id) if err != nil { return err @@ -145,6 +174,161 @@ func (r *DatabaseRepository) UpdateAge(ctx context.Context, id string, age *int, return nil } +// UpdateShirtSize updates shirt size +func (r *DatabaseRepository) UpdateShirtSize(ctx context.Context, id string, shirtSize *model.ShirtSize, tx pgx.Tx) error { + commandTag, err := tx.Exec(ctx, "UPDATE users SET shirt_size = $1 WHERE id = $2", shirtSize.String(), id) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} + +// UpdateYearsOfExperience updates years of experience +func (r *DatabaseRepository) UpdateYearsOfExperience(ctx context.Context, id string, years *float64, tx pgx.Tx) error { + commandTag, err := tx.Exec(ctx, "UPDATE users SET years_of_experience = $1 WHERE id = $2", *years, id) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} + +// UpdateMLHTerms updates user's MLH Terms +func (r *DatabaseRepository) UpdateMLHTerms(ctx context.Context, id string, input *model.MLHTermsUpdate, tx pgx.Tx) error { + var keys []any + var values []any + + if input.CodeOfConduct != nil { + keys = append(keys, "code_of_conduct") + values = append(values, *input.CodeOfConduct) + } + if input.ShareInfo != nil { + keys = append(keys, "share_info") + values = append(values, *input.ShareInfo) + } + if input.SendMessages != nil { + keys = append(keys, "send_messages") + values = append(values, *input.SendMessages) + } + // Extra check to ensure there is something being sent, should never happen + if len(keys) == 0 || len(values) == 0 || len(values) != len(keys) { + return errors.New("something went wrong calculating keys and values for sql") + } + + sql := fmt.Sprintf(`UPDATE mlh_terms SET (%s) = (%s) WHERE user_id = $1`, + database.GeneratePlaceholderNumbers(2, len(keys)+1), + database.GeneratePlaceholderNumbers(len(keys)+2, len(keys)+len(values)+1)) + + combined := append(keys, values...) + + commandTag, err := tx.Exec(ctx, sql, id, combined) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} + +// UpdateEducationInfo updates user's Edu info +func (r *DatabaseRepository) UpdateEducationInfo(ctx context.Context, id string, input *model.EducationInfoUpdate, tx pgx.Tx) error { + var keys []any + var values []any + + if input.Level != nil { + keys = append(keys, "level") + values = append(values, *input.Level) + } + if input.Name != nil { + keys = append(keys, "name") + values = append(values, *input.Name) + } + if input.GraduationDate != nil { + keys = append(keys, "graduation_date") + values = append(values, *input.GraduationDate) + } + if input.Major != nil { + keys = append(keys, "major") + values = append(values, *input.Major) + } + // Extra check to ensure there is something being sent, should never happen + if len(keys) == 0 || len(values) == 0 || len(values) != len(keys) { + return errors.New("something went wrong calculating keys and values for sql") + } + + sql := fmt.Sprintf(`UPDATE education_info SET (%s) = (%s) WHERE user_id = $1`, + database.GeneratePlaceholderNumbers(2, len(keys)+1), + database.GeneratePlaceholderNumbers(len(keys)+2, len(keys)+len(values)+1)) + + combined := append(keys, values...) + + commandTag, err := tx.Exec(ctx, sql, id, combined) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} + +// UpdateMailingAddress updates user's mailing address +func (r *DatabaseRepository) UpdateMailingAddress(ctx context.Context, id string, input *model.MailingAddressUpdate, tx pgx.Tx) error { + var keys []any + var values []any + + if input.Country != nil { + keys = append(keys, "country") + values = append(values, *input.Country) + } + if input.State != nil { + keys = append(keys, "state") + values = append(values, *input.State) + } + if input.City != nil { + keys = append(keys, "city") + values = append(values, *input.City) + } + if input.PostalCode != nil { + keys = append(keys, "postal_code") + values = append(values, *input.PostalCode) + } + if input.AddressLines != nil && len(input.AddressLines) > 0 { + keys = append(keys, "address_lines") + values = append(values, input.AddressLines) + } + // Extra check to ensure there is something being sent, should never happen + if len(keys) == 0 || len(values) == 0 || len(values) != len(keys) { + return errors.New("something went wrong calculating keys and values for sql") + } + + sql := fmt.Sprintf(`UPDATE mailing_addresses SET (%s) = (%s) WHERE user_id = $1`, + database.GeneratePlaceholderNumbers(2, len(keys)+1), + database.GeneratePlaceholderNumbers(len(keys)+2, len(keys)+len(values)+1)) + + combined := append(keys, values...) + + commandTag, err := tx.Exec(ctx, sql, id, combined) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} + // UpdatePronouns updates user Pronouns func (r *DatabaseRepository) UpdatePronouns(ctx context.Context, id string, pronoun *model.PronounsInput, tx pgx.Tx) error { // first find pronouns, if it doesn't exist this will add to database and then update user pronoun in database From f80f9f88536ca7d4dc505390a6e3334cabc7b5a2 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 04:06:20 -0500 Subject: [PATCH 15/29] updated shared --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 42f62c5..6c06c1e 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/99designs/gqlgen v0.17.13 - github.com/KnightHacks/knighthacks_shared v0.0.0-20221029020239-4248bfa6f0dd + github.com/KnightHacks/knighthacks_shared v0.0.0-20221108080447-3d7bd40b913a github.com/gin-gonic/gin v1.8.1 github.com/jackc/pgx/v4 v4.16.1 github.com/vektah/gqlparser/v2 v2.4.7 diff --git a/go.sum b/go.sum index 19e84ed..e99ad68 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/KnightHacks/knighthacks_shared v0.0.0-20221029020239-4248bfa6f0dd h1:y1d0uyNpLbtLjru/ybdfWwmSfz9jDHh9/tk7cDpaGP0= github.com/KnightHacks/knighthacks_shared v0.0.0-20221029020239-4248bfa6f0dd/go.mod h1:W6x/SycHYHMTE51Mo1MZeGQJUTJGME5LF3hdPFdGp4c= +github.com/KnightHacks/knighthacks_shared v0.0.0-20221108080447-3d7bd40b913a h1:R474w9kB/3X1TcgRaboPBy/zO6lL3CRon7g/6g8YFFw= +github.com/KnightHacks/knighthacks_shared v0.0.0-20221108080447-3d7bd40b913a/go.mod h1:W6x/SycHYHMTE51Mo1MZeGQJUTJGME5LF3hdPFdGp4c= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= From 91f84c61930cf75f29fb836e0b62d9c5388e262e Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Tue, 8 Nov 2022 16:36:45 -0500 Subject: [PATCH 16/29] added gender, race, shirtSize, and yearsOfExperience to all CRUD operations on user --- go.sum | 2 - graph/generated/generated.go | 266 ++++++++++++++++++++- graph/model/models_gen.go | 6 + graph/schema.graphqls | 8 +- repository/database/create_user.go | 6 +- repository/database/database_repository.go | 29 --- repository/database/get_user.go | 8 +- repository/database/update_user.go | 66 ++++- 8 files changed, 350 insertions(+), 41 deletions(-) diff --git a/go.sum b/go.sum index e99ad68..14a8bf8 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ github.com/99designs/gqlgen v0.17.13 h1:ETUEqvRg5Zvr1lXtpoRdj026fzVay0ZlJPwI33qX github.com/99designs/gqlgen v0.17.13/go.mod h1:w1brbeOdqVyNJI553BGwtwdVcYu1LKeYE1opLWN9RgQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/KnightHacks/knighthacks_shared v0.0.0-20221029020239-4248bfa6f0dd h1:y1d0uyNpLbtLjru/ybdfWwmSfz9jDHh9/tk7cDpaGP0= -github.com/KnightHacks/knighthacks_shared v0.0.0-20221029020239-4248bfa6f0dd/go.mod h1:W6x/SycHYHMTE51Mo1MZeGQJUTJGME5LF3hdPFdGp4c= github.com/KnightHacks/knighthacks_shared v0.0.0-20221108080447-3d7bd40b913a h1:R474w9kB/3X1TcgRaboPBy/zO6lL3CRon7g/6g8YFFw= github.com/KnightHacks/knighthacks_shared v0.0.0-20221108080447-3d7bd40b913a/go.mod h1:W6x/SycHYHMTE51Mo1MZeGQJUTJGME5LF3hdPFdGp4c= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= diff --git a/graph/generated/generated.go b/graph/generated/generated.go index 7d7993f..b8f6019 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -130,6 +130,7 @@ type ComplexityRoot struct { Email func(childComplexity int) int FirstName func(childComplexity int) int FullName func(childComplexity int) int + Gender func(childComplexity int) int ID func(childComplexity int) int LastName func(childComplexity int) int MailingAddress func(childComplexity int) int @@ -137,6 +138,7 @@ type ComplexityRoot struct { OAuth func(childComplexity int) int PhoneNumber func(childComplexity int) int Pronouns func(childComplexity int) int + Race func(childComplexity int) int Role func(childComplexity int) int ShirtSize func(childComplexity int) int YearsOfExperience func(childComplexity int) int @@ -569,6 +571,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.FullName(childComplexity), true + case "User.gender": + if e.complexity.User.Gender == nil { + break + } + + return e.complexity.User.Gender(childComplexity), true + case "User.id": if e.complexity.User.ID == nil { break @@ -618,6 +627,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Pronouns(childComplexity), true + case "User.race": + if e.complexity.User.Race == nil { + break + } + + return e.complexity.User.Race(childComplexity), true + case "User.role": if e.complexity.User.Role == nil { break @@ -793,6 +809,9 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { age: Int @hasRole(role: OWNS) role: Role! @hasRole(role: OWNS) + gender: String @hasRole(role: OWNS) + race: [String] @hasRole(role: OWNS) + oAuth: OAuth! @goField(forceResolver: true) @hasRole(role: OWNS) mailingAddress: MailingAddress @goField(forceResolver: true) @hasRole(role: OWNS) @@ -920,6 +939,8 @@ input NewUser { shirtSize: ShirtSize! yearsOfExperience: Float educationInfo: EducationInfoInput! + gender: String + race: [String] } input UpdatedUser { @@ -929,12 +950,13 @@ input UpdatedUser { phoneNumber: String pronouns: PronounsInput age: Int - mailingAddress: MailingAddressUpdate mlh: MLHTermsUpdate shirtSize: ShirtSize yearsOfExperience: Float educationInfo: EducationInfoUpdate + gender: String + race: [String] } type LoginPayload { @@ -1582,6 +1604,10 @@ func (ec *executionContext) fieldContext_Entity_findUserByID(ctx context.Context return ec.fieldContext_User_age(ctx, field) case "role": return ec.fieldContext_User_role(ctx, field) + case "gender": + return ec.fieldContext_User_gender(ctx, field) + case "race": + return ec.fieldContext_User_race(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) case "mailingAddress": @@ -1669,6 +1695,10 @@ func (ec *executionContext) fieldContext_Entity_findUserByOAuthUIDAndOAuthProvid return ec.fieldContext_User_age(ctx, field) case "role": return ec.fieldContext_User_role(ctx, field) + case "gender": + return ec.fieldContext_User_gender(ctx, field) + case "race": + return ec.fieldContext_User_race(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) case "mailingAddress": @@ -1797,6 +1827,10 @@ func (ec *executionContext) fieldContext_LoginPayload_user(ctx context.Context, return ec.fieldContext_User_age(ctx, field) case "role": return ec.fieldContext_User_role(ctx, field) + case "gender": + return ec.fieldContext_User_gender(ctx, field) + case "race": + return ec.fieldContext_User_race(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) case "mailingAddress": @@ -2435,6 +2469,10 @@ func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context return ec.fieldContext_User_age(ctx, field) case "role": return ec.fieldContext_User_role(ctx, field) + case "gender": + return ec.fieldContext_User_gender(ctx, field) + case "race": + return ec.fieldContext_User_race(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) case "mailingAddress": @@ -3184,6 +3222,10 @@ func (ec *executionContext) fieldContext_Query_getUser(ctx context.Context, fiel return ec.fieldContext_User_age(ctx, field) case "role": return ec.fieldContext_User_role(ctx, field) + case "gender": + return ec.fieldContext_User_gender(ctx, field) + case "race": + return ec.fieldContext_User_race(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) case "mailingAddress": @@ -3295,6 +3337,10 @@ func (ec *executionContext) fieldContext_Query_searchUser(ctx context.Context, f return ec.fieldContext_User_age(ctx, field) case "role": return ec.fieldContext_User_role(ctx, field) + case "gender": + return ec.fieldContext_User_gender(ctx, field) + case "race": + return ec.fieldContext_User_race(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) case "mailingAddress": @@ -3403,6 +3449,10 @@ func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field gra return ec.fieldContext_User_age(ctx, field) case "role": return ec.fieldContext_User_role(ctx, field) + case "gender": + return ec.fieldContext_User_gender(ctx, field) + case "race": + return ec.fieldContext_User_race(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) case "mailingAddress": @@ -3711,6 +3761,10 @@ func (ec *executionContext) fieldContext_RegistrationPayload_user(ctx context.Co return ec.fieldContext_User_age(ctx, field) case "role": return ec.fieldContext_User_role(ctx, field) + case "gender": + return ec.fieldContext_User_gender(ctx, field) + case "race": + return ec.fieldContext_User_race(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) case "mailingAddress": @@ -4310,6 +4364,136 @@ func (ec *executionContext) fieldContext_User_role(ctx context.Context, field gr return fc, nil } +func (ec *executionContext) _User_gender(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_gender(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Gender, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, obj, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_gender(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_race(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_race(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Race, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, obj, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*string`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*string) + fc.Result = res + return ec.marshalOString2ᚕᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_race(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _User_oAuth(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { fc, err := ec.fieldContext_User_oAuth(ctx, field) if err != nil { @@ -4899,6 +5083,10 @@ func (ec *executionContext) fieldContext_UsersConnection_users(ctx context.Conte return ec.fieldContext_User_age(ctx, field) case "role": return ec.fieldContext_User_role(ctx, field) + case "gender": + return ec.fieldContext_User_gender(ctx, field) + case "race": + return ec.fieldContext_User_race(ctx, field) case "oAuth": return ec.fieldContext_User_oAuth(ctx, field) case "mailingAddress": @@ -7051,7 +7239,7 @@ func (ec *executionContext) unmarshalInputNewUser(ctx context.Context, obj inter asMap[k] = v } - fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age", "mailingAddress", "mlh", "shirtSize", "yearsOfExperience", "educationInfo"} + fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age", "mailingAddress", "mlh", "shirtSize", "yearsOfExperience", "educationInfo", "gender", "race"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -7146,6 +7334,22 @@ func (ec *executionContext) unmarshalInputNewUser(ctx context.Context, obj inter if err != nil { return it, err } + case "gender": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gender")) + it.Gender, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "race": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("race")) + it.Race, err = ec.unmarshalOString2ᚕᚖstring(ctx, v) + if err != nil { + return it, err + } } } @@ -7195,7 +7399,7 @@ func (ec *executionContext) unmarshalInputUpdatedUser(ctx context.Context, obj i asMap[k] = v } - fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age", "mailingAddress", "mlh", "shirtSize", "yearsOfExperience", "educationInfo"} + fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age", "mailingAddress", "mlh", "shirtSize", "yearsOfExperience", "educationInfo", "gender", "race"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -7290,6 +7494,22 @@ func (ec *executionContext) unmarshalInputUpdatedUser(ctx context.Context, obj i if err != nil { return it, err } + case "gender": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gender")) + it.Gender, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "race": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("race")) + it.Race, err = ec.unmarshalOString2ᚕᚖstring(ctx, v) + if err != nil { + return it, err + } } } @@ -8127,6 +8347,14 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } + case "gender": + + out.Values[i] = ec._User_gender(ctx, field, obj) + + case "race": + + out.Values[i] = ec._User_race(ctx, field, obj) + case "oAuth": field := field @@ -9458,6 +9686,38 @@ func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel return ret } +func (ec *executionContext) unmarshalOString2ᚕᚖstring(ctx context.Context, v interface{}) ([]*string, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOString2ᚖstring(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOString2ᚕᚖstring(ctx context.Context, sel ast.SelectionSet, v []*string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalOString2ᚖstring(ctx, sel, v[i]) + } + + return ret +} + func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil diff --git a/graph/model/models_gen.go b/graph/model/models_gen.go index 8348291..41a8933 100644 --- a/graph/model/models_gen.go +++ b/graph/model/models_gen.go @@ -99,6 +99,8 @@ type NewUser struct { ShirtSize ShirtSize `json:"shirtSize"` YearsOfExperience *float64 `json:"yearsOfExperience"` EducationInfo *EducationInfoInput `json:"educationInfo"` + Gender *string `json:"gender"` + Race []*string `json:"race"` } type OAuth struct { @@ -137,6 +139,8 @@ type UpdatedUser struct { ShirtSize *ShirtSize `json:"shirtSize"` YearsOfExperience *float64 `json:"yearsOfExperience"` EducationInfo *EducationInfoUpdate `json:"educationInfo"` + Gender *string `json:"gender"` + Race []*string `json:"race"` } type User struct { @@ -149,6 +153,8 @@ type User struct { Pronouns *Pronouns `json:"pronouns"` Age *int `json:"age"` Role models.Role `json:"role"` + Gender *string `json:"gender"` + Race []*string `json:"race"` OAuth *OAuth `json:"oAuth"` MailingAddress *MailingAddress `json:"mailingAddress"` Mlh *MLHTerms `json:"mlh"` diff --git a/graph/schema.graphqls b/graph/schema.graphqls index 854441c..1528123 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -47,6 +47,9 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { age: Int @hasRole(role: OWNS) role: Role! @hasRole(role: OWNS) + gender: String @hasRole(role: OWNS) + race: [String] @hasRole(role: OWNS) + oAuth: OAuth! @goField(forceResolver: true) @hasRole(role: OWNS) mailingAddress: MailingAddress @goField(forceResolver: true) @hasRole(role: OWNS) @@ -174,6 +177,8 @@ input NewUser { shirtSize: ShirtSize! yearsOfExperience: Float educationInfo: EducationInfoInput! + gender: String + race: [String] } input UpdatedUser { @@ -183,12 +188,13 @@ input UpdatedUser { phoneNumber: String pronouns: PronounsInput age: Int - mailingAddress: MailingAddressUpdate mlh: MLHTermsUpdate shirtSize: ShirtSize yearsOfExperience: Float educationInfo: EducationInfoUpdate + gender: String + race: [String] } type LoginPayload { diff --git a/repository/database/create_user.go b/repository/database/create_user.go index 25d3ee1..59837e4 100644 --- a/repository/database/create_user.go +++ b/repository/database/create_user.go @@ -90,7 +90,7 @@ func (r *DatabaseRepository) InsertUser(ctx context.Context, queryable database. // TODO: Possibly change ID type to int to stop this hacky fix? // insert user into database and return their ID var userIdInt int - err := queryable.QueryRow(ctx, "INSERT INTO users (first_name, last_name, email, phone_number, age, pronoun_id, oauth_uid, oauth_provider, role) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id", + err := queryable.QueryRow(ctx, "INSERT INTO users (first_name, last_name, email, phone_number, age, pronoun_id, oauth_uid, oauth_provider, role,years_of_experience, shirt_size, race, gender) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING id", input.FirstName, input.LastName, input.Email, @@ -100,6 +100,10 @@ func (r *DatabaseRepository) InsertUser(ctx context.Context, queryable database. oAuth.UID, oAuth.Provider.String(), sharedModels.RoleNormal, + input.YearsOfExperience, + input.ShirtSize, + input.Race, + input.Gender, ).Scan(&userIdInt) return userIdInt, err } diff --git a/repository/database/database_repository.go b/repository/database/database_repository.go index d899a6a..c8c4177 100644 --- a/repository/database/database_repository.go +++ b/repository/database/database_repository.go @@ -5,7 +5,6 @@ import ( "github.com/KnightHacks/knighthacks_users/graph/model" "github.com/KnightHacks/knighthacks_users/repository" "github.com/jackc/pgx/v4/pgxpool" - "strconv" ) // DatabaseRepository @@ -45,31 +44,3 @@ func (r *DatabaseRepository) DeleteUser(ctx context.Context, id string) (bool, e // then no error return true, nil } - -type Scannable interface { - Scan(dest ...interface{}) error -} - -func ScanUser[T Scannable](user *model.User, scannable T) (*int, error) { - var pronounId *int32 - var userIdInt int - err := scannable.Scan( - &userIdInt, - &user.FirstName, - &user.LastName, - &user.Email, - &user.PhoneNumber, - &pronounId, - &user.Age, - &user.Role, - ) - if err != nil { - return nil, err - } - user.ID = strconv.Itoa(userIdInt) - if pronounId != nil { - i := int(*pronounId) - return &i, nil - } - return nil, nil -} diff --git a/repository/database/get_user.go b/repository/database/get_user.go index 42fbc7e..435aa4a 100644 --- a/repository/database/get_user.go +++ b/repository/database/get_user.go @@ -26,7 +26,7 @@ func (r *DatabaseRepository) GetUsers(ctx context.Context, first int, after stri err := r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { rows, err := tx.Query( ctx, - "SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE id > $1 ORDER BY `id` DESC LIMIT $2", + "SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role, gender, race FROM users WHERE id > $1 ORDER BY `id` DESC LIMIT $2", after, first, ) @@ -67,7 +67,7 @@ func (r *DatabaseRepository) GetUsers(ctx context.Context, first int, after stri func (r *DatabaseRepository) GetUserByID(ctx context.Context, id string) (*model.User, error) { return r.getUser( ctx, - `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE id = $1 LIMIT 1`, + `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role, gender, race FROM users WHERE id = $1 LIMIT 1`, id, ) } @@ -76,7 +76,7 @@ func (r *DatabaseRepository) GetUserByID(ctx context.Context, id string) (*model func (r *DatabaseRepository) GetUserByOAuthUID(ctx context.Context, oAuthUID string, provider sharedModels.Provider) (*model.User, error) { return r.getUser( ctx, - `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE oauth_uid=cast($1 as varchar) AND oauth_provider=$2 LIMIT 1`, + `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role, gender, race FROM users WHERE oauth_uid=cast($1 as varchar) AND oauth_provider=$2 LIMIT 1`, oAuthUID, provider, ) @@ -121,7 +121,7 @@ func (r *DatabaseRepository) SearchUser(ctx context.Context, name string) ([]*mo users := make([]*model.User, 0, limit) err := r.DatabasePool.BeginTxFunc(ctx, pgx.TxOptions{}, func(tx pgx.Tx) error { - rows, err := tx.Query(ctx, "SELECT * from users WHERE to_tsvector(first_name || ' ' || last_name) @@ to_tsquery('$1:*') LIMIT $2", name, limit) + rows, err := tx.Query(ctx, "SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role, gender, race from users WHERE to_tsvector(first_name || ' ' || last_name) @@ to_tsquery('$1:*') LIMIT $2", name, limit) if err != nil { return err } diff --git a/repository/database/update_user.go b/repository/database/update_user.go index ea78a6a..280a0db 100644 --- a/repository/database/update_user.go +++ b/repository/database/update_user.go @@ -8,6 +8,7 @@ import ( "github.com/KnightHacks/knighthacks_users/graph/model" "github.com/KnightHacks/knighthacks_users/repository" "github.com/jackc/pgx/v4" + "strconv" ) /* @@ -35,6 +36,7 @@ func Validate[T *string | *float64 | *model.ShirtSize | *int | + []*string | *model.PronounsInput | *model.MailingAddressUpdate | *model.EducationInfoUpdate | @@ -89,12 +91,18 @@ func (r *DatabaseRepository) UpdateUser(ctx context.Context, id string, input *m if err = Validate(ctx, tx, id, input.ShirtSize, r.UpdateShirtSize); err != nil { return err } + if err = Validate(ctx, tx, id, input.Gender, r.UpdateGender); err != nil { + return err + } + if err = Validate(ctx, tx, id, input.Race, r.UpdateRace); err != nil { + return err + } if err = Validate(ctx, tx, id, input.YearsOfExperience, r.UpdateYearsOfExperience); err != nil { return err } user, err = r.getUserWithTx(ctx, - `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role FROM users WHERE id = $1 LIMIT 1`, + `SELECT id, first_name, last_name, email, phone_number, pronoun_id, age, role, gender, race FROM users WHERE id = $1 LIMIT 1`, tx, id) @@ -200,6 +208,32 @@ func (r *DatabaseRepository) UpdateYearsOfExperience(ctx context.Context, id str return nil } +// UpdateRace updates race +func (r *DatabaseRepository) UpdateRace(ctx context.Context, id string, race []*string, tx pgx.Tx) error { + commandTag, err := tx.Exec(ctx, "UPDATE users SET race = $1 WHERE id = $2", race, id) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} + +// UpdateGender updates gender +func (r *DatabaseRepository) UpdateGender(ctx context.Context, id string, gender *string, tx pgx.Tx) error { + commandTag, err := tx.Exec(ctx, "UPDATE users SET gender = $1 WHERE id = $2", *gender, id) + if err != nil { + return err + } + if commandTag.RowsAffected() != 1 { + return repository.UserNotFound + } + // then no error + return nil +} + // UpdateMLHTerms updates user's MLH Terms func (r *DatabaseRepository) UpdateMLHTerms(ctx context.Context, id string, input *model.MLHTermsUpdate, tx pgx.Tx) error { var keys []any @@ -380,3 +414,33 @@ func (r *DatabaseRepository) UpdatePronouns(ctx context.Context, id string, pron // then no error return nil } + +type Scannable interface { + Scan(dest ...interface{}) error +} + +func ScanUser[T Scannable](user *model.User, scannable T) (*int, error) { + var pronounId *int32 + var userIdInt int + err := scannable.Scan( + &userIdInt, + &user.FirstName, + &user.LastName, + &user.Email, + &user.PhoneNumber, + &pronounId, + &user.Age, + &user.Role, + &user.Gender, + &user.Race, + ) + if err != nil { + return nil, err + } + user.ID = strconv.Itoa(userIdInt) + if pronounId != nil { + i := int(*pronounId) + return &i, nil + } + return nil, nil +} From f38ad84974f5515e525e9e6449ca3b7c5e0fbe21 Mon Sep 17 00:00:00 2001 From: Jack Carson Date: Wed, 9 Nov 2022 19:29:28 -0500 Subject: [PATCH 17/29] Implemeted GetUserMLHTerms --- repository/database/get_user.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/repository/database/get_user.go b/repository/database/get_user.go index 435aa4a..d190dd4 100644 --- a/repository/database/get_user.go +++ b/repository/database/get_user.go @@ -3,6 +3,7 @@ package database import ( "context" "errors" + sharedModels "github.com/KnightHacks/knighthacks_shared/models" "github.com/KnightHacks/knighthacks_users/graph/model" "github.com/KnightHacks/knighthacks_users/repository" @@ -165,7 +166,16 @@ func (r *DatabaseRepository) GetUserMailingAddress(ctx context.Context, userId s panic("implement me") } +// GetUserMLHTerms returns the SQL fields (listed inside the function below) from the mlh_terms table +// Var mlhTerms is returning a result from the inputted SQL selection from the mlh_terms table +// The SQL function in err is selecting all of the boolean values to process our search request +// return &mlhTerms delivers the result to the user func (r *DatabaseRepository) GetUserMLHTerms(ctx context.Context, userId string) (*model.MLHTerms, error) { - //TODO implement me - panic("implement me") + var mlhTerms model.MLHTerms + err := r.DatabasePool.QueryRow(ctx, "SELECT send_messages, share_info, code_of_conduct FROM mlh_terms WHERE user_id = $1", userId).Scan(&mlhTerms.SendMessages, &mlhTerms.ShareInfo, &mlhTerms.CodeOfConduct) + if err != nil { + return nil, err + } + return &mlhTerms, err + } From 81c44420d90721ec6548eedd8b2250efa38b443e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Nov 2022 21:09:39 -0500 Subject: [PATCH 18/29] Implemented a function to get the data for a mailing address --- repository/database/get_user.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/repository/database/get_user.go b/repository/database/get_user.go index d190dd4..602fd86 100644 --- a/repository/database/get_user.go +++ b/repository/database/get_user.go @@ -162,8 +162,12 @@ func (r *DatabaseRepository) GetOAuth(ctx context.Context, id string) (*model.OA } func (r *DatabaseRepository) GetUserMailingAddress(ctx context.Context, userId string) (*model.MailingAddress, error) { - //TODO implement me - panic("implement me") + var mailingAddress model.MailingAddress + err := r.DatabasePool.QueryRow(ctx, "SELECT country, state, city, postal_code, address_lines FROM users WHERE user_id = $1", userId).Scan(&mailingAddress.Country, &mailingAddress.State, &mailingAddress.City, &mailingAddress.PostalCode, &mailingAddress.AddressLines) + if (err != nil) { + return nil, err + } + return &mailingAddress, nil } // GetUserMLHTerms returns the SQL fields (listed inside the function below) from the mlh_terms table @@ -178,4 +182,4 @@ func (r *DatabaseRepository) GetUserMLHTerms(ctx context.Context, userId string) } return &mlhTerms, err -} +} \ No newline at end of file From fcebbed076a6018f8338805c57c0152106977e90 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Nov 2022 21:13:31 -0500 Subject: [PATCH 19/29] Added a few comments --- repository/database/get_user.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/repository/database/get_user.go b/repository/database/get_user.go index 602fd86..637d49c 100644 --- a/repository/database/get_user.go +++ b/repository/database/get_user.go @@ -161,6 +161,8 @@ func (r *DatabaseRepository) GetOAuth(ctx context.Context, id string) (*model.OA return &oAuth, err } +// GetUserMailingAddress get the mailing address of the user specified by a userID. +// Uses SQL command to extract all parts of the data for mailing address. func (r *DatabaseRepository) GetUserMailingAddress(ctx context.Context, userId string) (*model.MailingAddress, error) { var mailingAddress model.MailingAddress err := r.DatabasePool.QueryRow(ctx, "SELECT country, state, city, postal_code, address_lines FROM users WHERE user_id = $1", userId).Scan(&mailingAddress.Country, &mailingAddress.State, &mailingAddress.City, &mailingAddress.PostalCode, &mailingAddress.AddressLines) From 792189db8385ccc0115f24b345db4b1137ca4b4f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Nov 2022 22:51:18 -0500 Subject: [PATCH 20/29] Changed SQL table reference --- repository/database/get_user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repository/database/get_user.go b/repository/database/get_user.go index 637d49c..d459c83 100644 --- a/repository/database/get_user.go +++ b/repository/database/get_user.go @@ -165,7 +165,7 @@ func (r *DatabaseRepository) GetOAuth(ctx context.Context, id string) (*model.OA // Uses SQL command to extract all parts of the data for mailing address. func (r *DatabaseRepository) GetUserMailingAddress(ctx context.Context, userId string) (*model.MailingAddress, error) { var mailingAddress model.MailingAddress - err := r.DatabasePool.QueryRow(ctx, "SELECT country, state, city, postal_code, address_lines FROM users WHERE user_id = $1", userId).Scan(&mailingAddress.Country, &mailingAddress.State, &mailingAddress.City, &mailingAddress.PostalCode, &mailingAddress.AddressLines) + err := r.DatabasePool.QueryRow(ctx, "SELECT country, state, city, postal_code, address_lines FROM mailing_addresses WHERE user_id = $1", userId).Scan(&mailingAddress.Country, &mailingAddress.State, &mailingAddress.City, &mailingAddress.PostalCode, &mailingAddress.AddressLines) if (err != nil) { return nil, err } From 1a4eb6383096a907c2e740eacbdcc7fd9642f750 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Sun, 20 Nov 2022 12:26:07 -0500 Subject: [PATCH 21/29] code reformat --- repository/database/get_user.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/repository/database/get_user.go b/repository/database/get_user.go index d459c83..fd9b0a3 100644 --- a/repository/database/get_user.go +++ b/repository/database/get_user.go @@ -165,8 +165,14 @@ func (r *DatabaseRepository) GetOAuth(ctx context.Context, id string) (*model.OA // Uses SQL command to extract all parts of the data for mailing address. func (r *DatabaseRepository) GetUserMailingAddress(ctx context.Context, userId string) (*model.MailingAddress, error) { var mailingAddress model.MailingAddress - err := r.DatabasePool.QueryRow(ctx, "SELECT country, state, city, postal_code, address_lines FROM mailing_addresses WHERE user_id = $1", userId).Scan(&mailingAddress.Country, &mailingAddress.State, &mailingAddress.City, &mailingAddress.PostalCode, &mailingAddress.AddressLines) - if (err != nil) { + err := r.DatabasePool.QueryRow(ctx, "SELECT country, state, city, postal_code, address_lines FROM mailing_addresses WHERE user_id = $1", userId).Scan( + &mailingAddress.Country, + &mailingAddress.State, + &mailingAddress.City, + &mailingAddress.PostalCode, + &mailingAddress.AddressLines, + ) + if err != nil { return nil, err } return &mailingAddress, nil @@ -178,10 +184,14 @@ func (r *DatabaseRepository) GetUserMailingAddress(ctx context.Context, userId s // return &mlhTerms delivers the result to the user func (r *DatabaseRepository) GetUserMLHTerms(ctx context.Context, userId string) (*model.MLHTerms, error) { var mlhTerms model.MLHTerms - err := r.DatabasePool.QueryRow(ctx, "SELECT send_messages, share_info, code_of_conduct FROM mlh_terms WHERE user_id = $1", userId).Scan(&mlhTerms.SendMessages, &mlhTerms.ShareInfo, &mlhTerms.CodeOfConduct) + err := r.DatabasePool.QueryRow(ctx, "SELECT send_messages, share_info, code_of_conduct FROM mlh_terms WHERE user_id = $1", userId).Scan( + &mlhTerms.SendMessages, + &mlhTerms.ShareInfo, + &mlhTerms.CodeOfConduct, + ) if err != nil { return nil, err } return &mlhTerms, err -} \ No newline at end of file +} From 69a42e5d6445036807ff5b00608db332d8c9f477 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Sun, 20 Nov 2022 12:27:24 -0500 Subject: [PATCH 22/29] added Race to schema --- graph/generated/generated.go | 137 ++++++++++++++++++++++++----------- graph/model/models_gen.go | 53 +++++++++++++- graph/schema.graphqls | 14 +++- 3 files changed, 156 insertions(+), 48 deletions(-) diff --git a/graph/generated/generated.go b/graph/generated/generated.go index b8f6019..7f49787 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -797,6 +797,14 @@ type UsersConnection implements Connection { users: [User!]! } +enum Race { + AFRICAN_AMERICAN + ASIAN_PACIFIC_ISLANDER + CAUCASIAN + LATINO + PREFER +} + type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { id: ID! firstName: String! @@ -810,7 +818,7 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { role: Role! @hasRole(role: OWNS) gender: String @hasRole(role: OWNS) - race: [String] @hasRole(role: OWNS) + race: [Race!] @hasRole(role: OWNS) oAuth: OAuth! @goField(forceResolver: true) @hasRole(role: OWNS) @@ -940,7 +948,7 @@ input NewUser { yearsOfExperience: Float educationInfo: EducationInfoInput! gender: String - race: [String] + race: [Race!] } input UpdatedUser { @@ -956,7 +964,7 @@ input UpdatedUser { yearsOfExperience: Float educationInfo: EducationInfoUpdate gender: String - race: [String] + race: [Race!] } type LoginPayload { @@ -4464,10 +4472,10 @@ func (ec *executionContext) _User_race(ctx context.Context, field graphql.Collec if tmp == nil { return nil, nil } - if data, ok := tmp.([]*string); ok { + if data, ok := tmp.([]model.Race); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*string`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be []github.com/KnightHacks/knighthacks_users/graph/model.Race`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -4476,9 +4484,9 @@ func (ec *executionContext) _User_race(ctx context.Context, field graphql.Collec if resTmp == nil { return graphql.Null } - res := resTmp.([]*string) + res := resTmp.([]model.Race) fc.Result = res - return ec.marshalOString2ᚕᚖstring(ctx, field.Selections, res) + return ec.marshalORace2ᚕgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRaceᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_User_race(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4488,7 +4496,7 @@ func (ec *executionContext) fieldContext_User_race(ctx context.Context, field gr IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Race does not have child fields") }, } return fc, nil @@ -7346,7 +7354,7 @@ func (ec *executionContext) unmarshalInputNewUser(ctx context.Context, obj inter var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("race")) - it.Race, err = ec.unmarshalOString2ᚕᚖstring(ctx, v) + it.Race, err = ec.unmarshalORace2ᚕgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRaceᚄ(ctx, v) if err != nil { return it, err } @@ -7506,7 +7514,7 @@ func (ec *executionContext) unmarshalInputUpdatedUser(ctx context.Context, obj i var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("race")) - it.Race, err = ec.unmarshalOString2ᚕᚖstring(ctx, v) + it.Race, err = ec.unmarshalORace2ᚕgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRaceᚄ(ctx, v) if err != nil { return it, err } @@ -8958,6 +8966,16 @@ func (ec *executionContext) marshalNProvider2githubᚗcomᚋKnightHacksᚋknight return v } +func (ec *executionContext) unmarshalNRace2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRace(ctx context.Context, v interface{}) (model.Race, error) { + var res model.Race + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNRace2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRace(ctx context.Context, sel ast.SelectionSet, v model.Race) graphql.Marshaler { + return v +} + func (ec *executionContext) marshalNRegistrationPayload2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRegistrationPayload(ctx context.Context, sel ast.SelectionSet, v model.RegistrationPayload) graphql.Marshaler { return ec._RegistrationPayload(ctx, sel, &v) } @@ -9622,6 +9640,73 @@ func (ec *executionContext) unmarshalOPronounsInput2ᚖgithubᚗcomᚋKnightHack return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalORace2ᚕgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRaceᚄ(ctx context.Context, v interface{}) ([]model.Race, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]model.Race, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNRace2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRace(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalORace2ᚕgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRaceᚄ(ctx context.Context, sel ast.SelectionSet, v []model.Race) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNRace2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐRace(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + func (ec *executionContext) unmarshalOShirtSize2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐShirtSize(ctx context.Context, v interface{}) (*model.ShirtSize, error) { if v == nil { return nil, nil @@ -9686,38 +9771,6 @@ func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel return ret } -func (ec *executionContext) unmarshalOString2ᚕᚖstring(ctx context.Context, v interface{}) ([]*string, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]*string, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalOString2ᚖstring(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOString2ᚕᚖstring(ctx context.Context, sel ast.SelectionSet, v []*string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalOString2ᚖstring(ctx, sel, v[i]) - } - - return ret -} - func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil diff --git a/graph/model/models_gen.go b/graph/model/models_gen.go index 41a8933..f7e6fc6 100644 --- a/graph/model/models_gen.go +++ b/graph/model/models_gen.go @@ -100,7 +100,7 @@ type NewUser struct { YearsOfExperience *float64 `json:"yearsOfExperience"` EducationInfo *EducationInfoInput `json:"educationInfo"` Gender *string `json:"gender"` - Race []*string `json:"race"` + Race []Race `json:"race"` } type OAuth struct { @@ -140,7 +140,7 @@ type UpdatedUser struct { YearsOfExperience *float64 `json:"yearsOfExperience"` EducationInfo *EducationInfoUpdate `json:"educationInfo"` Gender *string `json:"gender"` - Race []*string `json:"race"` + Race []Race `json:"race"` } type User struct { @@ -154,7 +154,7 @@ type User struct { Age *int `json:"age"` Role models.Role `json:"role"` Gender *string `json:"gender"` - Race []*string `json:"race"` + Race []Race `json:"race"` OAuth *OAuth `json:"oAuth"` MailingAddress *MailingAddress `json:"mailingAddress"` Mlh *MLHTerms `json:"mlh"` @@ -222,6 +222,53 @@ func (e LevelOfStudy) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +type Race string + +const ( + RaceAfricanAmerican Race = "AFRICAN_AMERICAN" + RaceAsianPacificIslander Race = "ASIAN_PACIFIC_ISLANDER" + RaceCaucasian Race = "CAUCASIAN" + RaceLatino Race = "LATINO" + RacePrefer Race = "PREFER" +) + +var AllRace = []Race{ + RaceAfricanAmerican, + RaceAsianPacificIslander, + RaceCaucasian, + RaceLatino, + RacePrefer, +} + +func (e Race) IsValid() bool { + switch e { + case RaceAfricanAmerican, RaceAsianPacificIslander, RaceCaucasian, RaceLatino, RacePrefer: + return true + } + return false +} + +func (e Race) String() string { + return string(e) +} + +func (e *Race) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = Race(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid Race", str) + } + return nil +} + +func (e Race) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + type ShirtSize string const ( diff --git a/graph/schema.graphqls b/graph/schema.graphqls index 1528123..8f59903 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -35,6 +35,14 @@ type UsersConnection implements Connection { users: [User!]! } +enum Race { + AFRICAN_AMERICAN + ASIAN_PACIFIC_ISLANDER + CAUCASIAN + LATINO + PREFER +} + type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { id: ID! firstName: String! @@ -48,7 +56,7 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { role: Role! @hasRole(role: OWNS) gender: String @hasRole(role: OWNS) - race: [String] @hasRole(role: OWNS) + race: [Race!] @hasRole(role: OWNS) oAuth: OAuth! @goField(forceResolver: true) @hasRole(role: OWNS) @@ -178,7 +186,7 @@ input NewUser { yearsOfExperience: Float educationInfo: EducationInfoInput! gender: String - race: [String] + race: [Race!] } input UpdatedUser { @@ -194,7 +202,7 @@ input UpdatedUser { yearsOfExperience: Float educationInfo: EducationInfoUpdate gender: String - race: [String] + race: [Race!] } type LoginPayload { From a5f5ca758942c41500687d000a1d6e5f197cf878 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Sun, 20 Nov 2022 12:29:24 -0500 Subject: [PATCH 23/29] implemented Race into InsertUser --- repository/database/create_user.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/repository/database/create_user.go b/repository/database/create_user.go index 59837e4..bffb278 100644 --- a/repository/database/create_user.go +++ b/repository/database/create_user.go @@ -89,8 +89,16 @@ func (r *DatabaseRepository) CreateUser(ctx context.Context, oAuth *model.OAuth, func (r *DatabaseRepository) InsertUser(ctx context.Context, queryable database.Queryable, input *model.NewUser, pronounIdPtr *int, oAuth *model.OAuth) (int, error) { // TODO: Possibly change ID type to int to stop this hacky fix? // insert user into database and return their ID + + var raceStringArray []string + if input.Race != nil && len(input.Race) > 0 { + raceStringArray = make([]string, 0, len(input.Race)) + for _, race := range input.Race { + raceStringArray = append(raceStringArray, race.String()) + } + } var userIdInt int - err := queryable.QueryRow(ctx, "INSERT INTO users (first_name, last_name, email, phone_number, age, pronoun_id, oauth_uid, oauth_provider, role,years_of_experience, shirt_size, race, gender) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING id", + err := queryable.QueryRow(ctx, "INSERT INTO users (first_name, last_name, email, phone_number, age, pronoun_id, oauth_uid, oauth_provider, role,years_of_experience, shirt_size, race, gender, race) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING id", input.FirstName, input.LastName, input.Email, @@ -104,6 +112,7 @@ func (r *DatabaseRepository) InsertUser(ctx context.Context, queryable database. input.ShirtSize, input.Race, input.Gender, + raceStringArray, ).Scan(&userIdInt) return userIdInt, err } From 3c3cda375c6ac06b1428d95e48741297bd1be30f Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Sun, 20 Nov 2022 12:32:41 -0500 Subject: [PATCH 24/29] modified UpdateRace to accept []model.Race --- repository/database/update_user.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/repository/database/update_user.go b/repository/database/update_user.go index 280a0db..5ba10fe 100644 --- a/repository/database/update_user.go +++ b/repository/database/update_user.go @@ -40,7 +40,8 @@ func Validate[T *string | *model.PronounsInput | *model.MailingAddressUpdate | *model.EducationInfoUpdate | - *model.MLHTermsUpdate](ctx context.Context, tx pgx.Tx, id string, input T, updateFunc UpdateFunc[T]) error { + *model.MLHTermsUpdate | + []model.Race](ctx context.Context, tx pgx.Tx, id string, input T, updateFunc UpdateFunc[T]) error { if input != nil { err := updateFunc(ctx, id, input, tx) if err != nil { @@ -209,8 +210,15 @@ func (r *DatabaseRepository) UpdateYearsOfExperience(ctx context.Context, id str } // UpdateRace updates race -func (r *DatabaseRepository) UpdateRace(ctx context.Context, id string, race []*string, tx pgx.Tx) error { - commandTag, err := tx.Exec(ctx, "UPDATE users SET race = $1 WHERE id = $2", race, id) +func (r *DatabaseRepository) UpdateRace(ctx context.Context, id string, races []model.Race, tx pgx.Tx) error { + var raceStringArray []string + if races != nil && len(races) > 0 { + raceStringArray = make([]string, 0, len(races)) + for _, race := range races { + raceStringArray = append(raceStringArray, race.String()) + } + } + commandTag, err := tx.Exec(ctx, "UPDATE users SET race = $1 WHERE id = $2", raceStringArray, id) if err != nil { return err } From a9d988973bcc49f0245c495318dd0e3a8ae28b8a Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Sun, 20 Nov 2022 13:13:49 -0500 Subject: [PATCH 25/29] updated shared --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6c06c1e..3eea16f 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/99designs/gqlgen v0.17.13 - github.com/KnightHacks/knighthacks_shared v0.0.0-20221108080447-3d7bd40b913a + github.com/KnightHacks/knighthacks_shared v0.0.0-20221120025925-541d81e10069 github.com/gin-gonic/gin v1.8.1 github.com/jackc/pgx/v4 v4.16.1 github.com/vektah/gqlparser/v2 v2.4.7 diff --git a/go.sum b/go.sum index 14a8bf8..5d4ae94 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/KnightHacks/knighthacks_shared v0.0.0-20221108080447-3d7bd40b913a h1:R474w9kB/3X1TcgRaboPBy/zO6lL3CRon7g/6g8YFFw= github.com/KnightHacks/knighthacks_shared v0.0.0-20221108080447-3d7bd40b913a/go.mod h1:W6x/SycHYHMTE51Mo1MZeGQJUTJGME5LF3hdPFdGp4c= +github.com/KnightHacks/knighthacks_shared v0.0.0-20221120025925-541d81e10069 h1:yvEO67PhIBcBO/Yn3Mh2iUPSgVC0az/T3ls7IRg3ZRk= +github.com/KnightHacks/knighthacks_shared v0.0.0-20221120025925-541d81e10069/go.mod h1:1PTL6VJL44UN/BdfFyxT8GsAa46W2+9C5dDRnfqKJYA= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= From ec4273498575c04a0ee737e7fd4b6011d3849277 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Sun, 20 Nov 2022 20:02:41 -0500 Subject: [PATCH 26/29] updated shared --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3eea16f..7039f0f 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/99designs/gqlgen v0.17.13 - github.com/KnightHacks/knighthacks_shared v0.0.0-20221120025925-541d81e10069 + github.com/KnightHacks/knighthacks_shared v0.0.0-20221121010043-cf2a1397df2e github.com/gin-gonic/gin v1.8.1 github.com/jackc/pgx/v4 v4.16.1 github.com/vektah/gqlparser/v2 v2.4.7 diff --git a/go.sum b/go.sum index 5d4ae94..2514356 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,10 @@ github.com/99designs/gqlgen v0.17.13 h1:ETUEqvRg5Zvr1lXtpoRdj026fzVay0ZlJPwI33qX github.com/99designs/gqlgen v0.17.13/go.mod h1:w1brbeOdqVyNJI553BGwtwdVcYu1LKeYE1opLWN9RgQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/KnightHacks/knighthacks_shared v0.0.0-20221108080447-3d7bd40b913a h1:R474w9kB/3X1TcgRaboPBy/zO6lL3CRon7g/6g8YFFw= -github.com/KnightHacks/knighthacks_shared v0.0.0-20221108080447-3d7bd40b913a/go.mod h1:W6x/SycHYHMTE51Mo1MZeGQJUTJGME5LF3hdPFdGp4c= github.com/KnightHacks/knighthacks_shared v0.0.0-20221120025925-541d81e10069 h1:yvEO67PhIBcBO/Yn3Mh2iUPSgVC0az/T3ls7IRg3ZRk= github.com/KnightHacks/knighthacks_shared v0.0.0-20221120025925-541d81e10069/go.mod h1:1PTL6VJL44UN/BdfFyxT8GsAa46W2+9C5dDRnfqKJYA= +github.com/KnightHacks/knighthacks_shared v0.0.0-20221121010043-cf2a1397df2e h1:2s45geYfGUlA0P+OQC9BB05WBKCaooB+TStnGXC6u/c= +github.com/KnightHacks/knighthacks_shared v0.0.0-20221121010043-cf2a1397df2e/go.mod h1:1PTL6VJL44UN/BdfFyxT8GsAa46W2+9C5dDRnfqKJYA= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= From 98b98742d3227b71161d9ec8034bf8aaf9654347 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Sun, 20 Nov 2022 20:03:04 -0500 Subject: [PATCH 27/29] implemented user API Keys --- graph/generated/generated.go | 490 ++++++++++++++++++++++++++++- graph/model/models_gen.go | 15 +- graph/schema.graphqls | 10 + graph/schema.resolvers.go | 19 ++ repository/database/get_user.go | 9 +- repository/database/update_user.go | 29 ++ repository/repository.go | 3 + 7 files changed, 567 insertions(+), 8 deletions(-) diff --git a/graph/generated/generated.go b/graph/generated/generated.go index 7f49787..c000278 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -51,6 +51,11 @@ type DirectiveRoot struct { } type ComplexityRoot struct { + APIKey struct { + Created func(childComplexity int) int + Key func(childComplexity int) int + } + EducationInfo struct { GraduationDate func(childComplexity int) int Level func(childComplexity int) int @@ -86,9 +91,11 @@ type ComplexityRoot struct { } Mutation struct { - DeleteUser func(childComplexity int, id string) int - Register func(childComplexity int, provider models.Provider, encryptedOauthAccessToken string, input model.NewUser) int - UpdateUser func(childComplexity int, id string, input model.UpdatedUser) int + AddAPIKey func(childComplexity int, userID string) int + DeleteAPIKey func(childComplexity int, userID string) int + DeleteUser func(childComplexity int, id string) int + Register func(childComplexity int, provider models.Provider, encryptedOauthAccessToken string, input model.NewUser) int + UpdateUser func(childComplexity int, id string, input model.UpdatedUser) int } OAuth struct { @@ -125,6 +132,7 @@ type ComplexityRoot struct { } User struct { + APIKey func(childComplexity int) int Age func(childComplexity int) int EducationInfo func(childComplexity int) int Email func(childComplexity int) int @@ -163,6 +171,8 @@ type MutationResolver interface { Register(ctx context.Context, provider models.Provider, encryptedOauthAccessToken string, input model.NewUser) (*model.RegistrationPayload, error) UpdateUser(ctx context.Context, id string, input model.UpdatedUser) (*model.User, error) DeleteUser(ctx context.Context, id string) (bool, error) + AddAPIKey(ctx context.Context, userID string) (*model.APIKey, error) + DeleteAPIKey(ctx context.Context, userID string) (bool, error) } type QueryResolver interface { GetAuthRedirectLink(ctx context.Context, provider models.Provider, redirect *string) (string, error) @@ -179,6 +189,8 @@ type UserResolver interface { OAuth(ctx context.Context, obj *model.User) (*model.OAuth, error) MailingAddress(ctx context.Context, obj *model.User) (*model.MailingAddress, error) Mlh(ctx context.Context, obj *model.User) (*model.MLHTerms, error) + + APIKey(ctx context.Context, obj *model.User) (*model.APIKey, error) } type executableSchema struct { @@ -196,6 +208,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { + case "APIKey.created": + if e.complexity.APIKey.Created == nil { + break + } + + return e.complexity.APIKey.Created(childComplexity), true + + case "APIKey.key": + if e.complexity.APIKey.Key == nil { + break + } + + return e.complexity.APIKey.Key(childComplexity), true + case "EducationInfo.graduationDate": if e.complexity.EducationInfo.GraduationDate == nil { break @@ -339,6 +365,30 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.MailingAddress.State(childComplexity), true + case "Mutation.addAPIKey": + if e.complexity.Mutation.AddAPIKey == nil { + break + } + + args, err := ec.field_Mutation_addAPIKey_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.AddAPIKey(childComplexity, args["userId"].(string)), true + + case "Mutation.deleteAPIKey": + if e.complexity.Mutation.DeleteAPIKey == nil { + break + } + + args, err := ec.field_Mutation_deleteAPIKey_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteAPIKey(childComplexity, args["userId"].(string)), true + case "Mutation.deleteUser": if e.complexity.Mutation.DeleteUser == nil { break @@ -536,6 +586,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.RegistrationPayload.User(childComplexity), true + case "User.apiKey": + if e.complexity.User.APIKey == nil { + break + } + + return e.complexity.User.APIKey(childComplexity), true + case "User.age": if e.complexity.User.Age == nil { break @@ -827,6 +884,13 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { shirtSize: ShirtSize! @hasRole(role: OWNS) yearsOfExperience: Float @hasRole(role: OWNS) educationInfo: EducationInfo! @hasRole(role: OWNS) + + apiKey: APIKey! @goField(forceResolver: true) @hasRole(role: OWNS) +} + +type APIKey { + created: Time! + key: String! } """ @@ -976,6 +1040,9 @@ type LoginPayload { accessToken: String refreshToken: String + """ + Not null when accountExists is false, use this in registration + """ encryptedOAuthAccessToken: String } @@ -1006,6 +1073,9 @@ type Mutation { register(provider: Provider!, encryptedOAuthAccessToken: String!, input: NewUser!): RegistrationPayload! updateUser(id: ID!, input: UpdatedUser!): User! @hasRole(role: NORMAL) deleteUser(id: ID!): Boolean! @hasRole(role: NORMAL) + + addAPIKey(userId: ID!): APIKey + deleteAPIKey(userId: ID!): Boolean! } `, BuiltIn: false}, @@ -1116,6 +1186,36 @@ func (ec *executionContext) field_Entity_findUserByOAuthUIDAndOAuthProvider_args return args, nil } +func (ec *executionContext) field_Mutation_addAPIKey_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["userId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["userId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_deleteAPIKey_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["userId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["userId"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation_deleteUser_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1382,6 +1482,94 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** +func (ec *executionContext) _APIKey_created(ctx context.Context, field graphql.CollectedField, obj *model.APIKey) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_APIKey_created(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Created, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_APIKey_created(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "APIKey", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _APIKey_key(ctx context.Context, field graphql.CollectedField, obj *model.APIKey) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_APIKey_key(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Key, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_APIKey_key(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "APIKey", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _EducationInfo_name(ctx context.Context, field graphql.CollectedField, obj *model.EducationInfo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_EducationInfo_name(ctx, field) if err != nil { @@ -1628,6 +1816,8 @@ func (ec *executionContext) fieldContext_Entity_findUserByID(ctx context.Context return ec.fieldContext_User_yearsOfExperience(ctx, field) case "educationInfo": return ec.fieldContext_User_educationInfo(ctx, field) + case "apiKey": + return ec.fieldContext_User_apiKey(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -1719,6 +1909,8 @@ func (ec *executionContext) fieldContext_Entity_findUserByOAuthUIDAndOAuthProvid return ec.fieldContext_User_yearsOfExperience(ctx, field) case "educationInfo": return ec.fieldContext_User_educationInfo(ctx, field) + case "apiKey": + return ec.fieldContext_User_apiKey(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -1851,6 +2043,8 @@ func (ec *executionContext) fieldContext_LoginPayload_user(ctx context.Context, return ec.fieldContext_User_yearsOfExperience(ctx, field) case "educationInfo": return ec.fieldContext_User_educationInfo(ctx, field) + case "apiKey": + return ec.fieldContext_User_apiKey(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -2493,6 +2687,8 @@ func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context return ec.fieldContext_User_yearsOfExperience(ctx, field) case "educationInfo": return ec.fieldContext_User_educationInfo(ctx, field) + case "apiKey": + return ec.fieldContext_User_apiKey(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -2590,6 +2786,119 @@ func (ec *executionContext) fieldContext_Mutation_deleteUser(ctx context.Context return fc, nil } +func (ec *executionContext) _Mutation_addAPIKey(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_addAPIKey(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().AddAPIKey(rctx, fc.Args["userId"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.APIKey) + fc.Result = res + return ec.marshalOAPIKey2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐAPIKey(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_addAPIKey(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "created": + return ec.fieldContext_APIKey_created(ctx, field) + case "key": + return ec.fieldContext_APIKey_key(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type APIKey", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_addAPIKey_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Mutation_deleteAPIKey(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteAPIKey(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteAPIKey(rctx, fc.Args["userId"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteAPIKey(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_deleteAPIKey_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + func (ec *executionContext) _OAuth_provider(ctx context.Context, field graphql.CollectedField, obj *model.OAuth) (ret graphql.Marshaler) { fc, err := ec.fieldContext_OAuth_provider(ctx, field) if err != nil { @@ -3246,6 +3555,8 @@ func (ec *executionContext) fieldContext_Query_getUser(ctx context.Context, fiel return ec.fieldContext_User_yearsOfExperience(ctx, field) case "educationInfo": return ec.fieldContext_User_educationInfo(ctx, field) + case "apiKey": + return ec.fieldContext_User_apiKey(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -3361,6 +3672,8 @@ func (ec *executionContext) fieldContext_Query_searchUser(ctx context.Context, f return ec.fieldContext_User_yearsOfExperience(ctx, field) case "educationInfo": return ec.fieldContext_User_educationInfo(ctx, field) + case "apiKey": + return ec.fieldContext_User_apiKey(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -3473,6 +3786,8 @@ func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field gra return ec.fieldContext_User_yearsOfExperience(ctx, field) case "educationInfo": return ec.fieldContext_User_educationInfo(ctx, field) + case "apiKey": + return ec.fieldContext_User_apiKey(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -3785,6 +4100,8 @@ func (ec *executionContext) fieldContext_RegistrationPayload_user(ctx context.Co return ec.fieldContext_User_yearsOfExperience(ctx, field) case "educationInfo": return ec.fieldContext_User_educationInfo(ctx, field) + case "apiKey": + return ec.fieldContext_User_apiKey(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -4940,6 +5257,80 @@ func (ec *executionContext) fieldContext_User_educationInfo(ctx context.Context, return fc, nil } +func (ec *executionContext) _User_apiKey(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_apiKey(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().APIKey(rctx, obj) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, obj, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.APIKey); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/KnightHacks/knighthacks_users/graph/model.APIKey`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.APIKey) + fc.Result = res + return ec.marshalNAPIKey2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐAPIKey(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_apiKey(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "created": + return ec.fieldContext_APIKey_created(ctx, field) + case "key": + return ec.fieldContext_APIKey_key(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type APIKey", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _UsersConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.UsersConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_UsersConnection_totalCount(ctx, field) if err != nil { @@ -5107,6 +5498,8 @@ func (ec *executionContext) fieldContext_UsersConnection_users(ctx context.Conte return ec.fieldContext_User_yearsOfExperience(ctx, field) case "educationInfo": return ec.fieldContext_User_educationInfo(ctx, field) + case "apiKey": + return ec.fieldContext_User_apiKey(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -7564,6 +7957,41 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, // region **************************** object.gotpl **************************** +var aPIKeyImplementors = []string{"APIKey"} + +func (ec *executionContext) _APIKey(ctx context.Context, sel ast.SelectionSet, obj *model.APIKey) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, aPIKeyImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("APIKey") + case "created": + + out.Values[i] = ec._APIKey_created(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "key": + + out.Values[i] = ec._APIKey_key(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + var educationInfoImplementors = []string{"EducationInfo"} func (ec *executionContext) _EducationInfo(ctx context.Context, sel ast.SelectionSet, obj *model.EducationInfo) graphql.Marshaler { @@ -7871,6 +8299,21 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) return ec._Mutation_deleteUser(ctx, field) }) + if out.Values[i] == graphql.Null { + invalids++ + } + case "addAPIKey": + + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_addAPIKey(ctx, field) + }) + + case "deleteAPIKey": + + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteAPIKey(ctx, field) + }) + if out.Values[i] == graphql.Null { invalids++ } @@ -8438,6 +8881,26 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } + case "apiKey": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_apiKey(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + } + + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) + + }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -8834,6 +9297,20 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** +func (ec *executionContext) marshalNAPIKey2githubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐAPIKey(ctx context.Context, sel ast.SelectionSet, v model.APIKey) graphql.Marshaler { + return ec._APIKey(ctx, sel, &v) +} + +func (ec *executionContext) marshalNAPIKey2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐAPIKey(ctx context.Context, sel ast.SelectionSet, v *model.APIKey) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._APIKey(ctx, sel, v) +} + func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { res, err := graphql.UnmarshalBoolean(v) return res, graphql.ErrorOnPath(ctx, err) @@ -9512,6 +9989,13 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return res } +func (ec *executionContext) marshalOAPIKey2ᚖgithubᚗcomᚋKnightHacksᚋknighthacks_usersᚋgraphᚋmodelᚐAPIKey(ctx context.Context, sel ast.SelectionSet, v *model.APIKey) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._APIKey(ctx, sel, v) +} + func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { res, err := graphql.UnmarshalBoolean(v) return res, graphql.ErrorOnPath(ctx, err) diff --git a/graph/model/models_gen.go b/graph/model/models_gen.go index f7e6fc6..0de55b5 100644 --- a/graph/model/models_gen.go +++ b/graph/model/models_gen.go @@ -15,6 +15,11 @@ type Connection interface { IsConnection() } +type APIKey struct { + Created time.Time `json:"created"` + Key string `json:"key"` +} + type EducationInfo struct { Name string `json:"name"` GraduationDate time.Time `json:"graduationDate"` @@ -38,10 +43,11 @@ type EducationInfoUpdate struct { type LoginPayload struct { // If false then you must register immediately following this. Else, you are logged in and have access to your own user. - AccountExists bool `json:"accountExists"` - User *User `json:"user"` - AccessToken *string `json:"accessToken"` - RefreshToken *string `json:"refreshToken"` + AccountExists bool `json:"accountExists"` + User *User `json:"user"` + AccessToken *string `json:"accessToken"` + RefreshToken *string `json:"refreshToken"` + // Not null when accountExists is false, use this in registration EncryptedOAuthAccessToken *string `json:"encryptedOAuthAccessToken"` } @@ -161,6 +167,7 @@ type User struct { ShirtSize ShirtSize `json:"shirtSize"` YearsOfExperience *float64 `json:"yearsOfExperience"` EducationInfo *EducationInfo `json:"educationInfo"` + APIKey *APIKey `json:"apiKey"` } func (User) IsEntity() {} diff --git a/graph/schema.graphqls b/graph/schema.graphqls index 02f2ea7..3a52ace 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -65,6 +65,13 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { shirtSize: ShirtSize! @hasRole(role: OWNS) yearsOfExperience: Float @hasRole(role: OWNS) educationInfo: EducationInfo! @hasRole(role: OWNS) + + apiKey: APIKey! @goField(forceResolver: true) @hasRole(role: OWNS) +} + +type APIKey { + created: Time! + key: String! } """ @@ -247,5 +254,8 @@ type Mutation { register(provider: Provider!, encryptedOAuthAccessToken: String!, input: NewUser!): RegistrationPayload! updateUser(id: ID!, input: UpdatedUser!): User! @hasRole(role: NORMAL) deleteUser(id: ID!): Boolean! @hasRole(role: NORMAL) + + addAPIKey(userId: ID!): APIKey + deleteAPIKey(userId: ID!): Boolean! } diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index 0acf6b4..7fb2e44 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -86,6 +86,20 @@ func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (bool, err return r.Repository.DeleteUser(ctx, id) } +// AddAPIKey is the resolver for the addAPIKey field. +func (r *mutationResolver) AddAPIKey(ctx context.Context, userID string) (*model.APIKey, error) { + return r.Repository.AddAPIKey(ctx, userID) +} + +// DeleteAPIKey is the resolver for the deleteAPIKey field. +func (r *mutationResolver) DeleteAPIKey(ctx context.Context, userID string) (bool, error) { + err := r.Repository.DeleteAPIKey(ctx, userID) + if err != nil { + return true, err + } + return false, nil +} + // GetAuthRedirectLink is the resolver for the getAuthRedirectLink field. func (r *queryResolver) GetAuthRedirectLink(ctx context.Context, provider models.Provider, redirect *string) (string, error) { ginContext, err := utils.GinContextFromContext(ctx) @@ -248,6 +262,11 @@ func (r *userResolver) Mlh(ctx context.Context, obj *model.User) (*model.MLHTerm return r.Repository.GetUserMLHTerms(ctx, obj.ID) } +// APIKey is the resolver for the apiKey field. +func (r *userResolver) APIKey(ctx context.Context, obj *model.User) (*model.APIKey, error) { + return r.Repository.GetAPIKey(ctx, obj) +} + // Mutation returns generated.MutationResolver implementation. func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } diff --git a/repository/database/get_user.go b/repository/database/get_user.go index fd9b0a3..8663de3 100644 --- a/repository/database/get_user.go +++ b/repository/database/get_user.go @@ -3,7 +3,6 @@ package database import ( "context" "errors" - sharedModels "github.com/KnightHacks/knighthacks_shared/models" "github.com/KnightHacks/knighthacks_users/graph/model" "github.com/KnightHacks/knighthacks_users/repository" @@ -195,3 +194,11 @@ func (r *DatabaseRepository) GetUserMLHTerms(ctx context.Context, userId string) return &mlhTerms, err } + +func (r *DatabaseRepository) GetAPIKey(ctx context.Context, obj *model.User) (apiKey *model.APIKey, err error) { + err = r.DatabasePool.QueryRow(ctx, "SELECT key, created FROM api_keys WHERE user_id = $1", obj.ID).Scan(&apiKey.Key, &apiKey.Created) + if err != nil { + return nil, err + } + return apiKey, nil +} diff --git a/repository/database/update_user.go b/repository/database/update_user.go index 5ba10fe..409fb55 100644 --- a/repository/database/update_user.go +++ b/repository/database/update_user.go @@ -8,7 +8,9 @@ import ( "github.com/KnightHacks/knighthacks_users/graph/model" "github.com/KnightHacks/knighthacks_users/repository" "github.com/jackc/pgx/v4" + "math/rand" "strconv" + "time" ) /* @@ -452,3 +454,30 @@ func ScanUser[T Scannable](user *model.User, scannable T) (*int, error) { } return nil, nil } + +func (r *DatabaseRepository) DeleteAPIKey(ctx context.Context, id string) error { + _, err := r.DatabasePool.Exec(ctx, "DELETE FROM api_keys WHERE user_id = $1", id) + if err != nil { + return err + } + return nil +} + +func (r *DatabaseRepository) AddAPIKey(ctx context.Context, id string) (*model.APIKey, error) { + apiKey := GenerateAPIKey(100) + _, err := r.DatabasePool.Exec(ctx, "INSERT INTO api_keys (user_id, key, created) VALUES ($1, $2, $3)", id, apiKey, time.Now()) + if err != nil { + return nil, err + } + return &model.APIKey{Key: apiKey, Created: time.Now()}, nil +} + +var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + +func GenerateAPIKey(length int) string { + b := make([]rune, length) + for i := range b { + b[i] = letterRunes[rand.Intn(len(letterRunes))] + } + return string(b) +} diff --git a/repository/repository.go b/repository/repository.go index 3d5e264..a428813 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -21,4 +21,7 @@ type Repository interface { SearchUser(ctx context.Context, name string) ([]*model.User, error) DeleteUser(ctx context.Context, id string) (bool, error) CreateUser(ctx context.Context, oAuth *model.OAuth, input *model.NewUser) (*model.User, error) + GetAPIKey(ctx context.Context, obj *model.User) (*model.APIKey, error) + DeleteAPIKey(ctx context.Context, id string) error + AddAPIKey(ctx context.Context, id string) (*model.APIKey, error) } From 3ec5fc8216b24cb8074744167afe823130563029 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Sun, 20 Nov 2022 20:25:08 -0500 Subject: [PATCH 28/29] updated to golang:1.19-alpine --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 55108e8..0a5cbc0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18 as build-env +FROM golang:1.19-alpine as build-env WORKDIR /go/src/app COPY . . From 805e033b7735d258f5e410e1c45489aff1dba504 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Sun, 20 Nov 2022 20:37:00 -0500 Subject: [PATCH 29/29] updated from go 1.18 to 1.19 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 7039f0f..af9dad1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/KnightHacks/knighthacks_users -go 1.18 +go 1.19 require ( github.com/99designs/gqlgen v0.17.13