├── .gitignore ├── domain ├── auth.go ├── domain.go └── meetups.go ├── go.mod ├── go.sum ├── gqlgen.yml ├── graphql ├── dataloader.go ├── generated.go ├── meetup_resolver.go ├── mutation_resolver.go ├── query_resolver.go ├── resolver.go ├── user_resolver.go ├── userloader_gen.go └── validation.go ├── middleware └── auth_middleware.go ├── models ├── meetup.go ├── models_gen.go ├── user.go └── validation.go ├── postgres ├── meetups.go ├── migrations │ ├── 20191214081927_create_users.down.sql │ ├── 20191214081927_create_users.up.sql │ ├── 20191214081931_create_meetups.down.sql │ └── 20191214081931_create_meetups.up.sql ├── postgres.go ├── seeds.sql └── users.go ├── schema.graphql ├── server └── server.go └── validator ├── email.go ├── equal_to_field.go ├── min_length.go ├── required.go └── validator.go /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .env -------------------------------------------------------------------------------- /domain/auth.go: -------------------------------------------------------------------------------- 1 | package domain 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "log" 7 | 8 | "github.com/equimper/meetmeup/models" 9 | ) 10 | 11 | func (d *Domain) Login(ctx context.Context, input models.LoginInput) (*models.AuthResponse, error) { 12 | user, err := d.UsersRepo.GetUserByEmail(input.Email) 13 | if err != nil { 14 | return nil, ErrBadCredentials 15 | } 16 | 17 | err = user.ComparePassword(input.Password) 18 | if err != nil { 19 | return nil, ErrBadCredentials 20 | } 21 | 22 | token, err := user.GenToken() 23 | if err != nil { 24 | return nil, errors.New("something went wrong") 25 | } 26 | 27 | return &models.AuthResponse{ 28 | AuthToken: token, 29 | User: user, 30 | }, nil 31 | } 32 | 33 | func (d *Domain) Register(ctx context.Context, input models.RegisterInput) (*models.AuthResponse, error) { 34 | _, err := d.UsersRepo.GetUserByEmail(input.Email) 35 | if err == nil { 36 | return nil, errors.New("email already in used") 37 | } 38 | 39 | _, err = d.UsersRepo.GetUserByUsername(input.Username) 40 | if err == nil { 41 | return nil, errors.New("username already in used") 42 | } 43 | 44 | user := &models.User{ 45 | Username: input.Username, 46 | Email: input.Email, 47 | FirstName: input.FirstName, 48 | LastName: input.LastName, 49 | } 50 | 51 | err = user.HashPassword(input.Password) 52 | if err != nil { 53 | log.Printf("error while hashing password: %v", err) 54 | return nil, errors.New("something went wrong") 55 | } 56 | 57 | // TODO: create verification code 58 | 59 | tx, err := d.UsersRepo.DB.Begin() 60 | if err != nil { 61 | log.Printf("error creating a transaction: %v", err) 62 | return nil, errors.New("something went wrong") 63 | } 64 | defer tx.Rollback() 65 | 66 | if _, err := d.UsersRepo.CreateUser(tx, user); err != nil { 67 | log.Printf("error creating a user: %v", err) 68 | return nil, err 69 | } 70 | 71 | if err := tx.Commit(); err != nil { 72 | log.Printf("error while commiting: %v", err) 73 | return nil, err 74 | } 75 | 76 | token, err := user.GenToken() 77 | if err != nil { 78 | log.Printf("error while generating the token: %v", err) 79 | return nil, errors.New("something went wrong") 80 | } 81 | 82 | return &models.AuthResponse{ 83 | AuthToken: token, 84 | User: user, 85 | }, nil 86 | } 87 | -------------------------------------------------------------------------------- /domain/domain.go: -------------------------------------------------------------------------------- 1 | package domain 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/equimper/meetmeup/models" 7 | "github.com/equimper/meetmeup/postgres" 8 | ) 9 | 10 | var ( 11 | ErrBadCredentials = errors.New("email/password combination don't work") 12 | ErrUnauthenticated = errors.New("unauthenticated") 13 | ErrForbidden = errors.New("unauthorized") 14 | ) 15 | 16 | type Domain struct { 17 | UsersRepo postgres.UsersRepo 18 | MeetupsRepo postgres.MeetupsRepo 19 | } 20 | 21 | func NewDomain(usersRepo postgres.UsersRepo, meetupsRepo postgres.MeetupsRepo) *Domain { 22 | return &Domain{UsersRepo: usersRepo, MeetupsRepo: meetupsRepo} 23 | } 24 | 25 | type Ownable interface { 26 | IsOwner(user *models.User) bool 27 | } 28 | 29 | func checkOwnership(o Ownable, user *models.User) bool { 30 | return o.IsOwner(user) 31 | } 32 | -------------------------------------------------------------------------------- /domain/meetups.go: -------------------------------------------------------------------------------- 1 | package domain 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "fmt" 7 | 8 | "github.com/equimper/meetmeup/middleware" 9 | "github.com/equimper/meetmeup/models" 10 | ) 11 | 12 | func (d *Domain) DeleteMeetup(ctx context.Context, id string) (bool, error) { 13 | currentUser, err := middleware.GetCurrentUserFromCTX(ctx) 14 | if err != nil { 15 | return false, ErrUnauthenticated 16 | } 17 | 18 | meetup, err := d.MeetupsRepo.GetByID(id) 19 | if err != nil || meetup == nil { 20 | return false, errors.New("meetup not exist") 21 | } 22 | 23 | if !meetup.IsOwner(currentUser) { 24 | return false, ErrForbidden 25 | } 26 | 27 | err = d.MeetupsRepo.Delete(meetup) 28 | if err != nil { 29 | return false, fmt.Errorf("error while deleting meetup: %v", err) 30 | } 31 | 32 | return true, nil 33 | } 34 | 35 | func (d *Domain) UpdateMeetup(ctx context.Context, id string, input models.UpdateMeetup) (*models.Meetup, error) { 36 | currentUser, err := middleware.GetCurrentUserFromCTX(ctx) 37 | if err != nil { 38 | return nil, ErrUnauthenticated 39 | } 40 | 41 | meetup, err := d.MeetupsRepo.GetByID(id) 42 | if err != nil || meetup == nil { 43 | return nil, errors.New("meetup not exist") 44 | } 45 | 46 | if !meetup.IsOwner(currentUser) { 47 | return nil, ErrForbidden 48 | } 49 | 50 | didUpdate := false 51 | 52 | if input.Name != nil { 53 | if len(*input.Name) < 3 { 54 | return nil, errors.New("name is not long enough") 55 | } 56 | meetup.Name = *input.Name 57 | didUpdate = true 58 | } 59 | 60 | if input.Description != nil { 61 | if len(*input.Description) < 3 { 62 | return nil, errors.New("description is not long enough") 63 | } 64 | meetup.Description = *input.Description 65 | didUpdate = true 66 | } 67 | 68 | if !didUpdate { 69 | return nil, errors.New("no update done") 70 | } 71 | 72 | meetup, err = d.MeetupsRepo.Update(meetup) 73 | if err != nil { 74 | return nil, fmt.Errorf("error while updating meetup: %v", err) 75 | } 76 | 77 | return meetup, nil 78 | } 79 | 80 | func (d *Domain) CreateMeetup(ctx context.Context, input models.NewMeetup) (*models.Meetup, error) { 81 | currentUser, err := middleware.GetCurrentUserFromCTX(ctx) 82 | if err != nil { 83 | return nil, ErrUnauthenticated 84 | } 85 | 86 | if len(input.Name) < 3 { 87 | return nil, errors.New("name not long enough") 88 | } 89 | 90 | if len(input.Description) < 3 { 91 | return nil, errors.New("description not long enough") 92 | } 93 | 94 | meetup := &models.Meetup{ 95 | Name: input.Name, 96 | Description: input.Description, 97 | UserID: currentUser.ID, 98 | } 99 | 100 | return d.MeetupsRepo.CreateMeetup(meetup) 101 | } 102 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/equimper/meetmeup 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/99designs/gqlgen v0.10.2 7 | github.com/dgrijalva/jwt-go v3.2.0+incompatible 8 | github.com/go-chi/chi v4.0.2+incompatible // indirect 9 | github.com/go-pg/pg/v9 v9.0.4 10 | github.com/pkg/errors v0.8.1 11 | github.com/rs/cors v1.7.0 // indirect 12 | github.com/vektah/gqlparser v1.2.0 13 | golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 14 | ) 15 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/99designs/gqlgen v0.10.2 h1:FfjCqIWejHDJeLpQTI0neoZo5vDO3sdo5oNCucet3A0= 2 | github.com/99designs/gqlgen v0.10.2/go.mod h1:aDB7oabSAyZ4kUHLEySsLxnWrBy3lA0A2gWKU+qoHwI= 3 | github.com/agnivade/levenshtein v1.0.1 h1:3oJU7J3FGFmyhn8KHjmVaZCN5hxTr7GxgRue+sxIXdQ= 4 | github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= 5 | github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= 6 | github.com/codemodus/kace v0.5.1 h1:4OCsBlE2c/rSJo375ggfnucv9eRzge/U5LrrOZd47HA= 7 | github.com/codemodus/kace v0.5.1/go.mod h1:coddaHoX1ku1YFSe4Ip0mL9kQjJvKkzb9CfIdG1YR04= 8 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 9 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 10 | github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= 11 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 12 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 13 | github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= 14 | github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs= 15 | github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= 16 | github.com/go-pg/pg v8.0.6+incompatible h1:Hi7yUJ2zwmHFq1Mar5XqhCe3NJ7j9r+BaiNmd+vqf+A= 17 | github.com/go-pg/pg/v9 v9.0.0-beta.14/go.mod h1:T2Sr6bpTCOr2lUqOUMiXLMJqZHSUBKk1LdgSqjwhZfA= 18 | github.com/go-pg/pg/v9 v9.0.3/go.mod h1:Tm/Q3Vt6gdQOH6TTN1H/xLlIXc+Qrka7TZ6uREtu/eA= 19 | github.com/go-pg/pg/v9 v9.0.4 h1:51ejKdKMEB/pzq8mz3GiARXkAKE8uGCfBNPa436DrrY= 20 | github.com/go-pg/pg/v9 v9.0.4/go.mod h1:R3slXUnppC1am3XiioEeszbPnU6uAzGHipxNyvpfpr4= 21 | github.com/go-pg/urlstruct v0.1.0/go.mod h1:2Nag+BIny6G/KYCkdt++ZnqU/VinzimGapKfs4kwlN0= 22 | github.com/go-pg/urlstruct v0.2.6/go.mod h1:dxENwVISWSOX+k87hDt0ueEJadD+gZWv3tHzwfmZPu8= 23 | github.com/go-pg/urlstruct v0.2.8 h1:pasKiKzYyAtJ9YEpGe6G+3PB0M5Ez0qsMtjSA3gsw/g= 24 | github.com/go-pg/urlstruct v0.2.8/go.mod h1:/XKyiUOUUS3onjF+LJxbfmSywYAdl6qMfVbX33Q8rgg= 25 | github.com/go-pg/zerochecker v0.1.1 h1:av77Qe7Gs+1oYGGh51k0sbZ0bUaxJEdeP0r8YE64Dco= 26 | github.com/go-pg/zerochecker v0.1.1/go.mod h1:NJZ4wKL0NmTtz0GKCoJ8kym6Xn/EQzXRl2OnAe7MmDo= 27 | github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 28 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 29 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 30 | github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= 31 | github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 32 | github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= 33 | github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 34 | github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= 35 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 36 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 37 | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= 38 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 39 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 40 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 41 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 42 | github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 43 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 44 | github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 45 | github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 46 | github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= 47 | github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 48 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 49 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 50 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 51 | github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= 52 | github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= 53 | github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= 54 | github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= 55 | github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= 56 | github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= 57 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 58 | github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 59 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 60 | github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= 61 | github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= 62 | github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e h1:+w0Zm/9gaWpEAyDlU1eKOuk5twTjAjuevXqcJJw8hrg= 63 | github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= 64 | github.com/vektah/gqlparser v1.2.0 h1:ntkSCX7F5ZJKl+HIVnmLaO269MruasVpNiMOjX9kgo0= 65 | github.com/vektah/gqlparser v1.2.0/go.mod h1:bkVf0FX+Stjg/MHnm8mEyubuaArhNEqfQhF+OTiAL74= 66 | github.com/vmihailenco/tagparser v0.1.0/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= 67 | github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= 68 | github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= 69 | golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 70 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 71 | golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= 72 | golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 73 | golang.org/x/crypto v0.0.0-20191128160524-b544559bb6d1/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 74 | golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g= 75 | golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 76 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 77 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 78 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 79 | golang.org/x/net v0.0.0-20190420063019-afa5a82059c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 80 | golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 81 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 82 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 83 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 84 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 85 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 86 | golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 87 | golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 88 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 89 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 90 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 91 | golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 92 | golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd h1:oMEQDWVXVNpceQoVd1JN3CQ7LYJJzs5qWqZIUcxXHHw= 93 | golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 94 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 95 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 96 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 97 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 98 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 99 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 100 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 101 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 102 | gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= 103 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 104 | mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w= 105 | mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ= 106 | sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= 107 | sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= 108 | -------------------------------------------------------------------------------- /gqlgen.yml: -------------------------------------------------------------------------------- 1 | # .gqlgen.yml example 2 | # 3 | # Refer to https://gqlgen.com/config/ 4 | # for detailed .gqlgen.yml documentation. 5 | 6 | schema: 7 | - schema.graphql 8 | exec: 9 | filename: graphql/generated.go 10 | model: 11 | filename: models/models_gen.go 12 | models: 13 | User: 14 | model: github.com/equimper/meetmeup/models.User 15 | fields: 16 | meetups: 17 | resolver: true 18 | Meetup: 19 | model: github.com/equimper/meetmeup/models.Meetup 20 | fields: 21 | user: 22 | resolver: true 23 | resolver: 24 | filename: graphql/resolver.go 25 | type: Resolver 26 | autobind: [] 27 | -------------------------------------------------------------------------------- /graphql/dataloader.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "time" 7 | 8 | "github.com/go-pg/pg/v9" 9 | 10 | "github.com/equimper/meetmeup/models" 11 | ) 12 | 13 | const userloaderKey = "userloader" 14 | 15 | func DataloaderMiddleware(db *pg.DB, next http.Handler) http.Handler { 16 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 17 | userloader := UserLoader{ 18 | maxBatch: 100, 19 | wait: 1 * time.Millisecond, 20 | fetch: func(ids []string) ([]*models.User, []error) { 21 | var users []*models.User 22 | 23 | err := db.Model(&users).Where("id in (?)", pg.In(ids)).Select() 24 | 25 | if err != nil { 26 | return nil, []error{err} 27 | } 28 | 29 | u := make(map[string]*models.User, len(users)) 30 | 31 | for _, user := range users { 32 | u[user.ID] = user 33 | } 34 | 35 | result := make([]*models.User, len(ids)) 36 | 37 | for i, id := range ids { 38 | result[i] = u[id] 39 | } 40 | 41 | return result, nil 42 | }, 43 | } 44 | 45 | ctx := context.WithValue(r.Context(), userloaderKey, &userloader) 46 | 47 | next.ServeHTTP(w, r.WithContext(ctx)) 48 | }) 49 | } 50 | 51 | func getUserLoader(ctx context.Context) *UserLoader { 52 | return ctx.Value(userloaderKey).(*UserLoader) 53 | } 54 | -------------------------------------------------------------------------------- /graphql/generated.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 | 3 | package graphql 4 | 5 | import ( 6 | "bytes" 7 | "context" 8 | "errors" 9 | "strconv" 10 | "sync" 11 | "sync/atomic" 12 | "time" 13 | 14 | "github.com/99designs/gqlgen/graphql" 15 | "github.com/99designs/gqlgen/graphql/introspection" 16 | "github.com/equimper/meetmeup/models" 17 | "github.com/vektah/gqlparser" 18 | "github.com/vektah/gqlparser/ast" 19 | ) 20 | 21 | // region ************************** generated!.gotpl ************************** 22 | 23 | // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. 24 | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { 25 | return &executableSchema{ 26 | resolvers: cfg.Resolvers, 27 | directives: cfg.Directives, 28 | complexity: cfg.Complexity, 29 | } 30 | } 31 | 32 | type Config struct { 33 | Resolvers ResolverRoot 34 | Directives DirectiveRoot 35 | Complexity ComplexityRoot 36 | } 37 | 38 | type ResolverRoot interface { 39 | Meetup() MeetupResolver 40 | Mutation() MutationResolver 41 | Query() QueryResolver 42 | User() UserResolver 43 | } 44 | 45 | type DirectiveRoot struct { 46 | } 47 | 48 | type ComplexityRoot struct { 49 | AuthResponse struct { 50 | AuthToken func(childComplexity int) int 51 | User func(childComplexity int) int 52 | } 53 | 54 | AuthToken struct { 55 | AccessToken func(childComplexity int) int 56 | ExpiredAt func(childComplexity int) int 57 | } 58 | 59 | Meetup struct { 60 | Description func(childComplexity int) int 61 | ID func(childComplexity int) int 62 | Name func(childComplexity int) int 63 | User func(childComplexity int) int 64 | } 65 | 66 | Mutation struct { 67 | CreateMeetup func(childComplexity int, input models.NewMeetup) int 68 | DeleteMeetup func(childComplexity int, id string) int 69 | Login func(childComplexity int, input models.LoginInput) int 70 | Register func(childComplexity int, input models.RegisterInput) int 71 | UpdateMeetup func(childComplexity int, id string, input models.UpdateMeetup) int 72 | } 73 | 74 | Query struct { 75 | Meetups func(childComplexity int, filter *models.MeetupFilter, limit *int, offset *int) int 76 | User func(childComplexity int, id string) int 77 | } 78 | 79 | User struct { 80 | CreatedAt func(childComplexity int) int 81 | Email func(childComplexity int) int 82 | FirstName func(childComplexity int) int 83 | ID func(childComplexity int) int 84 | LastName func(childComplexity int) int 85 | Meetups func(childComplexity int) int 86 | UpdatedAt func(childComplexity int) int 87 | Username func(childComplexity int) int 88 | } 89 | } 90 | 91 | type MeetupResolver interface { 92 | User(ctx context.Context, obj *models.Meetup) (*models.User, error) 93 | } 94 | type MutationResolver interface { 95 | Register(ctx context.Context, input models.RegisterInput) (*models.AuthResponse, error) 96 | Login(ctx context.Context, input models.LoginInput) (*models.AuthResponse, error) 97 | CreateMeetup(ctx context.Context, input models.NewMeetup) (*models.Meetup, error) 98 | UpdateMeetup(ctx context.Context, id string, input models.UpdateMeetup) (*models.Meetup, error) 99 | DeleteMeetup(ctx context.Context, id string) (bool, error) 100 | } 101 | type QueryResolver interface { 102 | Meetups(ctx context.Context, filter *models.MeetupFilter, limit *int, offset *int) ([]*models.Meetup, error) 103 | User(ctx context.Context, id string) (*models.User, error) 104 | } 105 | type UserResolver interface { 106 | Meetups(ctx context.Context, obj *models.User) ([]*models.Meetup, error) 107 | } 108 | 109 | type executableSchema struct { 110 | resolvers ResolverRoot 111 | directives DirectiveRoot 112 | complexity ComplexityRoot 113 | } 114 | 115 | func (e *executableSchema) Schema() *ast.Schema { 116 | return parsedSchema 117 | } 118 | 119 | func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { 120 | ec := executionContext{nil, e} 121 | _ = ec 122 | switch typeName + "." + field { 123 | 124 | case "AuthResponse.authToken": 125 | if e.complexity.AuthResponse.AuthToken == nil { 126 | break 127 | } 128 | 129 | return e.complexity.AuthResponse.AuthToken(childComplexity), true 130 | 131 | case "AuthResponse.user": 132 | if e.complexity.AuthResponse.User == nil { 133 | break 134 | } 135 | 136 | return e.complexity.AuthResponse.User(childComplexity), true 137 | 138 | case "AuthToken.accessToken": 139 | if e.complexity.AuthToken.AccessToken == nil { 140 | break 141 | } 142 | 143 | return e.complexity.AuthToken.AccessToken(childComplexity), true 144 | 145 | case "AuthToken.expiredAt": 146 | if e.complexity.AuthToken.ExpiredAt == nil { 147 | break 148 | } 149 | 150 | return e.complexity.AuthToken.ExpiredAt(childComplexity), true 151 | 152 | case "Meetup.description": 153 | if e.complexity.Meetup.Description == nil { 154 | break 155 | } 156 | 157 | return e.complexity.Meetup.Description(childComplexity), true 158 | 159 | case "Meetup.id": 160 | if e.complexity.Meetup.ID == nil { 161 | break 162 | } 163 | 164 | return e.complexity.Meetup.ID(childComplexity), true 165 | 166 | case "Meetup.name": 167 | if e.complexity.Meetup.Name == nil { 168 | break 169 | } 170 | 171 | return e.complexity.Meetup.Name(childComplexity), true 172 | 173 | case "Meetup.user": 174 | if e.complexity.Meetup.User == nil { 175 | break 176 | } 177 | 178 | return e.complexity.Meetup.User(childComplexity), true 179 | 180 | case "Mutation.createMeetup": 181 | if e.complexity.Mutation.CreateMeetup == nil { 182 | break 183 | } 184 | 185 | args, err := ec.field_Mutation_createMeetup_args(context.TODO(), rawArgs) 186 | if err != nil { 187 | return 0, false 188 | } 189 | 190 | return e.complexity.Mutation.CreateMeetup(childComplexity, args["input"].(models.NewMeetup)), true 191 | 192 | case "Mutation.deleteMeetup": 193 | if e.complexity.Mutation.DeleteMeetup == nil { 194 | break 195 | } 196 | 197 | args, err := ec.field_Mutation_deleteMeetup_args(context.TODO(), rawArgs) 198 | if err != nil { 199 | return 0, false 200 | } 201 | 202 | return e.complexity.Mutation.DeleteMeetup(childComplexity, args["id"].(string)), true 203 | 204 | case "Mutation.login": 205 | if e.complexity.Mutation.Login == nil { 206 | break 207 | } 208 | 209 | args, err := ec.field_Mutation_login_args(context.TODO(), rawArgs) 210 | if err != nil { 211 | return 0, false 212 | } 213 | 214 | return e.complexity.Mutation.Login(childComplexity, args["input"].(models.LoginInput)), true 215 | 216 | case "Mutation.register": 217 | if e.complexity.Mutation.Register == nil { 218 | break 219 | } 220 | 221 | args, err := ec.field_Mutation_register_args(context.TODO(), rawArgs) 222 | if err != nil { 223 | return 0, false 224 | } 225 | 226 | return e.complexity.Mutation.Register(childComplexity, args["input"].(models.RegisterInput)), true 227 | 228 | case "Mutation.updateMeetup": 229 | if e.complexity.Mutation.UpdateMeetup == nil { 230 | break 231 | } 232 | 233 | args, err := ec.field_Mutation_updateMeetup_args(context.TODO(), rawArgs) 234 | if err != nil { 235 | return 0, false 236 | } 237 | 238 | return e.complexity.Mutation.UpdateMeetup(childComplexity, args["id"].(string), args["input"].(models.UpdateMeetup)), true 239 | 240 | case "Query.meetups": 241 | if e.complexity.Query.Meetups == nil { 242 | break 243 | } 244 | 245 | args, err := ec.field_Query_meetups_args(context.TODO(), rawArgs) 246 | if err != nil { 247 | return 0, false 248 | } 249 | 250 | return e.complexity.Query.Meetups(childComplexity, args["filter"].(*models.MeetupFilter), args["limit"].(*int), args["offset"].(*int)), true 251 | 252 | case "Query.user": 253 | if e.complexity.Query.User == nil { 254 | break 255 | } 256 | 257 | args, err := ec.field_Query_user_args(context.TODO(), rawArgs) 258 | if err != nil { 259 | return 0, false 260 | } 261 | 262 | return e.complexity.Query.User(childComplexity, args["id"].(string)), true 263 | 264 | case "User.createdAt": 265 | if e.complexity.User.CreatedAt == nil { 266 | break 267 | } 268 | 269 | return e.complexity.User.CreatedAt(childComplexity), true 270 | 271 | case "User.email": 272 | if e.complexity.User.Email == nil { 273 | break 274 | } 275 | 276 | return e.complexity.User.Email(childComplexity), true 277 | 278 | case "User.firstName": 279 | if e.complexity.User.FirstName == nil { 280 | break 281 | } 282 | 283 | return e.complexity.User.FirstName(childComplexity), true 284 | 285 | case "User.id": 286 | if e.complexity.User.ID == nil { 287 | break 288 | } 289 | 290 | return e.complexity.User.ID(childComplexity), true 291 | 292 | case "User.lastName": 293 | if e.complexity.User.LastName == nil { 294 | break 295 | } 296 | 297 | return e.complexity.User.LastName(childComplexity), true 298 | 299 | case "User.meetups": 300 | if e.complexity.User.Meetups == nil { 301 | break 302 | } 303 | 304 | return e.complexity.User.Meetups(childComplexity), true 305 | 306 | case "User.updatedAt": 307 | if e.complexity.User.UpdatedAt == nil { 308 | break 309 | } 310 | 311 | return e.complexity.User.UpdatedAt(childComplexity), true 312 | 313 | case "User.username": 314 | if e.complexity.User.Username == nil { 315 | break 316 | } 317 | 318 | return e.complexity.User.Username(childComplexity), true 319 | 320 | } 321 | return 0, false 322 | } 323 | 324 | func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { 325 | ec := executionContext{graphql.GetRequestContext(ctx), e} 326 | 327 | buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { 328 | data := ec._Query(ctx, op.SelectionSet) 329 | var buf bytes.Buffer 330 | data.MarshalGQL(&buf) 331 | return buf.Bytes() 332 | }) 333 | 334 | return &graphql.Response{ 335 | Data: buf, 336 | Errors: ec.Errors, 337 | Extensions: ec.Extensions, 338 | } 339 | } 340 | 341 | func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { 342 | ec := executionContext{graphql.GetRequestContext(ctx), e} 343 | 344 | buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { 345 | data := ec._Mutation(ctx, op.SelectionSet) 346 | var buf bytes.Buffer 347 | data.MarshalGQL(&buf) 348 | return buf.Bytes() 349 | }) 350 | 351 | return &graphql.Response{ 352 | Data: buf, 353 | Errors: ec.Errors, 354 | Extensions: ec.Extensions, 355 | } 356 | } 357 | 358 | func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { 359 | return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) 360 | } 361 | 362 | type executionContext struct { 363 | *graphql.RequestContext 364 | *executableSchema 365 | } 366 | 367 | func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { 368 | if ec.DisableIntrospection { 369 | return nil, errors.New("introspection disabled") 370 | } 371 | return introspection.WrapSchema(parsedSchema), nil 372 | } 373 | 374 | func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { 375 | if ec.DisableIntrospection { 376 | return nil, errors.New("introspection disabled") 377 | } 378 | return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil 379 | } 380 | 381 | var parsedSchema = gqlparser.MustLoadSchema( 382 | &ast.Source{Name: "schema.graphql", Input: `scalar Time 383 | 384 | type AuthToken { 385 | accessToken: String! 386 | expiredAt: Time! 387 | } 388 | 389 | type AuthResponse { 390 | authToken: AuthToken! 391 | user: User! 392 | } 393 | 394 | type User { 395 | id: ID! 396 | username: String! 397 | email: String! 398 | firstName: String! 399 | lastName: String! 400 | meetups: [Meetup!]! 401 | createdAt: Time! 402 | updatedAt: Time! 403 | } 404 | 405 | type Meetup { 406 | id: ID! 407 | name: String! 408 | description: String! 409 | user: User! 410 | } 411 | 412 | input RegisterInput { 413 | username: String! 414 | email: String! 415 | password: String! 416 | confirmPassword: String! 417 | firstName: String! 418 | lastName: String! 419 | } 420 | 421 | input LoginInput { 422 | email: String! 423 | password: String! 424 | } 425 | 426 | input NewMeetup { 427 | name: String! 428 | description: String! 429 | } 430 | 431 | input UpdateMeetup { 432 | name: String 433 | description: String 434 | } 435 | 436 | input MeetupFilter { 437 | name: String 438 | } 439 | 440 | type Query { 441 | meetups(filter: MeetupFilter, limit: Int = 10, offset: Int = 0): [Meetup!]! 442 | user(id: ID!): User! 443 | } 444 | 445 | type Mutation { 446 | register(input: RegisterInput!): AuthResponse! 447 | login(input: LoginInput!): AuthResponse! 448 | createMeetup(input: NewMeetup!): Meetup! 449 | updateMeetup(id: ID!, input: UpdateMeetup!): Meetup! 450 | deleteMeetup(id: ID!): Boolean! 451 | }`}, 452 | ) 453 | 454 | // endregion ************************** generated!.gotpl ************************** 455 | 456 | // region ***************************** args.gotpl ***************************** 457 | 458 | func (ec *executionContext) field_Mutation_createMeetup_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 459 | var err error 460 | args := map[string]interface{}{} 461 | var arg0 models.NewMeetup 462 | if tmp, ok := rawArgs["input"]; ok { 463 | arg0, err = ec.unmarshalNNewMeetup2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐNewMeetup(ctx, tmp) 464 | if err != nil { 465 | return nil, err 466 | } 467 | } 468 | args["input"] = arg0 469 | return args, nil 470 | } 471 | 472 | func (ec *executionContext) field_Mutation_deleteMeetup_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 473 | var err error 474 | args := map[string]interface{}{} 475 | var arg0 string 476 | if tmp, ok := rawArgs["id"]; ok { 477 | arg0, err = ec.unmarshalNID2string(ctx, tmp) 478 | if err != nil { 479 | return nil, err 480 | } 481 | } 482 | args["id"] = arg0 483 | return args, nil 484 | } 485 | 486 | func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 487 | var err error 488 | args := map[string]interface{}{} 489 | var arg0 models.LoginInput 490 | if tmp, ok := rawArgs["input"]; ok { 491 | arg0, err = ec.unmarshalNLoginInput2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐLoginInput(ctx, tmp) 492 | if err != nil { 493 | return nil, err 494 | } 495 | } 496 | args["input"] = arg0 497 | return args, nil 498 | } 499 | 500 | func (ec *executionContext) field_Mutation_register_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 501 | var err error 502 | args := map[string]interface{}{} 503 | var arg0 models.RegisterInput 504 | if tmp, ok := rawArgs["input"]; ok { 505 | arg0, err = ec.unmarshalNRegisterInput2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐRegisterInput(ctx, tmp) 506 | if err != nil { 507 | return nil, err 508 | } 509 | } 510 | args["input"] = arg0 511 | return args, nil 512 | } 513 | 514 | func (ec *executionContext) field_Mutation_updateMeetup_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 515 | var err error 516 | args := map[string]interface{}{} 517 | var arg0 string 518 | if tmp, ok := rawArgs["id"]; ok { 519 | arg0, err = ec.unmarshalNID2string(ctx, tmp) 520 | if err != nil { 521 | return nil, err 522 | } 523 | } 524 | args["id"] = arg0 525 | var arg1 models.UpdateMeetup 526 | if tmp, ok := rawArgs["input"]; ok { 527 | arg1, err = ec.unmarshalNUpdateMeetup2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐUpdateMeetup(ctx, tmp) 528 | if err != nil { 529 | return nil, err 530 | } 531 | } 532 | args["input"] = arg1 533 | return args, nil 534 | } 535 | 536 | func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 537 | var err error 538 | args := map[string]interface{}{} 539 | var arg0 string 540 | if tmp, ok := rawArgs["name"]; ok { 541 | arg0, err = ec.unmarshalNString2string(ctx, tmp) 542 | if err != nil { 543 | return nil, err 544 | } 545 | } 546 | args["name"] = arg0 547 | return args, nil 548 | } 549 | 550 | func (ec *executionContext) field_Query_meetups_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 551 | var err error 552 | args := map[string]interface{}{} 553 | var arg0 *models.MeetupFilter 554 | if tmp, ok := rawArgs["filter"]; ok { 555 | arg0, err = ec.unmarshalOMeetupFilter2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetupFilter(ctx, tmp) 556 | if err != nil { 557 | return nil, err 558 | } 559 | } 560 | args["filter"] = arg0 561 | var arg1 *int 562 | if tmp, ok := rawArgs["limit"]; ok { 563 | arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) 564 | if err != nil { 565 | return nil, err 566 | } 567 | } 568 | args["limit"] = arg1 569 | var arg2 *int 570 | if tmp, ok := rawArgs["offset"]; ok { 571 | arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) 572 | if err != nil { 573 | return nil, err 574 | } 575 | } 576 | args["offset"] = arg2 577 | return args, nil 578 | } 579 | 580 | func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 581 | var err error 582 | args := map[string]interface{}{} 583 | var arg0 string 584 | if tmp, ok := rawArgs["id"]; ok { 585 | arg0, err = ec.unmarshalNID2string(ctx, tmp) 586 | if err != nil { 587 | return nil, err 588 | } 589 | } 590 | args["id"] = arg0 591 | return args, nil 592 | } 593 | 594 | func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 595 | var err error 596 | args := map[string]interface{}{} 597 | var arg0 bool 598 | if tmp, ok := rawArgs["includeDeprecated"]; ok { 599 | arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) 600 | if err != nil { 601 | return nil, err 602 | } 603 | } 604 | args["includeDeprecated"] = arg0 605 | return args, nil 606 | } 607 | 608 | func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 609 | var err error 610 | args := map[string]interface{}{} 611 | var arg0 bool 612 | if tmp, ok := rawArgs["includeDeprecated"]; ok { 613 | arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) 614 | if err != nil { 615 | return nil, err 616 | } 617 | } 618 | args["includeDeprecated"] = arg0 619 | return args, nil 620 | } 621 | 622 | // endregion ***************************** args.gotpl ***************************** 623 | 624 | // region ************************** directives.gotpl ************************** 625 | 626 | // endregion ************************** directives.gotpl ************************** 627 | 628 | // region **************************** field.gotpl ***************************** 629 | 630 | func (ec *executionContext) _AuthResponse_authToken(ctx context.Context, field graphql.CollectedField, obj *models.AuthResponse) (ret graphql.Marshaler) { 631 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 632 | defer func() { 633 | if r := recover(); r != nil { 634 | ec.Error(ctx, ec.Recover(ctx, r)) 635 | ret = graphql.Null 636 | } 637 | ec.Tracer.EndFieldExecution(ctx) 638 | }() 639 | rctx := &graphql.ResolverContext{ 640 | Object: "AuthResponse", 641 | Field: field, 642 | Args: nil, 643 | IsMethod: false, 644 | } 645 | ctx = graphql.WithResolverContext(ctx, rctx) 646 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 647 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 648 | ctx = rctx // use context from middleware stack in children 649 | return obj.AuthToken, nil 650 | }) 651 | if err != nil { 652 | ec.Error(ctx, err) 653 | return graphql.Null 654 | } 655 | if resTmp == nil { 656 | if !ec.HasError(rctx) { 657 | ec.Errorf(ctx, "must not be null") 658 | } 659 | return graphql.Null 660 | } 661 | res := resTmp.(*models.AuthToken) 662 | rctx.Result = res 663 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 664 | return ec.marshalNAuthToken2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐAuthToken(ctx, field.Selections, res) 665 | } 666 | 667 | func (ec *executionContext) _AuthResponse_user(ctx context.Context, field graphql.CollectedField, obj *models.AuthResponse) (ret graphql.Marshaler) { 668 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 669 | defer func() { 670 | if r := recover(); r != nil { 671 | ec.Error(ctx, ec.Recover(ctx, r)) 672 | ret = graphql.Null 673 | } 674 | ec.Tracer.EndFieldExecution(ctx) 675 | }() 676 | rctx := &graphql.ResolverContext{ 677 | Object: "AuthResponse", 678 | Field: field, 679 | Args: nil, 680 | IsMethod: false, 681 | } 682 | ctx = graphql.WithResolverContext(ctx, rctx) 683 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 684 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 685 | ctx = rctx // use context from middleware stack in children 686 | return obj.User, nil 687 | }) 688 | if err != nil { 689 | ec.Error(ctx, err) 690 | return graphql.Null 691 | } 692 | if resTmp == nil { 693 | if !ec.HasError(rctx) { 694 | ec.Errorf(ctx, "must not be null") 695 | } 696 | return graphql.Null 697 | } 698 | res := resTmp.(*models.User) 699 | rctx.Result = res 700 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 701 | return ec.marshalNUser2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐUser(ctx, field.Selections, res) 702 | } 703 | 704 | func (ec *executionContext) _AuthToken_accessToken(ctx context.Context, field graphql.CollectedField, obj *models.AuthToken) (ret graphql.Marshaler) { 705 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 706 | defer func() { 707 | if r := recover(); r != nil { 708 | ec.Error(ctx, ec.Recover(ctx, r)) 709 | ret = graphql.Null 710 | } 711 | ec.Tracer.EndFieldExecution(ctx) 712 | }() 713 | rctx := &graphql.ResolverContext{ 714 | Object: "AuthToken", 715 | Field: field, 716 | Args: nil, 717 | IsMethod: false, 718 | } 719 | ctx = graphql.WithResolverContext(ctx, rctx) 720 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 721 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 722 | ctx = rctx // use context from middleware stack in children 723 | return obj.AccessToken, nil 724 | }) 725 | if err != nil { 726 | ec.Error(ctx, err) 727 | return graphql.Null 728 | } 729 | if resTmp == nil { 730 | if !ec.HasError(rctx) { 731 | ec.Errorf(ctx, "must not be null") 732 | } 733 | return graphql.Null 734 | } 735 | res := resTmp.(string) 736 | rctx.Result = res 737 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 738 | return ec.marshalNString2string(ctx, field.Selections, res) 739 | } 740 | 741 | func (ec *executionContext) _AuthToken_expiredAt(ctx context.Context, field graphql.CollectedField, obj *models.AuthToken) (ret graphql.Marshaler) { 742 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 743 | defer func() { 744 | if r := recover(); r != nil { 745 | ec.Error(ctx, ec.Recover(ctx, r)) 746 | ret = graphql.Null 747 | } 748 | ec.Tracer.EndFieldExecution(ctx) 749 | }() 750 | rctx := &graphql.ResolverContext{ 751 | Object: "AuthToken", 752 | Field: field, 753 | Args: nil, 754 | IsMethod: false, 755 | } 756 | ctx = graphql.WithResolverContext(ctx, rctx) 757 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 758 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 759 | ctx = rctx // use context from middleware stack in children 760 | return obj.ExpiredAt, nil 761 | }) 762 | if err != nil { 763 | ec.Error(ctx, err) 764 | return graphql.Null 765 | } 766 | if resTmp == nil { 767 | if !ec.HasError(rctx) { 768 | ec.Errorf(ctx, "must not be null") 769 | } 770 | return graphql.Null 771 | } 772 | res := resTmp.(time.Time) 773 | rctx.Result = res 774 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 775 | return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) 776 | } 777 | 778 | func (ec *executionContext) _Meetup_id(ctx context.Context, field graphql.CollectedField, obj *models.Meetup) (ret graphql.Marshaler) { 779 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 780 | defer func() { 781 | if r := recover(); r != nil { 782 | ec.Error(ctx, ec.Recover(ctx, r)) 783 | ret = graphql.Null 784 | } 785 | ec.Tracer.EndFieldExecution(ctx) 786 | }() 787 | rctx := &graphql.ResolverContext{ 788 | Object: "Meetup", 789 | Field: field, 790 | Args: nil, 791 | IsMethod: false, 792 | } 793 | ctx = graphql.WithResolverContext(ctx, rctx) 794 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 795 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 796 | ctx = rctx // use context from middleware stack in children 797 | return obj.ID, nil 798 | }) 799 | if err != nil { 800 | ec.Error(ctx, err) 801 | return graphql.Null 802 | } 803 | if resTmp == nil { 804 | if !ec.HasError(rctx) { 805 | ec.Errorf(ctx, "must not be null") 806 | } 807 | return graphql.Null 808 | } 809 | res := resTmp.(string) 810 | rctx.Result = res 811 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 812 | return ec.marshalNID2string(ctx, field.Selections, res) 813 | } 814 | 815 | func (ec *executionContext) _Meetup_name(ctx context.Context, field graphql.CollectedField, obj *models.Meetup) (ret graphql.Marshaler) { 816 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 817 | defer func() { 818 | if r := recover(); r != nil { 819 | ec.Error(ctx, ec.Recover(ctx, r)) 820 | ret = graphql.Null 821 | } 822 | ec.Tracer.EndFieldExecution(ctx) 823 | }() 824 | rctx := &graphql.ResolverContext{ 825 | Object: "Meetup", 826 | Field: field, 827 | Args: nil, 828 | IsMethod: false, 829 | } 830 | ctx = graphql.WithResolverContext(ctx, rctx) 831 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 832 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 833 | ctx = rctx // use context from middleware stack in children 834 | return obj.Name, nil 835 | }) 836 | if err != nil { 837 | ec.Error(ctx, err) 838 | return graphql.Null 839 | } 840 | if resTmp == nil { 841 | if !ec.HasError(rctx) { 842 | ec.Errorf(ctx, "must not be null") 843 | } 844 | return graphql.Null 845 | } 846 | res := resTmp.(string) 847 | rctx.Result = res 848 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 849 | return ec.marshalNString2string(ctx, field.Selections, res) 850 | } 851 | 852 | func (ec *executionContext) _Meetup_description(ctx context.Context, field graphql.CollectedField, obj *models.Meetup) (ret graphql.Marshaler) { 853 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 854 | defer func() { 855 | if r := recover(); r != nil { 856 | ec.Error(ctx, ec.Recover(ctx, r)) 857 | ret = graphql.Null 858 | } 859 | ec.Tracer.EndFieldExecution(ctx) 860 | }() 861 | rctx := &graphql.ResolverContext{ 862 | Object: "Meetup", 863 | Field: field, 864 | Args: nil, 865 | IsMethod: false, 866 | } 867 | ctx = graphql.WithResolverContext(ctx, rctx) 868 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 869 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 870 | ctx = rctx // use context from middleware stack in children 871 | return obj.Description, nil 872 | }) 873 | if err != nil { 874 | ec.Error(ctx, err) 875 | return graphql.Null 876 | } 877 | if resTmp == nil { 878 | if !ec.HasError(rctx) { 879 | ec.Errorf(ctx, "must not be null") 880 | } 881 | return graphql.Null 882 | } 883 | res := resTmp.(string) 884 | rctx.Result = res 885 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 886 | return ec.marshalNString2string(ctx, field.Selections, res) 887 | } 888 | 889 | func (ec *executionContext) _Meetup_user(ctx context.Context, field graphql.CollectedField, obj *models.Meetup) (ret graphql.Marshaler) { 890 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 891 | defer func() { 892 | if r := recover(); r != nil { 893 | ec.Error(ctx, ec.Recover(ctx, r)) 894 | ret = graphql.Null 895 | } 896 | ec.Tracer.EndFieldExecution(ctx) 897 | }() 898 | rctx := &graphql.ResolverContext{ 899 | Object: "Meetup", 900 | Field: field, 901 | Args: nil, 902 | IsMethod: true, 903 | } 904 | ctx = graphql.WithResolverContext(ctx, rctx) 905 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 906 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 907 | ctx = rctx // use context from middleware stack in children 908 | return ec.resolvers.Meetup().User(rctx, obj) 909 | }) 910 | if err != nil { 911 | ec.Error(ctx, err) 912 | return graphql.Null 913 | } 914 | if resTmp == nil { 915 | if !ec.HasError(rctx) { 916 | ec.Errorf(ctx, "must not be null") 917 | } 918 | return graphql.Null 919 | } 920 | res := resTmp.(*models.User) 921 | rctx.Result = res 922 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 923 | return ec.marshalNUser2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐUser(ctx, field.Selections, res) 924 | } 925 | 926 | func (ec *executionContext) _Mutation_register(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 927 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 928 | defer func() { 929 | if r := recover(); r != nil { 930 | ec.Error(ctx, ec.Recover(ctx, r)) 931 | ret = graphql.Null 932 | } 933 | ec.Tracer.EndFieldExecution(ctx) 934 | }() 935 | rctx := &graphql.ResolverContext{ 936 | Object: "Mutation", 937 | Field: field, 938 | Args: nil, 939 | IsMethod: true, 940 | } 941 | ctx = graphql.WithResolverContext(ctx, rctx) 942 | rawArgs := field.ArgumentMap(ec.Variables) 943 | args, err := ec.field_Mutation_register_args(ctx, rawArgs) 944 | if err != nil { 945 | ec.Error(ctx, err) 946 | return graphql.Null 947 | } 948 | rctx.Args = args 949 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 950 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 951 | ctx = rctx // use context from middleware stack in children 952 | return ec.resolvers.Mutation().Register(rctx, args["input"].(models.RegisterInput)) 953 | }) 954 | if err != nil { 955 | ec.Error(ctx, err) 956 | return graphql.Null 957 | } 958 | if resTmp == nil { 959 | if !ec.HasError(rctx) { 960 | ec.Errorf(ctx, "must not be null") 961 | } 962 | return graphql.Null 963 | } 964 | res := resTmp.(*models.AuthResponse) 965 | rctx.Result = res 966 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 967 | return ec.marshalNAuthResponse2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐAuthResponse(ctx, field.Selections, res) 968 | } 969 | 970 | func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 971 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 972 | defer func() { 973 | if r := recover(); r != nil { 974 | ec.Error(ctx, ec.Recover(ctx, r)) 975 | ret = graphql.Null 976 | } 977 | ec.Tracer.EndFieldExecution(ctx) 978 | }() 979 | rctx := &graphql.ResolverContext{ 980 | Object: "Mutation", 981 | Field: field, 982 | Args: nil, 983 | IsMethod: true, 984 | } 985 | ctx = graphql.WithResolverContext(ctx, rctx) 986 | rawArgs := field.ArgumentMap(ec.Variables) 987 | args, err := ec.field_Mutation_login_args(ctx, rawArgs) 988 | if err != nil { 989 | ec.Error(ctx, err) 990 | return graphql.Null 991 | } 992 | rctx.Args = args 993 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 994 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 995 | ctx = rctx // use context from middleware stack in children 996 | return ec.resolvers.Mutation().Login(rctx, args["input"].(models.LoginInput)) 997 | }) 998 | if err != nil { 999 | ec.Error(ctx, err) 1000 | return graphql.Null 1001 | } 1002 | if resTmp == nil { 1003 | if !ec.HasError(rctx) { 1004 | ec.Errorf(ctx, "must not be null") 1005 | } 1006 | return graphql.Null 1007 | } 1008 | res := resTmp.(*models.AuthResponse) 1009 | rctx.Result = res 1010 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1011 | return ec.marshalNAuthResponse2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐAuthResponse(ctx, field.Selections, res) 1012 | } 1013 | 1014 | func (ec *executionContext) _Mutation_createMeetup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 1015 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1016 | defer func() { 1017 | if r := recover(); r != nil { 1018 | ec.Error(ctx, ec.Recover(ctx, r)) 1019 | ret = graphql.Null 1020 | } 1021 | ec.Tracer.EndFieldExecution(ctx) 1022 | }() 1023 | rctx := &graphql.ResolverContext{ 1024 | Object: "Mutation", 1025 | Field: field, 1026 | Args: nil, 1027 | IsMethod: true, 1028 | } 1029 | ctx = graphql.WithResolverContext(ctx, rctx) 1030 | rawArgs := field.ArgumentMap(ec.Variables) 1031 | args, err := ec.field_Mutation_createMeetup_args(ctx, rawArgs) 1032 | if err != nil { 1033 | ec.Error(ctx, err) 1034 | return graphql.Null 1035 | } 1036 | rctx.Args = args 1037 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1038 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1039 | ctx = rctx // use context from middleware stack in children 1040 | return ec.resolvers.Mutation().CreateMeetup(rctx, args["input"].(models.NewMeetup)) 1041 | }) 1042 | if err != nil { 1043 | ec.Error(ctx, err) 1044 | return graphql.Null 1045 | } 1046 | if resTmp == nil { 1047 | if !ec.HasError(rctx) { 1048 | ec.Errorf(ctx, "must not be null") 1049 | } 1050 | return graphql.Null 1051 | } 1052 | res := resTmp.(*models.Meetup) 1053 | rctx.Result = res 1054 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1055 | return ec.marshalNMeetup2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetup(ctx, field.Selections, res) 1056 | } 1057 | 1058 | func (ec *executionContext) _Mutation_updateMeetup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 1059 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1060 | defer func() { 1061 | if r := recover(); r != nil { 1062 | ec.Error(ctx, ec.Recover(ctx, r)) 1063 | ret = graphql.Null 1064 | } 1065 | ec.Tracer.EndFieldExecution(ctx) 1066 | }() 1067 | rctx := &graphql.ResolverContext{ 1068 | Object: "Mutation", 1069 | Field: field, 1070 | Args: nil, 1071 | IsMethod: true, 1072 | } 1073 | ctx = graphql.WithResolverContext(ctx, rctx) 1074 | rawArgs := field.ArgumentMap(ec.Variables) 1075 | args, err := ec.field_Mutation_updateMeetup_args(ctx, rawArgs) 1076 | if err != nil { 1077 | ec.Error(ctx, err) 1078 | return graphql.Null 1079 | } 1080 | rctx.Args = args 1081 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1082 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1083 | ctx = rctx // use context from middleware stack in children 1084 | return ec.resolvers.Mutation().UpdateMeetup(rctx, args["id"].(string), args["input"].(models.UpdateMeetup)) 1085 | }) 1086 | if err != nil { 1087 | ec.Error(ctx, err) 1088 | return graphql.Null 1089 | } 1090 | if resTmp == nil { 1091 | if !ec.HasError(rctx) { 1092 | ec.Errorf(ctx, "must not be null") 1093 | } 1094 | return graphql.Null 1095 | } 1096 | res := resTmp.(*models.Meetup) 1097 | rctx.Result = res 1098 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1099 | return ec.marshalNMeetup2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetup(ctx, field.Selections, res) 1100 | } 1101 | 1102 | func (ec *executionContext) _Mutation_deleteMeetup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 1103 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1104 | defer func() { 1105 | if r := recover(); r != nil { 1106 | ec.Error(ctx, ec.Recover(ctx, r)) 1107 | ret = graphql.Null 1108 | } 1109 | ec.Tracer.EndFieldExecution(ctx) 1110 | }() 1111 | rctx := &graphql.ResolverContext{ 1112 | Object: "Mutation", 1113 | Field: field, 1114 | Args: nil, 1115 | IsMethod: true, 1116 | } 1117 | ctx = graphql.WithResolverContext(ctx, rctx) 1118 | rawArgs := field.ArgumentMap(ec.Variables) 1119 | args, err := ec.field_Mutation_deleteMeetup_args(ctx, rawArgs) 1120 | if err != nil { 1121 | ec.Error(ctx, err) 1122 | return graphql.Null 1123 | } 1124 | rctx.Args = args 1125 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1126 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1127 | ctx = rctx // use context from middleware stack in children 1128 | return ec.resolvers.Mutation().DeleteMeetup(rctx, args["id"].(string)) 1129 | }) 1130 | if err != nil { 1131 | ec.Error(ctx, err) 1132 | return graphql.Null 1133 | } 1134 | if resTmp == nil { 1135 | if !ec.HasError(rctx) { 1136 | ec.Errorf(ctx, "must not be null") 1137 | } 1138 | return graphql.Null 1139 | } 1140 | res := resTmp.(bool) 1141 | rctx.Result = res 1142 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1143 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 1144 | } 1145 | 1146 | func (ec *executionContext) _Query_meetups(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 1147 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1148 | defer func() { 1149 | if r := recover(); r != nil { 1150 | ec.Error(ctx, ec.Recover(ctx, r)) 1151 | ret = graphql.Null 1152 | } 1153 | ec.Tracer.EndFieldExecution(ctx) 1154 | }() 1155 | rctx := &graphql.ResolverContext{ 1156 | Object: "Query", 1157 | Field: field, 1158 | Args: nil, 1159 | IsMethod: true, 1160 | } 1161 | ctx = graphql.WithResolverContext(ctx, rctx) 1162 | rawArgs := field.ArgumentMap(ec.Variables) 1163 | args, err := ec.field_Query_meetups_args(ctx, rawArgs) 1164 | if err != nil { 1165 | ec.Error(ctx, err) 1166 | return graphql.Null 1167 | } 1168 | rctx.Args = args 1169 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1170 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1171 | ctx = rctx // use context from middleware stack in children 1172 | return ec.resolvers.Query().Meetups(rctx, args["filter"].(*models.MeetupFilter), args["limit"].(*int), args["offset"].(*int)) 1173 | }) 1174 | if err != nil { 1175 | ec.Error(ctx, err) 1176 | return graphql.Null 1177 | } 1178 | if resTmp == nil { 1179 | if !ec.HasError(rctx) { 1180 | ec.Errorf(ctx, "must not be null") 1181 | } 1182 | return graphql.Null 1183 | } 1184 | res := resTmp.([]*models.Meetup) 1185 | rctx.Result = res 1186 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1187 | return ec.marshalNMeetup2ᚕᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetupᚄ(ctx, field.Selections, res) 1188 | } 1189 | 1190 | func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 1191 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1192 | defer func() { 1193 | if r := recover(); r != nil { 1194 | ec.Error(ctx, ec.Recover(ctx, r)) 1195 | ret = graphql.Null 1196 | } 1197 | ec.Tracer.EndFieldExecution(ctx) 1198 | }() 1199 | rctx := &graphql.ResolverContext{ 1200 | Object: "Query", 1201 | Field: field, 1202 | Args: nil, 1203 | IsMethod: true, 1204 | } 1205 | ctx = graphql.WithResolverContext(ctx, rctx) 1206 | rawArgs := field.ArgumentMap(ec.Variables) 1207 | args, err := ec.field_Query_user_args(ctx, rawArgs) 1208 | if err != nil { 1209 | ec.Error(ctx, err) 1210 | return graphql.Null 1211 | } 1212 | rctx.Args = args 1213 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1214 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1215 | ctx = rctx // use context from middleware stack in children 1216 | return ec.resolvers.Query().User(rctx, args["id"].(string)) 1217 | }) 1218 | if err != nil { 1219 | ec.Error(ctx, err) 1220 | return graphql.Null 1221 | } 1222 | if resTmp == nil { 1223 | if !ec.HasError(rctx) { 1224 | ec.Errorf(ctx, "must not be null") 1225 | } 1226 | return graphql.Null 1227 | } 1228 | res := resTmp.(*models.User) 1229 | rctx.Result = res 1230 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1231 | return ec.marshalNUser2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐUser(ctx, field.Selections, res) 1232 | } 1233 | 1234 | func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 1235 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1236 | defer func() { 1237 | if r := recover(); r != nil { 1238 | ec.Error(ctx, ec.Recover(ctx, r)) 1239 | ret = graphql.Null 1240 | } 1241 | ec.Tracer.EndFieldExecution(ctx) 1242 | }() 1243 | rctx := &graphql.ResolverContext{ 1244 | Object: "Query", 1245 | Field: field, 1246 | Args: nil, 1247 | IsMethod: true, 1248 | } 1249 | ctx = graphql.WithResolverContext(ctx, rctx) 1250 | rawArgs := field.ArgumentMap(ec.Variables) 1251 | args, err := ec.field_Query___type_args(ctx, rawArgs) 1252 | if err != nil { 1253 | ec.Error(ctx, err) 1254 | return graphql.Null 1255 | } 1256 | rctx.Args = args 1257 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1258 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1259 | ctx = rctx // use context from middleware stack in children 1260 | return ec.introspectType(args["name"].(string)) 1261 | }) 1262 | if err != nil { 1263 | ec.Error(ctx, err) 1264 | return graphql.Null 1265 | } 1266 | if resTmp == nil { 1267 | return graphql.Null 1268 | } 1269 | res := resTmp.(*introspection.Type) 1270 | rctx.Result = res 1271 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1272 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1273 | } 1274 | 1275 | func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 1276 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1277 | defer func() { 1278 | if r := recover(); r != nil { 1279 | ec.Error(ctx, ec.Recover(ctx, r)) 1280 | ret = graphql.Null 1281 | } 1282 | ec.Tracer.EndFieldExecution(ctx) 1283 | }() 1284 | rctx := &graphql.ResolverContext{ 1285 | Object: "Query", 1286 | Field: field, 1287 | Args: nil, 1288 | IsMethod: true, 1289 | } 1290 | ctx = graphql.WithResolverContext(ctx, rctx) 1291 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1292 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1293 | ctx = rctx // use context from middleware stack in children 1294 | return ec.introspectSchema() 1295 | }) 1296 | if err != nil { 1297 | ec.Error(ctx, err) 1298 | return graphql.Null 1299 | } 1300 | if resTmp == nil { 1301 | return graphql.Null 1302 | } 1303 | res := resTmp.(*introspection.Schema) 1304 | rctx.Result = res 1305 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1306 | return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) 1307 | } 1308 | 1309 | func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { 1310 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1311 | defer func() { 1312 | if r := recover(); r != nil { 1313 | ec.Error(ctx, ec.Recover(ctx, r)) 1314 | ret = graphql.Null 1315 | } 1316 | ec.Tracer.EndFieldExecution(ctx) 1317 | }() 1318 | rctx := &graphql.ResolverContext{ 1319 | Object: "User", 1320 | Field: field, 1321 | Args: nil, 1322 | IsMethod: false, 1323 | } 1324 | ctx = graphql.WithResolverContext(ctx, rctx) 1325 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1326 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1327 | ctx = rctx // use context from middleware stack in children 1328 | return obj.ID, nil 1329 | }) 1330 | if err != nil { 1331 | ec.Error(ctx, err) 1332 | return graphql.Null 1333 | } 1334 | if resTmp == nil { 1335 | if !ec.HasError(rctx) { 1336 | ec.Errorf(ctx, "must not be null") 1337 | } 1338 | return graphql.Null 1339 | } 1340 | res := resTmp.(string) 1341 | rctx.Result = res 1342 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1343 | return ec.marshalNID2string(ctx, field.Selections, res) 1344 | } 1345 | 1346 | func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { 1347 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1348 | defer func() { 1349 | if r := recover(); r != nil { 1350 | ec.Error(ctx, ec.Recover(ctx, r)) 1351 | ret = graphql.Null 1352 | } 1353 | ec.Tracer.EndFieldExecution(ctx) 1354 | }() 1355 | rctx := &graphql.ResolverContext{ 1356 | Object: "User", 1357 | Field: field, 1358 | Args: nil, 1359 | IsMethod: false, 1360 | } 1361 | ctx = graphql.WithResolverContext(ctx, rctx) 1362 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1363 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1364 | ctx = rctx // use context from middleware stack in children 1365 | return obj.Username, nil 1366 | }) 1367 | if err != nil { 1368 | ec.Error(ctx, err) 1369 | return graphql.Null 1370 | } 1371 | if resTmp == nil { 1372 | if !ec.HasError(rctx) { 1373 | ec.Errorf(ctx, "must not be null") 1374 | } 1375 | return graphql.Null 1376 | } 1377 | res := resTmp.(string) 1378 | rctx.Result = res 1379 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1380 | return ec.marshalNString2string(ctx, field.Selections, res) 1381 | } 1382 | 1383 | func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { 1384 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1385 | defer func() { 1386 | if r := recover(); r != nil { 1387 | ec.Error(ctx, ec.Recover(ctx, r)) 1388 | ret = graphql.Null 1389 | } 1390 | ec.Tracer.EndFieldExecution(ctx) 1391 | }() 1392 | rctx := &graphql.ResolverContext{ 1393 | Object: "User", 1394 | Field: field, 1395 | Args: nil, 1396 | IsMethod: false, 1397 | } 1398 | ctx = graphql.WithResolverContext(ctx, rctx) 1399 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1400 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1401 | ctx = rctx // use context from middleware stack in children 1402 | return obj.Email, nil 1403 | }) 1404 | if err != nil { 1405 | ec.Error(ctx, err) 1406 | return graphql.Null 1407 | } 1408 | if resTmp == nil { 1409 | if !ec.HasError(rctx) { 1410 | ec.Errorf(ctx, "must not be null") 1411 | } 1412 | return graphql.Null 1413 | } 1414 | res := resTmp.(string) 1415 | rctx.Result = res 1416 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1417 | return ec.marshalNString2string(ctx, field.Selections, res) 1418 | } 1419 | 1420 | func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { 1421 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1422 | defer func() { 1423 | if r := recover(); r != nil { 1424 | ec.Error(ctx, ec.Recover(ctx, r)) 1425 | ret = graphql.Null 1426 | } 1427 | ec.Tracer.EndFieldExecution(ctx) 1428 | }() 1429 | rctx := &graphql.ResolverContext{ 1430 | Object: "User", 1431 | Field: field, 1432 | Args: nil, 1433 | IsMethod: false, 1434 | } 1435 | ctx = graphql.WithResolverContext(ctx, rctx) 1436 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1437 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1438 | ctx = rctx // use context from middleware stack in children 1439 | return obj.FirstName, nil 1440 | }) 1441 | if err != nil { 1442 | ec.Error(ctx, err) 1443 | return graphql.Null 1444 | } 1445 | if resTmp == nil { 1446 | if !ec.HasError(rctx) { 1447 | ec.Errorf(ctx, "must not be null") 1448 | } 1449 | return graphql.Null 1450 | } 1451 | res := resTmp.(string) 1452 | rctx.Result = res 1453 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1454 | return ec.marshalNString2string(ctx, field.Selections, res) 1455 | } 1456 | 1457 | func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { 1458 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1459 | defer func() { 1460 | if r := recover(); r != nil { 1461 | ec.Error(ctx, ec.Recover(ctx, r)) 1462 | ret = graphql.Null 1463 | } 1464 | ec.Tracer.EndFieldExecution(ctx) 1465 | }() 1466 | rctx := &graphql.ResolverContext{ 1467 | Object: "User", 1468 | Field: field, 1469 | Args: nil, 1470 | IsMethod: false, 1471 | } 1472 | ctx = graphql.WithResolverContext(ctx, rctx) 1473 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1474 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1475 | ctx = rctx // use context from middleware stack in children 1476 | return obj.LastName, nil 1477 | }) 1478 | if err != nil { 1479 | ec.Error(ctx, err) 1480 | return graphql.Null 1481 | } 1482 | if resTmp == nil { 1483 | if !ec.HasError(rctx) { 1484 | ec.Errorf(ctx, "must not be null") 1485 | } 1486 | return graphql.Null 1487 | } 1488 | res := resTmp.(string) 1489 | rctx.Result = res 1490 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1491 | return ec.marshalNString2string(ctx, field.Selections, res) 1492 | } 1493 | 1494 | func (ec *executionContext) _User_meetups(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { 1495 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1496 | defer func() { 1497 | if r := recover(); r != nil { 1498 | ec.Error(ctx, ec.Recover(ctx, r)) 1499 | ret = graphql.Null 1500 | } 1501 | ec.Tracer.EndFieldExecution(ctx) 1502 | }() 1503 | rctx := &graphql.ResolverContext{ 1504 | Object: "User", 1505 | Field: field, 1506 | Args: nil, 1507 | IsMethod: true, 1508 | } 1509 | ctx = graphql.WithResolverContext(ctx, rctx) 1510 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1511 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1512 | ctx = rctx // use context from middleware stack in children 1513 | return ec.resolvers.User().Meetups(rctx, obj) 1514 | }) 1515 | if err != nil { 1516 | ec.Error(ctx, err) 1517 | return graphql.Null 1518 | } 1519 | if resTmp == nil { 1520 | if !ec.HasError(rctx) { 1521 | ec.Errorf(ctx, "must not be null") 1522 | } 1523 | return graphql.Null 1524 | } 1525 | res := resTmp.([]*models.Meetup) 1526 | rctx.Result = res 1527 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1528 | return ec.marshalNMeetup2ᚕᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetupᚄ(ctx, field.Selections, res) 1529 | } 1530 | 1531 | func (ec *executionContext) _User_createdAt(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { 1532 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1533 | defer func() { 1534 | if r := recover(); r != nil { 1535 | ec.Error(ctx, ec.Recover(ctx, r)) 1536 | ret = graphql.Null 1537 | } 1538 | ec.Tracer.EndFieldExecution(ctx) 1539 | }() 1540 | rctx := &graphql.ResolverContext{ 1541 | Object: "User", 1542 | Field: field, 1543 | Args: nil, 1544 | IsMethod: false, 1545 | } 1546 | ctx = graphql.WithResolverContext(ctx, rctx) 1547 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1548 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1549 | ctx = rctx // use context from middleware stack in children 1550 | return obj.CreatedAt, nil 1551 | }) 1552 | if err != nil { 1553 | ec.Error(ctx, err) 1554 | return graphql.Null 1555 | } 1556 | if resTmp == nil { 1557 | if !ec.HasError(rctx) { 1558 | ec.Errorf(ctx, "must not be null") 1559 | } 1560 | return graphql.Null 1561 | } 1562 | res := resTmp.(time.Time) 1563 | rctx.Result = res 1564 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1565 | return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) 1566 | } 1567 | 1568 | func (ec *executionContext) _User_updatedAt(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { 1569 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1570 | defer func() { 1571 | if r := recover(); r != nil { 1572 | ec.Error(ctx, ec.Recover(ctx, r)) 1573 | ret = graphql.Null 1574 | } 1575 | ec.Tracer.EndFieldExecution(ctx) 1576 | }() 1577 | rctx := &graphql.ResolverContext{ 1578 | Object: "User", 1579 | Field: field, 1580 | Args: nil, 1581 | IsMethod: false, 1582 | } 1583 | ctx = graphql.WithResolverContext(ctx, rctx) 1584 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1585 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1586 | ctx = rctx // use context from middleware stack in children 1587 | return obj.UpdatedAt, nil 1588 | }) 1589 | if err != nil { 1590 | ec.Error(ctx, err) 1591 | return graphql.Null 1592 | } 1593 | if resTmp == nil { 1594 | if !ec.HasError(rctx) { 1595 | ec.Errorf(ctx, "must not be null") 1596 | } 1597 | return graphql.Null 1598 | } 1599 | res := resTmp.(time.Time) 1600 | rctx.Result = res 1601 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1602 | return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) 1603 | } 1604 | 1605 | func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 1606 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1607 | defer func() { 1608 | if r := recover(); r != nil { 1609 | ec.Error(ctx, ec.Recover(ctx, r)) 1610 | ret = graphql.Null 1611 | } 1612 | ec.Tracer.EndFieldExecution(ctx) 1613 | }() 1614 | rctx := &graphql.ResolverContext{ 1615 | Object: "__Directive", 1616 | Field: field, 1617 | Args: nil, 1618 | IsMethod: false, 1619 | } 1620 | ctx = graphql.WithResolverContext(ctx, rctx) 1621 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1622 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1623 | ctx = rctx // use context from middleware stack in children 1624 | return obj.Name, nil 1625 | }) 1626 | if err != nil { 1627 | ec.Error(ctx, err) 1628 | return graphql.Null 1629 | } 1630 | if resTmp == nil { 1631 | if !ec.HasError(rctx) { 1632 | ec.Errorf(ctx, "must not be null") 1633 | } 1634 | return graphql.Null 1635 | } 1636 | res := resTmp.(string) 1637 | rctx.Result = res 1638 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1639 | return ec.marshalNString2string(ctx, field.Selections, res) 1640 | } 1641 | 1642 | func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 1643 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1644 | defer func() { 1645 | if r := recover(); r != nil { 1646 | ec.Error(ctx, ec.Recover(ctx, r)) 1647 | ret = graphql.Null 1648 | } 1649 | ec.Tracer.EndFieldExecution(ctx) 1650 | }() 1651 | rctx := &graphql.ResolverContext{ 1652 | Object: "__Directive", 1653 | Field: field, 1654 | Args: nil, 1655 | IsMethod: false, 1656 | } 1657 | ctx = graphql.WithResolverContext(ctx, rctx) 1658 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1659 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1660 | ctx = rctx // use context from middleware stack in children 1661 | return obj.Description, nil 1662 | }) 1663 | if err != nil { 1664 | ec.Error(ctx, err) 1665 | return graphql.Null 1666 | } 1667 | if resTmp == nil { 1668 | return graphql.Null 1669 | } 1670 | res := resTmp.(string) 1671 | rctx.Result = res 1672 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1673 | return ec.marshalOString2string(ctx, field.Selections, res) 1674 | } 1675 | 1676 | func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 1677 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1678 | defer func() { 1679 | if r := recover(); r != nil { 1680 | ec.Error(ctx, ec.Recover(ctx, r)) 1681 | ret = graphql.Null 1682 | } 1683 | ec.Tracer.EndFieldExecution(ctx) 1684 | }() 1685 | rctx := &graphql.ResolverContext{ 1686 | Object: "__Directive", 1687 | Field: field, 1688 | Args: nil, 1689 | IsMethod: false, 1690 | } 1691 | ctx = graphql.WithResolverContext(ctx, rctx) 1692 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1693 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1694 | ctx = rctx // use context from middleware stack in children 1695 | return obj.Locations, nil 1696 | }) 1697 | if err != nil { 1698 | ec.Error(ctx, err) 1699 | return graphql.Null 1700 | } 1701 | if resTmp == nil { 1702 | if !ec.HasError(rctx) { 1703 | ec.Errorf(ctx, "must not be null") 1704 | } 1705 | return graphql.Null 1706 | } 1707 | res := resTmp.([]string) 1708 | rctx.Result = res 1709 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1710 | return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) 1711 | } 1712 | 1713 | func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 1714 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1715 | defer func() { 1716 | if r := recover(); r != nil { 1717 | ec.Error(ctx, ec.Recover(ctx, r)) 1718 | ret = graphql.Null 1719 | } 1720 | ec.Tracer.EndFieldExecution(ctx) 1721 | }() 1722 | rctx := &graphql.ResolverContext{ 1723 | Object: "__Directive", 1724 | Field: field, 1725 | Args: nil, 1726 | IsMethod: false, 1727 | } 1728 | ctx = graphql.WithResolverContext(ctx, rctx) 1729 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1730 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1731 | ctx = rctx // use context from middleware stack in children 1732 | return obj.Args, nil 1733 | }) 1734 | if err != nil { 1735 | ec.Error(ctx, err) 1736 | return graphql.Null 1737 | } 1738 | if resTmp == nil { 1739 | if !ec.HasError(rctx) { 1740 | ec.Errorf(ctx, "must not be null") 1741 | } 1742 | return graphql.Null 1743 | } 1744 | res := resTmp.([]introspection.InputValue) 1745 | rctx.Result = res 1746 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1747 | return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 1748 | } 1749 | 1750 | func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1751 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1752 | defer func() { 1753 | if r := recover(); r != nil { 1754 | ec.Error(ctx, ec.Recover(ctx, r)) 1755 | ret = graphql.Null 1756 | } 1757 | ec.Tracer.EndFieldExecution(ctx) 1758 | }() 1759 | rctx := &graphql.ResolverContext{ 1760 | Object: "__EnumValue", 1761 | Field: field, 1762 | Args: nil, 1763 | IsMethod: false, 1764 | } 1765 | ctx = graphql.WithResolverContext(ctx, rctx) 1766 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1767 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1768 | ctx = rctx // use context from middleware stack in children 1769 | return obj.Name, nil 1770 | }) 1771 | if err != nil { 1772 | ec.Error(ctx, err) 1773 | return graphql.Null 1774 | } 1775 | if resTmp == nil { 1776 | if !ec.HasError(rctx) { 1777 | ec.Errorf(ctx, "must not be null") 1778 | } 1779 | return graphql.Null 1780 | } 1781 | res := resTmp.(string) 1782 | rctx.Result = res 1783 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1784 | return ec.marshalNString2string(ctx, field.Selections, res) 1785 | } 1786 | 1787 | func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1788 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1789 | defer func() { 1790 | if r := recover(); r != nil { 1791 | ec.Error(ctx, ec.Recover(ctx, r)) 1792 | ret = graphql.Null 1793 | } 1794 | ec.Tracer.EndFieldExecution(ctx) 1795 | }() 1796 | rctx := &graphql.ResolverContext{ 1797 | Object: "__EnumValue", 1798 | Field: field, 1799 | Args: nil, 1800 | IsMethod: false, 1801 | } 1802 | ctx = graphql.WithResolverContext(ctx, rctx) 1803 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1804 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1805 | ctx = rctx // use context from middleware stack in children 1806 | return obj.Description, nil 1807 | }) 1808 | if err != nil { 1809 | ec.Error(ctx, err) 1810 | return graphql.Null 1811 | } 1812 | if resTmp == nil { 1813 | return graphql.Null 1814 | } 1815 | res := resTmp.(string) 1816 | rctx.Result = res 1817 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1818 | return ec.marshalOString2string(ctx, field.Selections, res) 1819 | } 1820 | 1821 | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1822 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1823 | defer func() { 1824 | if r := recover(); r != nil { 1825 | ec.Error(ctx, ec.Recover(ctx, r)) 1826 | ret = graphql.Null 1827 | } 1828 | ec.Tracer.EndFieldExecution(ctx) 1829 | }() 1830 | rctx := &graphql.ResolverContext{ 1831 | Object: "__EnumValue", 1832 | Field: field, 1833 | Args: nil, 1834 | IsMethod: true, 1835 | } 1836 | ctx = graphql.WithResolverContext(ctx, rctx) 1837 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1838 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1839 | ctx = rctx // use context from middleware stack in children 1840 | return obj.IsDeprecated(), nil 1841 | }) 1842 | if err != nil { 1843 | ec.Error(ctx, err) 1844 | return graphql.Null 1845 | } 1846 | if resTmp == nil { 1847 | if !ec.HasError(rctx) { 1848 | ec.Errorf(ctx, "must not be null") 1849 | } 1850 | return graphql.Null 1851 | } 1852 | res := resTmp.(bool) 1853 | rctx.Result = res 1854 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1855 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 1856 | } 1857 | 1858 | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1859 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1860 | defer func() { 1861 | if r := recover(); r != nil { 1862 | ec.Error(ctx, ec.Recover(ctx, r)) 1863 | ret = graphql.Null 1864 | } 1865 | ec.Tracer.EndFieldExecution(ctx) 1866 | }() 1867 | rctx := &graphql.ResolverContext{ 1868 | Object: "__EnumValue", 1869 | Field: field, 1870 | Args: nil, 1871 | IsMethod: true, 1872 | } 1873 | ctx = graphql.WithResolverContext(ctx, rctx) 1874 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1875 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1876 | ctx = rctx // use context from middleware stack in children 1877 | return obj.DeprecationReason(), nil 1878 | }) 1879 | if err != nil { 1880 | ec.Error(ctx, err) 1881 | return graphql.Null 1882 | } 1883 | if resTmp == nil { 1884 | return graphql.Null 1885 | } 1886 | res := resTmp.(*string) 1887 | rctx.Result = res 1888 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1889 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1890 | } 1891 | 1892 | func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1893 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1894 | defer func() { 1895 | if r := recover(); r != nil { 1896 | ec.Error(ctx, ec.Recover(ctx, r)) 1897 | ret = graphql.Null 1898 | } 1899 | ec.Tracer.EndFieldExecution(ctx) 1900 | }() 1901 | rctx := &graphql.ResolverContext{ 1902 | Object: "__Field", 1903 | Field: field, 1904 | Args: nil, 1905 | IsMethod: false, 1906 | } 1907 | ctx = graphql.WithResolverContext(ctx, rctx) 1908 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1909 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1910 | ctx = rctx // use context from middleware stack in children 1911 | return obj.Name, nil 1912 | }) 1913 | if err != nil { 1914 | ec.Error(ctx, err) 1915 | return graphql.Null 1916 | } 1917 | if resTmp == nil { 1918 | if !ec.HasError(rctx) { 1919 | ec.Errorf(ctx, "must not be null") 1920 | } 1921 | return graphql.Null 1922 | } 1923 | res := resTmp.(string) 1924 | rctx.Result = res 1925 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1926 | return ec.marshalNString2string(ctx, field.Selections, res) 1927 | } 1928 | 1929 | func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1930 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1931 | defer func() { 1932 | if r := recover(); r != nil { 1933 | ec.Error(ctx, ec.Recover(ctx, r)) 1934 | ret = graphql.Null 1935 | } 1936 | ec.Tracer.EndFieldExecution(ctx) 1937 | }() 1938 | rctx := &graphql.ResolverContext{ 1939 | Object: "__Field", 1940 | Field: field, 1941 | Args: nil, 1942 | IsMethod: false, 1943 | } 1944 | ctx = graphql.WithResolverContext(ctx, rctx) 1945 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1946 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1947 | ctx = rctx // use context from middleware stack in children 1948 | return obj.Description, nil 1949 | }) 1950 | if err != nil { 1951 | ec.Error(ctx, err) 1952 | return graphql.Null 1953 | } 1954 | if resTmp == nil { 1955 | return graphql.Null 1956 | } 1957 | res := resTmp.(string) 1958 | rctx.Result = res 1959 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1960 | return ec.marshalOString2string(ctx, field.Selections, res) 1961 | } 1962 | 1963 | func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1964 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 1965 | defer func() { 1966 | if r := recover(); r != nil { 1967 | ec.Error(ctx, ec.Recover(ctx, r)) 1968 | ret = graphql.Null 1969 | } 1970 | ec.Tracer.EndFieldExecution(ctx) 1971 | }() 1972 | rctx := &graphql.ResolverContext{ 1973 | Object: "__Field", 1974 | Field: field, 1975 | Args: nil, 1976 | IsMethod: false, 1977 | } 1978 | ctx = graphql.WithResolverContext(ctx, rctx) 1979 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 1980 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1981 | ctx = rctx // use context from middleware stack in children 1982 | return obj.Args, nil 1983 | }) 1984 | if err != nil { 1985 | ec.Error(ctx, err) 1986 | return graphql.Null 1987 | } 1988 | if resTmp == nil { 1989 | if !ec.HasError(rctx) { 1990 | ec.Errorf(ctx, "must not be null") 1991 | } 1992 | return graphql.Null 1993 | } 1994 | res := resTmp.([]introspection.InputValue) 1995 | rctx.Result = res 1996 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 1997 | return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 1998 | } 1999 | 2000 | func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 2001 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2002 | defer func() { 2003 | if r := recover(); r != nil { 2004 | ec.Error(ctx, ec.Recover(ctx, r)) 2005 | ret = graphql.Null 2006 | } 2007 | ec.Tracer.EndFieldExecution(ctx) 2008 | }() 2009 | rctx := &graphql.ResolverContext{ 2010 | Object: "__Field", 2011 | Field: field, 2012 | Args: nil, 2013 | IsMethod: false, 2014 | } 2015 | ctx = graphql.WithResolverContext(ctx, rctx) 2016 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2017 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2018 | ctx = rctx // use context from middleware stack in children 2019 | return obj.Type, nil 2020 | }) 2021 | if err != nil { 2022 | ec.Error(ctx, err) 2023 | return graphql.Null 2024 | } 2025 | if resTmp == nil { 2026 | if !ec.HasError(rctx) { 2027 | ec.Errorf(ctx, "must not be null") 2028 | } 2029 | return graphql.Null 2030 | } 2031 | res := resTmp.(*introspection.Type) 2032 | rctx.Result = res 2033 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2034 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 2035 | } 2036 | 2037 | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 2038 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2039 | defer func() { 2040 | if r := recover(); r != nil { 2041 | ec.Error(ctx, ec.Recover(ctx, r)) 2042 | ret = graphql.Null 2043 | } 2044 | ec.Tracer.EndFieldExecution(ctx) 2045 | }() 2046 | rctx := &graphql.ResolverContext{ 2047 | Object: "__Field", 2048 | Field: field, 2049 | Args: nil, 2050 | IsMethod: true, 2051 | } 2052 | ctx = graphql.WithResolverContext(ctx, rctx) 2053 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2054 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2055 | ctx = rctx // use context from middleware stack in children 2056 | return obj.IsDeprecated(), nil 2057 | }) 2058 | if err != nil { 2059 | ec.Error(ctx, err) 2060 | return graphql.Null 2061 | } 2062 | if resTmp == nil { 2063 | if !ec.HasError(rctx) { 2064 | ec.Errorf(ctx, "must not be null") 2065 | } 2066 | return graphql.Null 2067 | } 2068 | res := resTmp.(bool) 2069 | rctx.Result = res 2070 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2071 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 2072 | } 2073 | 2074 | func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 2075 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2076 | defer func() { 2077 | if r := recover(); r != nil { 2078 | ec.Error(ctx, ec.Recover(ctx, r)) 2079 | ret = graphql.Null 2080 | } 2081 | ec.Tracer.EndFieldExecution(ctx) 2082 | }() 2083 | rctx := &graphql.ResolverContext{ 2084 | Object: "__Field", 2085 | Field: field, 2086 | Args: nil, 2087 | IsMethod: true, 2088 | } 2089 | ctx = graphql.WithResolverContext(ctx, rctx) 2090 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2091 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2092 | ctx = rctx // use context from middleware stack in children 2093 | return obj.DeprecationReason(), nil 2094 | }) 2095 | if err != nil { 2096 | ec.Error(ctx, err) 2097 | return graphql.Null 2098 | } 2099 | if resTmp == nil { 2100 | return graphql.Null 2101 | } 2102 | res := resTmp.(*string) 2103 | rctx.Result = res 2104 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2105 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 2106 | } 2107 | 2108 | func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 2109 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2110 | defer func() { 2111 | if r := recover(); r != nil { 2112 | ec.Error(ctx, ec.Recover(ctx, r)) 2113 | ret = graphql.Null 2114 | } 2115 | ec.Tracer.EndFieldExecution(ctx) 2116 | }() 2117 | rctx := &graphql.ResolverContext{ 2118 | Object: "__InputValue", 2119 | Field: field, 2120 | Args: nil, 2121 | IsMethod: false, 2122 | } 2123 | ctx = graphql.WithResolverContext(ctx, rctx) 2124 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2125 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2126 | ctx = rctx // use context from middleware stack in children 2127 | return obj.Name, nil 2128 | }) 2129 | if err != nil { 2130 | ec.Error(ctx, err) 2131 | return graphql.Null 2132 | } 2133 | if resTmp == nil { 2134 | if !ec.HasError(rctx) { 2135 | ec.Errorf(ctx, "must not be null") 2136 | } 2137 | return graphql.Null 2138 | } 2139 | res := resTmp.(string) 2140 | rctx.Result = res 2141 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2142 | return ec.marshalNString2string(ctx, field.Selections, res) 2143 | } 2144 | 2145 | func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 2146 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2147 | defer func() { 2148 | if r := recover(); r != nil { 2149 | ec.Error(ctx, ec.Recover(ctx, r)) 2150 | ret = graphql.Null 2151 | } 2152 | ec.Tracer.EndFieldExecution(ctx) 2153 | }() 2154 | rctx := &graphql.ResolverContext{ 2155 | Object: "__InputValue", 2156 | Field: field, 2157 | Args: nil, 2158 | IsMethod: false, 2159 | } 2160 | ctx = graphql.WithResolverContext(ctx, rctx) 2161 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2162 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2163 | ctx = rctx // use context from middleware stack in children 2164 | return obj.Description, nil 2165 | }) 2166 | if err != nil { 2167 | ec.Error(ctx, err) 2168 | return graphql.Null 2169 | } 2170 | if resTmp == nil { 2171 | return graphql.Null 2172 | } 2173 | res := resTmp.(string) 2174 | rctx.Result = res 2175 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2176 | return ec.marshalOString2string(ctx, field.Selections, res) 2177 | } 2178 | 2179 | func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 2180 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2181 | defer func() { 2182 | if r := recover(); r != nil { 2183 | ec.Error(ctx, ec.Recover(ctx, r)) 2184 | ret = graphql.Null 2185 | } 2186 | ec.Tracer.EndFieldExecution(ctx) 2187 | }() 2188 | rctx := &graphql.ResolverContext{ 2189 | Object: "__InputValue", 2190 | Field: field, 2191 | Args: nil, 2192 | IsMethod: false, 2193 | } 2194 | ctx = graphql.WithResolverContext(ctx, rctx) 2195 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2196 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2197 | ctx = rctx // use context from middleware stack in children 2198 | return obj.Type, nil 2199 | }) 2200 | if err != nil { 2201 | ec.Error(ctx, err) 2202 | return graphql.Null 2203 | } 2204 | if resTmp == nil { 2205 | if !ec.HasError(rctx) { 2206 | ec.Errorf(ctx, "must not be null") 2207 | } 2208 | return graphql.Null 2209 | } 2210 | res := resTmp.(*introspection.Type) 2211 | rctx.Result = res 2212 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2213 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 2214 | } 2215 | 2216 | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 2217 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2218 | defer func() { 2219 | if r := recover(); r != nil { 2220 | ec.Error(ctx, ec.Recover(ctx, r)) 2221 | ret = graphql.Null 2222 | } 2223 | ec.Tracer.EndFieldExecution(ctx) 2224 | }() 2225 | rctx := &graphql.ResolverContext{ 2226 | Object: "__InputValue", 2227 | Field: field, 2228 | Args: nil, 2229 | IsMethod: false, 2230 | } 2231 | ctx = graphql.WithResolverContext(ctx, rctx) 2232 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2233 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2234 | ctx = rctx // use context from middleware stack in children 2235 | return obj.DefaultValue, nil 2236 | }) 2237 | if err != nil { 2238 | ec.Error(ctx, err) 2239 | return graphql.Null 2240 | } 2241 | if resTmp == nil { 2242 | return graphql.Null 2243 | } 2244 | res := resTmp.(*string) 2245 | rctx.Result = res 2246 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2247 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 2248 | } 2249 | 2250 | func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 2251 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2252 | defer func() { 2253 | if r := recover(); r != nil { 2254 | ec.Error(ctx, ec.Recover(ctx, r)) 2255 | ret = graphql.Null 2256 | } 2257 | ec.Tracer.EndFieldExecution(ctx) 2258 | }() 2259 | rctx := &graphql.ResolverContext{ 2260 | Object: "__Schema", 2261 | Field: field, 2262 | Args: nil, 2263 | IsMethod: true, 2264 | } 2265 | ctx = graphql.WithResolverContext(ctx, rctx) 2266 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2267 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2268 | ctx = rctx // use context from middleware stack in children 2269 | return obj.Types(), nil 2270 | }) 2271 | if err != nil { 2272 | ec.Error(ctx, err) 2273 | return graphql.Null 2274 | } 2275 | if resTmp == nil { 2276 | if !ec.HasError(rctx) { 2277 | ec.Errorf(ctx, "must not be null") 2278 | } 2279 | return graphql.Null 2280 | } 2281 | res := resTmp.([]introspection.Type) 2282 | rctx.Result = res 2283 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2284 | return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 2285 | } 2286 | 2287 | func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 2288 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2289 | defer func() { 2290 | if r := recover(); r != nil { 2291 | ec.Error(ctx, ec.Recover(ctx, r)) 2292 | ret = graphql.Null 2293 | } 2294 | ec.Tracer.EndFieldExecution(ctx) 2295 | }() 2296 | rctx := &graphql.ResolverContext{ 2297 | Object: "__Schema", 2298 | Field: field, 2299 | Args: nil, 2300 | IsMethod: true, 2301 | } 2302 | ctx = graphql.WithResolverContext(ctx, rctx) 2303 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2304 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2305 | ctx = rctx // use context from middleware stack in children 2306 | return obj.QueryType(), nil 2307 | }) 2308 | if err != nil { 2309 | ec.Error(ctx, err) 2310 | return graphql.Null 2311 | } 2312 | if resTmp == nil { 2313 | if !ec.HasError(rctx) { 2314 | ec.Errorf(ctx, "must not be null") 2315 | } 2316 | return graphql.Null 2317 | } 2318 | res := resTmp.(*introspection.Type) 2319 | rctx.Result = res 2320 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2321 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 2322 | } 2323 | 2324 | func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 2325 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2326 | defer func() { 2327 | if r := recover(); r != nil { 2328 | ec.Error(ctx, ec.Recover(ctx, r)) 2329 | ret = graphql.Null 2330 | } 2331 | ec.Tracer.EndFieldExecution(ctx) 2332 | }() 2333 | rctx := &graphql.ResolverContext{ 2334 | Object: "__Schema", 2335 | Field: field, 2336 | Args: nil, 2337 | IsMethod: true, 2338 | } 2339 | ctx = graphql.WithResolverContext(ctx, rctx) 2340 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2341 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2342 | ctx = rctx // use context from middleware stack in children 2343 | return obj.MutationType(), nil 2344 | }) 2345 | if err != nil { 2346 | ec.Error(ctx, err) 2347 | return graphql.Null 2348 | } 2349 | if resTmp == nil { 2350 | return graphql.Null 2351 | } 2352 | res := resTmp.(*introspection.Type) 2353 | rctx.Result = res 2354 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2355 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 2356 | } 2357 | 2358 | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 2359 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2360 | defer func() { 2361 | if r := recover(); r != nil { 2362 | ec.Error(ctx, ec.Recover(ctx, r)) 2363 | ret = graphql.Null 2364 | } 2365 | ec.Tracer.EndFieldExecution(ctx) 2366 | }() 2367 | rctx := &graphql.ResolverContext{ 2368 | Object: "__Schema", 2369 | Field: field, 2370 | Args: nil, 2371 | IsMethod: true, 2372 | } 2373 | ctx = graphql.WithResolverContext(ctx, rctx) 2374 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2375 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2376 | ctx = rctx // use context from middleware stack in children 2377 | return obj.SubscriptionType(), nil 2378 | }) 2379 | if err != nil { 2380 | ec.Error(ctx, err) 2381 | return graphql.Null 2382 | } 2383 | if resTmp == nil { 2384 | return graphql.Null 2385 | } 2386 | res := resTmp.(*introspection.Type) 2387 | rctx.Result = res 2388 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2389 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 2390 | } 2391 | 2392 | func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 2393 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2394 | defer func() { 2395 | if r := recover(); r != nil { 2396 | ec.Error(ctx, ec.Recover(ctx, r)) 2397 | ret = graphql.Null 2398 | } 2399 | ec.Tracer.EndFieldExecution(ctx) 2400 | }() 2401 | rctx := &graphql.ResolverContext{ 2402 | Object: "__Schema", 2403 | Field: field, 2404 | Args: nil, 2405 | IsMethod: true, 2406 | } 2407 | ctx = graphql.WithResolverContext(ctx, rctx) 2408 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2409 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2410 | ctx = rctx // use context from middleware stack in children 2411 | return obj.Directives(), nil 2412 | }) 2413 | if err != nil { 2414 | ec.Error(ctx, err) 2415 | return graphql.Null 2416 | } 2417 | if resTmp == nil { 2418 | if !ec.HasError(rctx) { 2419 | ec.Errorf(ctx, "must not be null") 2420 | } 2421 | return graphql.Null 2422 | } 2423 | res := resTmp.([]introspection.Directive) 2424 | rctx.Result = res 2425 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2426 | return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) 2427 | } 2428 | 2429 | func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2430 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2431 | defer func() { 2432 | if r := recover(); r != nil { 2433 | ec.Error(ctx, ec.Recover(ctx, r)) 2434 | ret = graphql.Null 2435 | } 2436 | ec.Tracer.EndFieldExecution(ctx) 2437 | }() 2438 | rctx := &graphql.ResolverContext{ 2439 | Object: "__Type", 2440 | Field: field, 2441 | Args: nil, 2442 | IsMethod: true, 2443 | } 2444 | ctx = graphql.WithResolverContext(ctx, rctx) 2445 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2446 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2447 | ctx = rctx // use context from middleware stack in children 2448 | return obj.Kind(), nil 2449 | }) 2450 | if err != nil { 2451 | ec.Error(ctx, err) 2452 | return graphql.Null 2453 | } 2454 | if resTmp == nil { 2455 | if !ec.HasError(rctx) { 2456 | ec.Errorf(ctx, "must not be null") 2457 | } 2458 | return graphql.Null 2459 | } 2460 | res := resTmp.(string) 2461 | rctx.Result = res 2462 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2463 | return ec.marshalN__TypeKind2string(ctx, field.Selections, res) 2464 | } 2465 | 2466 | func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2467 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2468 | defer func() { 2469 | if r := recover(); r != nil { 2470 | ec.Error(ctx, ec.Recover(ctx, r)) 2471 | ret = graphql.Null 2472 | } 2473 | ec.Tracer.EndFieldExecution(ctx) 2474 | }() 2475 | rctx := &graphql.ResolverContext{ 2476 | Object: "__Type", 2477 | Field: field, 2478 | Args: nil, 2479 | IsMethod: true, 2480 | } 2481 | ctx = graphql.WithResolverContext(ctx, rctx) 2482 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2483 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2484 | ctx = rctx // use context from middleware stack in children 2485 | return obj.Name(), nil 2486 | }) 2487 | if err != nil { 2488 | ec.Error(ctx, err) 2489 | return graphql.Null 2490 | } 2491 | if resTmp == nil { 2492 | return graphql.Null 2493 | } 2494 | res := resTmp.(*string) 2495 | rctx.Result = res 2496 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2497 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 2498 | } 2499 | 2500 | func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2501 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2502 | defer func() { 2503 | if r := recover(); r != nil { 2504 | ec.Error(ctx, ec.Recover(ctx, r)) 2505 | ret = graphql.Null 2506 | } 2507 | ec.Tracer.EndFieldExecution(ctx) 2508 | }() 2509 | rctx := &graphql.ResolverContext{ 2510 | Object: "__Type", 2511 | Field: field, 2512 | Args: nil, 2513 | IsMethod: true, 2514 | } 2515 | ctx = graphql.WithResolverContext(ctx, rctx) 2516 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2517 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2518 | ctx = rctx // use context from middleware stack in children 2519 | return obj.Description(), nil 2520 | }) 2521 | if err != nil { 2522 | ec.Error(ctx, err) 2523 | return graphql.Null 2524 | } 2525 | if resTmp == nil { 2526 | return graphql.Null 2527 | } 2528 | res := resTmp.(string) 2529 | rctx.Result = res 2530 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2531 | return ec.marshalOString2string(ctx, field.Selections, res) 2532 | } 2533 | 2534 | func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2535 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2536 | defer func() { 2537 | if r := recover(); r != nil { 2538 | ec.Error(ctx, ec.Recover(ctx, r)) 2539 | ret = graphql.Null 2540 | } 2541 | ec.Tracer.EndFieldExecution(ctx) 2542 | }() 2543 | rctx := &graphql.ResolverContext{ 2544 | Object: "__Type", 2545 | Field: field, 2546 | Args: nil, 2547 | IsMethod: true, 2548 | } 2549 | ctx = graphql.WithResolverContext(ctx, rctx) 2550 | rawArgs := field.ArgumentMap(ec.Variables) 2551 | args, err := ec.field___Type_fields_args(ctx, rawArgs) 2552 | if err != nil { 2553 | ec.Error(ctx, err) 2554 | return graphql.Null 2555 | } 2556 | rctx.Args = args 2557 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2558 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2559 | ctx = rctx // use context from middleware stack in children 2560 | return obj.Fields(args["includeDeprecated"].(bool)), nil 2561 | }) 2562 | if err != nil { 2563 | ec.Error(ctx, err) 2564 | return graphql.Null 2565 | } 2566 | if resTmp == nil { 2567 | return graphql.Null 2568 | } 2569 | res := resTmp.([]introspection.Field) 2570 | rctx.Result = res 2571 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2572 | return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) 2573 | } 2574 | 2575 | func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2576 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2577 | defer func() { 2578 | if r := recover(); r != nil { 2579 | ec.Error(ctx, ec.Recover(ctx, r)) 2580 | ret = graphql.Null 2581 | } 2582 | ec.Tracer.EndFieldExecution(ctx) 2583 | }() 2584 | rctx := &graphql.ResolverContext{ 2585 | Object: "__Type", 2586 | Field: field, 2587 | Args: nil, 2588 | IsMethod: true, 2589 | } 2590 | ctx = graphql.WithResolverContext(ctx, rctx) 2591 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2592 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2593 | ctx = rctx // use context from middleware stack in children 2594 | return obj.Interfaces(), nil 2595 | }) 2596 | if err != nil { 2597 | ec.Error(ctx, err) 2598 | return graphql.Null 2599 | } 2600 | if resTmp == nil { 2601 | return graphql.Null 2602 | } 2603 | res := resTmp.([]introspection.Type) 2604 | rctx.Result = res 2605 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2606 | return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 2607 | } 2608 | 2609 | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2610 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2611 | defer func() { 2612 | if r := recover(); r != nil { 2613 | ec.Error(ctx, ec.Recover(ctx, r)) 2614 | ret = graphql.Null 2615 | } 2616 | ec.Tracer.EndFieldExecution(ctx) 2617 | }() 2618 | rctx := &graphql.ResolverContext{ 2619 | Object: "__Type", 2620 | Field: field, 2621 | Args: nil, 2622 | IsMethod: true, 2623 | } 2624 | ctx = graphql.WithResolverContext(ctx, rctx) 2625 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2626 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2627 | ctx = rctx // use context from middleware stack in children 2628 | return obj.PossibleTypes(), nil 2629 | }) 2630 | if err != nil { 2631 | ec.Error(ctx, err) 2632 | return graphql.Null 2633 | } 2634 | if resTmp == nil { 2635 | return graphql.Null 2636 | } 2637 | res := resTmp.([]introspection.Type) 2638 | rctx.Result = res 2639 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2640 | return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 2641 | } 2642 | 2643 | func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2644 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2645 | defer func() { 2646 | if r := recover(); r != nil { 2647 | ec.Error(ctx, ec.Recover(ctx, r)) 2648 | ret = graphql.Null 2649 | } 2650 | ec.Tracer.EndFieldExecution(ctx) 2651 | }() 2652 | rctx := &graphql.ResolverContext{ 2653 | Object: "__Type", 2654 | Field: field, 2655 | Args: nil, 2656 | IsMethod: true, 2657 | } 2658 | ctx = graphql.WithResolverContext(ctx, rctx) 2659 | rawArgs := field.ArgumentMap(ec.Variables) 2660 | args, err := ec.field___Type_enumValues_args(ctx, rawArgs) 2661 | if err != nil { 2662 | ec.Error(ctx, err) 2663 | return graphql.Null 2664 | } 2665 | rctx.Args = args 2666 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2667 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2668 | ctx = rctx // use context from middleware stack in children 2669 | return obj.EnumValues(args["includeDeprecated"].(bool)), nil 2670 | }) 2671 | if err != nil { 2672 | ec.Error(ctx, err) 2673 | return graphql.Null 2674 | } 2675 | if resTmp == nil { 2676 | return graphql.Null 2677 | } 2678 | res := resTmp.([]introspection.EnumValue) 2679 | rctx.Result = res 2680 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2681 | return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) 2682 | } 2683 | 2684 | func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2685 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2686 | defer func() { 2687 | if r := recover(); r != nil { 2688 | ec.Error(ctx, ec.Recover(ctx, r)) 2689 | ret = graphql.Null 2690 | } 2691 | ec.Tracer.EndFieldExecution(ctx) 2692 | }() 2693 | rctx := &graphql.ResolverContext{ 2694 | Object: "__Type", 2695 | Field: field, 2696 | Args: nil, 2697 | IsMethod: true, 2698 | } 2699 | ctx = graphql.WithResolverContext(ctx, rctx) 2700 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2701 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2702 | ctx = rctx // use context from middleware stack in children 2703 | return obj.InputFields(), nil 2704 | }) 2705 | if err != nil { 2706 | ec.Error(ctx, err) 2707 | return graphql.Null 2708 | } 2709 | if resTmp == nil { 2710 | return graphql.Null 2711 | } 2712 | res := resTmp.([]introspection.InputValue) 2713 | rctx.Result = res 2714 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2715 | return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 2716 | } 2717 | 2718 | func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2719 | ctx = ec.Tracer.StartFieldExecution(ctx, field) 2720 | defer func() { 2721 | if r := recover(); r != nil { 2722 | ec.Error(ctx, ec.Recover(ctx, r)) 2723 | ret = graphql.Null 2724 | } 2725 | ec.Tracer.EndFieldExecution(ctx) 2726 | }() 2727 | rctx := &graphql.ResolverContext{ 2728 | Object: "__Type", 2729 | Field: field, 2730 | Args: nil, 2731 | IsMethod: true, 2732 | } 2733 | ctx = graphql.WithResolverContext(ctx, rctx) 2734 | ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) 2735 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2736 | ctx = rctx // use context from middleware stack in children 2737 | return obj.OfType(), nil 2738 | }) 2739 | if err != nil { 2740 | ec.Error(ctx, err) 2741 | return graphql.Null 2742 | } 2743 | if resTmp == nil { 2744 | return graphql.Null 2745 | } 2746 | res := resTmp.(*introspection.Type) 2747 | rctx.Result = res 2748 | ctx = ec.Tracer.StartFieldChildExecution(ctx) 2749 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 2750 | } 2751 | 2752 | // endregion **************************** field.gotpl ***************************** 2753 | 2754 | // region **************************** input.gotpl ***************************** 2755 | 2756 | func (ec *executionContext) unmarshalInputLoginInput(ctx context.Context, obj interface{}) (models.LoginInput, error) { 2757 | var it models.LoginInput 2758 | var asMap = obj.(map[string]interface{}) 2759 | 2760 | for k, v := range asMap { 2761 | switch k { 2762 | case "email": 2763 | var err error 2764 | it.Email, err = ec.unmarshalNString2string(ctx, v) 2765 | if err != nil { 2766 | return it, err 2767 | } 2768 | case "password": 2769 | var err error 2770 | it.Password, err = ec.unmarshalNString2string(ctx, v) 2771 | if err != nil { 2772 | return it, err 2773 | } 2774 | } 2775 | } 2776 | 2777 | return it, nil 2778 | } 2779 | 2780 | func (ec *executionContext) unmarshalInputMeetupFilter(ctx context.Context, obj interface{}) (models.MeetupFilter, error) { 2781 | var it models.MeetupFilter 2782 | var asMap = obj.(map[string]interface{}) 2783 | 2784 | for k, v := range asMap { 2785 | switch k { 2786 | case "name": 2787 | var err error 2788 | it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) 2789 | if err != nil { 2790 | return it, err 2791 | } 2792 | } 2793 | } 2794 | 2795 | return it, nil 2796 | } 2797 | 2798 | func (ec *executionContext) unmarshalInputNewMeetup(ctx context.Context, obj interface{}) (models.NewMeetup, error) { 2799 | var it models.NewMeetup 2800 | var asMap = obj.(map[string]interface{}) 2801 | 2802 | for k, v := range asMap { 2803 | switch k { 2804 | case "name": 2805 | var err error 2806 | it.Name, err = ec.unmarshalNString2string(ctx, v) 2807 | if err != nil { 2808 | return it, err 2809 | } 2810 | case "description": 2811 | var err error 2812 | it.Description, err = ec.unmarshalNString2string(ctx, v) 2813 | if err != nil { 2814 | return it, err 2815 | } 2816 | } 2817 | } 2818 | 2819 | return it, nil 2820 | } 2821 | 2822 | func (ec *executionContext) unmarshalInputRegisterInput(ctx context.Context, obj interface{}) (models.RegisterInput, error) { 2823 | var it models.RegisterInput 2824 | var asMap = obj.(map[string]interface{}) 2825 | 2826 | for k, v := range asMap { 2827 | switch k { 2828 | case "username": 2829 | var err error 2830 | it.Username, err = ec.unmarshalNString2string(ctx, v) 2831 | if err != nil { 2832 | return it, err 2833 | } 2834 | case "email": 2835 | var err error 2836 | it.Email, err = ec.unmarshalNString2string(ctx, v) 2837 | if err != nil { 2838 | return it, err 2839 | } 2840 | case "password": 2841 | var err error 2842 | it.Password, err = ec.unmarshalNString2string(ctx, v) 2843 | if err != nil { 2844 | return it, err 2845 | } 2846 | case "confirmPassword": 2847 | var err error 2848 | it.ConfirmPassword, err = ec.unmarshalNString2string(ctx, v) 2849 | if err != nil { 2850 | return it, err 2851 | } 2852 | case "firstName": 2853 | var err error 2854 | it.FirstName, err = ec.unmarshalNString2string(ctx, v) 2855 | if err != nil { 2856 | return it, err 2857 | } 2858 | case "lastName": 2859 | var err error 2860 | it.LastName, err = ec.unmarshalNString2string(ctx, v) 2861 | if err != nil { 2862 | return it, err 2863 | } 2864 | } 2865 | } 2866 | 2867 | return it, nil 2868 | } 2869 | 2870 | func (ec *executionContext) unmarshalInputUpdateMeetup(ctx context.Context, obj interface{}) (models.UpdateMeetup, error) { 2871 | var it models.UpdateMeetup 2872 | var asMap = obj.(map[string]interface{}) 2873 | 2874 | for k, v := range asMap { 2875 | switch k { 2876 | case "name": 2877 | var err error 2878 | it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) 2879 | if err != nil { 2880 | return it, err 2881 | } 2882 | case "description": 2883 | var err error 2884 | it.Description, err = ec.unmarshalOString2ᚖstring(ctx, v) 2885 | if err != nil { 2886 | return it, err 2887 | } 2888 | } 2889 | } 2890 | 2891 | return it, nil 2892 | } 2893 | 2894 | // endregion **************************** input.gotpl ***************************** 2895 | 2896 | // region ************************** interface.gotpl *************************** 2897 | 2898 | // endregion ************************** interface.gotpl *************************** 2899 | 2900 | // region **************************** object.gotpl **************************** 2901 | 2902 | var authResponseImplementors = []string{"AuthResponse"} 2903 | 2904 | func (ec *executionContext) _AuthResponse(ctx context.Context, sel ast.SelectionSet, obj *models.AuthResponse) graphql.Marshaler { 2905 | fields := graphql.CollectFields(ec.RequestContext, sel, authResponseImplementors) 2906 | 2907 | out := graphql.NewFieldSet(fields) 2908 | var invalids uint32 2909 | for i, field := range fields { 2910 | switch field.Name { 2911 | case "__typename": 2912 | out.Values[i] = graphql.MarshalString("AuthResponse") 2913 | case "authToken": 2914 | out.Values[i] = ec._AuthResponse_authToken(ctx, field, obj) 2915 | if out.Values[i] == graphql.Null { 2916 | invalids++ 2917 | } 2918 | case "user": 2919 | out.Values[i] = ec._AuthResponse_user(ctx, field, obj) 2920 | if out.Values[i] == graphql.Null { 2921 | invalids++ 2922 | } 2923 | default: 2924 | panic("unknown field " + strconv.Quote(field.Name)) 2925 | } 2926 | } 2927 | out.Dispatch() 2928 | if invalids > 0 { 2929 | return graphql.Null 2930 | } 2931 | return out 2932 | } 2933 | 2934 | var authTokenImplementors = []string{"AuthToken"} 2935 | 2936 | func (ec *executionContext) _AuthToken(ctx context.Context, sel ast.SelectionSet, obj *models.AuthToken) graphql.Marshaler { 2937 | fields := graphql.CollectFields(ec.RequestContext, sel, authTokenImplementors) 2938 | 2939 | out := graphql.NewFieldSet(fields) 2940 | var invalids uint32 2941 | for i, field := range fields { 2942 | switch field.Name { 2943 | case "__typename": 2944 | out.Values[i] = graphql.MarshalString("AuthToken") 2945 | case "accessToken": 2946 | out.Values[i] = ec._AuthToken_accessToken(ctx, field, obj) 2947 | if out.Values[i] == graphql.Null { 2948 | invalids++ 2949 | } 2950 | case "expiredAt": 2951 | out.Values[i] = ec._AuthToken_expiredAt(ctx, field, obj) 2952 | if out.Values[i] == graphql.Null { 2953 | invalids++ 2954 | } 2955 | default: 2956 | panic("unknown field " + strconv.Quote(field.Name)) 2957 | } 2958 | } 2959 | out.Dispatch() 2960 | if invalids > 0 { 2961 | return graphql.Null 2962 | } 2963 | return out 2964 | } 2965 | 2966 | var meetupImplementors = []string{"Meetup"} 2967 | 2968 | func (ec *executionContext) _Meetup(ctx context.Context, sel ast.SelectionSet, obj *models.Meetup) graphql.Marshaler { 2969 | fields := graphql.CollectFields(ec.RequestContext, sel, meetupImplementors) 2970 | 2971 | out := graphql.NewFieldSet(fields) 2972 | var invalids uint32 2973 | for i, field := range fields { 2974 | switch field.Name { 2975 | case "__typename": 2976 | out.Values[i] = graphql.MarshalString("Meetup") 2977 | case "id": 2978 | out.Values[i] = ec._Meetup_id(ctx, field, obj) 2979 | if out.Values[i] == graphql.Null { 2980 | atomic.AddUint32(&invalids, 1) 2981 | } 2982 | case "name": 2983 | out.Values[i] = ec._Meetup_name(ctx, field, obj) 2984 | if out.Values[i] == graphql.Null { 2985 | atomic.AddUint32(&invalids, 1) 2986 | } 2987 | case "description": 2988 | out.Values[i] = ec._Meetup_description(ctx, field, obj) 2989 | if out.Values[i] == graphql.Null { 2990 | atomic.AddUint32(&invalids, 1) 2991 | } 2992 | case "user": 2993 | field := field 2994 | out.Concurrently(i, func() (res graphql.Marshaler) { 2995 | defer func() { 2996 | if r := recover(); r != nil { 2997 | ec.Error(ctx, ec.Recover(ctx, r)) 2998 | } 2999 | }() 3000 | res = ec._Meetup_user(ctx, field, obj) 3001 | if res == graphql.Null { 3002 | atomic.AddUint32(&invalids, 1) 3003 | } 3004 | return res 3005 | }) 3006 | default: 3007 | panic("unknown field " + strconv.Quote(field.Name)) 3008 | } 3009 | } 3010 | out.Dispatch() 3011 | if invalids > 0 { 3012 | return graphql.Null 3013 | } 3014 | return out 3015 | } 3016 | 3017 | var mutationImplementors = []string{"Mutation"} 3018 | 3019 | func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { 3020 | fields := graphql.CollectFields(ec.RequestContext, sel, mutationImplementors) 3021 | 3022 | ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ 3023 | Object: "Mutation", 3024 | }) 3025 | 3026 | out := graphql.NewFieldSet(fields) 3027 | var invalids uint32 3028 | for i, field := range fields { 3029 | switch field.Name { 3030 | case "__typename": 3031 | out.Values[i] = graphql.MarshalString("Mutation") 3032 | case "register": 3033 | out.Values[i] = ec._Mutation_register(ctx, field) 3034 | if out.Values[i] == graphql.Null { 3035 | invalids++ 3036 | } 3037 | case "login": 3038 | out.Values[i] = ec._Mutation_login(ctx, field) 3039 | if out.Values[i] == graphql.Null { 3040 | invalids++ 3041 | } 3042 | case "createMeetup": 3043 | out.Values[i] = ec._Mutation_createMeetup(ctx, field) 3044 | if out.Values[i] == graphql.Null { 3045 | invalids++ 3046 | } 3047 | case "updateMeetup": 3048 | out.Values[i] = ec._Mutation_updateMeetup(ctx, field) 3049 | if out.Values[i] == graphql.Null { 3050 | invalids++ 3051 | } 3052 | case "deleteMeetup": 3053 | out.Values[i] = ec._Mutation_deleteMeetup(ctx, field) 3054 | if out.Values[i] == graphql.Null { 3055 | invalids++ 3056 | } 3057 | default: 3058 | panic("unknown field " + strconv.Quote(field.Name)) 3059 | } 3060 | } 3061 | out.Dispatch() 3062 | if invalids > 0 { 3063 | return graphql.Null 3064 | } 3065 | return out 3066 | } 3067 | 3068 | var queryImplementors = []string{"Query"} 3069 | 3070 | func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { 3071 | fields := graphql.CollectFields(ec.RequestContext, sel, queryImplementors) 3072 | 3073 | ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ 3074 | Object: "Query", 3075 | }) 3076 | 3077 | out := graphql.NewFieldSet(fields) 3078 | var invalids uint32 3079 | for i, field := range fields { 3080 | switch field.Name { 3081 | case "__typename": 3082 | out.Values[i] = graphql.MarshalString("Query") 3083 | case "meetups": 3084 | field := field 3085 | out.Concurrently(i, func() (res graphql.Marshaler) { 3086 | defer func() { 3087 | if r := recover(); r != nil { 3088 | ec.Error(ctx, ec.Recover(ctx, r)) 3089 | } 3090 | }() 3091 | res = ec._Query_meetups(ctx, field) 3092 | if res == graphql.Null { 3093 | atomic.AddUint32(&invalids, 1) 3094 | } 3095 | return res 3096 | }) 3097 | case "user": 3098 | field := field 3099 | out.Concurrently(i, func() (res graphql.Marshaler) { 3100 | defer func() { 3101 | if r := recover(); r != nil { 3102 | ec.Error(ctx, ec.Recover(ctx, r)) 3103 | } 3104 | }() 3105 | res = ec._Query_user(ctx, field) 3106 | if res == graphql.Null { 3107 | atomic.AddUint32(&invalids, 1) 3108 | } 3109 | return res 3110 | }) 3111 | case "__type": 3112 | out.Values[i] = ec._Query___type(ctx, field) 3113 | case "__schema": 3114 | out.Values[i] = ec._Query___schema(ctx, field) 3115 | default: 3116 | panic("unknown field " + strconv.Quote(field.Name)) 3117 | } 3118 | } 3119 | out.Dispatch() 3120 | if invalids > 0 { 3121 | return graphql.Null 3122 | } 3123 | return out 3124 | } 3125 | 3126 | var userImplementors = []string{"User"} 3127 | 3128 | func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *models.User) graphql.Marshaler { 3129 | fields := graphql.CollectFields(ec.RequestContext, sel, userImplementors) 3130 | 3131 | out := graphql.NewFieldSet(fields) 3132 | var invalids uint32 3133 | for i, field := range fields { 3134 | switch field.Name { 3135 | case "__typename": 3136 | out.Values[i] = graphql.MarshalString("User") 3137 | case "id": 3138 | out.Values[i] = ec._User_id(ctx, field, obj) 3139 | if out.Values[i] == graphql.Null { 3140 | atomic.AddUint32(&invalids, 1) 3141 | } 3142 | case "username": 3143 | out.Values[i] = ec._User_username(ctx, field, obj) 3144 | if out.Values[i] == graphql.Null { 3145 | atomic.AddUint32(&invalids, 1) 3146 | } 3147 | case "email": 3148 | out.Values[i] = ec._User_email(ctx, field, obj) 3149 | if out.Values[i] == graphql.Null { 3150 | atomic.AddUint32(&invalids, 1) 3151 | } 3152 | case "firstName": 3153 | out.Values[i] = ec._User_firstName(ctx, field, obj) 3154 | if out.Values[i] == graphql.Null { 3155 | atomic.AddUint32(&invalids, 1) 3156 | } 3157 | case "lastName": 3158 | out.Values[i] = ec._User_lastName(ctx, field, obj) 3159 | if out.Values[i] == graphql.Null { 3160 | atomic.AddUint32(&invalids, 1) 3161 | } 3162 | case "meetups": 3163 | field := field 3164 | out.Concurrently(i, func() (res graphql.Marshaler) { 3165 | defer func() { 3166 | if r := recover(); r != nil { 3167 | ec.Error(ctx, ec.Recover(ctx, r)) 3168 | } 3169 | }() 3170 | res = ec._User_meetups(ctx, field, obj) 3171 | if res == graphql.Null { 3172 | atomic.AddUint32(&invalids, 1) 3173 | } 3174 | return res 3175 | }) 3176 | case "createdAt": 3177 | out.Values[i] = ec._User_createdAt(ctx, field, obj) 3178 | if out.Values[i] == graphql.Null { 3179 | atomic.AddUint32(&invalids, 1) 3180 | } 3181 | case "updatedAt": 3182 | out.Values[i] = ec._User_updatedAt(ctx, field, obj) 3183 | if out.Values[i] == graphql.Null { 3184 | atomic.AddUint32(&invalids, 1) 3185 | } 3186 | default: 3187 | panic("unknown field " + strconv.Quote(field.Name)) 3188 | } 3189 | } 3190 | out.Dispatch() 3191 | if invalids > 0 { 3192 | return graphql.Null 3193 | } 3194 | return out 3195 | } 3196 | 3197 | var __DirectiveImplementors = []string{"__Directive"} 3198 | 3199 | func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { 3200 | fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) 3201 | 3202 | out := graphql.NewFieldSet(fields) 3203 | var invalids uint32 3204 | for i, field := range fields { 3205 | switch field.Name { 3206 | case "__typename": 3207 | out.Values[i] = graphql.MarshalString("__Directive") 3208 | case "name": 3209 | out.Values[i] = ec.___Directive_name(ctx, field, obj) 3210 | if out.Values[i] == graphql.Null { 3211 | invalids++ 3212 | } 3213 | case "description": 3214 | out.Values[i] = ec.___Directive_description(ctx, field, obj) 3215 | case "locations": 3216 | out.Values[i] = ec.___Directive_locations(ctx, field, obj) 3217 | if out.Values[i] == graphql.Null { 3218 | invalids++ 3219 | } 3220 | case "args": 3221 | out.Values[i] = ec.___Directive_args(ctx, field, obj) 3222 | if out.Values[i] == graphql.Null { 3223 | invalids++ 3224 | } 3225 | default: 3226 | panic("unknown field " + strconv.Quote(field.Name)) 3227 | } 3228 | } 3229 | out.Dispatch() 3230 | if invalids > 0 { 3231 | return graphql.Null 3232 | } 3233 | return out 3234 | } 3235 | 3236 | var __EnumValueImplementors = []string{"__EnumValue"} 3237 | 3238 | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { 3239 | fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) 3240 | 3241 | out := graphql.NewFieldSet(fields) 3242 | var invalids uint32 3243 | for i, field := range fields { 3244 | switch field.Name { 3245 | case "__typename": 3246 | out.Values[i] = graphql.MarshalString("__EnumValue") 3247 | case "name": 3248 | out.Values[i] = ec.___EnumValue_name(ctx, field, obj) 3249 | if out.Values[i] == graphql.Null { 3250 | invalids++ 3251 | } 3252 | case "description": 3253 | out.Values[i] = ec.___EnumValue_description(ctx, field, obj) 3254 | case "isDeprecated": 3255 | out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) 3256 | if out.Values[i] == graphql.Null { 3257 | invalids++ 3258 | } 3259 | case "deprecationReason": 3260 | out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) 3261 | default: 3262 | panic("unknown field " + strconv.Quote(field.Name)) 3263 | } 3264 | } 3265 | out.Dispatch() 3266 | if invalids > 0 { 3267 | return graphql.Null 3268 | } 3269 | return out 3270 | } 3271 | 3272 | var __FieldImplementors = []string{"__Field"} 3273 | 3274 | func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { 3275 | fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) 3276 | 3277 | out := graphql.NewFieldSet(fields) 3278 | var invalids uint32 3279 | for i, field := range fields { 3280 | switch field.Name { 3281 | case "__typename": 3282 | out.Values[i] = graphql.MarshalString("__Field") 3283 | case "name": 3284 | out.Values[i] = ec.___Field_name(ctx, field, obj) 3285 | if out.Values[i] == graphql.Null { 3286 | invalids++ 3287 | } 3288 | case "description": 3289 | out.Values[i] = ec.___Field_description(ctx, field, obj) 3290 | case "args": 3291 | out.Values[i] = ec.___Field_args(ctx, field, obj) 3292 | if out.Values[i] == graphql.Null { 3293 | invalids++ 3294 | } 3295 | case "type": 3296 | out.Values[i] = ec.___Field_type(ctx, field, obj) 3297 | if out.Values[i] == graphql.Null { 3298 | invalids++ 3299 | } 3300 | case "isDeprecated": 3301 | out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) 3302 | if out.Values[i] == graphql.Null { 3303 | invalids++ 3304 | } 3305 | case "deprecationReason": 3306 | out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) 3307 | default: 3308 | panic("unknown field " + strconv.Quote(field.Name)) 3309 | } 3310 | } 3311 | out.Dispatch() 3312 | if invalids > 0 { 3313 | return graphql.Null 3314 | } 3315 | return out 3316 | } 3317 | 3318 | var __InputValueImplementors = []string{"__InputValue"} 3319 | 3320 | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { 3321 | fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) 3322 | 3323 | out := graphql.NewFieldSet(fields) 3324 | var invalids uint32 3325 | for i, field := range fields { 3326 | switch field.Name { 3327 | case "__typename": 3328 | out.Values[i] = graphql.MarshalString("__InputValue") 3329 | case "name": 3330 | out.Values[i] = ec.___InputValue_name(ctx, field, obj) 3331 | if out.Values[i] == graphql.Null { 3332 | invalids++ 3333 | } 3334 | case "description": 3335 | out.Values[i] = ec.___InputValue_description(ctx, field, obj) 3336 | case "type": 3337 | out.Values[i] = ec.___InputValue_type(ctx, field, obj) 3338 | if out.Values[i] == graphql.Null { 3339 | invalids++ 3340 | } 3341 | case "defaultValue": 3342 | out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) 3343 | default: 3344 | panic("unknown field " + strconv.Quote(field.Name)) 3345 | } 3346 | } 3347 | out.Dispatch() 3348 | if invalids > 0 { 3349 | return graphql.Null 3350 | } 3351 | return out 3352 | } 3353 | 3354 | var __SchemaImplementors = []string{"__Schema"} 3355 | 3356 | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { 3357 | fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) 3358 | 3359 | out := graphql.NewFieldSet(fields) 3360 | var invalids uint32 3361 | for i, field := range fields { 3362 | switch field.Name { 3363 | case "__typename": 3364 | out.Values[i] = graphql.MarshalString("__Schema") 3365 | case "types": 3366 | out.Values[i] = ec.___Schema_types(ctx, field, obj) 3367 | if out.Values[i] == graphql.Null { 3368 | invalids++ 3369 | } 3370 | case "queryType": 3371 | out.Values[i] = ec.___Schema_queryType(ctx, field, obj) 3372 | if out.Values[i] == graphql.Null { 3373 | invalids++ 3374 | } 3375 | case "mutationType": 3376 | out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) 3377 | case "subscriptionType": 3378 | out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) 3379 | case "directives": 3380 | out.Values[i] = ec.___Schema_directives(ctx, field, obj) 3381 | if out.Values[i] == graphql.Null { 3382 | invalids++ 3383 | } 3384 | default: 3385 | panic("unknown field " + strconv.Quote(field.Name)) 3386 | } 3387 | } 3388 | out.Dispatch() 3389 | if invalids > 0 { 3390 | return graphql.Null 3391 | } 3392 | return out 3393 | } 3394 | 3395 | var __TypeImplementors = []string{"__Type"} 3396 | 3397 | func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { 3398 | fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) 3399 | 3400 | out := graphql.NewFieldSet(fields) 3401 | var invalids uint32 3402 | for i, field := range fields { 3403 | switch field.Name { 3404 | case "__typename": 3405 | out.Values[i] = graphql.MarshalString("__Type") 3406 | case "kind": 3407 | out.Values[i] = ec.___Type_kind(ctx, field, obj) 3408 | if out.Values[i] == graphql.Null { 3409 | invalids++ 3410 | } 3411 | case "name": 3412 | out.Values[i] = ec.___Type_name(ctx, field, obj) 3413 | case "description": 3414 | out.Values[i] = ec.___Type_description(ctx, field, obj) 3415 | case "fields": 3416 | out.Values[i] = ec.___Type_fields(ctx, field, obj) 3417 | case "interfaces": 3418 | out.Values[i] = ec.___Type_interfaces(ctx, field, obj) 3419 | case "possibleTypes": 3420 | out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) 3421 | case "enumValues": 3422 | out.Values[i] = ec.___Type_enumValues(ctx, field, obj) 3423 | case "inputFields": 3424 | out.Values[i] = ec.___Type_inputFields(ctx, field, obj) 3425 | case "ofType": 3426 | out.Values[i] = ec.___Type_ofType(ctx, field, obj) 3427 | default: 3428 | panic("unknown field " + strconv.Quote(field.Name)) 3429 | } 3430 | } 3431 | out.Dispatch() 3432 | if invalids > 0 { 3433 | return graphql.Null 3434 | } 3435 | return out 3436 | } 3437 | 3438 | // endregion **************************** object.gotpl **************************** 3439 | 3440 | // region ***************************** type.gotpl ***************************** 3441 | 3442 | func (ec *executionContext) marshalNAuthResponse2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐAuthResponse(ctx context.Context, sel ast.SelectionSet, v models.AuthResponse) graphql.Marshaler { 3443 | return ec._AuthResponse(ctx, sel, &v) 3444 | } 3445 | 3446 | func (ec *executionContext) marshalNAuthResponse2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐAuthResponse(ctx context.Context, sel ast.SelectionSet, v *models.AuthResponse) graphql.Marshaler { 3447 | if v == nil { 3448 | if !ec.HasError(graphql.GetResolverContext(ctx)) { 3449 | ec.Errorf(ctx, "must not be null") 3450 | } 3451 | return graphql.Null 3452 | } 3453 | return ec._AuthResponse(ctx, sel, v) 3454 | } 3455 | 3456 | func (ec *executionContext) marshalNAuthToken2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐAuthToken(ctx context.Context, sel ast.SelectionSet, v models.AuthToken) graphql.Marshaler { 3457 | return ec._AuthToken(ctx, sel, &v) 3458 | } 3459 | 3460 | func (ec *executionContext) marshalNAuthToken2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐAuthToken(ctx context.Context, sel ast.SelectionSet, v *models.AuthToken) graphql.Marshaler { 3461 | if v == nil { 3462 | if !ec.HasError(graphql.GetResolverContext(ctx)) { 3463 | ec.Errorf(ctx, "must not be null") 3464 | } 3465 | return graphql.Null 3466 | } 3467 | return ec._AuthToken(ctx, sel, v) 3468 | } 3469 | 3470 | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { 3471 | return graphql.UnmarshalBoolean(v) 3472 | } 3473 | 3474 | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { 3475 | res := graphql.MarshalBoolean(v) 3476 | if res == graphql.Null { 3477 | if !ec.HasError(graphql.GetResolverContext(ctx)) { 3478 | ec.Errorf(ctx, "must not be null") 3479 | } 3480 | } 3481 | return res 3482 | } 3483 | 3484 | func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { 3485 | return graphql.UnmarshalID(v) 3486 | } 3487 | 3488 | func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 3489 | res := graphql.MarshalID(v) 3490 | if res == graphql.Null { 3491 | if !ec.HasError(graphql.GetResolverContext(ctx)) { 3492 | ec.Errorf(ctx, "must not be null") 3493 | } 3494 | } 3495 | return res 3496 | } 3497 | 3498 | func (ec *executionContext) unmarshalNLoginInput2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐLoginInput(ctx context.Context, v interface{}) (models.LoginInput, error) { 3499 | return ec.unmarshalInputLoginInput(ctx, v) 3500 | } 3501 | 3502 | func (ec *executionContext) marshalNMeetup2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetup(ctx context.Context, sel ast.SelectionSet, v models.Meetup) graphql.Marshaler { 3503 | return ec._Meetup(ctx, sel, &v) 3504 | } 3505 | 3506 | func (ec *executionContext) marshalNMeetup2ᚕᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetupᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Meetup) graphql.Marshaler { 3507 | ret := make(graphql.Array, len(v)) 3508 | var wg sync.WaitGroup 3509 | isLen1 := len(v) == 1 3510 | if !isLen1 { 3511 | wg.Add(len(v)) 3512 | } 3513 | for i := range v { 3514 | i := i 3515 | rctx := &graphql.ResolverContext{ 3516 | Index: &i, 3517 | Result: &v[i], 3518 | } 3519 | ctx := graphql.WithResolverContext(ctx, rctx) 3520 | f := func(i int) { 3521 | defer func() { 3522 | if r := recover(); r != nil { 3523 | ec.Error(ctx, ec.Recover(ctx, r)) 3524 | ret = nil 3525 | } 3526 | }() 3527 | if !isLen1 { 3528 | defer wg.Done() 3529 | } 3530 | ret[i] = ec.marshalNMeetup2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetup(ctx, sel, v[i]) 3531 | } 3532 | if isLen1 { 3533 | f(i) 3534 | } else { 3535 | go f(i) 3536 | } 3537 | 3538 | } 3539 | wg.Wait() 3540 | return ret 3541 | } 3542 | 3543 | func (ec *executionContext) marshalNMeetup2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetup(ctx context.Context, sel ast.SelectionSet, v *models.Meetup) graphql.Marshaler { 3544 | if v == nil { 3545 | if !ec.HasError(graphql.GetResolverContext(ctx)) { 3546 | ec.Errorf(ctx, "must not be null") 3547 | } 3548 | return graphql.Null 3549 | } 3550 | return ec._Meetup(ctx, sel, v) 3551 | } 3552 | 3553 | func (ec *executionContext) unmarshalNNewMeetup2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐNewMeetup(ctx context.Context, v interface{}) (models.NewMeetup, error) { 3554 | return ec.unmarshalInputNewMeetup(ctx, v) 3555 | } 3556 | 3557 | func (ec *executionContext) unmarshalNRegisterInput2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐRegisterInput(ctx context.Context, v interface{}) (models.RegisterInput, error) { 3558 | return ec.unmarshalInputRegisterInput(ctx, v) 3559 | } 3560 | 3561 | func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { 3562 | return graphql.UnmarshalString(v) 3563 | } 3564 | 3565 | func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 3566 | res := graphql.MarshalString(v) 3567 | if res == graphql.Null { 3568 | if !ec.HasError(graphql.GetResolverContext(ctx)) { 3569 | ec.Errorf(ctx, "must not be null") 3570 | } 3571 | } 3572 | return res 3573 | } 3574 | 3575 | func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { 3576 | return graphql.UnmarshalTime(v) 3577 | } 3578 | 3579 | func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { 3580 | res := graphql.MarshalTime(v) 3581 | if res == graphql.Null { 3582 | if !ec.HasError(graphql.GetResolverContext(ctx)) { 3583 | ec.Errorf(ctx, "must not be null") 3584 | } 3585 | } 3586 | return res 3587 | } 3588 | 3589 | func (ec *executionContext) unmarshalNUpdateMeetup2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐUpdateMeetup(ctx context.Context, v interface{}) (models.UpdateMeetup, error) { 3590 | return ec.unmarshalInputUpdateMeetup(ctx, v) 3591 | } 3592 | 3593 | func (ec *executionContext) marshalNUser2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐUser(ctx context.Context, sel ast.SelectionSet, v models.User) graphql.Marshaler { 3594 | return ec._User(ctx, sel, &v) 3595 | } 3596 | 3597 | func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐUser(ctx context.Context, sel ast.SelectionSet, v *models.User) graphql.Marshaler { 3598 | if v == nil { 3599 | if !ec.HasError(graphql.GetResolverContext(ctx)) { 3600 | ec.Errorf(ctx, "must not be null") 3601 | } 3602 | return graphql.Null 3603 | } 3604 | return ec._User(ctx, sel, v) 3605 | } 3606 | 3607 | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { 3608 | return ec.___Directive(ctx, sel, &v) 3609 | } 3610 | 3611 | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { 3612 | ret := make(graphql.Array, len(v)) 3613 | var wg sync.WaitGroup 3614 | isLen1 := len(v) == 1 3615 | if !isLen1 { 3616 | wg.Add(len(v)) 3617 | } 3618 | for i := range v { 3619 | i := i 3620 | rctx := &graphql.ResolverContext{ 3621 | Index: &i, 3622 | Result: &v[i], 3623 | } 3624 | ctx := graphql.WithResolverContext(ctx, rctx) 3625 | f := func(i int) { 3626 | defer func() { 3627 | if r := recover(); r != nil { 3628 | ec.Error(ctx, ec.Recover(ctx, r)) 3629 | ret = nil 3630 | } 3631 | }() 3632 | if !isLen1 { 3633 | defer wg.Done() 3634 | } 3635 | ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) 3636 | } 3637 | if isLen1 { 3638 | f(i) 3639 | } else { 3640 | go f(i) 3641 | } 3642 | 3643 | } 3644 | wg.Wait() 3645 | return ret 3646 | } 3647 | 3648 | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { 3649 | return graphql.UnmarshalString(v) 3650 | } 3651 | 3652 | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 3653 | res := graphql.MarshalString(v) 3654 | if res == graphql.Null { 3655 | if !ec.HasError(graphql.GetResolverContext(ctx)) { 3656 | ec.Errorf(ctx, "must not be null") 3657 | } 3658 | } 3659 | return res 3660 | } 3661 | 3662 | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { 3663 | var vSlice []interface{} 3664 | if v != nil { 3665 | if tmp1, ok := v.([]interface{}); ok { 3666 | vSlice = tmp1 3667 | } else { 3668 | vSlice = []interface{}{v} 3669 | } 3670 | } 3671 | var err error 3672 | res := make([]string, len(vSlice)) 3673 | for i := range vSlice { 3674 | res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) 3675 | if err != nil { 3676 | return nil, err 3677 | } 3678 | } 3679 | return res, nil 3680 | } 3681 | 3682 | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { 3683 | ret := make(graphql.Array, len(v)) 3684 | var wg sync.WaitGroup 3685 | isLen1 := len(v) == 1 3686 | if !isLen1 { 3687 | wg.Add(len(v)) 3688 | } 3689 | for i := range v { 3690 | i := i 3691 | rctx := &graphql.ResolverContext{ 3692 | Index: &i, 3693 | Result: &v[i], 3694 | } 3695 | ctx := graphql.WithResolverContext(ctx, rctx) 3696 | f := func(i int) { 3697 | defer func() { 3698 | if r := recover(); r != nil { 3699 | ec.Error(ctx, ec.Recover(ctx, r)) 3700 | ret = nil 3701 | } 3702 | }() 3703 | if !isLen1 { 3704 | defer wg.Done() 3705 | } 3706 | ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) 3707 | } 3708 | if isLen1 { 3709 | f(i) 3710 | } else { 3711 | go f(i) 3712 | } 3713 | 3714 | } 3715 | wg.Wait() 3716 | return ret 3717 | } 3718 | 3719 | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { 3720 | return ec.___EnumValue(ctx, sel, &v) 3721 | } 3722 | 3723 | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { 3724 | return ec.___Field(ctx, sel, &v) 3725 | } 3726 | 3727 | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { 3728 | return ec.___InputValue(ctx, sel, &v) 3729 | } 3730 | 3731 | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { 3732 | ret := make(graphql.Array, len(v)) 3733 | var wg sync.WaitGroup 3734 | isLen1 := len(v) == 1 3735 | if !isLen1 { 3736 | wg.Add(len(v)) 3737 | } 3738 | for i := range v { 3739 | i := i 3740 | rctx := &graphql.ResolverContext{ 3741 | Index: &i, 3742 | Result: &v[i], 3743 | } 3744 | ctx := graphql.WithResolverContext(ctx, rctx) 3745 | f := func(i int) { 3746 | defer func() { 3747 | if r := recover(); r != nil { 3748 | ec.Error(ctx, ec.Recover(ctx, r)) 3749 | ret = nil 3750 | } 3751 | }() 3752 | if !isLen1 { 3753 | defer wg.Done() 3754 | } 3755 | ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) 3756 | } 3757 | if isLen1 { 3758 | f(i) 3759 | } else { 3760 | go f(i) 3761 | } 3762 | 3763 | } 3764 | wg.Wait() 3765 | return ret 3766 | } 3767 | 3768 | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { 3769 | return ec.___Type(ctx, sel, &v) 3770 | } 3771 | 3772 | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { 3773 | ret := make(graphql.Array, len(v)) 3774 | var wg sync.WaitGroup 3775 | isLen1 := len(v) == 1 3776 | if !isLen1 { 3777 | wg.Add(len(v)) 3778 | } 3779 | for i := range v { 3780 | i := i 3781 | rctx := &graphql.ResolverContext{ 3782 | Index: &i, 3783 | Result: &v[i], 3784 | } 3785 | ctx := graphql.WithResolverContext(ctx, rctx) 3786 | f := func(i int) { 3787 | defer func() { 3788 | if r := recover(); r != nil { 3789 | ec.Error(ctx, ec.Recover(ctx, r)) 3790 | ret = nil 3791 | } 3792 | }() 3793 | if !isLen1 { 3794 | defer wg.Done() 3795 | } 3796 | ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) 3797 | } 3798 | if isLen1 { 3799 | f(i) 3800 | } else { 3801 | go f(i) 3802 | } 3803 | 3804 | } 3805 | wg.Wait() 3806 | return ret 3807 | } 3808 | 3809 | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { 3810 | if v == nil { 3811 | if !ec.HasError(graphql.GetResolverContext(ctx)) { 3812 | ec.Errorf(ctx, "must not be null") 3813 | } 3814 | return graphql.Null 3815 | } 3816 | return ec.___Type(ctx, sel, v) 3817 | } 3818 | 3819 | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { 3820 | return graphql.UnmarshalString(v) 3821 | } 3822 | 3823 | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 3824 | res := graphql.MarshalString(v) 3825 | if res == graphql.Null { 3826 | if !ec.HasError(graphql.GetResolverContext(ctx)) { 3827 | ec.Errorf(ctx, "must not be null") 3828 | } 3829 | } 3830 | return res 3831 | } 3832 | 3833 | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { 3834 | return graphql.UnmarshalBoolean(v) 3835 | } 3836 | 3837 | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { 3838 | return graphql.MarshalBoolean(v) 3839 | } 3840 | 3841 | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { 3842 | if v == nil { 3843 | return nil, nil 3844 | } 3845 | res, err := ec.unmarshalOBoolean2bool(ctx, v) 3846 | return &res, err 3847 | } 3848 | 3849 | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { 3850 | if v == nil { 3851 | return graphql.Null 3852 | } 3853 | return ec.marshalOBoolean2bool(ctx, sel, *v) 3854 | } 3855 | 3856 | func (ec *executionContext) unmarshalOInt2int(ctx context.Context, v interface{}) (int, error) { 3857 | return graphql.UnmarshalInt(v) 3858 | } 3859 | 3860 | func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { 3861 | return graphql.MarshalInt(v) 3862 | } 3863 | 3864 | func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { 3865 | if v == nil { 3866 | return nil, nil 3867 | } 3868 | res, err := ec.unmarshalOInt2int(ctx, v) 3869 | return &res, err 3870 | } 3871 | 3872 | func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { 3873 | if v == nil { 3874 | return graphql.Null 3875 | } 3876 | return ec.marshalOInt2int(ctx, sel, *v) 3877 | } 3878 | 3879 | func (ec *executionContext) unmarshalOMeetupFilter2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetupFilter(ctx context.Context, v interface{}) (models.MeetupFilter, error) { 3880 | return ec.unmarshalInputMeetupFilter(ctx, v) 3881 | } 3882 | 3883 | func (ec *executionContext) unmarshalOMeetupFilter2ᚖgithubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetupFilter(ctx context.Context, v interface{}) (*models.MeetupFilter, error) { 3884 | if v == nil { 3885 | return nil, nil 3886 | } 3887 | res, err := ec.unmarshalOMeetupFilter2githubᚗcomᚋequimperᚋmeetmeupᚋmodelsᚐMeetupFilter(ctx, v) 3888 | return &res, err 3889 | } 3890 | 3891 | func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { 3892 | return graphql.UnmarshalString(v) 3893 | } 3894 | 3895 | func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 3896 | return graphql.MarshalString(v) 3897 | } 3898 | 3899 | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { 3900 | if v == nil { 3901 | return nil, nil 3902 | } 3903 | res, err := ec.unmarshalOString2string(ctx, v) 3904 | return &res, err 3905 | } 3906 | 3907 | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { 3908 | if v == nil { 3909 | return graphql.Null 3910 | } 3911 | return ec.marshalOString2string(ctx, sel, *v) 3912 | } 3913 | 3914 | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { 3915 | if v == nil { 3916 | return graphql.Null 3917 | } 3918 | ret := make(graphql.Array, len(v)) 3919 | var wg sync.WaitGroup 3920 | isLen1 := len(v) == 1 3921 | if !isLen1 { 3922 | wg.Add(len(v)) 3923 | } 3924 | for i := range v { 3925 | i := i 3926 | rctx := &graphql.ResolverContext{ 3927 | Index: &i, 3928 | Result: &v[i], 3929 | } 3930 | ctx := graphql.WithResolverContext(ctx, rctx) 3931 | f := func(i int) { 3932 | defer func() { 3933 | if r := recover(); r != nil { 3934 | ec.Error(ctx, ec.Recover(ctx, r)) 3935 | ret = nil 3936 | } 3937 | }() 3938 | if !isLen1 { 3939 | defer wg.Done() 3940 | } 3941 | ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) 3942 | } 3943 | if isLen1 { 3944 | f(i) 3945 | } else { 3946 | go f(i) 3947 | } 3948 | 3949 | } 3950 | wg.Wait() 3951 | return ret 3952 | } 3953 | 3954 | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { 3955 | if v == nil { 3956 | return graphql.Null 3957 | } 3958 | ret := make(graphql.Array, len(v)) 3959 | var wg sync.WaitGroup 3960 | isLen1 := len(v) == 1 3961 | if !isLen1 { 3962 | wg.Add(len(v)) 3963 | } 3964 | for i := range v { 3965 | i := i 3966 | rctx := &graphql.ResolverContext{ 3967 | Index: &i, 3968 | Result: &v[i], 3969 | } 3970 | ctx := graphql.WithResolverContext(ctx, rctx) 3971 | f := func(i int) { 3972 | defer func() { 3973 | if r := recover(); r != nil { 3974 | ec.Error(ctx, ec.Recover(ctx, r)) 3975 | ret = nil 3976 | } 3977 | }() 3978 | if !isLen1 { 3979 | defer wg.Done() 3980 | } 3981 | ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) 3982 | } 3983 | if isLen1 { 3984 | f(i) 3985 | } else { 3986 | go f(i) 3987 | } 3988 | 3989 | } 3990 | wg.Wait() 3991 | return ret 3992 | } 3993 | 3994 | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { 3995 | if v == nil { 3996 | return graphql.Null 3997 | } 3998 | ret := make(graphql.Array, len(v)) 3999 | var wg sync.WaitGroup 4000 | isLen1 := len(v) == 1 4001 | if !isLen1 { 4002 | wg.Add(len(v)) 4003 | } 4004 | for i := range v { 4005 | i := i 4006 | rctx := &graphql.ResolverContext{ 4007 | Index: &i, 4008 | Result: &v[i], 4009 | } 4010 | ctx := graphql.WithResolverContext(ctx, rctx) 4011 | f := func(i int) { 4012 | defer func() { 4013 | if r := recover(); r != nil { 4014 | ec.Error(ctx, ec.Recover(ctx, r)) 4015 | ret = nil 4016 | } 4017 | }() 4018 | if !isLen1 { 4019 | defer wg.Done() 4020 | } 4021 | ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) 4022 | } 4023 | if isLen1 { 4024 | f(i) 4025 | } else { 4026 | go f(i) 4027 | } 4028 | 4029 | } 4030 | wg.Wait() 4031 | return ret 4032 | } 4033 | 4034 | func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { 4035 | return ec.___Schema(ctx, sel, &v) 4036 | } 4037 | 4038 | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { 4039 | if v == nil { 4040 | return graphql.Null 4041 | } 4042 | return ec.___Schema(ctx, sel, v) 4043 | } 4044 | 4045 | func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { 4046 | return ec.___Type(ctx, sel, &v) 4047 | } 4048 | 4049 | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { 4050 | if v == nil { 4051 | return graphql.Null 4052 | } 4053 | ret := make(graphql.Array, len(v)) 4054 | var wg sync.WaitGroup 4055 | isLen1 := len(v) == 1 4056 | if !isLen1 { 4057 | wg.Add(len(v)) 4058 | } 4059 | for i := range v { 4060 | i := i 4061 | rctx := &graphql.ResolverContext{ 4062 | Index: &i, 4063 | Result: &v[i], 4064 | } 4065 | ctx := graphql.WithResolverContext(ctx, rctx) 4066 | f := func(i int) { 4067 | defer func() { 4068 | if r := recover(); r != nil { 4069 | ec.Error(ctx, ec.Recover(ctx, r)) 4070 | ret = nil 4071 | } 4072 | }() 4073 | if !isLen1 { 4074 | defer wg.Done() 4075 | } 4076 | ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) 4077 | } 4078 | if isLen1 { 4079 | f(i) 4080 | } else { 4081 | go f(i) 4082 | } 4083 | 4084 | } 4085 | wg.Wait() 4086 | return ret 4087 | } 4088 | 4089 | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { 4090 | if v == nil { 4091 | return graphql.Null 4092 | } 4093 | return ec.___Type(ctx, sel, v) 4094 | } 4095 | 4096 | // endregion ***************************** type.gotpl ***************************** 4097 | -------------------------------------------------------------------------------- /graphql/meetup_resolver.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/equimper/meetmeup/models" 7 | ) 8 | 9 | type meetupResolver struct{ *Resolver } 10 | 11 | func (m *meetupResolver) User(ctx context.Context, obj *models.Meetup) (*models.User, error) { 12 | return getUserLoader(ctx).Load(obj.UserID) 13 | } 14 | 15 | func (r *Resolver) Meetup() MeetupResolver { 16 | return &meetupResolver{r} 17 | } 18 | -------------------------------------------------------------------------------- /graphql/mutation_resolver.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | 7 | "github.com/equimper/meetmeup/models" 8 | ) 9 | 10 | var ( 11 | ErrInput = errors.New("input errors") 12 | ) 13 | 14 | func (r *Resolver) Mutation() MutationResolver { 15 | return &mutationResolver{r} 16 | } 17 | 18 | type mutationResolver struct{ *Resolver } 19 | 20 | func (m *mutationResolver) Login(ctx context.Context, input models.LoginInput) (*models.AuthResponse, error) { 21 | isValid := validation(ctx, input) 22 | if !isValid { 23 | return nil, ErrInput 24 | } 25 | 26 | return m.Domain.Login(ctx, input) 27 | } 28 | 29 | func (m *mutationResolver) Register(ctx context.Context, input models.RegisterInput) (*models.AuthResponse, error) { 30 | isValid := validation(ctx, input) 31 | if !isValid { 32 | return nil, ErrInput 33 | } 34 | 35 | return m.Domain.Register(ctx, input) 36 | } 37 | 38 | func (m *mutationResolver) DeleteMeetup(ctx context.Context, id string) (bool, error) { 39 | return m.Domain.DeleteMeetup(ctx, id) 40 | } 41 | 42 | func (m *mutationResolver) UpdateMeetup(ctx context.Context, id string, input models.UpdateMeetup) (*models.Meetup, error) { 43 | return m.Domain.UpdateMeetup(ctx, id, input) 44 | } 45 | 46 | func (m *mutationResolver) CreateMeetup(ctx context.Context, input models.NewMeetup) (*models.Meetup, error) { 47 | return m.Domain.CreateMeetup(ctx, input) 48 | } 49 | -------------------------------------------------------------------------------- /graphql/query_resolver.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/equimper/meetmeup/models" 7 | ) 8 | 9 | func (r *Resolver) Query() QueryResolver { 10 | return &queryResolver{r} 11 | } 12 | 13 | type queryResolver struct{ *Resolver } 14 | 15 | func (r *queryResolver) User(ctx context.Context, id string) (*models.User, error) { 16 | return r.Domain.UsersRepo.GetUserByID(id) 17 | } 18 | 19 | func (r *queryResolver) Meetups(ctx context.Context, filter *models.MeetupFilter, limit *int, offset *int) ([]*models.Meetup, error) { 20 | return r.Domain.MeetupsRepo.GetMeetups(filter, limit, offset) 21 | } 22 | -------------------------------------------------------------------------------- /graphql/resolver.go: -------------------------------------------------------------------------------- 1 | //go:generate go run github.com/99designs/gqlgen -v 2 | 3 | package graphql 4 | 5 | import "github.com/equimper/meetmeup/domain" 6 | 7 | type Resolver struct { 8 | Domain *domain.Domain 9 | } 10 | -------------------------------------------------------------------------------- /graphql/user_resolver.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/equimper/meetmeup/models" 7 | ) 8 | 9 | type userResolver struct{ *Resolver } 10 | 11 | func (r *Resolver) User() UserResolver { 12 | return &userResolver{r} 13 | } 14 | 15 | func (u *userResolver) Meetups(ctx context.Context, obj *models.User) ([]*models.Meetup, error) { 16 | return u.Domain.MeetupsRepo.GetMeetupsForUser(obj) 17 | } 18 | -------------------------------------------------------------------------------- /graphql/userloader_gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/vektah/dataloaden, DO NOT EDIT. 2 | 3 | package graphql 4 | 5 | import ( 6 | "sync" 7 | "time" 8 | 9 | "github.com/equimper/meetmeup/models" 10 | ) 11 | 12 | // UserLoaderConfig captures the config to create a new UserLoader 13 | type UserLoaderConfig struct { 14 | // Fetch is a method that provides the data for the loader 15 | Fetch func(keys []string) ([]*models.User, []error) 16 | 17 | // Wait is how long wait before sending a batch 18 | Wait time.Duration 19 | 20 | // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit 21 | MaxBatch int 22 | } 23 | 24 | // NewUserLoader creates a new UserLoader given a fetch, wait, and maxBatch 25 | func NewUserLoader(config UserLoaderConfig) *UserLoader { 26 | return &UserLoader{ 27 | fetch: config.Fetch, 28 | wait: config.Wait, 29 | maxBatch: config.MaxBatch, 30 | } 31 | } 32 | 33 | // UserLoader batches and caches requests 34 | type UserLoader struct { 35 | // this method provides the data for the loader 36 | fetch func(keys []string) ([]*models.User, []error) 37 | 38 | // how long to done before sending a batch 39 | wait time.Duration 40 | 41 | // this will limit the maximum number of keys to send in one batch, 0 = no limit 42 | maxBatch int 43 | 44 | // INTERNAL 45 | 46 | // lazily created cache 47 | cache map[string]*models.User 48 | 49 | // the current batch. keys will continue to be collected until timeout is hit, 50 | // then everything will be sent to the fetch method and out to the listeners 51 | batch *userLoaderBatch 52 | 53 | // mutex to prevent races 54 | mu sync.Mutex 55 | } 56 | 57 | type userLoaderBatch struct { 58 | keys []string 59 | data []*models.User 60 | error []error 61 | closing bool 62 | done chan struct{} 63 | } 64 | 65 | // Load a User by key, batching and caching will be applied automatically 66 | func (l *UserLoader) Load(key string) (*models.User, error) { 67 | return l.LoadThunk(key)() 68 | } 69 | 70 | // LoadThunk returns a function that when called will block waiting for a User. 71 | // This method should be used if you want one goroutine to make requests to many 72 | // different data loaders without blocking until the thunk is called. 73 | func (l *UserLoader) LoadThunk(key string) func() (*models.User, error) { 74 | l.mu.Lock() 75 | if it, ok := l.cache[key]; ok { 76 | l.mu.Unlock() 77 | return func() (*models.User, error) { 78 | return it, nil 79 | } 80 | } 81 | if l.batch == nil { 82 | l.batch = &userLoaderBatch{done: make(chan struct{})} 83 | } 84 | batch := l.batch 85 | pos := batch.keyIndex(l, key) 86 | l.mu.Unlock() 87 | 88 | return func() (*models.User, error) { 89 | <-batch.done 90 | 91 | var data *models.User 92 | if pos < len(batch.data) { 93 | data = batch.data[pos] 94 | } 95 | 96 | var err error 97 | // its convenient to be able to return a single error for everything 98 | if len(batch.error) == 1 { 99 | err = batch.error[0] 100 | } else if batch.error != nil { 101 | err = batch.error[pos] 102 | } 103 | 104 | if err == nil { 105 | l.mu.Lock() 106 | l.unsafeSet(key, data) 107 | l.mu.Unlock() 108 | } 109 | 110 | return data, err 111 | } 112 | } 113 | 114 | // LoadAll fetches many keys at once. It will be broken into appropriate sized 115 | // sub batches depending on how the loader is configured 116 | func (l *UserLoader) LoadAll(keys []string) ([]*models.User, []error) { 117 | results := make([]func() (*models.User, error), len(keys)) 118 | 119 | for i, key := range keys { 120 | results[i] = l.LoadThunk(key) 121 | } 122 | 123 | users := make([]*models.User, len(keys)) 124 | errors := make([]error, len(keys)) 125 | for i, thunk := range results { 126 | users[i], errors[i] = thunk() 127 | } 128 | return users, errors 129 | } 130 | 131 | // LoadAllThunk returns a function that when called will block waiting for a Users. 132 | // This method should be used if you want one goroutine to make requests to many 133 | // different data loaders without blocking until the thunk is called. 134 | func (l *UserLoader) LoadAllThunk(keys []string) func() ([]*models.User, []error) { 135 | results := make([]func() (*models.User, error), len(keys)) 136 | for i, key := range keys { 137 | results[i] = l.LoadThunk(key) 138 | } 139 | return func() ([]*models.User, []error) { 140 | users := make([]*models.User, len(keys)) 141 | errors := make([]error, len(keys)) 142 | for i, thunk := range results { 143 | users[i], errors[i] = thunk() 144 | } 145 | return users, errors 146 | } 147 | } 148 | 149 | // Prime the cache with the provided key and value. If the key already exists, no change is made 150 | // and false is returned. 151 | // (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) 152 | func (l *UserLoader) Prime(key string, value *models.User) bool { 153 | l.mu.Lock() 154 | var found bool 155 | if _, found = l.cache[key]; !found { 156 | // make a copy when writing to the cache, its easy to pass a pointer in from a loop var 157 | // and end up with the whole cache pointing to the same value. 158 | cpy := *value 159 | l.unsafeSet(key, &cpy) 160 | } 161 | l.mu.Unlock() 162 | return !found 163 | } 164 | 165 | // Clear the value at key from the cache, if it exists 166 | func (l *UserLoader) Clear(key string) { 167 | l.mu.Lock() 168 | delete(l.cache, key) 169 | l.mu.Unlock() 170 | } 171 | 172 | func (l *UserLoader) unsafeSet(key string, value *models.User) { 173 | if l.cache == nil { 174 | l.cache = map[string]*models.User{} 175 | } 176 | l.cache[key] = value 177 | } 178 | 179 | // keyIndex will return the location of the key in the batch, if its not found 180 | // it will add the key to the batch 181 | func (b *userLoaderBatch) keyIndex(l *UserLoader, key string) int { 182 | for i, existingKey := range b.keys { 183 | if key == existingKey { 184 | return i 185 | } 186 | } 187 | 188 | pos := len(b.keys) 189 | b.keys = append(b.keys, key) 190 | if pos == 0 { 191 | go b.startTimer(l) 192 | } 193 | 194 | if l.maxBatch != 0 && pos >= l.maxBatch-1 { 195 | if !b.closing { 196 | b.closing = true 197 | l.batch = nil 198 | go b.end(l) 199 | } 200 | } 201 | 202 | return pos 203 | } 204 | 205 | func (b *userLoaderBatch) startTimer(l *UserLoader) { 206 | time.Sleep(l.wait) 207 | l.mu.Lock() 208 | 209 | // we must have hit a batch limit and are already finalizing this batch 210 | if b.closing { 211 | l.mu.Unlock() 212 | return 213 | } 214 | 215 | l.batch = nil 216 | l.mu.Unlock() 217 | 218 | b.end(l) 219 | } 220 | 221 | func (b *userLoaderBatch) end(l *UserLoader) { 222 | b.data, b.error = l.fetch(b.keys) 223 | close(b.done) 224 | } 225 | -------------------------------------------------------------------------------- /graphql/validation.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/99designs/gqlgen/graphql" 7 | "github.com/vektah/gqlparser/gqlerror" 8 | 9 | "github.com/equimper/meetmeup/validator" 10 | ) 11 | 12 | func validation(ctx context.Context, v validator.Validation) bool { 13 | isValid, errors := v.Validate() 14 | 15 | if !isValid { 16 | for k, e := range errors { 17 | graphql.AddError(ctx, &gqlerror.Error{ 18 | Message: e, 19 | Extensions: map[string]interface{}{ 20 | "field": k, 21 | }, 22 | }) 23 | } 24 | } 25 | 26 | return isValid 27 | } 28 | -------------------------------------------------------------------------------- /middleware/auth_middleware.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "os" 7 | "strings" 8 | 9 | "github.com/dgrijalva/jwt-go" 10 | "github.com/dgrijalva/jwt-go/request" 11 | "github.com/pkg/errors" 12 | 13 | "github.com/equimper/meetmeup/models" 14 | "github.com/equimper/meetmeup/postgres" 15 | ) 16 | 17 | const CurrentUserKey = "currentUser" 18 | 19 | func AuthMiddleware(repo postgres.UsersRepo) func(http.Handler) http.Handler { 20 | return func(next http.Handler) http.Handler { 21 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 22 | token, err := parseToken(r) 23 | if err != nil { 24 | next.ServeHTTP(w, r) 25 | return 26 | } 27 | 28 | claims, ok := token.Claims.(jwt.MapClaims) 29 | 30 | if !ok || !token.Valid { 31 | next.ServeHTTP(w, r) 32 | return 33 | } 34 | 35 | user, err := repo.GetUserByID(claims["jti"].(string)) 36 | if err != nil { 37 | next.ServeHTTP(w, r) 38 | return 39 | } 40 | 41 | ctx := context.WithValue(r.Context(), CurrentUserKey, user) 42 | 43 | next.ServeHTTP(w, r.WithContext(ctx)) 44 | }) 45 | } 46 | } 47 | 48 | var authHeaderExtractor = &request.PostExtractionFilter{ 49 | Extractor: request.HeaderExtractor{"Authorization"}, 50 | Filter: stripBearerPrefixFromToken, 51 | } 52 | 53 | func stripBearerPrefixFromToken(token string) (string, error) { 54 | bearer := "BEARER" 55 | 56 | if len(token) > len(bearer) && strings.ToUpper(token[0:len(bearer)]) == bearer { 57 | return token[len(bearer)+1:], nil 58 | } 59 | 60 | return token, nil 61 | } 62 | 63 | var authExtractor = &request.MultiExtractor{ 64 | authHeaderExtractor, 65 | request.ArgumentExtractor{"access_token"}, 66 | } 67 | 68 | func parseToken(r *http.Request) (*jwt.Token, error) { 69 | jwtToken, err := request.ParseFromRequest(r, authExtractor, func(token *jwt.Token) (interface{}, error) { 70 | t := []byte(os.Getenv("JWT_SECRET")) 71 | return t, nil 72 | }) 73 | 74 | return jwtToken, errors.Wrap(err, "parseToken error: ") 75 | } 76 | 77 | func GetCurrentUserFromCTX(ctx context.Context) (*models.User, error) { 78 | errNoUserInContext := errors.New("no user in context") 79 | 80 | if ctx.Value(CurrentUserKey) == nil { 81 | return nil, errNoUserInContext 82 | } 83 | 84 | user, ok := ctx.Value(CurrentUserKey).(*models.User) 85 | if !ok || user.ID == "" { 86 | return nil, errNoUserInContext 87 | } 88 | 89 | return user, nil 90 | } 91 | -------------------------------------------------------------------------------- /models/meetup.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | type Meetup struct { 4 | ID string `json:"id"` 5 | Name string `json:"name"` 6 | Description string `json:"description"` 7 | UserID string `json:"userId"` 8 | } 9 | 10 | func (m *Meetup) IsOwner(user *User) bool { 11 | return m.UserID == user.ID 12 | } 13 | -------------------------------------------------------------------------------- /models/models_gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 | 3 | package models 4 | 5 | import ( 6 | "time" 7 | ) 8 | 9 | type AuthResponse struct { 10 | AuthToken *AuthToken `json:"authToken"` 11 | User *User `json:"user"` 12 | } 13 | 14 | type AuthToken struct { 15 | AccessToken string `json:"accessToken"` 16 | ExpiredAt time.Time `json:"expiredAt"` 17 | } 18 | 19 | type LoginInput struct { 20 | Email string `json:"email"` 21 | Password string `json:"password"` 22 | } 23 | 24 | type MeetupFilter struct { 25 | Name *string `json:"name"` 26 | } 27 | 28 | type NewMeetup struct { 29 | Name string `json:"name"` 30 | Description string `json:"description"` 31 | } 32 | 33 | type RegisterInput struct { 34 | Username string `json:"username"` 35 | Email string `json:"email"` 36 | Password string `json:"password"` 37 | ConfirmPassword string `json:"confirmPassword"` 38 | FirstName string `json:"firstName"` 39 | LastName string `json:"lastName"` 40 | } 41 | 42 | type UpdateMeetup struct { 43 | Name *string `json:"name"` 44 | Description *string `json:"description"` 45 | } 46 | -------------------------------------------------------------------------------- /models/user.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "os" 5 | "time" 6 | 7 | "github.com/dgrijalva/jwt-go" 8 | "golang.org/x/crypto/bcrypt" 9 | ) 10 | 11 | type User struct { 12 | ID string `json:"id"` 13 | Username string `json:"username"` 14 | Email string `json:"email"` 15 | Password string `json:"password"` 16 | FirstName string `json:"firstName"` 17 | LastName string `json:"lastName"` 18 | CreatedAt time.Time `json:"createdAt"` 19 | UpdatedAt time.Time `json:"updatedAt"` 20 | DeletedAt *time.Time `json:"-" pg:",soft_delete"` 21 | } 22 | 23 | func (u *User) HashPassword(password string) error { 24 | bytePassword := []byte(password) 25 | passwordHash, err := bcrypt.GenerateFromPassword(bytePassword, bcrypt.DefaultCost) 26 | if err != nil { 27 | return err 28 | } 29 | 30 | u.Password = string(passwordHash) 31 | 32 | return nil 33 | } 34 | 35 | func (u *User) GenToken() (*AuthToken, error) { 36 | expiredAt := time.Now().Add(time.Hour * 24 * 7) // a week 37 | 38 | token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.StandardClaims{ 39 | ExpiresAt: expiredAt.Unix(), 40 | Id: u.ID, 41 | IssuedAt: time.Now().Unix(), 42 | Issuer: "meetmeup", 43 | }) 44 | 45 | accessToken, err := token.SignedString([]byte(os.Getenv("JWT_SECRET"))) 46 | if err != nil { 47 | return nil, err 48 | } 49 | 50 | return &AuthToken{ 51 | AccessToken: accessToken, 52 | ExpiredAt: expiredAt, 53 | }, nil 54 | } 55 | 56 | func (u *User) ComparePassword(password string) error { 57 | bytePassword := []byte(password) 58 | byteHashedPassword := []byte(u.Password) 59 | return bcrypt.CompareHashAndPassword(byteHashedPassword, bytePassword) 60 | } 61 | -------------------------------------------------------------------------------- /models/validation.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "github.com/equimper/meetmeup/validator" 4 | 5 | func (r RegisterInput) Validate() (bool, map[string]string) { 6 | v := validator.New() 7 | 8 | v.Required("email", r.Email) 9 | v.IsEmail("email", r.Email) 10 | 11 | v.Required("password", r.Password) 12 | v.MinLength("password", r.Password, 6) 13 | 14 | v.Required("confirmPassword", r.ConfirmPassword) 15 | v.EqualToField("confirmPassword", r.ConfirmPassword, "password", r.Password) 16 | 17 | v.Required("username", r.Username) 18 | v.MinLength("username", r.Username, 2) 19 | 20 | v.Required("firstName", r.FirstName) 21 | v.MinLength("firstName", r.FirstName, 2) 22 | 23 | v.Required("lastName", r.LastName) 24 | v.MinLength("lastName", r.LastName, 2) 25 | 26 | return v.IsValid(), v.Errors 27 | } 28 | 29 | func (l LoginInput) Validate() (bool, map[string]string) { 30 | v := validator.New() 31 | 32 | v.Required("email", l.Email) 33 | v.IsEmail("email", l.Email) 34 | 35 | v.Required("password", l.Password) 36 | 37 | return v.IsValid(), v.Errors 38 | } 39 | -------------------------------------------------------------------------------- /postgres/meetups.go: -------------------------------------------------------------------------------- 1 | package postgres 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/go-pg/pg/v9" 7 | 8 | "github.com/equimper/meetmeup/models" 9 | ) 10 | 11 | type MeetupsRepo struct { 12 | DB *pg.DB 13 | } 14 | 15 | func (m *MeetupsRepo) GetMeetups(filter *models.MeetupFilter, limit, offset *int) ([]*models.Meetup, error) { 16 | var meetups []*models.Meetup 17 | 18 | query := m.DB.Model(&meetups).Order("id") 19 | 20 | if filter != nil { 21 | if filter.Name != nil && *filter.Name != "" { 22 | query.Where("name ILIKE ?", fmt.Sprintf("%%%s%%", *filter.Name)) 23 | } 24 | } 25 | 26 | if limit != nil { 27 | query.Limit(*limit) 28 | } 29 | 30 | if offset != nil { 31 | query.Offset(*offset) 32 | } 33 | 34 | err := query.Select() 35 | if err != nil { 36 | return nil, err 37 | } 38 | 39 | return meetups, nil 40 | } 41 | 42 | func (m *MeetupsRepo) CreateMeetup(meetup *models.Meetup) (*models.Meetup, error) { 43 | _, err := m.DB.Model(meetup).Returning("*").Insert() 44 | 45 | return meetup, err 46 | } 47 | 48 | func (m *MeetupsRepo) GetByID(id string) (*models.Meetup, error) { 49 | var meetup models.Meetup 50 | err := m.DB.Model(&meetup).Where("id = ?", id).First() 51 | return &meetup, err 52 | } 53 | 54 | func (m *MeetupsRepo) Update(meetup *models.Meetup) (*models.Meetup, error) { 55 | _, err := m.DB.Model(meetup).Where("id = ?", meetup.ID).Update() 56 | return meetup, err 57 | } 58 | 59 | func (m *MeetupsRepo) Delete(meetup *models.Meetup) error { 60 | _, err := m.DB.Model(meetup).Where("id = ?", meetup.ID).Delete() 61 | return err 62 | } 63 | 64 | func (m *MeetupsRepo) GetMeetupsForUser(user *models.User) ([]*models.Meetup, error) { 65 | var meetups []*models.Meetup 66 | err := m.DB.Model(&meetups).Where("user_id = ?", user.ID).Order("id").Select() 67 | return meetups, err 68 | } 69 | -------------------------------------------------------------------------------- /postgres/migrations/20191214081927_create_users.down.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EQuimper/youtube-golang-graphql-tutorial/bd228d538364184ee861332ff4bc3bcacc13e466/postgres/migrations/20191214081927_create_users.down.sql -------------------------------------------------------------------------------- /postgres/migrations/20191214081927_create_users.up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE users 2 | ( 3 | id BIGSERIAL PRIMARY KEY, 4 | username VARCHAR(55) UNIQUE NOT NULL, 5 | email VARCHAR(255) UNIQUE NOT NULL, 6 | first_name VARCHAR(255) NOT NULL, 7 | last_name VARCHAR(255) NOT NULL, 8 | password TEXT, 9 | created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL, 10 | updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL, 11 | deleted_at TIMESTAMP WITH TIME ZONE DEFAULT NULL 12 | ); -------------------------------------------------------------------------------- /postgres/migrations/20191214081931_create_meetups.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE meetups; -------------------------------------------------------------------------------- /postgres/migrations/20191214081931_create_meetups.up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE meetups 2 | ( 3 | id BIGSERIAL PRIMARY KEY, 4 | name VARCHAR(255) UNIQUE NOT NULL, 5 | description TEXT, 6 | 7 | user_id BIGSERIAL REFERENCES users (id) ON DELETE CASCADE NOT NULL 8 | ); -------------------------------------------------------------------------------- /postgres/postgres.go: -------------------------------------------------------------------------------- 1 | package postgres 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/go-pg/pg/v9" 8 | ) 9 | 10 | type DBLogger struct{} 11 | 12 | func (d DBLogger) BeforeQuery(ctx context.Context, q *pg.QueryEvent) (context.Context, error) { 13 | return ctx, nil 14 | } 15 | 16 | func (d DBLogger) AfterQuery(ctx context.Context, q *pg.QueryEvent) error { 17 | fmt.Println(q.FormattedQuery()) 18 | return nil 19 | } 20 | 21 | func New(opts *pg.Options) *pg.DB { 22 | return pg.Connect(opts) 23 | } 24 | -------------------------------------------------------------------------------- /postgres/seeds.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO users (username, email) VALUES ('bob', 'bob@gmail.com'); 2 | INSERT INTO users (username, email) VALUES ('jon', 'jon@gmail.com'); 3 | INSERT INTO users (username, email) VALUES ('jane', 'jane@gmail.com'); 4 | 5 | INSERT INTO meetups (name, description, user_id) VALUES ('My first meetup', 'This is a description', 1); 6 | INSERT INTO meetups (name, description, user_id) VALUES ('My second meetup', 'This is a description', 1); -------------------------------------------------------------------------------- /postgres/users.go: -------------------------------------------------------------------------------- 1 | package postgres 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/go-pg/pg/v9" 7 | 8 | "github.com/equimper/meetmeup/models" 9 | ) 10 | 11 | type UsersRepo struct { 12 | DB *pg.DB 13 | } 14 | 15 | func (u *UsersRepo) GetUserByField(field, value string) (*models.User, error) { 16 | var user models.User 17 | err := u.DB.Model(&user).Where(fmt.Sprintf("%v = ?", field), value).First() 18 | return &user, err 19 | } 20 | 21 | func (u *UsersRepo) GetUserByID(id string) (*models.User, error) { 22 | return u.GetUserByField("id", id) 23 | } 24 | 25 | func (u *UsersRepo) GetUserByEmail(email string) (*models.User, error) { 26 | return u.GetUserByField("email", email) 27 | } 28 | 29 | func (u *UsersRepo) GetUserByUsername(username string) (*models.User, error) { 30 | return u.GetUserByField("username", username) 31 | } 32 | 33 | func (u *UsersRepo) CreateUser(tx *pg.Tx, user *models.User) (*models.User, error) { 34 | _, err := tx.Model(user).Returning("*").Insert() 35 | return user, err 36 | } 37 | -------------------------------------------------------------------------------- /schema.graphql: -------------------------------------------------------------------------------- 1 | scalar Time 2 | 3 | type AuthToken { 4 | accessToken: String! 5 | expiredAt: Time! 6 | } 7 | 8 | type AuthResponse { 9 | authToken: AuthToken! 10 | user: User! 11 | } 12 | 13 | type User { 14 | id: ID! 15 | username: String! 16 | email: String! 17 | firstName: String! 18 | lastName: String! 19 | meetups: [Meetup!]! 20 | createdAt: Time! 21 | updatedAt: Time! 22 | } 23 | 24 | type Meetup { 25 | id: ID! 26 | name: String! 27 | description: String! 28 | user: User! 29 | } 30 | 31 | input RegisterInput { 32 | username: String! 33 | email: String! 34 | password: String! 35 | confirmPassword: String! 36 | firstName: String! 37 | lastName: String! 38 | } 39 | 40 | input LoginInput { 41 | email: String! 42 | password: String! 43 | } 44 | 45 | input NewMeetup { 46 | name: String! 47 | description: String! 48 | } 49 | 50 | input UpdateMeetup { 51 | name: String 52 | description: String 53 | } 54 | 55 | input MeetupFilter { 56 | name: String 57 | } 58 | 59 | type Query { 60 | meetups(filter: MeetupFilter, limit: Int = 10, offset: Int = 0): [Meetup!]! 61 | user(id: ID!): User! 62 | } 63 | 64 | type Mutation { 65 | register(input: RegisterInput!): AuthResponse! 66 | login(input: LoginInput!): AuthResponse! 67 | createMeetup(input: NewMeetup!): Meetup! 68 | updateMeetup(id: ID!, input: UpdateMeetup!): Meetup! 69 | deleteMeetup(id: ID!): Boolean! 70 | } -------------------------------------------------------------------------------- /server/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | "os" 7 | 8 | "github.com/99designs/gqlgen/handler" 9 | "github.com/go-chi/chi" 10 | "github.com/go-chi/chi/middleware" 11 | "github.com/go-pg/pg/v9" 12 | "github.com/rs/cors" 13 | 14 | "github.com/equimper/meetmeup/domain" 15 | "github.com/equimper/meetmeup/graphql" 16 | customMiddleware "github.com/equimper/meetmeup/middleware" 17 | "github.com/equimper/meetmeup/postgres" 18 | ) 19 | 20 | const defaultPort = "8080" 21 | 22 | func main() { 23 | DB := postgres.New(&pg.Options{ 24 | User: "postgres", 25 | Password: "postgres", 26 | Database: "meetmeup_dev", 27 | }) 28 | 29 | defer DB.Close() 30 | 31 | DB.AddQueryHook(postgres.DBLogger{}) 32 | 33 | port := os.Getenv("PORT") 34 | if port == "" { 35 | port = defaultPort 36 | } 37 | 38 | userRepo := postgres.UsersRepo{DB: DB} 39 | 40 | router := chi.NewRouter() 41 | 42 | router.Use(cors.New(cors.Options{ 43 | AllowedOrigins: []string{"http://localhost:8000"}, 44 | AllowCredentials: true, 45 | Debug: true, 46 | }).Handler) 47 | router.Use(middleware.RequestID) 48 | router.Use(middleware.Logger) 49 | router.Use(customMiddleware.AuthMiddleware(userRepo)) 50 | 51 | d := domain.NewDomain(userRepo, postgres.MeetupsRepo{DB: DB}) 52 | 53 | c := graphql.Config{Resolvers: &graphql.Resolver{Domain: d}} 54 | 55 | queryHandler := handler.GraphQL(graphql.NewExecutableSchema(c)) 56 | 57 | router.Handle("/", handler.Playground("GraphQL playground", "/query")) 58 | router.Handle("/query", graphql.DataloaderMiddleware(DB, queryHandler)) 59 | 60 | log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) 61 | log.Fatal(http.ListenAndServe(":"+port, router)) 62 | } 63 | -------------------------------------------------------------------------------- /validator/email.go: -------------------------------------------------------------------------------- 1 | package validator 2 | 3 | import "regexp" 4 | 5 | var emailRegexp = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$") 6 | 7 | func (v *Validator) IsEmail(field, email string) bool { 8 | if _, ok := v.Errors[field]; ok { 9 | return false 10 | } 11 | 12 | if !emailRegexp.MatchString(email) { 13 | v.Errors[field] = "not a valid email" 14 | return false 15 | } 16 | 17 | return true 18 | } 19 | -------------------------------------------------------------------------------- /validator/equal_to_field.go: -------------------------------------------------------------------------------- 1 | package validator 2 | 3 | import "fmt" 4 | 5 | func (v *Validator) EqualToField(field string, value interface{}, toEqualField string, toEqualValue interface{}) bool { 6 | if _, ok := v.Errors[field]; ok { 7 | return false 8 | } 9 | 10 | if value != toEqualValue { 11 | v.Errors[field] = fmt.Sprintf("%s must equal %s", field, toEqualField) 12 | return false 13 | } 14 | 15 | return true 16 | } 17 | -------------------------------------------------------------------------------- /validator/min_length.go: -------------------------------------------------------------------------------- 1 | package validator 2 | 3 | import "fmt" 4 | 5 | func (v *Validator) MinLength(field, value string, high int) bool { 6 | if _, ok := v.Errors[field]; ok { 7 | return false 8 | } 9 | 10 | if len(value) < high { 11 | v.Errors[field] = fmt.Sprintf("%s must be at least (%d) characters long", field, high) 12 | 13 | return false 14 | } 15 | 16 | return true 17 | } 18 | -------------------------------------------------------------------------------- /validator/required.go: -------------------------------------------------------------------------------- 1 | package validator 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | func (v *Validator) Required(field string, value interface{}) bool { 9 | if _, ok := v.Errors[field]; ok { 10 | return false 11 | } 12 | 13 | if IsEmpty(value) { 14 | v.Errors[field] = fmt.Sprintf("%s is required", field) 15 | return false 16 | } 17 | 18 | return true 19 | } 20 | 21 | func IsEmpty(value interface{}) bool { 22 | t := reflect.ValueOf(value) 23 | 24 | switch t.Kind() { 25 | case reflect.String, reflect.Array, reflect.Slice, reflect.Map: 26 | return t.Len() == 0 27 | } 28 | 29 | return false 30 | } 31 | -------------------------------------------------------------------------------- /validator/validator.go: -------------------------------------------------------------------------------- 1 | package validator 2 | 3 | type Validation interface { 4 | Validate() (bool, map[string]string) 5 | } 6 | 7 | type Validator struct { 8 | Errors map[string]string 9 | } 10 | 11 | func New() *Validator { 12 | return &Validator{Errors: make(map[string]string)} 13 | } 14 | 15 | func (v *Validator) IsValid() bool { 16 | return len(v.Errors) == 0 17 | } 18 | --------------------------------------------------------------------------------