├── .gitignore ├── README.md ├── go.mod ├── go.sum ├── gqlgen.yml ├── graph ├── generated │ └── generated.go ├── model │ └── models_gen.go ├── resolver.go ├── schema.graphql ├── schema.graphqls └── schema.resolvers.go ├── internal ├── auth │ └── middleware.go ├── links │ └── links.go ├── pkg │ └── db │ │ ├── migrations │ │ └── mysql │ │ │ ├── 000001_create_users_table.down.sql │ │ │ ├── 000001_create_users_table.up.sql │ │ │ ├── 000002_create_links_table.down.sql │ │ │ └── 000002_create_links_table.up.sql │ │ └── mysql │ │ └── mysql.go └── users │ ├── errors.go │ └── users.go ├── pkg └── jwt │ └── jwt.go └── server.go /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ‌Introduction To GraphQL Server With Golang 3 | published: false 4 | description: Introduction to GraphQL Server with Golang and Gqlgen. 5 | tags: graphql, go, api, gqlgen 6 | --- 7 | ## Table Of Contents 8 | - [Table Of Contents](#table-of-contents) 9 | - [How to Run The Project](#how-to-run-project) 10 | - [Motivation ](#motivation) 11 | - [What is a GraphQL server?](#what-is-a-graphql-server) 12 | - [Schema-Driven Development](#schema-driven-development) 13 | - [Getting started ](#getting-started) 14 | - [Project Setup](#project-setup) 15 | - [Defining Our Schema](#defining-out-schema) 16 | - [Queries](#queries) 17 | - [What Is A Query](#what-is-a-query) 18 | - [Simple Query](#simple-query) 19 | - [Mutations](#mutations) 20 | - [What Is A Mutation](#what-is-a-mutation) 21 | - [A Simple Mutation](#a-simple-mutation) 22 | - [Database](#database) 23 | - [Setup MySQL](#setup-mysql) 24 | - [Models and migrations](#models-and-migrations) 25 | - [Create and Retrieve Links](#create-and-retrieve-links) 26 | - [CreateLinks](#createlinks) 27 | - [Links Query](#links-query) 28 | - [Authentication](#authentication) 29 | - [JWT](#jwt) 30 | - [Setup](#setup) 31 | - [Generating and Parsing JWT Tokens](#generating-and-parsing-jwt-tokens) 32 | - [User Signup and Login Functionality](#user-signup-and-login-functionality) 33 | - [Authentication Middleware](#authentication-middleware) 34 | - [Continue Implementing schema](#continue-implementing-schema) 35 | - [CreateUser](#createuser) 36 | - [Login](#login) 37 | - [RefreshToken](#refresh-token) 38 | - [Completing Our App](#completing-our-app) 39 | - [Summary](#summary) 40 | - [Further Steps](#further-steps) 41 | 42 | 43 | ### How to Run The Project 44 | First start mysql server with docker: 45 | ```bash 46 | docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=dbpass -e MYSQL_DATABASE=hackernews -d mysql:latest 47 | ``` 48 | Then create a Table names hackernews for our app: 49 | ```sql 50 | docker exec -it mysql bash 51 | mysql -u root -p 52 | CREATE DATABASE hackernews; 53 | ``` 54 | finally run the server: 55 | ```bash 56 | go run server/server.go 57 | ``` 58 | Now navigate to https://localhost:8080 you can see graphiql playground and query the graphql server. 59 | 60 | 61 | ### Tutorial 62 | to see the latest version of tutorial visit https://www.howtographql.com/graphql-go/0-introduction/ 63 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/glyphack/graphlq-golang 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/99designs/gqlgen v0.17.24 7 | github.com/Microsoft/go-winio v0.4.14 // indirect 8 | github.com/docker/distribution v2.7.1+incompatible // indirect 9 | github.com/docker/docker v1.13.1 // indirect 10 | github.com/docker/go-connections v0.4.0 // indirect 11 | github.com/docker/go-units v0.4.0 // indirect 12 | github.com/go-chi/chi v3.3.2+incompatible 13 | github.com/go-sql-driver/mysql v1.5.0 14 | github.com/golang-jwt/jwt/v4 v4.4.3 15 | github.com/golang-migrate/migrate v3.5.4+incompatible 16 | github.com/opencontainers/go-digest v1.0.0-rc1 // indirect 17 | github.com/pkg/errors v0.9.1 // indirect 18 | github.com/vektah/gqlparser/v2 v2.5.1 19 | golang.org/x/crypto v0.7.0 20 | ) 21 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/99designs/gqlgen v0.17.24 h1:pcd/HFIoSdRvyADYQG2dHvQN2KZqX/nXzlVm6TMMq7E= 2 | github.com/99designs/gqlgen v0.17.24/go.mod h1:BMhYIhe4bp7OlCo5I2PnowSK/Wimpv/YlxfNkqZGwLo= 3 | github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= 4 | github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU= 5 | github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= 6 | github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= 7 | github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= 8 | github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= 9 | github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= 10 | github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= 11 | github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= 12 | github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= 13 | github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= 14 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 15 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 16 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 17 | github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= 18 | github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= 19 | github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= 20 | github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= 21 | github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo= 22 | github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= 23 | github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= 24 | github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= 25 | github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= 26 | github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= 27 | github.com/go-chi/chi v3.3.2+incompatible h1:uQNcQN3NsV1j4ANsPh42P4ew4t6rnRbJb8frvpp31qQ= 28 | github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= 29 | github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= 30 | github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= 31 | github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU= 32 | github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= 33 | github.com/golang-migrate/migrate v3.5.4+incompatible h1:R7OzwvCJTCgwapPCiX6DyBiu2czIUMDCB118gFTKTUA= 34 | github.com/golang-migrate/migrate v3.5.4+incompatible/go.mod h1:IsVUlFN5puWOmXrqjgGUfIRIbU7mr8oNBE2tyERd9Wk= 35 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 36 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 37 | github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= 38 | github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 39 | github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= 40 | github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= 41 | github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM= 42 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 43 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 44 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 45 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 46 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 47 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 48 | github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc= 49 | github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk= 50 | github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= 51 | github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= 52 | github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= 53 | github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= 54 | github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= 55 | github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= 56 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 57 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 58 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 59 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 60 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 61 | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 62 | github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= 63 | github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 64 | github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= 65 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 66 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 67 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 68 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 69 | github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= 70 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 71 | github.com/urfave/cli/v2 v2.8.1/go.mod h1:Z41J9TPoffeoqP0Iza0YbAhGvymRdZAd2uPmZ5JxRdY= 72 | github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUOHcr4= 73 | github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs= 74 | github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= 75 | github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 76 | github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= 77 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 78 | golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 79 | golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b h1:Qwe1rC8PSniVfAFPFJeyUkB+zcysC3RgJBAGk7eqBEU= 80 | golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= 81 | golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= 82 | golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= 83 | golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= 84 | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= 85 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 86 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 87 | golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 88 | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 89 | golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= 90 | golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q= 91 | golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= 92 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 93 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 94 | golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 95 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 96 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 97 | golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 98 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 99 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 100 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 101 | golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 102 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 103 | golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 104 | golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 105 | golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= 106 | golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 107 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 108 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 109 | golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= 110 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 111 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 112 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 113 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 114 | golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= 115 | golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 116 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 117 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 118 | golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= 119 | golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= 120 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 121 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 122 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 123 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 124 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 125 | google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= 126 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 127 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= 128 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 129 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 130 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 131 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 132 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 133 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 134 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 135 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 136 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 137 | -------------------------------------------------------------------------------- /gqlgen.yml: -------------------------------------------------------------------------------- 1 | # Where are all the schema files located? globs are supported eg src/**/*.graphqls 2 | schema: 3 | - graph/*.graphqls 4 | 5 | # Where should the generated server code go? 6 | exec: 7 | filename: graph/generated/generated.go 8 | package: generated 9 | 10 | # Uncomment to enable federation 11 | # federation: 12 | # filename: graph/generated/federation.go 13 | # package: generated 14 | 15 | # Where should any generated models go? 16 | model: 17 | filename: graph/model/models_gen.go 18 | package: model 19 | 20 | # Where should the resolver implementations go? 21 | resolver: 22 | layout: follow-schema 23 | dir: graph 24 | package: graph 25 | 26 | # Optional: turn on use `gqlgen:"fieldName"` tags in your models 27 | # struct_tag: json 28 | 29 | # Optional: turn on to use []Thing instead of []*Thing 30 | # omit_slice_element_pointers: false 31 | 32 | # Optional: set to speed up generation time by not performing a final validation pass. 33 | # skip_validation: true 34 | 35 | # gqlgen will search for any type names in the schema in these go packages 36 | # if they match it will use them, otherwise it will generate them. 37 | autobind: 38 | - "github.com/glyphack/graphlq-golang/graph/model" 39 | 40 | # This section declares type mapping between the GraphQL and go type systems 41 | # 42 | # The first line in each type will be used as defaults for resolver arguments and 43 | # modelgen, the others will be allowed when binding to fields. Configure them to 44 | # your liking 45 | models: 46 | ID: 47 | model: 48 | - github.com/99designs/gqlgen/graphql.ID 49 | - github.com/99designs/gqlgen/graphql.Int 50 | - github.com/99designs/gqlgen/graphql.Int64 51 | - github.com/99designs/gqlgen/graphql.Int32 52 | Int: 53 | model: 54 | - github.com/99designs/gqlgen/graphql.Int 55 | - github.com/99designs/gqlgen/graphql.Int64 56 | - github.com/99designs/gqlgen/graphql.Int32 57 | -------------------------------------------------------------------------------- /graph/generated/generated.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 | 3 | package generated 4 | 5 | import ( 6 | "bytes" 7 | "context" 8 | "errors" 9 | "strconv" 10 | "sync" 11 | "sync/atomic" 12 | 13 | "github.com/99designs/gqlgen/graphql" 14 | "github.com/99designs/gqlgen/graphql/introspection" 15 | "github.com/glyphack/graphlq-golang/graph/model" 16 | gqlparser "github.com/vektah/gqlparser/v2" 17 | "github.com/vektah/gqlparser/v2/ast" 18 | ) 19 | 20 | // region ************************** generated!.gotpl ************************** 21 | 22 | // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. 23 | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { 24 | return &executableSchema{ 25 | resolvers: cfg.Resolvers, 26 | directives: cfg.Directives, 27 | complexity: cfg.Complexity, 28 | } 29 | } 30 | 31 | type Config struct { 32 | Resolvers ResolverRoot 33 | Directives DirectiveRoot 34 | Complexity ComplexityRoot 35 | } 36 | 37 | type ResolverRoot interface { 38 | Mutation() MutationResolver 39 | Query() QueryResolver 40 | } 41 | 42 | type DirectiveRoot struct { 43 | } 44 | 45 | type ComplexityRoot struct { 46 | Link struct { 47 | Address func(childComplexity int) int 48 | ID func(childComplexity int) int 49 | Title func(childComplexity int) int 50 | User func(childComplexity int) int 51 | } 52 | 53 | Mutation struct { 54 | CreateLink func(childComplexity int, input model.NewLink) int 55 | CreateUser func(childComplexity int, input model.NewUser) int 56 | Login func(childComplexity int, input model.Login) int 57 | RefreshToken func(childComplexity int, input model.RefreshTokenInput) int 58 | } 59 | 60 | Query struct { 61 | Links func(childComplexity int) int 62 | } 63 | 64 | User struct { 65 | ID func(childComplexity int) int 66 | Name func(childComplexity int) int 67 | } 68 | } 69 | 70 | type MutationResolver interface { 71 | CreateLink(ctx context.Context, input model.NewLink) (*model.Link, error) 72 | CreateUser(ctx context.Context, input model.NewUser) (string, error) 73 | Login(ctx context.Context, input model.Login) (string, error) 74 | RefreshToken(ctx context.Context, input model.RefreshTokenInput) (string, error) 75 | } 76 | type QueryResolver interface { 77 | Links(ctx context.Context) ([]*model.Link, error) 78 | } 79 | 80 | type executableSchema struct { 81 | resolvers ResolverRoot 82 | directives DirectiveRoot 83 | complexity ComplexityRoot 84 | } 85 | 86 | func (e *executableSchema) Schema() *ast.Schema { 87 | return parsedSchema 88 | } 89 | 90 | func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { 91 | ec := executionContext{nil, e} 92 | _ = ec 93 | switch typeName + "." + field { 94 | 95 | case "Link.address": 96 | if e.complexity.Link.Address == nil { 97 | break 98 | } 99 | 100 | return e.complexity.Link.Address(childComplexity), true 101 | 102 | case "Link.id": 103 | if e.complexity.Link.ID == nil { 104 | break 105 | } 106 | 107 | return e.complexity.Link.ID(childComplexity), true 108 | 109 | case "Link.title": 110 | if e.complexity.Link.Title == nil { 111 | break 112 | } 113 | 114 | return e.complexity.Link.Title(childComplexity), true 115 | 116 | case "Link.user": 117 | if e.complexity.Link.User == nil { 118 | break 119 | } 120 | 121 | return e.complexity.Link.User(childComplexity), true 122 | 123 | case "Mutation.createLink": 124 | if e.complexity.Mutation.CreateLink == nil { 125 | break 126 | } 127 | 128 | args, err := ec.field_Mutation_createLink_args(context.TODO(), rawArgs) 129 | if err != nil { 130 | return 0, false 131 | } 132 | 133 | return e.complexity.Mutation.CreateLink(childComplexity, args["input"].(model.NewLink)), true 134 | 135 | case "Mutation.createUser": 136 | if e.complexity.Mutation.CreateUser == nil { 137 | break 138 | } 139 | 140 | args, err := ec.field_Mutation_createUser_args(context.TODO(), rawArgs) 141 | if err != nil { 142 | return 0, false 143 | } 144 | 145 | return e.complexity.Mutation.CreateUser(childComplexity, args["input"].(model.NewUser)), true 146 | 147 | case "Mutation.login": 148 | if e.complexity.Mutation.Login == nil { 149 | break 150 | } 151 | 152 | args, err := ec.field_Mutation_login_args(context.TODO(), rawArgs) 153 | if err != nil { 154 | return 0, false 155 | } 156 | 157 | return e.complexity.Mutation.Login(childComplexity, args["input"].(model.Login)), true 158 | 159 | case "Mutation.refreshToken": 160 | if e.complexity.Mutation.RefreshToken == nil { 161 | break 162 | } 163 | 164 | args, err := ec.field_Mutation_refreshToken_args(context.TODO(), rawArgs) 165 | if err != nil { 166 | return 0, false 167 | } 168 | 169 | return e.complexity.Mutation.RefreshToken(childComplexity, args["input"].(model.RefreshTokenInput)), true 170 | 171 | case "Query.links": 172 | if e.complexity.Query.Links == nil { 173 | break 174 | } 175 | 176 | return e.complexity.Query.Links(childComplexity), true 177 | 178 | case "User.id": 179 | if e.complexity.User.ID == nil { 180 | break 181 | } 182 | 183 | return e.complexity.User.ID(childComplexity), true 184 | 185 | case "User.name": 186 | if e.complexity.User.Name == nil { 187 | break 188 | } 189 | 190 | return e.complexity.User.Name(childComplexity), true 191 | 192 | } 193 | return 0, false 194 | } 195 | 196 | func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { 197 | rc := graphql.GetOperationContext(ctx) 198 | ec := executionContext{rc, e} 199 | first := true 200 | 201 | switch rc.Operation.Operation { 202 | case ast.Query: 203 | return func(ctx context.Context) *graphql.Response { 204 | if !first { 205 | return nil 206 | } 207 | first = false 208 | data := ec._Query(ctx, rc.Operation.SelectionSet) 209 | var buf bytes.Buffer 210 | data.MarshalGQL(&buf) 211 | 212 | return &graphql.Response{ 213 | Data: buf.Bytes(), 214 | } 215 | } 216 | case ast.Mutation: 217 | return func(ctx context.Context) *graphql.Response { 218 | if !first { 219 | return nil 220 | } 221 | first = false 222 | data := ec._Mutation(ctx, rc.Operation.SelectionSet) 223 | var buf bytes.Buffer 224 | data.MarshalGQL(&buf) 225 | 226 | return &graphql.Response{ 227 | Data: buf.Bytes(), 228 | } 229 | } 230 | 231 | default: 232 | return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) 233 | } 234 | } 235 | 236 | type executionContext struct { 237 | *graphql.OperationContext 238 | *executableSchema 239 | } 240 | 241 | func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { 242 | if ec.DisableIntrospection { 243 | return nil, errors.New("introspection disabled") 244 | } 245 | return introspection.WrapSchema(parsedSchema), nil 246 | } 247 | 248 | func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { 249 | if ec.DisableIntrospection { 250 | return nil, errors.New("introspection disabled") 251 | } 252 | return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil 253 | } 254 | 255 | var sources = []*ast.Source{ 256 | &ast.Source{Name: "graph/schema.graphqls", Input: `type Link { 257 | id: ID! 258 | title: String! 259 | address: String! 260 | user: User! 261 | } 262 | 263 | type User { 264 | id: ID! 265 | name: String! 266 | } 267 | 268 | type Query { 269 | links: [Link!]! 270 | } 271 | 272 | input NewLink { 273 | title: String! 274 | address: String! 275 | } 276 | 277 | input RefreshTokenInput{ 278 | token: String! 279 | } 280 | 281 | input NewUser { 282 | username: String! 283 | password: String! 284 | } 285 | 286 | input Login { 287 | username: String! 288 | password: String! 289 | } 290 | 291 | type Mutation { 292 | createLink(input: NewLink!): Link! 293 | createUser(input: NewUser!): String! 294 | login(input: Login!): String! 295 | # we'll talk about this in authentication section 296 | refreshToken(input: RefreshTokenInput!): String! 297 | } 298 | `, BuiltIn: false}, 299 | } 300 | var parsedSchema = gqlparser.MustLoadSchema(sources...) 301 | 302 | // endregion ************************** generated!.gotpl ************************** 303 | 304 | // region ***************************** args.gotpl ***************************** 305 | 306 | func (ec *executionContext) field_Mutation_createLink_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 307 | var err error 308 | args := map[string]interface{}{} 309 | var arg0 model.NewLink 310 | if tmp, ok := rawArgs["input"]; ok { 311 | arg0, err = ec.unmarshalNNewLink2githubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐNewLink(ctx, tmp) 312 | if err != nil { 313 | return nil, err 314 | } 315 | } 316 | args["input"] = arg0 317 | return args, nil 318 | } 319 | 320 | func (ec *executionContext) field_Mutation_createUser_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 321 | var err error 322 | args := map[string]interface{}{} 323 | var arg0 model.NewUser 324 | if tmp, ok := rawArgs["input"]; ok { 325 | arg0, err = ec.unmarshalNNewUser2githubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐNewUser(ctx, tmp) 326 | if err != nil { 327 | return nil, err 328 | } 329 | } 330 | args["input"] = arg0 331 | return args, nil 332 | } 333 | 334 | func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 335 | var err error 336 | args := map[string]interface{}{} 337 | var arg0 model.Login 338 | if tmp, ok := rawArgs["input"]; ok { 339 | arg0, err = ec.unmarshalNLogin2githubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐLogin(ctx, tmp) 340 | if err != nil { 341 | return nil, err 342 | } 343 | } 344 | args["input"] = arg0 345 | return args, nil 346 | } 347 | 348 | func (ec *executionContext) field_Mutation_refreshToken_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 349 | var err error 350 | args := map[string]interface{}{} 351 | var arg0 model.RefreshTokenInput 352 | if tmp, ok := rawArgs["input"]; ok { 353 | arg0, err = ec.unmarshalNRefreshTokenInput2githubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐRefreshTokenInput(ctx, tmp) 354 | if err != nil { 355 | return nil, err 356 | } 357 | } 358 | args["input"] = arg0 359 | return args, nil 360 | } 361 | 362 | func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 363 | var err error 364 | args := map[string]interface{}{} 365 | var arg0 string 366 | if tmp, ok := rawArgs["name"]; ok { 367 | arg0, err = ec.unmarshalNString2string(ctx, tmp) 368 | if err != nil { 369 | return nil, err 370 | } 371 | } 372 | args["name"] = arg0 373 | return args, nil 374 | } 375 | 376 | func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 377 | var err error 378 | args := map[string]interface{}{} 379 | var arg0 bool 380 | if tmp, ok := rawArgs["includeDeprecated"]; ok { 381 | arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) 382 | if err != nil { 383 | return nil, err 384 | } 385 | } 386 | args["includeDeprecated"] = arg0 387 | return args, nil 388 | } 389 | 390 | func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 391 | var err error 392 | args := map[string]interface{}{} 393 | var arg0 bool 394 | if tmp, ok := rawArgs["includeDeprecated"]; ok { 395 | arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) 396 | if err != nil { 397 | return nil, err 398 | } 399 | } 400 | args["includeDeprecated"] = arg0 401 | return args, nil 402 | } 403 | 404 | // endregion ***************************** args.gotpl ***************************** 405 | 406 | // region ************************** directives.gotpl ************************** 407 | 408 | // endregion ************************** directives.gotpl ************************** 409 | 410 | // region **************************** field.gotpl ***************************** 411 | 412 | func (ec *executionContext) _Link_id(ctx context.Context, field graphql.CollectedField, obj *model.Link) (ret graphql.Marshaler) { 413 | defer func() { 414 | if r := recover(); r != nil { 415 | ec.Error(ctx, ec.Recover(ctx, r)) 416 | ret = graphql.Null 417 | } 418 | }() 419 | fc := &graphql.FieldContext{ 420 | Object: "Link", 421 | Field: field, 422 | Args: nil, 423 | IsMethod: false, 424 | } 425 | 426 | ctx = graphql.WithFieldContext(ctx, fc) 427 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 428 | ctx = rctx // use context from middleware stack in children 429 | return obj.ID, nil 430 | }) 431 | if err != nil { 432 | ec.Error(ctx, err) 433 | return graphql.Null 434 | } 435 | if resTmp == nil { 436 | if !graphql.HasFieldError(ctx, fc) { 437 | ec.Errorf(ctx, "must not be null") 438 | } 439 | return graphql.Null 440 | } 441 | res := resTmp.(string) 442 | fc.Result = res 443 | return ec.marshalNID2string(ctx, field.Selections, res) 444 | } 445 | 446 | func (ec *executionContext) _Link_title(ctx context.Context, field graphql.CollectedField, obj *model.Link) (ret graphql.Marshaler) { 447 | defer func() { 448 | if r := recover(); r != nil { 449 | ec.Error(ctx, ec.Recover(ctx, r)) 450 | ret = graphql.Null 451 | } 452 | }() 453 | fc := &graphql.FieldContext{ 454 | Object: "Link", 455 | Field: field, 456 | Args: nil, 457 | IsMethod: false, 458 | } 459 | 460 | ctx = graphql.WithFieldContext(ctx, fc) 461 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 462 | ctx = rctx // use context from middleware stack in children 463 | return obj.Title, nil 464 | }) 465 | if err != nil { 466 | ec.Error(ctx, err) 467 | return graphql.Null 468 | } 469 | if resTmp == nil { 470 | if !graphql.HasFieldError(ctx, fc) { 471 | ec.Errorf(ctx, "must not be null") 472 | } 473 | return graphql.Null 474 | } 475 | res := resTmp.(string) 476 | fc.Result = res 477 | return ec.marshalNString2string(ctx, field.Selections, res) 478 | } 479 | 480 | func (ec *executionContext) _Link_address(ctx context.Context, field graphql.CollectedField, obj *model.Link) (ret graphql.Marshaler) { 481 | defer func() { 482 | if r := recover(); r != nil { 483 | ec.Error(ctx, ec.Recover(ctx, r)) 484 | ret = graphql.Null 485 | } 486 | }() 487 | fc := &graphql.FieldContext{ 488 | Object: "Link", 489 | Field: field, 490 | Args: nil, 491 | IsMethod: false, 492 | } 493 | 494 | ctx = graphql.WithFieldContext(ctx, fc) 495 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 496 | ctx = rctx // use context from middleware stack in children 497 | return obj.Address, nil 498 | }) 499 | if err != nil { 500 | ec.Error(ctx, err) 501 | return graphql.Null 502 | } 503 | if resTmp == nil { 504 | if !graphql.HasFieldError(ctx, fc) { 505 | ec.Errorf(ctx, "must not be null") 506 | } 507 | return graphql.Null 508 | } 509 | res := resTmp.(string) 510 | fc.Result = res 511 | return ec.marshalNString2string(ctx, field.Selections, res) 512 | } 513 | 514 | func (ec *executionContext) _Link_user(ctx context.Context, field graphql.CollectedField, obj *model.Link) (ret graphql.Marshaler) { 515 | defer func() { 516 | if r := recover(); r != nil { 517 | ec.Error(ctx, ec.Recover(ctx, r)) 518 | ret = graphql.Null 519 | } 520 | }() 521 | fc := &graphql.FieldContext{ 522 | Object: "Link", 523 | Field: field, 524 | Args: nil, 525 | IsMethod: false, 526 | } 527 | 528 | ctx = graphql.WithFieldContext(ctx, fc) 529 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 530 | ctx = rctx // use context from middleware stack in children 531 | return obj.User, nil 532 | }) 533 | if err != nil { 534 | ec.Error(ctx, err) 535 | return graphql.Null 536 | } 537 | if resTmp == nil { 538 | if !graphql.HasFieldError(ctx, fc) { 539 | ec.Errorf(ctx, "must not be null") 540 | } 541 | return graphql.Null 542 | } 543 | res := resTmp.(*model.User) 544 | fc.Result = res 545 | return ec.marshalNUser2ᚖgithubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) 546 | } 547 | 548 | func (ec *executionContext) _Mutation_createLink(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 549 | defer func() { 550 | if r := recover(); r != nil { 551 | ec.Error(ctx, ec.Recover(ctx, r)) 552 | ret = graphql.Null 553 | } 554 | }() 555 | fc := &graphql.FieldContext{ 556 | Object: "Mutation", 557 | Field: field, 558 | Args: nil, 559 | IsMethod: true, 560 | } 561 | 562 | ctx = graphql.WithFieldContext(ctx, fc) 563 | rawArgs := field.ArgumentMap(ec.Variables) 564 | args, err := ec.field_Mutation_createLink_args(ctx, rawArgs) 565 | if err != nil { 566 | ec.Error(ctx, err) 567 | return graphql.Null 568 | } 569 | fc.Args = args 570 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 571 | ctx = rctx // use context from middleware stack in children 572 | return ec.resolvers.Mutation().CreateLink(rctx, args["input"].(model.NewLink)) 573 | }) 574 | if err != nil { 575 | ec.Error(ctx, err) 576 | return graphql.Null 577 | } 578 | if resTmp == nil { 579 | if !graphql.HasFieldError(ctx, fc) { 580 | ec.Errorf(ctx, "must not be null") 581 | } 582 | return graphql.Null 583 | } 584 | res := resTmp.(*model.Link) 585 | fc.Result = res 586 | return ec.marshalNLink2ᚖgithubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐLink(ctx, field.Selections, res) 587 | } 588 | 589 | func (ec *executionContext) _Mutation_createUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 590 | defer func() { 591 | if r := recover(); r != nil { 592 | ec.Error(ctx, ec.Recover(ctx, r)) 593 | ret = graphql.Null 594 | } 595 | }() 596 | fc := &graphql.FieldContext{ 597 | Object: "Mutation", 598 | Field: field, 599 | Args: nil, 600 | IsMethod: true, 601 | } 602 | 603 | ctx = graphql.WithFieldContext(ctx, fc) 604 | rawArgs := field.ArgumentMap(ec.Variables) 605 | args, err := ec.field_Mutation_createUser_args(ctx, rawArgs) 606 | if err != nil { 607 | ec.Error(ctx, err) 608 | return graphql.Null 609 | } 610 | fc.Args = args 611 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 612 | ctx = rctx // use context from middleware stack in children 613 | return ec.resolvers.Mutation().CreateUser(rctx, args["input"].(model.NewUser)) 614 | }) 615 | if err != nil { 616 | ec.Error(ctx, err) 617 | return graphql.Null 618 | } 619 | if resTmp == nil { 620 | if !graphql.HasFieldError(ctx, fc) { 621 | ec.Errorf(ctx, "must not be null") 622 | } 623 | return graphql.Null 624 | } 625 | res := resTmp.(string) 626 | fc.Result = res 627 | return ec.marshalNString2string(ctx, field.Selections, res) 628 | } 629 | 630 | func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 631 | defer func() { 632 | if r := recover(); r != nil { 633 | ec.Error(ctx, ec.Recover(ctx, r)) 634 | ret = graphql.Null 635 | } 636 | }() 637 | fc := &graphql.FieldContext{ 638 | Object: "Mutation", 639 | Field: field, 640 | Args: nil, 641 | IsMethod: true, 642 | } 643 | 644 | ctx = graphql.WithFieldContext(ctx, fc) 645 | rawArgs := field.ArgumentMap(ec.Variables) 646 | args, err := ec.field_Mutation_login_args(ctx, rawArgs) 647 | if err != nil { 648 | ec.Error(ctx, err) 649 | return graphql.Null 650 | } 651 | fc.Args = args 652 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 653 | ctx = rctx // use context from middleware stack in children 654 | return ec.resolvers.Mutation().Login(rctx, args["input"].(model.Login)) 655 | }) 656 | if err != nil { 657 | ec.Error(ctx, err) 658 | return graphql.Null 659 | } 660 | if resTmp == nil { 661 | if !graphql.HasFieldError(ctx, fc) { 662 | ec.Errorf(ctx, "must not be null") 663 | } 664 | return graphql.Null 665 | } 666 | res := resTmp.(string) 667 | fc.Result = res 668 | return ec.marshalNString2string(ctx, field.Selections, res) 669 | } 670 | 671 | func (ec *executionContext) _Mutation_refreshToken(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 672 | defer func() { 673 | if r := recover(); r != nil { 674 | ec.Error(ctx, ec.Recover(ctx, r)) 675 | ret = graphql.Null 676 | } 677 | }() 678 | fc := &graphql.FieldContext{ 679 | Object: "Mutation", 680 | Field: field, 681 | Args: nil, 682 | IsMethod: true, 683 | } 684 | 685 | ctx = graphql.WithFieldContext(ctx, fc) 686 | rawArgs := field.ArgumentMap(ec.Variables) 687 | args, err := ec.field_Mutation_refreshToken_args(ctx, rawArgs) 688 | if err != nil { 689 | ec.Error(ctx, err) 690 | return graphql.Null 691 | } 692 | fc.Args = args 693 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 694 | ctx = rctx // use context from middleware stack in children 695 | return ec.resolvers.Mutation().RefreshToken(rctx, args["input"].(model.RefreshTokenInput)) 696 | }) 697 | if err != nil { 698 | ec.Error(ctx, err) 699 | return graphql.Null 700 | } 701 | if resTmp == nil { 702 | if !graphql.HasFieldError(ctx, fc) { 703 | ec.Errorf(ctx, "must not be null") 704 | } 705 | return graphql.Null 706 | } 707 | res := resTmp.(string) 708 | fc.Result = res 709 | return ec.marshalNString2string(ctx, field.Selections, res) 710 | } 711 | 712 | func (ec *executionContext) _Query_links(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 713 | defer func() { 714 | if r := recover(); r != nil { 715 | ec.Error(ctx, ec.Recover(ctx, r)) 716 | ret = graphql.Null 717 | } 718 | }() 719 | fc := &graphql.FieldContext{ 720 | Object: "Query", 721 | Field: field, 722 | Args: nil, 723 | IsMethod: true, 724 | } 725 | 726 | ctx = graphql.WithFieldContext(ctx, fc) 727 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 728 | ctx = rctx // use context from middleware stack in children 729 | return ec.resolvers.Query().Links(rctx) 730 | }) 731 | if err != nil { 732 | ec.Error(ctx, err) 733 | return graphql.Null 734 | } 735 | if resTmp == nil { 736 | if !graphql.HasFieldError(ctx, fc) { 737 | ec.Errorf(ctx, "must not be null") 738 | } 739 | return graphql.Null 740 | } 741 | res := resTmp.([]*model.Link) 742 | fc.Result = res 743 | return ec.marshalNLink2ᚕᚖgithubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐLinkᚄ(ctx, field.Selections, res) 744 | } 745 | 746 | func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 747 | defer func() { 748 | if r := recover(); r != nil { 749 | ec.Error(ctx, ec.Recover(ctx, r)) 750 | ret = graphql.Null 751 | } 752 | }() 753 | fc := &graphql.FieldContext{ 754 | Object: "Query", 755 | Field: field, 756 | Args: nil, 757 | IsMethod: true, 758 | } 759 | 760 | ctx = graphql.WithFieldContext(ctx, fc) 761 | rawArgs := field.ArgumentMap(ec.Variables) 762 | args, err := ec.field_Query___type_args(ctx, rawArgs) 763 | if err != nil { 764 | ec.Error(ctx, err) 765 | return graphql.Null 766 | } 767 | fc.Args = args 768 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 769 | ctx = rctx // use context from middleware stack in children 770 | return ec.introspectType(args["name"].(string)) 771 | }) 772 | if err != nil { 773 | ec.Error(ctx, err) 774 | return graphql.Null 775 | } 776 | if resTmp == nil { 777 | return graphql.Null 778 | } 779 | res := resTmp.(*introspection.Type) 780 | fc.Result = res 781 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 782 | } 783 | 784 | func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 785 | defer func() { 786 | if r := recover(); r != nil { 787 | ec.Error(ctx, ec.Recover(ctx, r)) 788 | ret = graphql.Null 789 | } 790 | }() 791 | fc := &graphql.FieldContext{ 792 | Object: "Query", 793 | Field: field, 794 | Args: nil, 795 | IsMethod: true, 796 | } 797 | 798 | ctx = graphql.WithFieldContext(ctx, fc) 799 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 800 | ctx = rctx // use context from middleware stack in children 801 | return ec.introspectSchema() 802 | }) 803 | if err != nil { 804 | ec.Error(ctx, err) 805 | return graphql.Null 806 | } 807 | if resTmp == nil { 808 | return graphql.Null 809 | } 810 | res := resTmp.(*introspection.Schema) 811 | fc.Result = res 812 | return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) 813 | } 814 | 815 | func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { 816 | defer func() { 817 | if r := recover(); r != nil { 818 | ec.Error(ctx, ec.Recover(ctx, r)) 819 | ret = graphql.Null 820 | } 821 | }() 822 | fc := &graphql.FieldContext{ 823 | Object: "User", 824 | Field: field, 825 | Args: nil, 826 | IsMethod: false, 827 | } 828 | 829 | ctx = graphql.WithFieldContext(ctx, fc) 830 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 831 | ctx = rctx // use context from middleware stack in children 832 | return obj.ID, nil 833 | }) 834 | if err != nil { 835 | ec.Error(ctx, err) 836 | return graphql.Null 837 | } 838 | if resTmp == nil { 839 | if !graphql.HasFieldError(ctx, fc) { 840 | ec.Errorf(ctx, "must not be null") 841 | } 842 | return graphql.Null 843 | } 844 | res := resTmp.(string) 845 | fc.Result = res 846 | return ec.marshalNID2string(ctx, field.Selections, res) 847 | } 848 | 849 | func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { 850 | defer func() { 851 | if r := recover(); r != nil { 852 | ec.Error(ctx, ec.Recover(ctx, r)) 853 | ret = graphql.Null 854 | } 855 | }() 856 | fc := &graphql.FieldContext{ 857 | Object: "User", 858 | Field: field, 859 | Args: nil, 860 | IsMethod: false, 861 | } 862 | 863 | ctx = graphql.WithFieldContext(ctx, fc) 864 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 865 | ctx = rctx // use context from middleware stack in children 866 | return obj.Name, nil 867 | }) 868 | if err != nil { 869 | ec.Error(ctx, err) 870 | return graphql.Null 871 | } 872 | if resTmp == nil { 873 | if !graphql.HasFieldError(ctx, fc) { 874 | ec.Errorf(ctx, "must not be null") 875 | } 876 | return graphql.Null 877 | } 878 | res := resTmp.(string) 879 | fc.Result = res 880 | return ec.marshalNString2string(ctx, field.Selections, res) 881 | } 882 | 883 | func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 884 | defer func() { 885 | if r := recover(); r != nil { 886 | ec.Error(ctx, ec.Recover(ctx, r)) 887 | ret = graphql.Null 888 | } 889 | }() 890 | fc := &graphql.FieldContext{ 891 | Object: "__Directive", 892 | Field: field, 893 | Args: nil, 894 | IsMethod: false, 895 | } 896 | 897 | ctx = graphql.WithFieldContext(ctx, fc) 898 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 899 | ctx = rctx // use context from middleware stack in children 900 | return obj.Name, nil 901 | }) 902 | if err != nil { 903 | ec.Error(ctx, err) 904 | return graphql.Null 905 | } 906 | if resTmp == nil { 907 | if !graphql.HasFieldError(ctx, fc) { 908 | ec.Errorf(ctx, "must not be null") 909 | } 910 | return graphql.Null 911 | } 912 | res := resTmp.(string) 913 | fc.Result = res 914 | return ec.marshalNString2string(ctx, field.Selections, res) 915 | } 916 | 917 | func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 918 | defer func() { 919 | if r := recover(); r != nil { 920 | ec.Error(ctx, ec.Recover(ctx, r)) 921 | ret = graphql.Null 922 | } 923 | }() 924 | fc := &graphql.FieldContext{ 925 | Object: "__Directive", 926 | Field: field, 927 | Args: nil, 928 | IsMethod: false, 929 | } 930 | 931 | ctx = graphql.WithFieldContext(ctx, fc) 932 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 933 | ctx = rctx // use context from middleware stack in children 934 | return obj.Description, nil 935 | }) 936 | if err != nil { 937 | ec.Error(ctx, err) 938 | return graphql.Null 939 | } 940 | if resTmp == nil { 941 | return graphql.Null 942 | } 943 | res := resTmp.(string) 944 | fc.Result = res 945 | return ec.marshalOString2string(ctx, field.Selections, res) 946 | } 947 | 948 | func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 949 | defer func() { 950 | if r := recover(); r != nil { 951 | ec.Error(ctx, ec.Recover(ctx, r)) 952 | ret = graphql.Null 953 | } 954 | }() 955 | fc := &graphql.FieldContext{ 956 | Object: "__Directive", 957 | Field: field, 958 | Args: nil, 959 | IsMethod: false, 960 | } 961 | 962 | ctx = graphql.WithFieldContext(ctx, fc) 963 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 964 | ctx = rctx // use context from middleware stack in children 965 | return obj.Locations, nil 966 | }) 967 | if err != nil { 968 | ec.Error(ctx, err) 969 | return graphql.Null 970 | } 971 | if resTmp == nil { 972 | if !graphql.HasFieldError(ctx, fc) { 973 | ec.Errorf(ctx, "must not be null") 974 | } 975 | return graphql.Null 976 | } 977 | res := resTmp.([]string) 978 | fc.Result = res 979 | return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) 980 | } 981 | 982 | func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 983 | defer func() { 984 | if r := recover(); r != nil { 985 | ec.Error(ctx, ec.Recover(ctx, r)) 986 | ret = graphql.Null 987 | } 988 | }() 989 | fc := &graphql.FieldContext{ 990 | Object: "__Directive", 991 | Field: field, 992 | Args: nil, 993 | IsMethod: false, 994 | } 995 | 996 | ctx = graphql.WithFieldContext(ctx, fc) 997 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 998 | ctx = rctx // use context from middleware stack in children 999 | return obj.Args, nil 1000 | }) 1001 | if err != nil { 1002 | ec.Error(ctx, err) 1003 | return graphql.Null 1004 | } 1005 | if resTmp == nil { 1006 | if !graphql.HasFieldError(ctx, fc) { 1007 | ec.Errorf(ctx, "must not be null") 1008 | } 1009 | return graphql.Null 1010 | } 1011 | res := resTmp.([]introspection.InputValue) 1012 | fc.Result = res 1013 | return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 1014 | } 1015 | 1016 | func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1017 | defer func() { 1018 | if r := recover(); r != nil { 1019 | ec.Error(ctx, ec.Recover(ctx, r)) 1020 | ret = graphql.Null 1021 | } 1022 | }() 1023 | fc := &graphql.FieldContext{ 1024 | Object: "__EnumValue", 1025 | Field: field, 1026 | Args: nil, 1027 | IsMethod: false, 1028 | } 1029 | 1030 | ctx = graphql.WithFieldContext(ctx, fc) 1031 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1032 | ctx = rctx // use context from middleware stack in children 1033 | return obj.Name, nil 1034 | }) 1035 | if err != nil { 1036 | ec.Error(ctx, err) 1037 | return graphql.Null 1038 | } 1039 | if resTmp == nil { 1040 | if !graphql.HasFieldError(ctx, fc) { 1041 | ec.Errorf(ctx, "must not be null") 1042 | } 1043 | return graphql.Null 1044 | } 1045 | res := resTmp.(string) 1046 | fc.Result = res 1047 | return ec.marshalNString2string(ctx, field.Selections, res) 1048 | } 1049 | 1050 | func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1051 | defer func() { 1052 | if r := recover(); r != nil { 1053 | ec.Error(ctx, ec.Recover(ctx, r)) 1054 | ret = graphql.Null 1055 | } 1056 | }() 1057 | fc := &graphql.FieldContext{ 1058 | Object: "__EnumValue", 1059 | Field: field, 1060 | Args: nil, 1061 | IsMethod: false, 1062 | } 1063 | 1064 | ctx = graphql.WithFieldContext(ctx, fc) 1065 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1066 | ctx = rctx // use context from middleware stack in children 1067 | return obj.Description, nil 1068 | }) 1069 | if err != nil { 1070 | ec.Error(ctx, err) 1071 | return graphql.Null 1072 | } 1073 | if resTmp == nil { 1074 | return graphql.Null 1075 | } 1076 | res := resTmp.(string) 1077 | fc.Result = res 1078 | return ec.marshalOString2string(ctx, field.Selections, res) 1079 | } 1080 | 1081 | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1082 | defer func() { 1083 | if r := recover(); r != nil { 1084 | ec.Error(ctx, ec.Recover(ctx, r)) 1085 | ret = graphql.Null 1086 | } 1087 | }() 1088 | fc := &graphql.FieldContext{ 1089 | Object: "__EnumValue", 1090 | Field: field, 1091 | Args: nil, 1092 | IsMethod: true, 1093 | } 1094 | 1095 | ctx = graphql.WithFieldContext(ctx, fc) 1096 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1097 | ctx = rctx // use context from middleware stack in children 1098 | return obj.IsDeprecated(), nil 1099 | }) 1100 | if err != nil { 1101 | ec.Error(ctx, err) 1102 | return graphql.Null 1103 | } 1104 | if resTmp == nil { 1105 | if !graphql.HasFieldError(ctx, fc) { 1106 | ec.Errorf(ctx, "must not be null") 1107 | } 1108 | return graphql.Null 1109 | } 1110 | res := resTmp.(bool) 1111 | fc.Result = res 1112 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 1113 | } 1114 | 1115 | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1116 | defer func() { 1117 | if r := recover(); r != nil { 1118 | ec.Error(ctx, ec.Recover(ctx, r)) 1119 | ret = graphql.Null 1120 | } 1121 | }() 1122 | fc := &graphql.FieldContext{ 1123 | Object: "__EnumValue", 1124 | Field: field, 1125 | Args: nil, 1126 | IsMethod: true, 1127 | } 1128 | 1129 | ctx = graphql.WithFieldContext(ctx, fc) 1130 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1131 | ctx = rctx // use context from middleware stack in children 1132 | return obj.DeprecationReason(), nil 1133 | }) 1134 | if err != nil { 1135 | ec.Error(ctx, err) 1136 | return graphql.Null 1137 | } 1138 | if resTmp == nil { 1139 | return graphql.Null 1140 | } 1141 | res := resTmp.(*string) 1142 | fc.Result = res 1143 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1144 | } 1145 | 1146 | func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1147 | defer func() { 1148 | if r := recover(); r != nil { 1149 | ec.Error(ctx, ec.Recover(ctx, r)) 1150 | ret = graphql.Null 1151 | } 1152 | }() 1153 | fc := &graphql.FieldContext{ 1154 | Object: "__Field", 1155 | Field: field, 1156 | Args: nil, 1157 | IsMethod: false, 1158 | } 1159 | 1160 | ctx = graphql.WithFieldContext(ctx, fc) 1161 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1162 | ctx = rctx // use context from middleware stack in children 1163 | return obj.Name, nil 1164 | }) 1165 | if err != nil { 1166 | ec.Error(ctx, err) 1167 | return graphql.Null 1168 | } 1169 | if resTmp == nil { 1170 | if !graphql.HasFieldError(ctx, fc) { 1171 | ec.Errorf(ctx, "must not be null") 1172 | } 1173 | return graphql.Null 1174 | } 1175 | res := resTmp.(string) 1176 | fc.Result = res 1177 | return ec.marshalNString2string(ctx, field.Selections, res) 1178 | } 1179 | 1180 | func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1181 | defer func() { 1182 | if r := recover(); r != nil { 1183 | ec.Error(ctx, ec.Recover(ctx, r)) 1184 | ret = graphql.Null 1185 | } 1186 | }() 1187 | fc := &graphql.FieldContext{ 1188 | Object: "__Field", 1189 | Field: field, 1190 | Args: nil, 1191 | IsMethod: false, 1192 | } 1193 | 1194 | ctx = graphql.WithFieldContext(ctx, fc) 1195 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1196 | ctx = rctx // use context from middleware stack in children 1197 | return obj.Description, nil 1198 | }) 1199 | if err != nil { 1200 | ec.Error(ctx, err) 1201 | return graphql.Null 1202 | } 1203 | if resTmp == nil { 1204 | return graphql.Null 1205 | } 1206 | res := resTmp.(string) 1207 | fc.Result = res 1208 | return ec.marshalOString2string(ctx, field.Selections, res) 1209 | } 1210 | 1211 | func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1212 | defer func() { 1213 | if r := recover(); r != nil { 1214 | ec.Error(ctx, ec.Recover(ctx, r)) 1215 | ret = graphql.Null 1216 | } 1217 | }() 1218 | fc := &graphql.FieldContext{ 1219 | Object: "__Field", 1220 | Field: field, 1221 | Args: nil, 1222 | IsMethod: false, 1223 | } 1224 | 1225 | ctx = graphql.WithFieldContext(ctx, fc) 1226 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1227 | ctx = rctx // use context from middleware stack in children 1228 | return obj.Args, nil 1229 | }) 1230 | if err != nil { 1231 | ec.Error(ctx, err) 1232 | return graphql.Null 1233 | } 1234 | if resTmp == nil { 1235 | if !graphql.HasFieldError(ctx, fc) { 1236 | ec.Errorf(ctx, "must not be null") 1237 | } 1238 | return graphql.Null 1239 | } 1240 | res := resTmp.([]introspection.InputValue) 1241 | fc.Result = res 1242 | return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 1243 | } 1244 | 1245 | func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1246 | defer func() { 1247 | if r := recover(); r != nil { 1248 | ec.Error(ctx, ec.Recover(ctx, r)) 1249 | ret = graphql.Null 1250 | } 1251 | }() 1252 | fc := &graphql.FieldContext{ 1253 | Object: "__Field", 1254 | Field: field, 1255 | Args: nil, 1256 | IsMethod: false, 1257 | } 1258 | 1259 | ctx = graphql.WithFieldContext(ctx, fc) 1260 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1261 | ctx = rctx // use context from middleware stack in children 1262 | return obj.Type, nil 1263 | }) 1264 | if err != nil { 1265 | ec.Error(ctx, err) 1266 | return graphql.Null 1267 | } 1268 | if resTmp == nil { 1269 | if !graphql.HasFieldError(ctx, fc) { 1270 | ec.Errorf(ctx, "must not be null") 1271 | } 1272 | return graphql.Null 1273 | } 1274 | res := resTmp.(*introspection.Type) 1275 | fc.Result = res 1276 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1277 | } 1278 | 1279 | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1280 | defer func() { 1281 | if r := recover(); r != nil { 1282 | ec.Error(ctx, ec.Recover(ctx, r)) 1283 | ret = graphql.Null 1284 | } 1285 | }() 1286 | fc := &graphql.FieldContext{ 1287 | Object: "__Field", 1288 | Field: field, 1289 | Args: nil, 1290 | IsMethod: true, 1291 | } 1292 | 1293 | ctx = graphql.WithFieldContext(ctx, fc) 1294 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1295 | ctx = rctx // use context from middleware stack in children 1296 | return obj.IsDeprecated(), nil 1297 | }) 1298 | if err != nil { 1299 | ec.Error(ctx, err) 1300 | return graphql.Null 1301 | } 1302 | if resTmp == nil { 1303 | if !graphql.HasFieldError(ctx, fc) { 1304 | ec.Errorf(ctx, "must not be null") 1305 | } 1306 | return graphql.Null 1307 | } 1308 | res := resTmp.(bool) 1309 | fc.Result = res 1310 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 1311 | } 1312 | 1313 | func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1314 | defer func() { 1315 | if r := recover(); r != nil { 1316 | ec.Error(ctx, ec.Recover(ctx, r)) 1317 | ret = graphql.Null 1318 | } 1319 | }() 1320 | fc := &graphql.FieldContext{ 1321 | Object: "__Field", 1322 | Field: field, 1323 | Args: nil, 1324 | IsMethod: true, 1325 | } 1326 | 1327 | ctx = graphql.WithFieldContext(ctx, fc) 1328 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1329 | ctx = rctx // use context from middleware stack in children 1330 | return obj.DeprecationReason(), nil 1331 | }) 1332 | if err != nil { 1333 | ec.Error(ctx, err) 1334 | return graphql.Null 1335 | } 1336 | if resTmp == nil { 1337 | return graphql.Null 1338 | } 1339 | res := resTmp.(*string) 1340 | fc.Result = res 1341 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1342 | } 1343 | 1344 | func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 1345 | defer func() { 1346 | if r := recover(); r != nil { 1347 | ec.Error(ctx, ec.Recover(ctx, r)) 1348 | ret = graphql.Null 1349 | } 1350 | }() 1351 | fc := &graphql.FieldContext{ 1352 | Object: "__InputValue", 1353 | Field: field, 1354 | Args: nil, 1355 | IsMethod: false, 1356 | } 1357 | 1358 | ctx = graphql.WithFieldContext(ctx, fc) 1359 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1360 | ctx = rctx // use context from middleware stack in children 1361 | return obj.Name, nil 1362 | }) 1363 | if err != nil { 1364 | ec.Error(ctx, err) 1365 | return graphql.Null 1366 | } 1367 | if resTmp == nil { 1368 | if !graphql.HasFieldError(ctx, fc) { 1369 | ec.Errorf(ctx, "must not be null") 1370 | } 1371 | return graphql.Null 1372 | } 1373 | res := resTmp.(string) 1374 | fc.Result = res 1375 | return ec.marshalNString2string(ctx, field.Selections, res) 1376 | } 1377 | 1378 | func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 1379 | defer func() { 1380 | if r := recover(); r != nil { 1381 | ec.Error(ctx, ec.Recover(ctx, r)) 1382 | ret = graphql.Null 1383 | } 1384 | }() 1385 | fc := &graphql.FieldContext{ 1386 | Object: "__InputValue", 1387 | Field: field, 1388 | Args: nil, 1389 | IsMethod: false, 1390 | } 1391 | 1392 | ctx = graphql.WithFieldContext(ctx, fc) 1393 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1394 | ctx = rctx // use context from middleware stack in children 1395 | return obj.Description, nil 1396 | }) 1397 | if err != nil { 1398 | ec.Error(ctx, err) 1399 | return graphql.Null 1400 | } 1401 | if resTmp == nil { 1402 | return graphql.Null 1403 | } 1404 | res := resTmp.(string) 1405 | fc.Result = res 1406 | return ec.marshalOString2string(ctx, field.Selections, res) 1407 | } 1408 | 1409 | func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 1410 | defer func() { 1411 | if r := recover(); r != nil { 1412 | ec.Error(ctx, ec.Recover(ctx, r)) 1413 | ret = graphql.Null 1414 | } 1415 | }() 1416 | fc := &graphql.FieldContext{ 1417 | Object: "__InputValue", 1418 | Field: field, 1419 | Args: nil, 1420 | IsMethod: false, 1421 | } 1422 | 1423 | ctx = graphql.WithFieldContext(ctx, fc) 1424 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1425 | ctx = rctx // use context from middleware stack in children 1426 | return obj.Type, nil 1427 | }) 1428 | if err != nil { 1429 | ec.Error(ctx, err) 1430 | return graphql.Null 1431 | } 1432 | if resTmp == nil { 1433 | if !graphql.HasFieldError(ctx, fc) { 1434 | ec.Errorf(ctx, "must not be null") 1435 | } 1436 | return graphql.Null 1437 | } 1438 | res := resTmp.(*introspection.Type) 1439 | fc.Result = res 1440 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1441 | } 1442 | 1443 | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 1444 | defer func() { 1445 | if r := recover(); r != nil { 1446 | ec.Error(ctx, ec.Recover(ctx, r)) 1447 | ret = graphql.Null 1448 | } 1449 | }() 1450 | fc := &graphql.FieldContext{ 1451 | Object: "__InputValue", 1452 | Field: field, 1453 | Args: nil, 1454 | IsMethod: false, 1455 | } 1456 | 1457 | ctx = graphql.WithFieldContext(ctx, fc) 1458 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1459 | ctx = rctx // use context from middleware stack in children 1460 | return obj.DefaultValue, nil 1461 | }) 1462 | if err != nil { 1463 | ec.Error(ctx, err) 1464 | return graphql.Null 1465 | } 1466 | if resTmp == nil { 1467 | return graphql.Null 1468 | } 1469 | res := resTmp.(*string) 1470 | fc.Result = res 1471 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1472 | } 1473 | 1474 | func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 1475 | defer func() { 1476 | if r := recover(); r != nil { 1477 | ec.Error(ctx, ec.Recover(ctx, r)) 1478 | ret = graphql.Null 1479 | } 1480 | }() 1481 | fc := &graphql.FieldContext{ 1482 | Object: "__Schema", 1483 | Field: field, 1484 | Args: nil, 1485 | IsMethod: true, 1486 | } 1487 | 1488 | ctx = graphql.WithFieldContext(ctx, fc) 1489 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1490 | ctx = rctx // use context from middleware stack in children 1491 | return obj.Types(), nil 1492 | }) 1493 | if err != nil { 1494 | ec.Error(ctx, err) 1495 | return graphql.Null 1496 | } 1497 | if resTmp == nil { 1498 | if !graphql.HasFieldError(ctx, fc) { 1499 | ec.Errorf(ctx, "must not be null") 1500 | } 1501 | return graphql.Null 1502 | } 1503 | res := resTmp.([]introspection.Type) 1504 | fc.Result = res 1505 | return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 1506 | } 1507 | 1508 | func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 1509 | defer func() { 1510 | if r := recover(); r != nil { 1511 | ec.Error(ctx, ec.Recover(ctx, r)) 1512 | ret = graphql.Null 1513 | } 1514 | }() 1515 | fc := &graphql.FieldContext{ 1516 | Object: "__Schema", 1517 | Field: field, 1518 | Args: nil, 1519 | IsMethod: true, 1520 | } 1521 | 1522 | ctx = graphql.WithFieldContext(ctx, fc) 1523 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1524 | ctx = rctx // use context from middleware stack in children 1525 | return obj.QueryType(), nil 1526 | }) 1527 | if err != nil { 1528 | ec.Error(ctx, err) 1529 | return graphql.Null 1530 | } 1531 | if resTmp == nil { 1532 | if !graphql.HasFieldError(ctx, fc) { 1533 | ec.Errorf(ctx, "must not be null") 1534 | } 1535 | return graphql.Null 1536 | } 1537 | res := resTmp.(*introspection.Type) 1538 | fc.Result = res 1539 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1540 | } 1541 | 1542 | func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 1543 | defer func() { 1544 | if r := recover(); r != nil { 1545 | ec.Error(ctx, ec.Recover(ctx, r)) 1546 | ret = graphql.Null 1547 | } 1548 | }() 1549 | fc := &graphql.FieldContext{ 1550 | Object: "__Schema", 1551 | Field: field, 1552 | Args: nil, 1553 | IsMethod: true, 1554 | } 1555 | 1556 | ctx = graphql.WithFieldContext(ctx, fc) 1557 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1558 | ctx = rctx // use context from middleware stack in children 1559 | return obj.MutationType(), nil 1560 | }) 1561 | if err != nil { 1562 | ec.Error(ctx, err) 1563 | return graphql.Null 1564 | } 1565 | if resTmp == nil { 1566 | return graphql.Null 1567 | } 1568 | res := resTmp.(*introspection.Type) 1569 | fc.Result = res 1570 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1571 | } 1572 | 1573 | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 1574 | defer func() { 1575 | if r := recover(); r != nil { 1576 | ec.Error(ctx, ec.Recover(ctx, r)) 1577 | ret = graphql.Null 1578 | } 1579 | }() 1580 | fc := &graphql.FieldContext{ 1581 | Object: "__Schema", 1582 | Field: field, 1583 | Args: nil, 1584 | IsMethod: true, 1585 | } 1586 | 1587 | ctx = graphql.WithFieldContext(ctx, fc) 1588 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1589 | ctx = rctx // use context from middleware stack in children 1590 | return obj.SubscriptionType(), nil 1591 | }) 1592 | if err != nil { 1593 | ec.Error(ctx, err) 1594 | return graphql.Null 1595 | } 1596 | if resTmp == nil { 1597 | return graphql.Null 1598 | } 1599 | res := resTmp.(*introspection.Type) 1600 | fc.Result = res 1601 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1602 | } 1603 | 1604 | func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 1605 | defer func() { 1606 | if r := recover(); r != nil { 1607 | ec.Error(ctx, ec.Recover(ctx, r)) 1608 | ret = graphql.Null 1609 | } 1610 | }() 1611 | fc := &graphql.FieldContext{ 1612 | Object: "__Schema", 1613 | Field: field, 1614 | Args: nil, 1615 | IsMethod: true, 1616 | } 1617 | 1618 | ctx = graphql.WithFieldContext(ctx, fc) 1619 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1620 | ctx = rctx // use context from middleware stack in children 1621 | return obj.Directives(), nil 1622 | }) 1623 | if err != nil { 1624 | ec.Error(ctx, err) 1625 | return graphql.Null 1626 | } 1627 | if resTmp == nil { 1628 | if !graphql.HasFieldError(ctx, fc) { 1629 | ec.Errorf(ctx, "must not be null") 1630 | } 1631 | return graphql.Null 1632 | } 1633 | res := resTmp.([]introspection.Directive) 1634 | fc.Result = res 1635 | return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) 1636 | } 1637 | 1638 | func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1639 | defer func() { 1640 | if r := recover(); r != nil { 1641 | ec.Error(ctx, ec.Recover(ctx, r)) 1642 | ret = graphql.Null 1643 | } 1644 | }() 1645 | fc := &graphql.FieldContext{ 1646 | Object: "__Type", 1647 | Field: field, 1648 | Args: nil, 1649 | IsMethod: true, 1650 | } 1651 | 1652 | ctx = graphql.WithFieldContext(ctx, fc) 1653 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1654 | ctx = rctx // use context from middleware stack in children 1655 | return obj.Kind(), nil 1656 | }) 1657 | if err != nil { 1658 | ec.Error(ctx, err) 1659 | return graphql.Null 1660 | } 1661 | if resTmp == nil { 1662 | if !graphql.HasFieldError(ctx, fc) { 1663 | ec.Errorf(ctx, "must not be null") 1664 | } 1665 | return graphql.Null 1666 | } 1667 | res := resTmp.(string) 1668 | fc.Result = res 1669 | return ec.marshalN__TypeKind2string(ctx, field.Selections, res) 1670 | } 1671 | 1672 | func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1673 | defer func() { 1674 | if r := recover(); r != nil { 1675 | ec.Error(ctx, ec.Recover(ctx, r)) 1676 | ret = graphql.Null 1677 | } 1678 | }() 1679 | fc := &graphql.FieldContext{ 1680 | Object: "__Type", 1681 | Field: field, 1682 | Args: nil, 1683 | IsMethod: true, 1684 | } 1685 | 1686 | ctx = graphql.WithFieldContext(ctx, fc) 1687 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1688 | ctx = rctx // use context from middleware stack in children 1689 | return obj.Name(), nil 1690 | }) 1691 | if err != nil { 1692 | ec.Error(ctx, err) 1693 | return graphql.Null 1694 | } 1695 | if resTmp == nil { 1696 | return graphql.Null 1697 | } 1698 | res := resTmp.(*string) 1699 | fc.Result = res 1700 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1701 | } 1702 | 1703 | func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1704 | defer func() { 1705 | if r := recover(); r != nil { 1706 | ec.Error(ctx, ec.Recover(ctx, r)) 1707 | ret = graphql.Null 1708 | } 1709 | }() 1710 | fc := &graphql.FieldContext{ 1711 | Object: "__Type", 1712 | Field: field, 1713 | Args: nil, 1714 | IsMethod: true, 1715 | } 1716 | 1717 | ctx = graphql.WithFieldContext(ctx, fc) 1718 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1719 | ctx = rctx // use context from middleware stack in children 1720 | return obj.Description(), nil 1721 | }) 1722 | if err != nil { 1723 | ec.Error(ctx, err) 1724 | return graphql.Null 1725 | } 1726 | if resTmp == nil { 1727 | return graphql.Null 1728 | } 1729 | res := resTmp.(string) 1730 | fc.Result = res 1731 | return ec.marshalOString2string(ctx, field.Selections, res) 1732 | } 1733 | 1734 | func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1735 | defer func() { 1736 | if r := recover(); r != nil { 1737 | ec.Error(ctx, ec.Recover(ctx, r)) 1738 | ret = graphql.Null 1739 | } 1740 | }() 1741 | fc := &graphql.FieldContext{ 1742 | Object: "__Type", 1743 | Field: field, 1744 | Args: nil, 1745 | IsMethod: true, 1746 | } 1747 | 1748 | ctx = graphql.WithFieldContext(ctx, fc) 1749 | rawArgs := field.ArgumentMap(ec.Variables) 1750 | args, err := ec.field___Type_fields_args(ctx, rawArgs) 1751 | if err != nil { 1752 | ec.Error(ctx, err) 1753 | return graphql.Null 1754 | } 1755 | fc.Args = args 1756 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1757 | ctx = rctx // use context from middleware stack in children 1758 | return obj.Fields(args["includeDeprecated"].(bool)), nil 1759 | }) 1760 | if err != nil { 1761 | ec.Error(ctx, err) 1762 | return graphql.Null 1763 | } 1764 | if resTmp == nil { 1765 | return graphql.Null 1766 | } 1767 | res := resTmp.([]introspection.Field) 1768 | fc.Result = res 1769 | return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) 1770 | } 1771 | 1772 | func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1773 | defer func() { 1774 | if r := recover(); r != nil { 1775 | ec.Error(ctx, ec.Recover(ctx, r)) 1776 | ret = graphql.Null 1777 | } 1778 | }() 1779 | fc := &graphql.FieldContext{ 1780 | Object: "__Type", 1781 | Field: field, 1782 | Args: nil, 1783 | IsMethod: true, 1784 | } 1785 | 1786 | ctx = graphql.WithFieldContext(ctx, fc) 1787 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1788 | ctx = rctx // use context from middleware stack in children 1789 | return obj.Interfaces(), nil 1790 | }) 1791 | if err != nil { 1792 | ec.Error(ctx, err) 1793 | return graphql.Null 1794 | } 1795 | if resTmp == nil { 1796 | return graphql.Null 1797 | } 1798 | res := resTmp.([]introspection.Type) 1799 | fc.Result = res 1800 | return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 1801 | } 1802 | 1803 | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1804 | defer func() { 1805 | if r := recover(); r != nil { 1806 | ec.Error(ctx, ec.Recover(ctx, r)) 1807 | ret = graphql.Null 1808 | } 1809 | }() 1810 | fc := &graphql.FieldContext{ 1811 | Object: "__Type", 1812 | Field: field, 1813 | Args: nil, 1814 | IsMethod: true, 1815 | } 1816 | 1817 | ctx = graphql.WithFieldContext(ctx, fc) 1818 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1819 | ctx = rctx // use context from middleware stack in children 1820 | return obj.PossibleTypes(), nil 1821 | }) 1822 | if err != nil { 1823 | ec.Error(ctx, err) 1824 | return graphql.Null 1825 | } 1826 | if resTmp == nil { 1827 | return graphql.Null 1828 | } 1829 | res := resTmp.([]introspection.Type) 1830 | fc.Result = res 1831 | return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 1832 | } 1833 | 1834 | func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1835 | defer func() { 1836 | if r := recover(); r != nil { 1837 | ec.Error(ctx, ec.Recover(ctx, r)) 1838 | ret = graphql.Null 1839 | } 1840 | }() 1841 | fc := &graphql.FieldContext{ 1842 | Object: "__Type", 1843 | Field: field, 1844 | Args: nil, 1845 | IsMethod: true, 1846 | } 1847 | 1848 | ctx = graphql.WithFieldContext(ctx, fc) 1849 | rawArgs := field.ArgumentMap(ec.Variables) 1850 | args, err := ec.field___Type_enumValues_args(ctx, rawArgs) 1851 | if err != nil { 1852 | ec.Error(ctx, err) 1853 | return graphql.Null 1854 | } 1855 | fc.Args = args 1856 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1857 | ctx = rctx // use context from middleware stack in children 1858 | return obj.EnumValues(args["includeDeprecated"].(bool)), nil 1859 | }) 1860 | if err != nil { 1861 | ec.Error(ctx, err) 1862 | return graphql.Null 1863 | } 1864 | if resTmp == nil { 1865 | return graphql.Null 1866 | } 1867 | res := resTmp.([]introspection.EnumValue) 1868 | fc.Result = res 1869 | return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) 1870 | } 1871 | 1872 | func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1873 | defer func() { 1874 | if r := recover(); r != nil { 1875 | ec.Error(ctx, ec.Recover(ctx, r)) 1876 | ret = graphql.Null 1877 | } 1878 | }() 1879 | fc := &graphql.FieldContext{ 1880 | Object: "__Type", 1881 | Field: field, 1882 | Args: nil, 1883 | IsMethod: true, 1884 | } 1885 | 1886 | ctx = graphql.WithFieldContext(ctx, fc) 1887 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1888 | ctx = rctx // use context from middleware stack in children 1889 | return obj.InputFields(), nil 1890 | }) 1891 | if err != nil { 1892 | ec.Error(ctx, err) 1893 | return graphql.Null 1894 | } 1895 | if resTmp == nil { 1896 | return graphql.Null 1897 | } 1898 | res := resTmp.([]introspection.InputValue) 1899 | fc.Result = res 1900 | return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 1901 | } 1902 | 1903 | func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1904 | defer func() { 1905 | if r := recover(); r != nil { 1906 | ec.Error(ctx, ec.Recover(ctx, r)) 1907 | ret = graphql.Null 1908 | } 1909 | }() 1910 | fc := &graphql.FieldContext{ 1911 | Object: "__Type", 1912 | Field: field, 1913 | Args: nil, 1914 | IsMethod: true, 1915 | } 1916 | 1917 | ctx = graphql.WithFieldContext(ctx, fc) 1918 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1919 | ctx = rctx // use context from middleware stack in children 1920 | return obj.OfType(), nil 1921 | }) 1922 | if err != nil { 1923 | ec.Error(ctx, err) 1924 | return graphql.Null 1925 | } 1926 | if resTmp == nil { 1927 | return graphql.Null 1928 | } 1929 | res := resTmp.(*introspection.Type) 1930 | fc.Result = res 1931 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1932 | } 1933 | 1934 | // endregion **************************** field.gotpl ***************************** 1935 | 1936 | // region **************************** input.gotpl ***************************** 1937 | 1938 | func (ec *executionContext) unmarshalInputLogin(ctx context.Context, obj interface{}) (model.Login, error) { 1939 | var it model.Login 1940 | var asMap = obj.(map[string]interface{}) 1941 | 1942 | for k, v := range asMap { 1943 | switch k { 1944 | case "username": 1945 | var err error 1946 | it.Username, err = ec.unmarshalNString2string(ctx, v) 1947 | if err != nil { 1948 | return it, err 1949 | } 1950 | case "password": 1951 | var err error 1952 | it.Password, err = ec.unmarshalNString2string(ctx, v) 1953 | if err != nil { 1954 | return it, err 1955 | } 1956 | } 1957 | } 1958 | 1959 | return it, nil 1960 | } 1961 | 1962 | func (ec *executionContext) unmarshalInputNewLink(ctx context.Context, obj interface{}) (model.NewLink, error) { 1963 | var it model.NewLink 1964 | var asMap = obj.(map[string]interface{}) 1965 | 1966 | for k, v := range asMap { 1967 | switch k { 1968 | case "title": 1969 | var err error 1970 | it.Title, err = ec.unmarshalNString2string(ctx, v) 1971 | if err != nil { 1972 | return it, err 1973 | } 1974 | case "address": 1975 | var err error 1976 | it.Address, err = ec.unmarshalNString2string(ctx, v) 1977 | if err != nil { 1978 | return it, err 1979 | } 1980 | } 1981 | } 1982 | 1983 | return it, nil 1984 | } 1985 | 1986 | func (ec *executionContext) unmarshalInputNewUser(ctx context.Context, obj interface{}) (model.NewUser, error) { 1987 | var it model.NewUser 1988 | var asMap = obj.(map[string]interface{}) 1989 | 1990 | for k, v := range asMap { 1991 | switch k { 1992 | case "username": 1993 | var err error 1994 | it.Username, err = ec.unmarshalNString2string(ctx, v) 1995 | if err != nil { 1996 | return it, err 1997 | } 1998 | case "password": 1999 | var err error 2000 | it.Password, err = ec.unmarshalNString2string(ctx, v) 2001 | if err != nil { 2002 | return it, err 2003 | } 2004 | } 2005 | } 2006 | 2007 | return it, nil 2008 | } 2009 | 2010 | func (ec *executionContext) unmarshalInputRefreshTokenInput(ctx context.Context, obj interface{}) (model.RefreshTokenInput, error) { 2011 | var it model.RefreshTokenInput 2012 | var asMap = obj.(map[string]interface{}) 2013 | 2014 | for k, v := range asMap { 2015 | switch k { 2016 | case "token": 2017 | var err error 2018 | it.Token, err = ec.unmarshalNString2string(ctx, v) 2019 | if err != nil { 2020 | return it, err 2021 | } 2022 | } 2023 | } 2024 | 2025 | return it, nil 2026 | } 2027 | 2028 | // endregion **************************** input.gotpl ***************************** 2029 | 2030 | // region ************************** interface.gotpl *************************** 2031 | 2032 | // endregion ************************** interface.gotpl *************************** 2033 | 2034 | // region **************************** object.gotpl **************************** 2035 | 2036 | var linkImplementors = []string{"Link"} 2037 | 2038 | func (ec *executionContext) _Link(ctx context.Context, sel ast.SelectionSet, obj *model.Link) graphql.Marshaler { 2039 | fields := graphql.CollectFields(ec.OperationContext, sel, linkImplementors) 2040 | 2041 | out := graphql.NewFieldSet(fields) 2042 | var invalids uint32 2043 | for i, field := range fields { 2044 | switch field.Name { 2045 | case "__typename": 2046 | out.Values[i] = graphql.MarshalString("Link") 2047 | case "id": 2048 | out.Values[i] = ec._Link_id(ctx, field, obj) 2049 | if out.Values[i] == graphql.Null { 2050 | invalids++ 2051 | } 2052 | case "title": 2053 | out.Values[i] = ec._Link_title(ctx, field, obj) 2054 | if out.Values[i] == graphql.Null { 2055 | invalids++ 2056 | } 2057 | case "address": 2058 | out.Values[i] = ec._Link_address(ctx, field, obj) 2059 | if out.Values[i] == graphql.Null { 2060 | invalids++ 2061 | } 2062 | case "user": 2063 | out.Values[i] = ec._Link_user(ctx, field, obj) 2064 | if out.Values[i] == graphql.Null { 2065 | invalids++ 2066 | } 2067 | default: 2068 | panic("unknown field " + strconv.Quote(field.Name)) 2069 | } 2070 | } 2071 | out.Dispatch() 2072 | if invalids > 0 { 2073 | return graphql.Null 2074 | } 2075 | return out 2076 | } 2077 | 2078 | var mutationImplementors = []string{"Mutation"} 2079 | 2080 | func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { 2081 | fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) 2082 | 2083 | ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ 2084 | Object: "Mutation", 2085 | }) 2086 | 2087 | out := graphql.NewFieldSet(fields) 2088 | var invalids uint32 2089 | for i, field := range fields { 2090 | switch field.Name { 2091 | case "__typename": 2092 | out.Values[i] = graphql.MarshalString("Mutation") 2093 | case "createLink": 2094 | out.Values[i] = ec._Mutation_createLink(ctx, field) 2095 | if out.Values[i] == graphql.Null { 2096 | invalids++ 2097 | } 2098 | case "createUser": 2099 | out.Values[i] = ec._Mutation_createUser(ctx, field) 2100 | if out.Values[i] == graphql.Null { 2101 | invalids++ 2102 | } 2103 | case "login": 2104 | out.Values[i] = ec._Mutation_login(ctx, field) 2105 | if out.Values[i] == graphql.Null { 2106 | invalids++ 2107 | } 2108 | case "refreshToken": 2109 | out.Values[i] = ec._Mutation_refreshToken(ctx, field) 2110 | if out.Values[i] == graphql.Null { 2111 | invalids++ 2112 | } 2113 | default: 2114 | panic("unknown field " + strconv.Quote(field.Name)) 2115 | } 2116 | } 2117 | out.Dispatch() 2118 | if invalids > 0 { 2119 | return graphql.Null 2120 | } 2121 | return out 2122 | } 2123 | 2124 | var queryImplementors = []string{"Query"} 2125 | 2126 | func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { 2127 | fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) 2128 | 2129 | ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ 2130 | Object: "Query", 2131 | }) 2132 | 2133 | out := graphql.NewFieldSet(fields) 2134 | var invalids uint32 2135 | for i, field := range fields { 2136 | switch field.Name { 2137 | case "__typename": 2138 | out.Values[i] = graphql.MarshalString("Query") 2139 | case "links": 2140 | field := field 2141 | out.Concurrently(i, func() (res graphql.Marshaler) { 2142 | defer func() { 2143 | if r := recover(); r != nil { 2144 | ec.Error(ctx, ec.Recover(ctx, r)) 2145 | } 2146 | }() 2147 | res = ec._Query_links(ctx, field) 2148 | if res == graphql.Null { 2149 | atomic.AddUint32(&invalids, 1) 2150 | } 2151 | return res 2152 | }) 2153 | case "__type": 2154 | out.Values[i] = ec._Query___type(ctx, field) 2155 | case "__schema": 2156 | out.Values[i] = ec._Query___schema(ctx, field) 2157 | default: 2158 | panic("unknown field " + strconv.Quote(field.Name)) 2159 | } 2160 | } 2161 | out.Dispatch() 2162 | if invalids > 0 { 2163 | return graphql.Null 2164 | } 2165 | return out 2166 | } 2167 | 2168 | var userImplementors = []string{"User"} 2169 | 2170 | func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { 2171 | fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) 2172 | 2173 | out := graphql.NewFieldSet(fields) 2174 | var invalids uint32 2175 | for i, field := range fields { 2176 | switch field.Name { 2177 | case "__typename": 2178 | out.Values[i] = graphql.MarshalString("User") 2179 | case "id": 2180 | out.Values[i] = ec._User_id(ctx, field, obj) 2181 | if out.Values[i] == graphql.Null { 2182 | invalids++ 2183 | } 2184 | case "name": 2185 | out.Values[i] = ec._User_name(ctx, field, obj) 2186 | if out.Values[i] == graphql.Null { 2187 | invalids++ 2188 | } 2189 | default: 2190 | panic("unknown field " + strconv.Quote(field.Name)) 2191 | } 2192 | } 2193 | out.Dispatch() 2194 | if invalids > 0 { 2195 | return graphql.Null 2196 | } 2197 | return out 2198 | } 2199 | 2200 | var __DirectiveImplementors = []string{"__Directive"} 2201 | 2202 | func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { 2203 | fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) 2204 | 2205 | out := graphql.NewFieldSet(fields) 2206 | var invalids uint32 2207 | for i, field := range fields { 2208 | switch field.Name { 2209 | case "__typename": 2210 | out.Values[i] = graphql.MarshalString("__Directive") 2211 | case "name": 2212 | out.Values[i] = ec.___Directive_name(ctx, field, obj) 2213 | if out.Values[i] == graphql.Null { 2214 | invalids++ 2215 | } 2216 | case "description": 2217 | out.Values[i] = ec.___Directive_description(ctx, field, obj) 2218 | case "locations": 2219 | out.Values[i] = ec.___Directive_locations(ctx, field, obj) 2220 | if out.Values[i] == graphql.Null { 2221 | invalids++ 2222 | } 2223 | case "args": 2224 | out.Values[i] = ec.___Directive_args(ctx, field, obj) 2225 | if out.Values[i] == graphql.Null { 2226 | invalids++ 2227 | } 2228 | default: 2229 | panic("unknown field " + strconv.Quote(field.Name)) 2230 | } 2231 | } 2232 | out.Dispatch() 2233 | if invalids > 0 { 2234 | return graphql.Null 2235 | } 2236 | return out 2237 | } 2238 | 2239 | var __EnumValueImplementors = []string{"__EnumValue"} 2240 | 2241 | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { 2242 | fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) 2243 | 2244 | out := graphql.NewFieldSet(fields) 2245 | var invalids uint32 2246 | for i, field := range fields { 2247 | switch field.Name { 2248 | case "__typename": 2249 | out.Values[i] = graphql.MarshalString("__EnumValue") 2250 | case "name": 2251 | out.Values[i] = ec.___EnumValue_name(ctx, field, obj) 2252 | if out.Values[i] == graphql.Null { 2253 | invalids++ 2254 | } 2255 | case "description": 2256 | out.Values[i] = ec.___EnumValue_description(ctx, field, obj) 2257 | case "isDeprecated": 2258 | out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) 2259 | if out.Values[i] == graphql.Null { 2260 | invalids++ 2261 | } 2262 | case "deprecationReason": 2263 | out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) 2264 | default: 2265 | panic("unknown field " + strconv.Quote(field.Name)) 2266 | } 2267 | } 2268 | out.Dispatch() 2269 | if invalids > 0 { 2270 | return graphql.Null 2271 | } 2272 | return out 2273 | } 2274 | 2275 | var __FieldImplementors = []string{"__Field"} 2276 | 2277 | func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { 2278 | fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) 2279 | 2280 | out := graphql.NewFieldSet(fields) 2281 | var invalids uint32 2282 | for i, field := range fields { 2283 | switch field.Name { 2284 | case "__typename": 2285 | out.Values[i] = graphql.MarshalString("__Field") 2286 | case "name": 2287 | out.Values[i] = ec.___Field_name(ctx, field, obj) 2288 | if out.Values[i] == graphql.Null { 2289 | invalids++ 2290 | } 2291 | case "description": 2292 | out.Values[i] = ec.___Field_description(ctx, field, obj) 2293 | case "args": 2294 | out.Values[i] = ec.___Field_args(ctx, field, obj) 2295 | if out.Values[i] == graphql.Null { 2296 | invalids++ 2297 | } 2298 | case "type": 2299 | out.Values[i] = ec.___Field_type(ctx, field, obj) 2300 | if out.Values[i] == graphql.Null { 2301 | invalids++ 2302 | } 2303 | case "isDeprecated": 2304 | out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) 2305 | if out.Values[i] == graphql.Null { 2306 | invalids++ 2307 | } 2308 | case "deprecationReason": 2309 | out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) 2310 | default: 2311 | panic("unknown field " + strconv.Quote(field.Name)) 2312 | } 2313 | } 2314 | out.Dispatch() 2315 | if invalids > 0 { 2316 | return graphql.Null 2317 | } 2318 | return out 2319 | } 2320 | 2321 | var __InputValueImplementors = []string{"__InputValue"} 2322 | 2323 | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { 2324 | fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) 2325 | 2326 | out := graphql.NewFieldSet(fields) 2327 | var invalids uint32 2328 | for i, field := range fields { 2329 | switch field.Name { 2330 | case "__typename": 2331 | out.Values[i] = graphql.MarshalString("__InputValue") 2332 | case "name": 2333 | out.Values[i] = ec.___InputValue_name(ctx, field, obj) 2334 | if out.Values[i] == graphql.Null { 2335 | invalids++ 2336 | } 2337 | case "description": 2338 | out.Values[i] = ec.___InputValue_description(ctx, field, obj) 2339 | case "type": 2340 | out.Values[i] = ec.___InputValue_type(ctx, field, obj) 2341 | if out.Values[i] == graphql.Null { 2342 | invalids++ 2343 | } 2344 | case "defaultValue": 2345 | out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) 2346 | default: 2347 | panic("unknown field " + strconv.Quote(field.Name)) 2348 | } 2349 | } 2350 | out.Dispatch() 2351 | if invalids > 0 { 2352 | return graphql.Null 2353 | } 2354 | return out 2355 | } 2356 | 2357 | var __SchemaImplementors = []string{"__Schema"} 2358 | 2359 | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { 2360 | fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) 2361 | 2362 | out := graphql.NewFieldSet(fields) 2363 | var invalids uint32 2364 | for i, field := range fields { 2365 | switch field.Name { 2366 | case "__typename": 2367 | out.Values[i] = graphql.MarshalString("__Schema") 2368 | case "types": 2369 | out.Values[i] = ec.___Schema_types(ctx, field, obj) 2370 | if out.Values[i] == graphql.Null { 2371 | invalids++ 2372 | } 2373 | case "queryType": 2374 | out.Values[i] = ec.___Schema_queryType(ctx, field, obj) 2375 | if out.Values[i] == graphql.Null { 2376 | invalids++ 2377 | } 2378 | case "mutationType": 2379 | out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) 2380 | case "subscriptionType": 2381 | out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) 2382 | case "directives": 2383 | out.Values[i] = ec.___Schema_directives(ctx, field, obj) 2384 | if out.Values[i] == graphql.Null { 2385 | invalids++ 2386 | } 2387 | default: 2388 | panic("unknown field " + strconv.Quote(field.Name)) 2389 | } 2390 | } 2391 | out.Dispatch() 2392 | if invalids > 0 { 2393 | return graphql.Null 2394 | } 2395 | return out 2396 | } 2397 | 2398 | var __TypeImplementors = []string{"__Type"} 2399 | 2400 | func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { 2401 | fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) 2402 | 2403 | out := graphql.NewFieldSet(fields) 2404 | var invalids uint32 2405 | for i, field := range fields { 2406 | switch field.Name { 2407 | case "__typename": 2408 | out.Values[i] = graphql.MarshalString("__Type") 2409 | case "kind": 2410 | out.Values[i] = ec.___Type_kind(ctx, field, obj) 2411 | if out.Values[i] == graphql.Null { 2412 | invalids++ 2413 | } 2414 | case "name": 2415 | out.Values[i] = ec.___Type_name(ctx, field, obj) 2416 | case "description": 2417 | out.Values[i] = ec.___Type_description(ctx, field, obj) 2418 | case "fields": 2419 | out.Values[i] = ec.___Type_fields(ctx, field, obj) 2420 | case "interfaces": 2421 | out.Values[i] = ec.___Type_interfaces(ctx, field, obj) 2422 | case "possibleTypes": 2423 | out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) 2424 | case "enumValues": 2425 | out.Values[i] = ec.___Type_enumValues(ctx, field, obj) 2426 | case "inputFields": 2427 | out.Values[i] = ec.___Type_inputFields(ctx, field, obj) 2428 | case "ofType": 2429 | out.Values[i] = ec.___Type_ofType(ctx, field, obj) 2430 | default: 2431 | panic("unknown field " + strconv.Quote(field.Name)) 2432 | } 2433 | } 2434 | out.Dispatch() 2435 | if invalids > 0 { 2436 | return graphql.Null 2437 | } 2438 | return out 2439 | } 2440 | 2441 | // endregion **************************** object.gotpl **************************** 2442 | 2443 | // region ***************************** type.gotpl ***************************** 2444 | 2445 | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { 2446 | return graphql.UnmarshalBoolean(v) 2447 | } 2448 | 2449 | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { 2450 | res := graphql.MarshalBoolean(v) 2451 | if res == graphql.Null { 2452 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 2453 | ec.Errorf(ctx, "must not be null") 2454 | } 2455 | } 2456 | return res 2457 | } 2458 | 2459 | func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { 2460 | return graphql.UnmarshalID(v) 2461 | } 2462 | 2463 | func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 2464 | res := graphql.MarshalID(v) 2465 | if res == graphql.Null { 2466 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 2467 | ec.Errorf(ctx, "must not be null") 2468 | } 2469 | } 2470 | return res 2471 | } 2472 | 2473 | func (ec *executionContext) marshalNLink2githubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐLink(ctx context.Context, sel ast.SelectionSet, v model.Link) graphql.Marshaler { 2474 | return ec._Link(ctx, sel, &v) 2475 | } 2476 | 2477 | func (ec *executionContext) marshalNLink2ᚕᚖgithubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐLinkᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Link) graphql.Marshaler { 2478 | ret := make(graphql.Array, len(v)) 2479 | var wg sync.WaitGroup 2480 | isLen1 := len(v) == 1 2481 | if !isLen1 { 2482 | wg.Add(len(v)) 2483 | } 2484 | for i := range v { 2485 | i := i 2486 | fc := &graphql.FieldContext{ 2487 | Index: &i, 2488 | Result: &v[i], 2489 | } 2490 | ctx := graphql.WithFieldContext(ctx, fc) 2491 | f := func(i int) { 2492 | defer func() { 2493 | if r := recover(); r != nil { 2494 | ec.Error(ctx, ec.Recover(ctx, r)) 2495 | ret = nil 2496 | } 2497 | }() 2498 | if !isLen1 { 2499 | defer wg.Done() 2500 | } 2501 | ret[i] = ec.marshalNLink2ᚖgithubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐLink(ctx, sel, v[i]) 2502 | } 2503 | if isLen1 { 2504 | f(i) 2505 | } else { 2506 | go f(i) 2507 | } 2508 | 2509 | } 2510 | wg.Wait() 2511 | return ret 2512 | } 2513 | 2514 | func (ec *executionContext) marshalNLink2ᚖgithubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐLink(ctx context.Context, sel ast.SelectionSet, v *model.Link) graphql.Marshaler { 2515 | if v == nil { 2516 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 2517 | ec.Errorf(ctx, "must not be null") 2518 | } 2519 | return graphql.Null 2520 | } 2521 | return ec._Link(ctx, sel, v) 2522 | } 2523 | 2524 | func (ec *executionContext) unmarshalNLogin2githubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐLogin(ctx context.Context, v interface{}) (model.Login, error) { 2525 | return ec.unmarshalInputLogin(ctx, v) 2526 | } 2527 | 2528 | func (ec *executionContext) unmarshalNNewLink2githubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐNewLink(ctx context.Context, v interface{}) (model.NewLink, error) { 2529 | return ec.unmarshalInputNewLink(ctx, v) 2530 | } 2531 | 2532 | func (ec *executionContext) unmarshalNNewUser2githubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐNewUser(ctx context.Context, v interface{}) (model.NewUser, error) { 2533 | return ec.unmarshalInputNewUser(ctx, v) 2534 | } 2535 | 2536 | func (ec *executionContext) unmarshalNRefreshTokenInput2githubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐRefreshTokenInput(ctx context.Context, v interface{}) (model.RefreshTokenInput, error) { 2537 | return ec.unmarshalInputRefreshTokenInput(ctx, v) 2538 | } 2539 | 2540 | func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { 2541 | return graphql.UnmarshalString(v) 2542 | } 2543 | 2544 | func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 2545 | res := graphql.MarshalString(v) 2546 | if res == graphql.Null { 2547 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 2548 | ec.Errorf(ctx, "must not be null") 2549 | } 2550 | } 2551 | return res 2552 | } 2553 | 2554 | func (ec *executionContext) marshalNUser2githubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { 2555 | return ec._User(ctx, sel, &v) 2556 | } 2557 | 2558 | func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋglyphackᚋgraphlqᚑgolangᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { 2559 | if v == nil { 2560 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 2561 | ec.Errorf(ctx, "must not be null") 2562 | } 2563 | return graphql.Null 2564 | } 2565 | return ec._User(ctx, sel, v) 2566 | } 2567 | 2568 | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { 2569 | return ec.___Directive(ctx, sel, &v) 2570 | } 2571 | 2572 | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { 2573 | ret := make(graphql.Array, len(v)) 2574 | var wg sync.WaitGroup 2575 | isLen1 := len(v) == 1 2576 | if !isLen1 { 2577 | wg.Add(len(v)) 2578 | } 2579 | for i := range v { 2580 | i := i 2581 | fc := &graphql.FieldContext{ 2582 | Index: &i, 2583 | Result: &v[i], 2584 | } 2585 | ctx := graphql.WithFieldContext(ctx, fc) 2586 | f := func(i int) { 2587 | defer func() { 2588 | if r := recover(); r != nil { 2589 | ec.Error(ctx, ec.Recover(ctx, r)) 2590 | ret = nil 2591 | } 2592 | }() 2593 | if !isLen1 { 2594 | defer wg.Done() 2595 | } 2596 | ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) 2597 | } 2598 | if isLen1 { 2599 | f(i) 2600 | } else { 2601 | go f(i) 2602 | } 2603 | 2604 | } 2605 | wg.Wait() 2606 | return ret 2607 | } 2608 | 2609 | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { 2610 | return graphql.UnmarshalString(v) 2611 | } 2612 | 2613 | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 2614 | res := graphql.MarshalString(v) 2615 | if res == graphql.Null { 2616 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 2617 | ec.Errorf(ctx, "must not be null") 2618 | } 2619 | } 2620 | return res 2621 | } 2622 | 2623 | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { 2624 | var vSlice []interface{} 2625 | if v != nil { 2626 | if tmp1, ok := v.([]interface{}); ok { 2627 | vSlice = tmp1 2628 | } else { 2629 | vSlice = []interface{}{v} 2630 | } 2631 | } 2632 | var err error 2633 | res := make([]string, len(vSlice)) 2634 | for i := range vSlice { 2635 | res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) 2636 | if err != nil { 2637 | return nil, err 2638 | } 2639 | } 2640 | return res, nil 2641 | } 2642 | 2643 | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { 2644 | ret := make(graphql.Array, len(v)) 2645 | var wg sync.WaitGroup 2646 | isLen1 := len(v) == 1 2647 | if !isLen1 { 2648 | wg.Add(len(v)) 2649 | } 2650 | for i := range v { 2651 | i := i 2652 | fc := &graphql.FieldContext{ 2653 | Index: &i, 2654 | Result: &v[i], 2655 | } 2656 | ctx := graphql.WithFieldContext(ctx, fc) 2657 | f := func(i int) { 2658 | defer func() { 2659 | if r := recover(); r != nil { 2660 | ec.Error(ctx, ec.Recover(ctx, r)) 2661 | ret = nil 2662 | } 2663 | }() 2664 | if !isLen1 { 2665 | defer wg.Done() 2666 | } 2667 | ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) 2668 | } 2669 | if isLen1 { 2670 | f(i) 2671 | } else { 2672 | go f(i) 2673 | } 2674 | 2675 | } 2676 | wg.Wait() 2677 | return ret 2678 | } 2679 | 2680 | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { 2681 | return ec.___EnumValue(ctx, sel, &v) 2682 | } 2683 | 2684 | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { 2685 | return ec.___Field(ctx, sel, &v) 2686 | } 2687 | 2688 | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { 2689 | return ec.___InputValue(ctx, sel, &v) 2690 | } 2691 | 2692 | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { 2693 | ret := make(graphql.Array, len(v)) 2694 | var wg sync.WaitGroup 2695 | isLen1 := len(v) == 1 2696 | if !isLen1 { 2697 | wg.Add(len(v)) 2698 | } 2699 | for i := range v { 2700 | i := i 2701 | fc := &graphql.FieldContext{ 2702 | Index: &i, 2703 | Result: &v[i], 2704 | } 2705 | ctx := graphql.WithFieldContext(ctx, fc) 2706 | f := func(i int) { 2707 | defer func() { 2708 | if r := recover(); r != nil { 2709 | ec.Error(ctx, ec.Recover(ctx, r)) 2710 | ret = nil 2711 | } 2712 | }() 2713 | if !isLen1 { 2714 | defer wg.Done() 2715 | } 2716 | ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) 2717 | } 2718 | if isLen1 { 2719 | f(i) 2720 | } else { 2721 | go f(i) 2722 | } 2723 | 2724 | } 2725 | wg.Wait() 2726 | return ret 2727 | } 2728 | 2729 | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { 2730 | return ec.___Type(ctx, sel, &v) 2731 | } 2732 | 2733 | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { 2734 | ret := make(graphql.Array, len(v)) 2735 | var wg sync.WaitGroup 2736 | isLen1 := len(v) == 1 2737 | if !isLen1 { 2738 | wg.Add(len(v)) 2739 | } 2740 | for i := range v { 2741 | i := i 2742 | fc := &graphql.FieldContext{ 2743 | Index: &i, 2744 | Result: &v[i], 2745 | } 2746 | ctx := graphql.WithFieldContext(ctx, fc) 2747 | f := func(i int) { 2748 | defer func() { 2749 | if r := recover(); r != nil { 2750 | ec.Error(ctx, ec.Recover(ctx, r)) 2751 | ret = nil 2752 | } 2753 | }() 2754 | if !isLen1 { 2755 | defer wg.Done() 2756 | } 2757 | ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) 2758 | } 2759 | if isLen1 { 2760 | f(i) 2761 | } else { 2762 | go f(i) 2763 | } 2764 | 2765 | } 2766 | wg.Wait() 2767 | return ret 2768 | } 2769 | 2770 | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { 2771 | if v == nil { 2772 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 2773 | ec.Errorf(ctx, "must not be null") 2774 | } 2775 | return graphql.Null 2776 | } 2777 | return ec.___Type(ctx, sel, v) 2778 | } 2779 | 2780 | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { 2781 | return graphql.UnmarshalString(v) 2782 | } 2783 | 2784 | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 2785 | res := graphql.MarshalString(v) 2786 | if res == graphql.Null { 2787 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 2788 | ec.Errorf(ctx, "must not be null") 2789 | } 2790 | } 2791 | return res 2792 | } 2793 | 2794 | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { 2795 | return graphql.UnmarshalBoolean(v) 2796 | } 2797 | 2798 | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { 2799 | return graphql.MarshalBoolean(v) 2800 | } 2801 | 2802 | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { 2803 | if v == nil { 2804 | return nil, nil 2805 | } 2806 | res, err := ec.unmarshalOBoolean2bool(ctx, v) 2807 | return &res, err 2808 | } 2809 | 2810 | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { 2811 | if v == nil { 2812 | return graphql.Null 2813 | } 2814 | return ec.marshalOBoolean2bool(ctx, sel, *v) 2815 | } 2816 | 2817 | func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { 2818 | return graphql.UnmarshalString(v) 2819 | } 2820 | 2821 | func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 2822 | return graphql.MarshalString(v) 2823 | } 2824 | 2825 | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { 2826 | if v == nil { 2827 | return nil, nil 2828 | } 2829 | res, err := ec.unmarshalOString2string(ctx, v) 2830 | return &res, err 2831 | } 2832 | 2833 | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { 2834 | if v == nil { 2835 | return graphql.Null 2836 | } 2837 | return ec.marshalOString2string(ctx, sel, *v) 2838 | } 2839 | 2840 | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { 2841 | if v == nil { 2842 | return graphql.Null 2843 | } 2844 | ret := make(graphql.Array, len(v)) 2845 | var wg sync.WaitGroup 2846 | isLen1 := len(v) == 1 2847 | if !isLen1 { 2848 | wg.Add(len(v)) 2849 | } 2850 | for i := range v { 2851 | i := i 2852 | fc := &graphql.FieldContext{ 2853 | Index: &i, 2854 | Result: &v[i], 2855 | } 2856 | ctx := graphql.WithFieldContext(ctx, fc) 2857 | f := func(i int) { 2858 | defer func() { 2859 | if r := recover(); r != nil { 2860 | ec.Error(ctx, ec.Recover(ctx, r)) 2861 | ret = nil 2862 | } 2863 | }() 2864 | if !isLen1 { 2865 | defer wg.Done() 2866 | } 2867 | ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) 2868 | } 2869 | if isLen1 { 2870 | f(i) 2871 | } else { 2872 | go f(i) 2873 | } 2874 | 2875 | } 2876 | wg.Wait() 2877 | return ret 2878 | } 2879 | 2880 | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { 2881 | if v == nil { 2882 | return graphql.Null 2883 | } 2884 | ret := make(graphql.Array, len(v)) 2885 | var wg sync.WaitGroup 2886 | isLen1 := len(v) == 1 2887 | if !isLen1 { 2888 | wg.Add(len(v)) 2889 | } 2890 | for i := range v { 2891 | i := i 2892 | fc := &graphql.FieldContext{ 2893 | Index: &i, 2894 | Result: &v[i], 2895 | } 2896 | ctx := graphql.WithFieldContext(ctx, fc) 2897 | f := func(i int) { 2898 | defer func() { 2899 | if r := recover(); r != nil { 2900 | ec.Error(ctx, ec.Recover(ctx, r)) 2901 | ret = nil 2902 | } 2903 | }() 2904 | if !isLen1 { 2905 | defer wg.Done() 2906 | } 2907 | ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) 2908 | } 2909 | if isLen1 { 2910 | f(i) 2911 | } else { 2912 | go f(i) 2913 | } 2914 | 2915 | } 2916 | wg.Wait() 2917 | return ret 2918 | } 2919 | 2920 | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { 2921 | if v == nil { 2922 | return graphql.Null 2923 | } 2924 | ret := make(graphql.Array, len(v)) 2925 | var wg sync.WaitGroup 2926 | isLen1 := len(v) == 1 2927 | if !isLen1 { 2928 | wg.Add(len(v)) 2929 | } 2930 | for i := range v { 2931 | i := i 2932 | fc := &graphql.FieldContext{ 2933 | Index: &i, 2934 | Result: &v[i], 2935 | } 2936 | ctx := graphql.WithFieldContext(ctx, fc) 2937 | f := func(i int) { 2938 | defer func() { 2939 | if r := recover(); r != nil { 2940 | ec.Error(ctx, ec.Recover(ctx, r)) 2941 | ret = nil 2942 | } 2943 | }() 2944 | if !isLen1 { 2945 | defer wg.Done() 2946 | } 2947 | ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) 2948 | } 2949 | if isLen1 { 2950 | f(i) 2951 | } else { 2952 | go f(i) 2953 | } 2954 | 2955 | } 2956 | wg.Wait() 2957 | return ret 2958 | } 2959 | 2960 | func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { 2961 | return ec.___Schema(ctx, sel, &v) 2962 | } 2963 | 2964 | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { 2965 | if v == nil { 2966 | return graphql.Null 2967 | } 2968 | return ec.___Schema(ctx, sel, v) 2969 | } 2970 | 2971 | func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { 2972 | return ec.___Type(ctx, sel, &v) 2973 | } 2974 | 2975 | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { 2976 | if v == nil { 2977 | return graphql.Null 2978 | } 2979 | ret := make(graphql.Array, len(v)) 2980 | var wg sync.WaitGroup 2981 | isLen1 := len(v) == 1 2982 | if !isLen1 { 2983 | wg.Add(len(v)) 2984 | } 2985 | for i := range v { 2986 | i := i 2987 | fc := &graphql.FieldContext{ 2988 | Index: &i, 2989 | Result: &v[i], 2990 | } 2991 | ctx := graphql.WithFieldContext(ctx, fc) 2992 | f := func(i int) { 2993 | defer func() { 2994 | if r := recover(); r != nil { 2995 | ec.Error(ctx, ec.Recover(ctx, r)) 2996 | ret = nil 2997 | } 2998 | }() 2999 | if !isLen1 { 3000 | defer wg.Done() 3001 | } 3002 | ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) 3003 | } 3004 | if isLen1 { 3005 | f(i) 3006 | } else { 3007 | go f(i) 3008 | } 3009 | 3010 | } 3011 | wg.Wait() 3012 | return ret 3013 | } 3014 | 3015 | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { 3016 | if v == nil { 3017 | return graphql.Null 3018 | } 3019 | return ec.___Type(ctx, sel, v) 3020 | } 3021 | 3022 | // endregion ***************************** type.gotpl ***************************** 3023 | -------------------------------------------------------------------------------- /graph/model/models_gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 | 3 | package model 4 | 5 | type Link struct { 6 | ID string `json:"id"` 7 | Title string `json:"title"` 8 | Address string `json:"address"` 9 | User *User `json:"user"` 10 | } 11 | 12 | type Login struct { 13 | Username string `json:"username"` 14 | Password string `json:"password"` 15 | } 16 | 17 | type NewLink struct { 18 | Title string `json:"title"` 19 | Address string `json:"address"` 20 | } 21 | 22 | type NewUser struct { 23 | Username string `json:"username"` 24 | Password string `json:"password"` 25 | } 26 | 27 | type RefreshTokenInput struct { 28 | Token string `json:"token"` 29 | } 30 | 31 | type User struct { 32 | ID string `json:"id"` 33 | Name string `json:"name"` 34 | } 35 | -------------------------------------------------------------------------------- /graph/resolver.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | // This file will not be regenerated automatically. 4 | // 5 | // It serves as dependency injection for your app, add any dependencies you require here. 6 | 7 | type Resolver struct{} 8 | -------------------------------------------------------------------------------- /graph/schema.graphql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Glyphack/graphql-golang/3e605bf25fdb341b0747c3f3f58d73613d295473/graph/schema.graphql -------------------------------------------------------------------------------- /graph/schema.graphqls: -------------------------------------------------------------------------------- 1 | type Link { 2 | id: ID! 3 | title: String! 4 | address: String! 5 | user: User! 6 | } 7 | 8 | type User { 9 | id: ID! 10 | name: String! 11 | } 12 | 13 | type Query { 14 | links: [Link!]! 15 | } 16 | 17 | input NewLink { 18 | title: String! 19 | address: String! 20 | } 21 | 22 | input RefreshTokenInput{ 23 | token: String! 24 | } 25 | 26 | input NewUser { 27 | username: String! 28 | password: String! 29 | } 30 | 31 | input Login { 32 | username: String! 33 | password: String! 34 | } 35 | 36 | type Mutation { 37 | createLink(input: NewLink!): Link! 38 | createUser(input: NewUser!): String! 39 | login(input: Login!): String! 40 | # we'll talk about this in authentication section 41 | refreshToken(input: RefreshTokenInput!): String! 42 | } 43 | -------------------------------------------------------------------------------- /graph/schema.resolvers.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | // This file will be automatically regenerated based on the schema, any resolver implementations 4 | // will be copied through when generating and any unknown code will be moved to the end. 5 | 6 | import ( 7 | "context" 8 | "fmt" 9 | "strconv" 10 | 11 | "github.com/glyphack/graphlq-golang/graph/generated" 12 | "github.com/glyphack/graphlq-golang/graph/model" 13 | "github.com/glyphack/graphlq-golang/internal/auth" 14 | "github.com/glyphack/graphlq-golang/internal/links" 15 | "github.com/glyphack/graphlq-golang/internal/users" 16 | "github.com/glyphack/graphlq-golang/pkg/jwt" 17 | ) 18 | 19 | func (r *mutationResolver) CreateLink( 20 | ctx context.Context, 21 | input model.NewLink, 22 | ) (*model.Link, error) { 23 | user := auth.ForContext(ctx) 24 | if user == nil { 25 | return &model.Link{}, fmt.Errorf("access denied") 26 | } 27 | var link links.Link 28 | link.Title = input.Title 29 | link.Address = input.Address 30 | link.User = user 31 | linkId := link.Save() 32 | grahpqlUser := &model.User{ 33 | ID: user.ID, 34 | Name: user.Username, 35 | } 36 | return &model.Link{ 37 | ID: strconv.FormatInt(linkId, 10), 38 | Title: link.Title, 39 | Address: link.Address, 40 | User: grahpqlUser, 41 | }, nil 42 | } 43 | 44 | func (r *mutationResolver) CreateUser(ctx context.Context, input model.NewUser) (string, error) { 45 | var user users.User 46 | user.Username = input.Username 47 | user.Password = input.Password 48 | user.Create() 49 | token, err := jwt.GenerateToken(user.Username) 50 | if err != nil { 51 | return "", err 52 | } 53 | return token, nil 54 | } 55 | 56 | func (r *mutationResolver) Login(ctx context.Context, input model.Login) (string, error) { 57 | var user users.User 58 | user.Username = input.Username 59 | user.Password = input.Password 60 | correct := user.Authenticate() 61 | if !correct { 62 | // 1 63 | return "", &users.WrongUsernameOrPasswordError{} 64 | } 65 | token, err := jwt.GenerateToken(user.Username) 66 | if err != nil { 67 | return "", err 68 | } 69 | return token, nil 70 | } 71 | 72 | func (r *mutationResolver) RefreshToken( 73 | ctx context.Context, 74 | input model.RefreshTokenInput, 75 | ) (string, error) { 76 | username, err := jwt.ParseToken(input.Token) 77 | if err != nil { 78 | return "", fmt.Errorf("access denied") 79 | } 80 | token, err := jwt.GenerateToken(username) 81 | if err != nil { 82 | return "", err 83 | } 84 | return token, nil 85 | } 86 | 87 | func (r *queryResolver) Links(ctx context.Context) ([]*model.Link, error) { 88 | var resultLinks []*model.Link 89 | var dbLinks []links.Link 90 | dbLinks = links.GetAll() 91 | for _, link := range dbLinks { 92 | grahpqlUser := &model.User{ 93 | Name: link.User.Password, 94 | } 95 | resultLinks = append( 96 | resultLinks, 97 | &model.Link{ID: link.ID, Title: link.Title, Address: link.Address, User: grahpqlUser}, 98 | ) 99 | } 100 | return resultLinks, nil 101 | } 102 | 103 | // Mutation returns generated.MutationResolver implementation. 104 | func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } 105 | 106 | // Query returns generated.QueryResolver implementation. 107 | func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } 108 | 109 | type mutationResolver struct{ *Resolver } 110 | type queryResolver struct{ *Resolver } 111 | -------------------------------------------------------------------------------- /internal/auth/middleware.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "strconv" 7 | 8 | "github.com/glyphack/graphlq-golang/internal/users" 9 | "github.com/glyphack/graphlq-golang/pkg/jwt" 10 | ) 11 | 12 | var userCtxKey = &contextKey{"user"} 13 | 14 | type contextKey struct { 15 | name string 16 | } 17 | 18 | func Middleware() func(http.Handler) http.Handler { 19 | return func(next http.Handler) http.Handler { 20 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 21 | header := r.Header.Get("Authorization") 22 | 23 | // Allow unauthenticated users in 24 | if header == "" { 25 | next.ServeHTTP(w, r) 26 | return 27 | } 28 | 29 | //validate jwt token 30 | tokenStr := header 31 | username, err := jwt.ParseToken(tokenStr) 32 | if err != nil { 33 | http.Error(w, "Invalid token", http.StatusForbidden) 34 | return 35 | } 36 | 37 | // create user and check if user exists in db 38 | user := users.User{Username: username} 39 | id, err := users.GetUserIdByUsername(username) 40 | if err != nil { 41 | next.ServeHTTP(w, r) 42 | return 43 | } 44 | user.ID = strconv.Itoa(id) 45 | // put it in context 46 | ctx := context.WithValue(r.Context(), userCtxKey, &user) 47 | 48 | // and call the next with our new context 49 | r = r.WithContext(ctx) 50 | next.ServeHTTP(w, r) 51 | }) 52 | } 53 | } 54 | 55 | // ForContext finds the user from the context. REQUIRES Middleware to have run. 56 | func ForContext(ctx context.Context) *users.User { 57 | raw, _ := ctx.Value(userCtxKey).(*users.User) 58 | return raw 59 | } 60 | -------------------------------------------------------------------------------- /internal/links/links.go: -------------------------------------------------------------------------------- 1 | package links 2 | 3 | import ( 4 | "log" 5 | 6 | database "github.com/glyphack/graphlq-golang/internal/pkg/db/mysql" 7 | "github.com/glyphack/graphlq-golang/internal/users" 8 | ) 9 | 10 | // #1 11 | type Link struct { 12 | ID string 13 | Title string 14 | Address string 15 | User *users.User 16 | } 17 | 18 | //#2 19 | func (link Link) Save() int64 { 20 | //#3 21 | stmt, err := database.Db.Prepare("INSERT INTO Links(Title,Address, UserID) VALUES(?,?, ?)") 22 | if err != nil { 23 | log.Fatal(err) 24 | } 25 | //#4 26 | res, err := stmt.Exec(link.Title, link.Address, link.User.ID) 27 | if err != nil { 28 | log.Fatal(err) 29 | } 30 | //#5 31 | id, err := res.LastInsertId() 32 | if err != nil { 33 | log.Fatal("Error:", err.Error()) 34 | } 35 | log.Print("Row inserted!") 36 | return id 37 | } 38 | 39 | func GetAll() []Link { 40 | stmt, err := database.Db.Prepare( 41 | "select L.id, L.title, L.address, L.UserID, U.Username from Links L inner join Users U on L.UserID = U.ID", 42 | ) 43 | if err != nil { 44 | log.Fatal(err) 45 | } 46 | defer stmt.Close() 47 | rows, err := stmt.Query() 48 | if err != nil { 49 | log.Fatal(err) 50 | } 51 | defer rows.Close() 52 | var links []Link 53 | var username string 54 | var id string 55 | for rows.Next() { 56 | var link Link 57 | err := rows.Scan(&link.ID, &link.Title, &link.Address, &id, &username) 58 | if err != nil { 59 | log.Fatal(err) 60 | } 61 | link.User = &users.User{ 62 | ID: id, 63 | Username: username, 64 | } 65 | links = append(links, link) 66 | } 67 | if err = rows.Err(); err != nil { 68 | log.Fatal(err) 69 | } 70 | return links 71 | } 72 | -------------------------------------------------------------------------------- /internal/pkg/db/migrations/mysql/000001_create_users_table.down.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Glyphack/graphql-golang/3e605bf25fdb341b0747c3f3f58d73613d295473/internal/pkg/db/migrations/mysql/000001_create_users_table.down.sql -------------------------------------------------------------------------------- /internal/pkg/db/migrations/mysql/000001_create_users_table.up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS Users( 2 | ID INT NOT NULL UNIQUE AUTO_INCREMENT, 3 | Username VARCHAR (127) NOT NULL UNIQUE, 4 | Password VARCHAR (127) NOT NULL, 5 | PRIMARY KEY (ID) 6 | ) 7 | -------------------------------------------------------------------------------- /internal/pkg/db/migrations/mysql/000002_create_links_table.down.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Glyphack/graphql-golang/3e605bf25fdb341b0747c3f3f58d73613d295473/internal/pkg/db/migrations/mysql/000002_create_links_table.down.sql -------------------------------------------------------------------------------- /internal/pkg/db/migrations/mysql/000002_create_links_table.up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS Links( 2 | ID INT NOT NULL UNIQUE AUTO_INCREMENT, 3 | Title VARCHAR (255) , 4 | Address VARCHAR (255) , 5 | UserID INT , 6 | FOREIGN KEY (UserID) REFERENCES Users(ID) , 7 | PRIMARY KEY (ID) 8 | ) -------------------------------------------------------------------------------- /internal/pkg/db/mysql/mysql.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "database/sql" 5 | "log" 6 | 7 | _ "github.com/go-sql-driver/mysql" 8 | "github.com/golang-migrate/migrate" 9 | "github.com/golang-migrate/migrate/database/mysql" 10 | _ "github.com/golang-migrate/migrate/source/file" 11 | ) 12 | 13 | var Db *sql.DB 14 | 15 | func InitDB() { 16 | db, err := sql.Open("mysql", "root:dbpass@(172.17.0.2:3306)/hackernews") 17 | if err != nil { 18 | log.Panic(err) 19 | } 20 | 21 | if err = db.Ping(); err != nil { 22 | log.Panic(err) 23 | } 24 | Db = db 25 | } 26 | 27 | func CloseDB() error { 28 | return Db.Close() 29 | } 30 | 31 | func Migrate() { 32 | if err := Db.Ping(); err != nil { 33 | log.Fatal(err) 34 | } 35 | driver, _ := mysql.WithInstance(Db, &mysql.Config{}) 36 | m, _ := migrate.NewWithDatabaseInstance( 37 | "file://internal/pkg/db/migrations/mysql", 38 | "mysql", 39 | driver, 40 | ) 41 | if err := m.Up(); err != nil && err != migrate.ErrNoChange { 42 | log.Fatal(err) 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /internal/users/errors.go: -------------------------------------------------------------------------------- 1 | package users 2 | 3 | type WrongUsernameOrPasswordError struct{} 4 | 5 | func (m *WrongUsernameOrPasswordError) Error() string { 6 | return "wrong username or password" 7 | } 8 | -------------------------------------------------------------------------------- /internal/users/users.go: -------------------------------------------------------------------------------- 1 | package users 2 | 3 | import ( 4 | "database/sql" 5 | "log" 6 | 7 | database "github.com/glyphack/graphlq-golang/internal/pkg/db/mysql" 8 | 9 | "golang.org/x/crypto/bcrypt" 10 | ) 11 | 12 | type User struct { 13 | ID string `json:"id"` 14 | Username string `json:"name"` 15 | Password string `json:"password"` 16 | } 17 | 18 | func (user *User) Create() { 19 | statement, err := database.Db.Prepare("INSERT INTO Users(Username,Password) VALUES(?,?)") 20 | print(statement) 21 | if err != nil { 22 | log.Fatal(err) 23 | } 24 | hashedPassword, err := HashPassword(user.Password) 25 | _, err = statement.Exec(user.Username, hashedPassword) 26 | if err != nil { 27 | log.Fatal(err) 28 | } 29 | } 30 | 31 | func (user *User) Authenticate() bool { 32 | statement, err := database.Db.Prepare("select Password from Users WHERE Username = ?") 33 | if err != nil { 34 | log.Fatal(err) 35 | } 36 | row := statement.QueryRow(user.Username) 37 | 38 | var hashedPassword string 39 | err = row.Scan(&hashedPassword) 40 | if err != nil { 41 | if err == sql.ErrNoRows { 42 | return false 43 | } else { 44 | log.Fatal(err) 45 | } 46 | } 47 | 48 | return CheckPasswordHash(user.Password, hashedPassword) 49 | } 50 | 51 | // GetUserIdByUsername check if a user exists in database by given username 52 | func GetUserIdByUsername(username string) (int, error) { 53 | statement, err := database.Db.Prepare("select ID from Users WHERE Username = ?") 54 | if err != nil { 55 | log.Fatal(err) 56 | } 57 | row := statement.QueryRow(username) 58 | 59 | var Id int 60 | err = row.Scan(&Id) 61 | if err != nil { 62 | if err != sql.ErrNoRows { 63 | log.Print(err) 64 | } 65 | return 0, err 66 | } 67 | 68 | return Id, nil 69 | } 70 | 71 | // GetUserByID check if a user exists in database and return the user object. 72 | func GetUsernameById(userId string) (User, error) { 73 | statement, err := database.Db.Prepare("select Username from Users WHERE ID = ?") 74 | if err != nil { 75 | log.Fatal(err) 76 | } 77 | row := statement.QueryRow(userId) 78 | 79 | var username string 80 | err = row.Scan(&username) 81 | if err != nil { 82 | if err != sql.ErrNoRows { 83 | log.Print(err) 84 | } 85 | return User{}, err 86 | } 87 | 88 | return User{ID: userId, Username: username}, nil 89 | } 90 | 91 | // HashPassword hashes given password 92 | func HashPassword(password string) (string, error) { 93 | bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14) 94 | return string(bytes), err 95 | } 96 | 97 | // CheckPassword hash compares raw password with it's hashed values 98 | func CheckPasswordHash(password, hash string) bool { 99 | err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) 100 | return err == nil 101 | } 102 | -------------------------------------------------------------------------------- /pkg/jwt/jwt.go: -------------------------------------------------------------------------------- 1 | package jwt 2 | 3 | import ( 4 | "log" 5 | "time" 6 | 7 | "github.com/golang-jwt/jwt/v4" 8 | ) 9 | 10 | // secret key being used to sign tokens 11 | var ( 12 | SecretKey = []byte("secret") 13 | ) 14 | 15 | // data we save in each token 16 | type Claims struct { 17 | username string 18 | jwt.StandardClaims 19 | } 20 | 21 | // GenerateToken generates a jwt token and assign a username to it's claims and return it 22 | func GenerateToken(username string) (string, error) { 23 | token := jwt.New(jwt.SigningMethodHS256) 24 | /* Create a map to store our claims */ 25 | claims := token.Claims.(jwt.MapClaims) 26 | /* Set token claims */ 27 | claims["username"] = username 28 | claims["exp"] = time.Now().Add(time.Hour * 24).Unix() 29 | tokenString, err := token.SignedString(SecretKey) 30 | if err != nil { 31 | log.Fatal("Error in Generating key") 32 | return "", err 33 | } 34 | return tokenString, nil 35 | } 36 | 37 | // ParseToken parses a jwt token and returns the username it it's claims 38 | func ParseToken(tokenStr string) (string, error) { 39 | token, err := jwt.Parse(tokenStr, func(token *jwt.Token) (interface{}, error) { 40 | return SecretKey, nil 41 | }) 42 | if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid { 43 | username := claims["username"].(string) 44 | return username, nil 45 | } else { 46 | return "", err 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | "os" 7 | 8 | "github.com/glyphack/graphlq-golang/graph" 9 | "github.com/glyphack/graphlq-golang/graph/generated" 10 | "github.com/glyphack/graphlq-golang/internal/auth" 11 | _ "github.com/glyphack/graphlq-golang/internal/auth" 12 | database "github.com/glyphack/graphlq-golang/internal/pkg/db/mysql" 13 | 14 | "github.com/99designs/gqlgen/graphql/handler" 15 | "github.com/99designs/gqlgen/graphql/playground" 16 | "github.com/go-chi/chi" 17 | ) 18 | 19 | const defaultPort = "8080" 20 | 21 | func main() { 22 | port := os.Getenv("PORT") 23 | if port == "" { 24 | port = defaultPort 25 | } 26 | 27 | router := chi.NewRouter() 28 | 29 | router.Use(auth.Middleware()) 30 | 31 | database.InitDB() 32 | defer database.CloseDB() 33 | database.Migrate() 34 | server := handler.NewDefaultServer( 35 | generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}}), 36 | ) 37 | router.Handle("/", playground.Handler("GraphQL playground", "/query")) 38 | router.Handle("/query", server) 39 | 40 | log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) 41 | log.Fatal(http.ListenAndServe(":"+port, router)) 42 | } 43 | --------------------------------------------------------------------------------