├── .drone.yml ├── .gitignore ├── LICENSE ├── README.md ├── go.mod ├── go.sum ├── golang ├── fastgqlgen │ ├── fasthttp-server │ │ └── server.go │ ├── fiber-server │ │ └── server.go │ ├── generated.go │ ├── go.mod │ ├── go.sum │ ├── gqlgen.yml │ ├── resolver.go │ └── schema.graphql ├── gin-json │ └── main.go ├── gqlgen │ ├── generated.go │ ├── gin-server │ │ └── server.go │ ├── gqlgen.yml │ ├── httpd-server │ │ └── server.go │ ├── resolver.go │ ├── schema.graphql │ └── scripts │ │ └── gqlgen.go ├── graph-gophers │ └── main.go ├── graphql-go │ └── main.go ├── json.lua ├── post.lua └── thunder │ └── main.go ├── graphqlHttp_test.go ├── graphql_test.go └── schema.go /.drone.yml: -------------------------------------------------------------------------------- 1 | kind: pipeline 2 | name: testing 3 | 4 | clone: 5 | depth: 1 6 | 7 | steps: 8 | - name: testing 9 | image: golang:1.15 10 | environment: 11 | GO111MODULE: on 12 | commands: 13 | - go test -v -bench=Master -benchmem 14 | - go test -v -bench=Route -benchmem 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Bo-Yi Wu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # golang-graphql-benchmark 2 | 3 | [![Build Status](https://cloud.drone.io/api/badges/appleboy/golang-graphql-benchmark/status.svg)](https://cloud.drone.io/appleboy/golang-graphql-benchmark) 4 | 5 | benchmark of graphql framework in [go1.15](https://golang.org/doc/go1.15) version. 6 | 7 | * [graphql-go/graphql](https://github.com/graphql-go/graphql) version: v0.7.9 8 | * [playlyfe/go-graphql](https://github.com/playlyfe/go-graphql) version: v0.0.0-20191219091308-23c3f22218ef 9 | * [graph-gophers/graphql-go](https://github.com/graph-gophers/graphql-go) version: v0.0.0-20200622220639-c1d9693c95a6 10 | * [samsarahq/thunder](https://github.com/samsarahq/thunder) version: v0.5.0 11 | * [99designs/gqlgen](https://github.com/99designs/gqlgen) version: v0.13.0 12 | 13 | ## Benchmark Result (2020/09/26) 14 | 15 | Please execute the following command. 16 | 17 | ```sh 18 | git clone https://github.com/appleboy/golang-graphql-benchmark.git 19 | cd golang-graphql-benchmark 20 | go test -v -bench=Master -benchmem 21 | ``` 22 | 23 | Result: 24 | 25 | ```sh 26 | goos: linux 27 | goarch: amd64 28 | pkg: github.com/appleboy/golang-graphql-benchmark 29 | BenchmarkGoGraphQLMaster-48 12556 95348 ns/op 27433 B/op 444 allocs/op 30 | BenchmarkPlaylyfeGraphQLMaster-48 123614 10340 ns/op 2857 B/op 56 allocs/op 31 | BenchmarkGophersGraphQLMaster-48 165276 7354 ns/op 3683 B/op 38 allocs/op 32 | BenchmarkThunderGraphQLMaster-48 324900 3755 ns/op 1336 B/op 30 allocs/op 33 | ``` 34 | 35 | Testing with http framwork using [Gin](https://github.com/gin-gonic/gin) 36 | 37 | ```sh 38 | go test -v -bench=Route -benchmem 39 | ``` 40 | 41 | Result: 42 | 43 | ```sh 44 | goos: linux 45 | goarch: amd64 46 | pkg: github.com/appleboy/golang-graphql-benchmark 47 | BenchmarkGinHttpRoute-48 397496 2790 ns/op 1262 B/op 18 allocs/op 48 | BenchmarkGinGQLGenRoute-48 383760 3034 ns/op 986 B/op 13 allocs/op 49 | BenchmarkGinGoGraphQLRoute-48 29984 38296 ns/op 17489 B/op 226 allocs/op 50 | BenchmarkGinGopherGraphQLRoute-48 952279 1189 ns/op 972 B/op 6 allocs/op 51 | BenchmarkGinThunderGraphQLRoute-48 571414 1840 ns/op 1193 B/op 11 allocs/op 52 | ``` 53 | 54 | ## Benchmark from wrk benchmarking tool 55 | 56 | [wrk](https://github.com/wg/wrk) - a HTTP benchmarking tool 57 | 58 | ### [gin + graphql-go](golang/graphql-go) 59 | 60 | ```sh 61 | $ wrk -t12 -c400 -d30s --timeout 10s --script=golang/post.lua --latency http://localhost:8080/graphql 62 | Running 30s test @ http://localhost:8080/graphql 63 | 12 threads and 400 connections 64 | Thread Stats Avg Stdev Max +/- Stdev 65 | Latency 78.26ms 114.59ms 1.31s 86.37% 66 | Req/Sec 1.59k 537.11 4.15k 68.81% 67 | Latency Distribution 68 | 50% 7.68ms 69 | 75% 128.89ms 70 | 90% 221.97ms 71 | 99% 499.33ms 72 | 571048 requests in 30.05s, 81.14MB read 73 | Socket errors: connect 0, read 233, write 0, timeout 0 74 | Requests/sec: 19004.92 75 | Transfer/sec: 2.70MB 76 | ``` 77 | 78 | ### [gin + graph-gophers](golang/graph-gophers) 79 | 80 | ```sh 81 | $ wrk -t12 -c400 -d30s --timeout 10s --script=golang/post.lua --latency http://localhost:8080/graphql 82 | Running 30s test @ http://localhost:8080/graphql 83 | 12 threads and 400 connections 84 | Thread Stats Avg Stdev Max +/- Stdev 85 | Latency 10.75ms 10.75ms 214.71ms 88.06% 86 | Req/Sec 3.71k 583.50 6.30k 72.11% 87 | Latency Distribution 88 | 50% 7.21ms 89 | 75% 12.15ms 90 | 90% 23.80ms 91 | 99% 53.21ms 92 | 1331529 requests in 30.05s, 170.16MB read 93 | Socket errors: connect 0, read 236, write 0, timeout 0 94 | Requests/sec: 44308.44 95 | Transfer/sec: 5.66MB 96 | ``` 97 | 98 | ### [gin + thunder](golang/thunder) 99 | 100 | ```sh 101 | $ wrk -t12 -c400 -d30s --timeout 10s --script=golang/post.lua --latency http://localhost:8080/graphql 102 | Running 30s test @ http://localhost:8080/graphql 103 | 12 threads and 400 connections 104 | Thread Stats Avg Stdev Max +/- Stdev 105 | Latency 12.34ms 13.20ms 181.22ms 85.99% 106 | Req/Sec 3.43k 540.37 5.90k 72.64% 107 | Latency Distribution 108 | 50% 8.09ms 109 | 75% 17.52ms 110 | 90% 30.13ms 111 | 99% 58.72ms 112 | 1232462 requests in 30.06s, 224.50MB read 113 | Socket errors: connect 0, read 232, write 0, timeout 0 114 | Requests/sec: 40994.33 115 | Transfer/sec: 7.47MB 116 | ``` 117 | 118 | ### [gin + gqlgen](golang/gqlgen/gin-server) 119 | 120 | ```sh 121 | $ wrk -t12 -c400 -d30s --timeout 10s --script=golang/post.lua --latency http://localhost:8080/graphql 122 | Running 30s test @ http://localhost:8080/graphql 123 | 12 threads and 400 connections 124 | Thread Stats Avg Stdev Max +/- Stdev 125 | Latency 7.77ms 2.61ms 66.76ms 82.63% 126 | Req/Sec 4.18k 474.51 9.97k 83.78% 127 | Latency Distribution 128 | 50% 7.48ms 129 | 75% 8.47ms 130 | 90% 9.99ms 131 | 99% 18.09ms 132 | 1501098 requests in 30.07s, 191.83MB read 133 | Socket errors: connect 0, read 239, write 0, timeout 0 134 | Requests/sec: 49925.73 135 | Transfer/sec: 6.38MB 136 | ``` 137 | 138 | ### [net/http + gqlgen](golang/gqlgen/httpd-server) 139 | 140 | ```sh 141 | $ wrk -t12 -c400 -d30s --timeout 10s --latency http://localhost:8080/graphql?query={hello} 142 | Running 30s test @ http://localhost:8080/graphql?query={hello} 143 | 12 threads and 400 connections 144 | Thread Stats Avg Stdev Max +/- Stdev 145 | Latency 7.61ms 4.44ms 143.61ms 97.03% 146 | Req/Sec 4.43k 491.36 6.86k 80.94% 147 | Latency Distribution 148 | 50% 7.24ms 149 | 75% 8.04ms 150 | 90% 8.99ms 151 | 99% 18.35ms 152 | 1588061 requests in 30.05s, 216.57MB read 153 | Socket errors: connect 0, read 255, write 0, timeout 0 154 | Requests/sec: 52854.88 155 | Transfer/sec: 7.21MB 156 | ``` 157 | 158 | ### [gin + josn](golang/gin-json) 159 | 160 | ```sh 161 | $ wrk -t12 -c400 -d30s --timeout 10s --script=golang/json.lua --latency http://localhost:8080/graphql 162 | Running 30s test @ http://localhost:8080/graphql 163 | 12 threads and 400 connections 164 | Thread Stats Avg Stdev Max +/- Stdev 165 | Latency 7.05ms 1.94ms 40.57ms 81.71% 166 | Req/Sec 4.64k 415.61 7.95k 85.89% 167 | Latency Distribution 168 | 50% 6.89ms 169 | 75% 7.66ms 170 | 90% 8.79ms 171 | 99% 14.50ms 172 | 1663093 requests in 30.06s, 356.86MB read 173 | Socket errors: connect 0, read 236, write 0, timeout 0 174 | Non-2xx or 3xx responses: 1663093 175 | Requests/sec: 55334.07 176 | Transfer/sec: 11.87MB 177 | ``` 178 | 179 | ## Summary 180 | 181 | | | Requests/sec | 182 | | ----------------- | ------------ | 183 | | graphql-go | 19004.92 | 184 | | graph-gophers | 44308.44 | 185 | | thunder | 40994.33 | 186 | | gqlgen + gin | 49925.73 | 187 | | gqlgen + net/http | **52854.88** | 188 | 189 | Without graphql (only gin render json output) 190 | 191 | | | Requests/sec | 192 | | -------------------- | ------------- | 193 | | json without graphql | **55334.07** | 194 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/appleboy/golang-graphql-benchmark 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/99designs/gqlgen v0.13.0 7 | github.com/gin-gonic/gin v1.6.3 8 | github.com/graph-gophers/graphql-go v0.0.0-20200622220639-c1d9693c95a6 9 | github.com/graphql-go/graphql v0.7.9 10 | github.com/graphql-go/handler v0.2.3 11 | github.com/kylelemons/godebug v1.1.0 // indirect 12 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 13 | github.com/modern-go/reflect2 v1.0.1 // indirect 14 | github.com/playlyfe/go-graphql v0.0.0-20191219091308-23c3f22218ef 15 | github.com/samsarahq/go v0.0.0-20191220233105-8077c9fbaed5 // indirect 16 | github.com/samsarahq/thunder v0.5.0 17 | github.com/satori/go.uuid v1.2.0 // indirect 18 | github.com/smartystreets/goconvey v1.6.4 // indirect 19 | github.com/vektah/gqlparser v1.3.1 // indirect 20 | github.com/vektah/gqlparser/v2 v2.1.0 21 | ) 22 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/99designs/gqlgen v0.11.3 h1:oFSxl1DFS9X///uHV3y6CEfpcXWrDUxVblR4Xib2bs4= 2 | github.com/99designs/gqlgen v0.11.3/go.mod h1:RgX5GRRdDWNkh4pBrdzNpNPFVsdoUFY2+adM6nb1N+4= 3 | github.com/99designs/gqlgen v0.12.2 h1:aOdpsiCycFtCnAv8CAI1exnKrIDHMqtMzQoXeTziY4o= 4 | github.com/99designs/gqlgen v0.12.2/go.mod h1:7zdGo6ry9u1YBp/qlb2uxSU5Mt2jQKLcBETQiKk+Bxo= 5 | github.com/99designs/gqlgen v0.13.0 h1:haLTcUp3Vwp80xMVEg5KRNwzfUrgFdRmtBY8fuB8scA= 6 | github.com/99designs/gqlgen v0.13.0/go.mod h1:NV130r6f4tpRWuAI+zsrSdooO/eWUv+Gyyoi3rEfXIk= 7 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 8 | github.com/agnivade/levenshtein v1.0.1 h1:3oJU7J3FGFmyhn8KHjmVaZCN5hxTr7GxgRue+sxIXdQ= 9 | github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= 10 | github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0= 11 | github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= 12 | github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= 13 | github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= 14 | github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= 15 | github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= 16 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= 17 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 18 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 19 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 20 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 21 | github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c h1:TUuUh0Xgj97tLMNtWtNvI9mIV6isjEb9lBMNv+77IGM= 22 | github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= 23 | github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= 24 | github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= 25 | github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= 26 | github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= 27 | github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= 28 | github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= 29 | github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= 30 | github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= 31 | github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= 32 | github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= 33 | github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= 34 | github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= 35 | github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= 36 | github.com/gogo/protobuf v1.0.0 h1:2jyBKDKU/8v3v2xVR2PtiWQviFUyiaGk2rpfyFT8rTM= 37 | github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 38 | github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= 39 | github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 40 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 41 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= 42 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 43 | github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= 44 | github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 45 | github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= 46 | github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 47 | github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= 48 | github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 49 | github.com/graph-gophers/graphql-go v0.0.0-20200622220639-c1d9693c95a6 h1:s0NiTDKy3CsD/GX4MoCaEgDFTxVV4dqlOHn/5pSrNIk= 50 | github.com/graph-gophers/graphql-go v0.0.0-20200622220639-c1d9693c95a6/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= 51 | github.com/graphql-go/graphql v0.7.9 h1:5Va/Rt4l5g3YjwDnid3vFfn43faaQBq7rMcIZ0VnV34= 52 | github.com/graphql-go/graphql v0.7.9/go.mod h1:k6yrAYQaSP59DC5UVxbgxESlmVyojThKdORUqGDGmrI= 53 | github.com/graphql-go/handler v0.2.3 h1:CANh8WPnl5M9uA25c2GBhPqJhE53Fg0Iue/fRNla71E= 54 | github.com/graphql-go/handler v0.2.3/go.mod h1:leLF6RpV5uZMN1CdImAxuiayrYYhOk33bZciaUGaXeU= 55 | github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= 56 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 57 | github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= 58 | github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 59 | github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= 60 | github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 61 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 62 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 63 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 64 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 65 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 66 | github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= 67 | github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= 68 | github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= 69 | github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= 70 | github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= 71 | github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007 h1:reVOUXwnhsYv/8UqjvhrMOu5CNT9UapHFLbQ2JcXsmg= 72 | github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= 73 | github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 74 | github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 75 | github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= 76 | github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= 77 | github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5nrJJVjbXiDZcVhOBSzKn3o9LgRLLMRNuru8= 78 | github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 79 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 80 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 81 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 82 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 83 | github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= 84 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 85 | github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= 86 | github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg= 87 | github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 88 | github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= 89 | github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 90 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 91 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 92 | github.com/playlyfe/go-graphql v0.0.0-20191219091308-23c3f22218ef h1:/QB22oEjzLaHdr+bX7ngTO1FSMWf2ori9GmuZHba9mo= 93 | github.com/playlyfe/go-graphql v0.0.0-20191219091308-23c3f22218ef/go.mod h1:msw2CYoewf4Bi4Y+Mlj/W0JH4UhZiEXuvg0ji0lEhDo= 94 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 95 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 96 | github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= 97 | github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= 98 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 99 | github.com/samsarahq/go v0.0.0-20191220233105-8077c9fbaed5 h1:x45emkhsiiRJQxqtI1tMxxqDDHVpz30YjQhl+WTozRE= 100 | github.com/samsarahq/go v0.0.0-20191220233105-8077c9fbaed5/go.mod h1:J7RmrHmcZ0rfq31ocAbPajAg/xxWSXOXy1ruhdpDL5Y= 101 | github.com/samsarahq/thunder v0.5.0 h1:HS+YU83Jy8ETc23C3SXgn06gyp38qCVYzypKuqyq6Ns= 102 | github.com/samsarahq/thunder v0.5.0/go.mod h1:06tNhg8V+ML+yOMLvGPOJkV2G7mo8BTq41OqP53jogI= 103 | github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= 104 | github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= 105 | github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= 106 | github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= 107 | github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 108 | github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= 109 | github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= 110 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 111 | github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= 112 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= 113 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 114 | github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= 115 | github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= 116 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 117 | github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 118 | github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= 119 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 120 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 121 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 122 | github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= 123 | github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= 124 | github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= 125 | github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= 126 | github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k= 127 | github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= 128 | github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e h1:+w0Zm/9gaWpEAyDlU1eKOuk5twTjAjuevXqcJJw8hrg= 129 | github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= 130 | github.com/vektah/gqlparser v1.3.1 h1:8b0IcD3qZKWJQHSzynbDlrtP3IxVydZ2DZepCGofqfU= 131 | github.com/vektah/gqlparser v1.3.1/go.mod h1:bkVf0FX+Stjg/MHnm8mEyubuaArhNEqfQhF+OTiAL74= 132 | github.com/vektah/gqlparser/v2 v2.0.1 h1:xgl5abVnsd4hkN9rk65OJID9bfcLSMuTaTcZj777q1o= 133 | github.com/vektah/gqlparser/v2 v2.0.1/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= 134 | github.com/vektah/gqlparser/v2 v2.1.0 h1:uiKJ+T5HMGGQM2kRKQ8Pxw8+Zq9qhhZhz/lieYvCMns= 135 | github.com/vektah/gqlparser/v2 v2.1.0/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= 136 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 137 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 138 | golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 139 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 140 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 141 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= 142 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 143 | golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= 144 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 145 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 146 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= 147 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 148 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 149 | golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= 150 | golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 151 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 152 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 153 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 154 | golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 155 | golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 156 | golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd h1:oMEQDWVXVNpceQoVd1JN3CQ7LYJJzs5qWqZIUcxXHHw= 157 | golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 158 | golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589 h1:rjUrONFu4kLchcZTfp3/96bR8bW8dIa8uz3cR5n0cgM= 159 | golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 160 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 161 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 162 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= 163 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 164 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 165 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 166 | gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= 167 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 168 | gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= 169 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 170 | sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= 171 | sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= 172 | -------------------------------------------------------------------------------- /golang/fastgqlgen/fasthttp-server/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | fastgqlgn "golang-graphql-benchmark/fastgqlgn" 7 | 8 | "github.com/99designs/gqlgen/graphql/handler" 9 | "github.com/valyala/fasthttp" 10 | ) 11 | 12 | func main() { 13 | srv := handler.NewDefaultServer(fastgqlgn.NewExecutableSchema(fastgqlgn.Config{Resolvers: &fastgqlgn.Resolver{}})) 14 | gqlHandler := srv.Handler() 15 | 16 | h := func(ctx *fasthttp.RequestCtx) { 17 | switch string(ctx.Path()) { 18 | case "/graphql": 19 | gqlHandler(ctx) 20 | default: 21 | ctx.Error("not found", fasthttp.StatusNotFound) 22 | } 23 | } 24 | 25 | log.Fatal(fasthttp.ListenAndServe(":8080", h)) 26 | } 27 | -------------------------------------------------------------------------------- /golang/fastgqlgen/fiber-server/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | fastgqlgn "golang-graphql-benchmark/fastgqlgn" 6 | "log" 7 | 8 | "github.com/99designs/gqlgen/graphql/handler" 9 | fiber "github.com/gofiber/fiber/v2" 10 | ) 11 | 12 | func main() { 13 | prefork := flag.Bool("prefork", false, "enable prefork") 14 | flag.Parse() 15 | 16 | app := fiber.New(fiber.Config{ 17 | Prefork: *prefork, 18 | }) 19 | 20 | srv := handler.NewDefaultServer(fastgqlgn.NewExecutableSchema(fastgqlgn.Config{Resolvers: &fastgqlgn.Resolver{}})) 21 | gqlHandler := srv.Handler() 22 | 23 | app.All("/graphql", func(c *fiber.Ctx) error { 24 | gqlHandler(c.Context()) 25 | return nil 26 | }) 27 | 28 | log.Fatal(app.Listen(":8080")) 29 | } 30 | -------------------------------------------------------------------------------- /golang/fastgqlgen/generated.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 | 3 | package fastgqlgen 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 | gqlparser "github.com/vektah/gqlparser/v2" 16 | "github.com/vektah/gqlparser/v2/ast" 17 | ) 18 | 19 | // region ************************** generated!.gotpl ************************** 20 | 21 | // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. 22 | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { 23 | return &executableSchema{ 24 | resolvers: cfg.Resolvers, 25 | directives: cfg.Directives, 26 | complexity: cfg.Complexity, 27 | } 28 | } 29 | 30 | type Config struct { 31 | Resolvers ResolverRoot 32 | Directives DirectiveRoot 33 | Complexity ComplexityRoot 34 | } 35 | 36 | type ResolverRoot interface { 37 | Query() QueryResolver 38 | } 39 | 40 | type DirectiveRoot struct { 41 | } 42 | 43 | type ComplexityRoot struct { 44 | Query struct { 45 | Hello func(childComplexity int) int 46 | } 47 | } 48 | 49 | type QueryResolver interface { 50 | Hello(ctx context.Context) (string, error) 51 | } 52 | 53 | type executableSchema struct { 54 | resolvers ResolverRoot 55 | directives DirectiveRoot 56 | complexity ComplexityRoot 57 | } 58 | 59 | func (e *executableSchema) Schema() *ast.Schema { 60 | return parsedSchema 61 | } 62 | 63 | func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { 64 | ec := executionContext{nil, e} 65 | _ = ec 66 | switch typeName + "." + field { 67 | 68 | case "Query.hello": 69 | if e.complexity.Query.Hello == nil { 70 | break 71 | } 72 | 73 | return e.complexity.Query.Hello(childComplexity), true 74 | 75 | } 76 | return 0, false 77 | } 78 | 79 | func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { 80 | rc := graphql.GetOperationContext(ctx) 81 | ec := executionContext{rc, e} 82 | first := true 83 | 84 | switch rc.Operation.Operation { 85 | case ast.Query: 86 | return func(ctx context.Context) *graphql.Response { 87 | if !first { 88 | return nil 89 | } 90 | first = false 91 | data := ec._Query(ctx, rc.Operation.SelectionSet) 92 | var buf bytes.Buffer 93 | data.MarshalGQL(&buf) 94 | 95 | return &graphql.Response{ 96 | Data: buf.Bytes(), 97 | } 98 | } 99 | 100 | default: 101 | return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) 102 | } 103 | } 104 | 105 | type executionContext struct { 106 | *graphql.OperationContext 107 | *executableSchema 108 | } 109 | 110 | func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { 111 | if ec.DisableIntrospection { 112 | return nil, errors.New("introspection disabled") 113 | } 114 | return introspection.WrapSchema(parsedSchema), nil 115 | } 116 | 117 | func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { 118 | if ec.DisableIntrospection { 119 | return nil, errors.New("introspection disabled") 120 | } 121 | return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil 122 | } 123 | 124 | var sources = []*ast.Source{ 125 | {Name: "schema.graphql", Input: `type Query { 126 | hello: String! 127 | } 128 | `, BuiltIn: false}, 129 | } 130 | var parsedSchema = gqlparser.MustLoadSchema(sources...) 131 | 132 | // endregion ************************** generated!.gotpl ************************** 133 | 134 | // region ***************************** args.gotpl ***************************** 135 | 136 | func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 137 | var err error 138 | args := map[string]interface{}{} 139 | var arg0 string 140 | if tmp, ok := rawArgs["name"]; ok { 141 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) 142 | arg0, err = ec.unmarshalNString2string(ctx, tmp) 143 | if err != nil { 144 | return nil, err 145 | } 146 | } 147 | args["name"] = arg0 148 | return args, nil 149 | } 150 | 151 | func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 152 | var err error 153 | args := map[string]interface{}{} 154 | var arg0 bool 155 | if tmp, ok := rawArgs["includeDeprecated"]; ok { 156 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) 157 | arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) 158 | if err != nil { 159 | return nil, err 160 | } 161 | } 162 | args["includeDeprecated"] = arg0 163 | return args, nil 164 | } 165 | 166 | func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 167 | var err error 168 | args := map[string]interface{}{} 169 | var arg0 bool 170 | if tmp, ok := rawArgs["includeDeprecated"]; ok { 171 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) 172 | arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) 173 | if err != nil { 174 | return nil, err 175 | } 176 | } 177 | args["includeDeprecated"] = arg0 178 | return args, nil 179 | } 180 | 181 | // endregion ***************************** args.gotpl ***************************** 182 | 183 | // region ************************** directives.gotpl ************************** 184 | 185 | // endregion ************************** directives.gotpl ************************** 186 | 187 | // region **************************** field.gotpl ***************************** 188 | 189 | func (ec *executionContext) _Query_hello(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 190 | defer func() { 191 | if r := recover(); r != nil { 192 | ec.Error(ctx, ec.Recover(ctx, r)) 193 | ret = graphql.Null 194 | } 195 | }() 196 | fc := &graphql.FieldContext{ 197 | Object: "Query", 198 | Field: field, 199 | Args: nil, 200 | IsMethod: true, 201 | IsResolver: true, 202 | } 203 | 204 | ctx = graphql.WithFieldContext(ctx, fc) 205 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 206 | ctx = rctx // use context from middleware stack in children 207 | return ec.resolvers.Query().Hello(rctx) 208 | }) 209 | if err != nil { 210 | ec.Error(ctx, err) 211 | return graphql.Null 212 | } 213 | if resTmp == nil { 214 | if !graphql.HasFieldError(ctx, fc) { 215 | ec.Errorf(ctx, "must not be null") 216 | } 217 | return graphql.Null 218 | } 219 | res := resTmp.(string) 220 | fc.Result = res 221 | return ec.marshalNString2string(ctx, field.Selections, res) 222 | } 223 | 224 | func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 225 | defer func() { 226 | if r := recover(); r != nil { 227 | ec.Error(ctx, ec.Recover(ctx, r)) 228 | ret = graphql.Null 229 | } 230 | }() 231 | fc := &graphql.FieldContext{ 232 | Object: "Query", 233 | Field: field, 234 | Args: nil, 235 | IsMethod: true, 236 | IsResolver: false, 237 | } 238 | 239 | ctx = graphql.WithFieldContext(ctx, fc) 240 | rawArgs := field.ArgumentMap(ec.Variables) 241 | args, err := ec.field_Query___type_args(ctx, rawArgs) 242 | if err != nil { 243 | ec.Error(ctx, err) 244 | return graphql.Null 245 | } 246 | fc.Args = args 247 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 248 | ctx = rctx // use context from middleware stack in children 249 | return ec.introspectType(args["name"].(string)) 250 | }) 251 | if err != nil { 252 | ec.Error(ctx, err) 253 | return graphql.Null 254 | } 255 | if resTmp == nil { 256 | return graphql.Null 257 | } 258 | res := resTmp.(*introspection.Type) 259 | fc.Result = res 260 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 261 | } 262 | 263 | func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 264 | defer func() { 265 | if r := recover(); r != nil { 266 | ec.Error(ctx, ec.Recover(ctx, r)) 267 | ret = graphql.Null 268 | } 269 | }() 270 | fc := &graphql.FieldContext{ 271 | Object: "Query", 272 | Field: field, 273 | Args: nil, 274 | IsMethod: true, 275 | IsResolver: false, 276 | } 277 | 278 | ctx = graphql.WithFieldContext(ctx, fc) 279 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 280 | ctx = rctx // use context from middleware stack in children 281 | return ec.introspectSchema() 282 | }) 283 | if err != nil { 284 | ec.Error(ctx, err) 285 | return graphql.Null 286 | } 287 | if resTmp == nil { 288 | return graphql.Null 289 | } 290 | res := resTmp.(*introspection.Schema) 291 | fc.Result = res 292 | return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) 293 | } 294 | 295 | func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 296 | defer func() { 297 | if r := recover(); r != nil { 298 | ec.Error(ctx, ec.Recover(ctx, r)) 299 | ret = graphql.Null 300 | } 301 | }() 302 | fc := &graphql.FieldContext{ 303 | Object: "__Directive", 304 | Field: field, 305 | Args: nil, 306 | IsMethod: false, 307 | IsResolver: false, 308 | } 309 | 310 | ctx = graphql.WithFieldContext(ctx, fc) 311 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 312 | ctx = rctx // use context from middleware stack in children 313 | return obj.Name, nil 314 | }) 315 | if err != nil { 316 | ec.Error(ctx, err) 317 | return graphql.Null 318 | } 319 | if resTmp == nil { 320 | if !graphql.HasFieldError(ctx, fc) { 321 | ec.Errorf(ctx, "must not be null") 322 | } 323 | return graphql.Null 324 | } 325 | res := resTmp.(string) 326 | fc.Result = res 327 | return ec.marshalNString2string(ctx, field.Selections, res) 328 | } 329 | 330 | func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 331 | defer func() { 332 | if r := recover(); r != nil { 333 | ec.Error(ctx, ec.Recover(ctx, r)) 334 | ret = graphql.Null 335 | } 336 | }() 337 | fc := &graphql.FieldContext{ 338 | Object: "__Directive", 339 | Field: field, 340 | Args: nil, 341 | IsMethod: false, 342 | IsResolver: false, 343 | } 344 | 345 | ctx = graphql.WithFieldContext(ctx, fc) 346 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 347 | ctx = rctx // use context from middleware stack in children 348 | return obj.Description, nil 349 | }) 350 | if err != nil { 351 | ec.Error(ctx, err) 352 | return graphql.Null 353 | } 354 | if resTmp == nil { 355 | return graphql.Null 356 | } 357 | res := resTmp.(string) 358 | fc.Result = res 359 | return ec.marshalOString2string(ctx, field.Selections, res) 360 | } 361 | 362 | func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 363 | defer func() { 364 | if r := recover(); r != nil { 365 | ec.Error(ctx, ec.Recover(ctx, r)) 366 | ret = graphql.Null 367 | } 368 | }() 369 | fc := &graphql.FieldContext{ 370 | Object: "__Directive", 371 | Field: field, 372 | Args: nil, 373 | IsMethod: false, 374 | IsResolver: false, 375 | } 376 | 377 | ctx = graphql.WithFieldContext(ctx, fc) 378 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 379 | ctx = rctx // use context from middleware stack in children 380 | return obj.Locations, nil 381 | }) 382 | if err != nil { 383 | ec.Error(ctx, err) 384 | return graphql.Null 385 | } 386 | if resTmp == nil { 387 | if !graphql.HasFieldError(ctx, fc) { 388 | ec.Errorf(ctx, "must not be null") 389 | } 390 | return graphql.Null 391 | } 392 | res := resTmp.([]string) 393 | fc.Result = res 394 | return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) 395 | } 396 | 397 | func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 398 | defer func() { 399 | if r := recover(); r != nil { 400 | ec.Error(ctx, ec.Recover(ctx, r)) 401 | ret = graphql.Null 402 | } 403 | }() 404 | fc := &graphql.FieldContext{ 405 | Object: "__Directive", 406 | Field: field, 407 | Args: nil, 408 | IsMethod: false, 409 | IsResolver: false, 410 | } 411 | 412 | ctx = graphql.WithFieldContext(ctx, fc) 413 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 414 | ctx = rctx // use context from middleware stack in children 415 | return obj.Args, nil 416 | }) 417 | if err != nil { 418 | ec.Error(ctx, err) 419 | return graphql.Null 420 | } 421 | if resTmp == nil { 422 | if !graphql.HasFieldError(ctx, fc) { 423 | ec.Errorf(ctx, "must not be null") 424 | } 425 | return graphql.Null 426 | } 427 | res := resTmp.([]introspection.InputValue) 428 | fc.Result = res 429 | return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 430 | } 431 | 432 | func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 433 | defer func() { 434 | if r := recover(); r != nil { 435 | ec.Error(ctx, ec.Recover(ctx, r)) 436 | ret = graphql.Null 437 | } 438 | }() 439 | fc := &graphql.FieldContext{ 440 | Object: "__EnumValue", 441 | Field: field, 442 | Args: nil, 443 | IsMethod: false, 444 | IsResolver: false, 445 | } 446 | 447 | ctx = graphql.WithFieldContext(ctx, fc) 448 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 449 | ctx = rctx // use context from middleware stack in children 450 | return obj.Name, nil 451 | }) 452 | if err != nil { 453 | ec.Error(ctx, err) 454 | return graphql.Null 455 | } 456 | if resTmp == nil { 457 | if !graphql.HasFieldError(ctx, fc) { 458 | ec.Errorf(ctx, "must not be null") 459 | } 460 | return graphql.Null 461 | } 462 | res := resTmp.(string) 463 | fc.Result = res 464 | return ec.marshalNString2string(ctx, field.Selections, res) 465 | } 466 | 467 | func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 468 | defer func() { 469 | if r := recover(); r != nil { 470 | ec.Error(ctx, ec.Recover(ctx, r)) 471 | ret = graphql.Null 472 | } 473 | }() 474 | fc := &graphql.FieldContext{ 475 | Object: "__EnumValue", 476 | Field: field, 477 | Args: nil, 478 | IsMethod: false, 479 | IsResolver: false, 480 | } 481 | 482 | ctx = graphql.WithFieldContext(ctx, fc) 483 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 484 | ctx = rctx // use context from middleware stack in children 485 | return obj.Description, nil 486 | }) 487 | if err != nil { 488 | ec.Error(ctx, err) 489 | return graphql.Null 490 | } 491 | if resTmp == nil { 492 | return graphql.Null 493 | } 494 | res := resTmp.(string) 495 | fc.Result = res 496 | return ec.marshalOString2string(ctx, field.Selections, res) 497 | } 498 | 499 | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 500 | defer func() { 501 | if r := recover(); r != nil { 502 | ec.Error(ctx, ec.Recover(ctx, r)) 503 | ret = graphql.Null 504 | } 505 | }() 506 | fc := &graphql.FieldContext{ 507 | Object: "__EnumValue", 508 | Field: field, 509 | Args: nil, 510 | IsMethod: true, 511 | IsResolver: false, 512 | } 513 | 514 | ctx = graphql.WithFieldContext(ctx, fc) 515 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 516 | ctx = rctx // use context from middleware stack in children 517 | return obj.IsDeprecated(), nil 518 | }) 519 | if err != nil { 520 | ec.Error(ctx, err) 521 | return graphql.Null 522 | } 523 | if resTmp == nil { 524 | if !graphql.HasFieldError(ctx, fc) { 525 | ec.Errorf(ctx, "must not be null") 526 | } 527 | return graphql.Null 528 | } 529 | res := resTmp.(bool) 530 | fc.Result = res 531 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 532 | } 533 | 534 | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 535 | defer func() { 536 | if r := recover(); r != nil { 537 | ec.Error(ctx, ec.Recover(ctx, r)) 538 | ret = graphql.Null 539 | } 540 | }() 541 | fc := &graphql.FieldContext{ 542 | Object: "__EnumValue", 543 | Field: field, 544 | Args: nil, 545 | IsMethod: true, 546 | IsResolver: false, 547 | } 548 | 549 | ctx = graphql.WithFieldContext(ctx, fc) 550 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 551 | ctx = rctx // use context from middleware stack in children 552 | return obj.DeprecationReason(), nil 553 | }) 554 | if err != nil { 555 | ec.Error(ctx, err) 556 | return graphql.Null 557 | } 558 | if resTmp == nil { 559 | return graphql.Null 560 | } 561 | res := resTmp.(*string) 562 | fc.Result = res 563 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 564 | } 565 | 566 | func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 567 | defer func() { 568 | if r := recover(); r != nil { 569 | ec.Error(ctx, ec.Recover(ctx, r)) 570 | ret = graphql.Null 571 | } 572 | }() 573 | fc := &graphql.FieldContext{ 574 | Object: "__Field", 575 | Field: field, 576 | Args: nil, 577 | IsMethod: false, 578 | IsResolver: false, 579 | } 580 | 581 | ctx = graphql.WithFieldContext(ctx, fc) 582 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 583 | ctx = rctx // use context from middleware stack in children 584 | return obj.Name, nil 585 | }) 586 | if err != nil { 587 | ec.Error(ctx, err) 588 | return graphql.Null 589 | } 590 | if resTmp == nil { 591 | if !graphql.HasFieldError(ctx, fc) { 592 | ec.Errorf(ctx, "must not be null") 593 | } 594 | return graphql.Null 595 | } 596 | res := resTmp.(string) 597 | fc.Result = res 598 | return ec.marshalNString2string(ctx, field.Selections, res) 599 | } 600 | 601 | func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 602 | defer func() { 603 | if r := recover(); r != nil { 604 | ec.Error(ctx, ec.Recover(ctx, r)) 605 | ret = graphql.Null 606 | } 607 | }() 608 | fc := &graphql.FieldContext{ 609 | Object: "__Field", 610 | Field: field, 611 | Args: nil, 612 | IsMethod: false, 613 | IsResolver: false, 614 | } 615 | 616 | ctx = graphql.WithFieldContext(ctx, fc) 617 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 618 | ctx = rctx // use context from middleware stack in children 619 | return obj.Description, nil 620 | }) 621 | if err != nil { 622 | ec.Error(ctx, err) 623 | return graphql.Null 624 | } 625 | if resTmp == nil { 626 | return graphql.Null 627 | } 628 | res := resTmp.(string) 629 | fc.Result = res 630 | return ec.marshalOString2string(ctx, field.Selections, res) 631 | } 632 | 633 | func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 634 | defer func() { 635 | if r := recover(); r != nil { 636 | ec.Error(ctx, ec.Recover(ctx, r)) 637 | ret = graphql.Null 638 | } 639 | }() 640 | fc := &graphql.FieldContext{ 641 | Object: "__Field", 642 | Field: field, 643 | Args: nil, 644 | IsMethod: false, 645 | IsResolver: false, 646 | } 647 | 648 | ctx = graphql.WithFieldContext(ctx, fc) 649 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 650 | ctx = rctx // use context from middleware stack in children 651 | return obj.Args, nil 652 | }) 653 | if err != nil { 654 | ec.Error(ctx, err) 655 | return graphql.Null 656 | } 657 | if resTmp == nil { 658 | if !graphql.HasFieldError(ctx, fc) { 659 | ec.Errorf(ctx, "must not be null") 660 | } 661 | return graphql.Null 662 | } 663 | res := resTmp.([]introspection.InputValue) 664 | fc.Result = res 665 | return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 666 | } 667 | 668 | func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 669 | defer func() { 670 | if r := recover(); r != nil { 671 | ec.Error(ctx, ec.Recover(ctx, r)) 672 | ret = graphql.Null 673 | } 674 | }() 675 | fc := &graphql.FieldContext{ 676 | Object: "__Field", 677 | Field: field, 678 | Args: nil, 679 | IsMethod: false, 680 | IsResolver: false, 681 | } 682 | 683 | ctx = graphql.WithFieldContext(ctx, fc) 684 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 685 | ctx = rctx // use context from middleware stack in children 686 | return obj.Type, nil 687 | }) 688 | if err != nil { 689 | ec.Error(ctx, err) 690 | return graphql.Null 691 | } 692 | if resTmp == nil { 693 | if !graphql.HasFieldError(ctx, fc) { 694 | ec.Errorf(ctx, "must not be null") 695 | } 696 | return graphql.Null 697 | } 698 | res := resTmp.(*introspection.Type) 699 | fc.Result = res 700 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 701 | } 702 | 703 | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 704 | defer func() { 705 | if r := recover(); r != nil { 706 | ec.Error(ctx, ec.Recover(ctx, r)) 707 | ret = graphql.Null 708 | } 709 | }() 710 | fc := &graphql.FieldContext{ 711 | Object: "__Field", 712 | Field: field, 713 | Args: nil, 714 | IsMethod: true, 715 | IsResolver: false, 716 | } 717 | 718 | ctx = graphql.WithFieldContext(ctx, fc) 719 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 720 | ctx = rctx // use context from middleware stack in children 721 | return obj.IsDeprecated(), nil 722 | }) 723 | if err != nil { 724 | ec.Error(ctx, err) 725 | return graphql.Null 726 | } 727 | if resTmp == nil { 728 | if !graphql.HasFieldError(ctx, fc) { 729 | ec.Errorf(ctx, "must not be null") 730 | } 731 | return graphql.Null 732 | } 733 | res := resTmp.(bool) 734 | fc.Result = res 735 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 736 | } 737 | 738 | func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 739 | defer func() { 740 | if r := recover(); r != nil { 741 | ec.Error(ctx, ec.Recover(ctx, r)) 742 | ret = graphql.Null 743 | } 744 | }() 745 | fc := &graphql.FieldContext{ 746 | Object: "__Field", 747 | Field: field, 748 | Args: nil, 749 | IsMethod: true, 750 | IsResolver: false, 751 | } 752 | 753 | ctx = graphql.WithFieldContext(ctx, fc) 754 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 755 | ctx = rctx // use context from middleware stack in children 756 | return obj.DeprecationReason(), nil 757 | }) 758 | if err != nil { 759 | ec.Error(ctx, err) 760 | return graphql.Null 761 | } 762 | if resTmp == nil { 763 | return graphql.Null 764 | } 765 | res := resTmp.(*string) 766 | fc.Result = res 767 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 768 | } 769 | 770 | func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 771 | defer func() { 772 | if r := recover(); r != nil { 773 | ec.Error(ctx, ec.Recover(ctx, r)) 774 | ret = graphql.Null 775 | } 776 | }() 777 | fc := &graphql.FieldContext{ 778 | Object: "__InputValue", 779 | Field: field, 780 | Args: nil, 781 | IsMethod: false, 782 | IsResolver: false, 783 | } 784 | 785 | ctx = graphql.WithFieldContext(ctx, fc) 786 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 787 | ctx = rctx // use context from middleware stack in children 788 | return obj.Name, nil 789 | }) 790 | if err != nil { 791 | ec.Error(ctx, err) 792 | return graphql.Null 793 | } 794 | if resTmp == nil { 795 | if !graphql.HasFieldError(ctx, fc) { 796 | ec.Errorf(ctx, "must not be null") 797 | } 798 | return graphql.Null 799 | } 800 | res := resTmp.(string) 801 | fc.Result = res 802 | return ec.marshalNString2string(ctx, field.Selections, res) 803 | } 804 | 805 | func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 806 | defer func() { 807 | if r := recover(); r != nil { 808 | ec.Error(ctx, ec.Recover(ctx, r)) 809 | ret = graphql.Null 810 | } 811 | }() 812 | fc := &graphql.FieldContext{ 813 | Object: "__InputValue", 814 | Field: field, 815 | Args: nil, 816 | IsMethod: false, 817 | IsResolver: false, 818 | } 819 | 820 | ctx = graphql.WithFieldContext(ctx, fc) 821 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 822 | ctx = rctx // use context from middleware stack in children 823 | return obj.Description, nil 824 | }) 825 | if err != nil { 826 | ec.Error(ctx, err) 827 | return graphql.Null 828 | } 829 | if resTmp == nil { 830 | return graphql.Null 831 | } 832 | res := resTmp.(string) 833 | fc.Result = res 834 | return ec.marshalOString2string(ctx, field.Selections, res) 835 | } 836 | 837 | func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 838 | defer func() { 839 | if r := recover(); r != nil { 840 | ec.Error(ctx, ec.Recover(ctx, r)) 841 | ret = graphql.Null 842 | } 843 | }() 844 | fc := &graphql.FieldContext{ 845 | Object: "__InputValue", 846 | Field: field, 847 | Args: nil, 848 | IsMethod: false, 849 | IsResolver: false, 850 | } 851 | 852 | ctx = graphql.WithFieldContext(ctx, fc) 853 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 854 | ctx = rctx // use context from middleware stack in children 855 | return obj.Type, nil 856 | }) 857 | if err != nil { 858 | ec.Error(ctx, err) 859 | return graphql.Null 860 | } 861 | if resTmp == nil { 862 | if !graphql.HasFieldError(ctx, fc) { 863 | ec.Errorf(ctx, "must not be null") 864 | } 865 | return graphql.Null 866 | } 867 | res := resTmp.(*introspection.Type) 868 | fc.Result = res 869 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 870 | } 871 | 872 | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 873 | defer func() { 874 | if r := recover(); r != nil { 875 | ec.Error(ctx, ec.Recover(ctx, r)) 876 | ret = graphql.Null 877 | } 878 | }() 879 | fc := &graphql.FieldContext{ 880 | Object: "__InputValue", 881 | Field: field, 882 | Args: nil, 883 | IsMethod: false, 884 | IsResolver: false, 885 | } 886 | 887 | ctx = graphql.WithFieldContext(ctx, fc) 888 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 889 | ctx = rctx // use context from middleware stack in children 890 | return obj.DefaultValue, nil 891 | }) 892 | if err != nil { 893 | ec.Error(ctx, err) 894 | return graphql.Null 895 | } 896 | if resTmp == nil { 897 | return graphql.Null 898 | } 899 | res := resTmp.(*string) 900 | fc.Result = res 901 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 902 | } 903 | 904 | func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 905 | defer func() { 906 | if r := recover(); r != nil { 907 | ec.Error(ctx, ec.Recover(ctx, r)) 908 | ret = graphql.Null 909 | } 910 | }() 911 | fc := &graphql.FieldContext{ 912 | Object: "__Schema", 913 | Field: field, 914 | Args: nil, 915 | IsMethod: true, 916 | IsResolver: false, 917 | } 918 | 919 | ctx = graphql.WithFieldContext(ctx, fc) 920 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 921 | ctx = rctx // use context from middleware stack in children 922 | return obj.Types(), nil 923 | }) 924 | if err != nil { 925 | ec.Error(ctx, err) 926 | return graphql.Null 927 | } 928 | if resTmp == nil { 929 | if !graphql.HasFieldError(ctx, fc) { 930 | ec.Errorf(ctx, "must not be null") 931 | } 932 | return graphql.Null 933 | } 934 | res := resTmp.([]introspection.Type) 935 | fc.Result = res 936 | return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 937 | } 938 | 939 | func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 940 | defer func() { 941 | if r := recover(); r != nil { 942 | ec.Error(ctx, ec.Recover(ctx, r)) 943 | ret = graphql.Null 944 | } 945 | }() 946 | fc := &graphql.FieldContext{ 947 | Object: "__Schema", 948 | Field: field, 949 | Args: nil, 950 | IsMethod: true, 951 | IsResolver: false, 952 | } 953 | 954 | ctx = graphql.WithFieldContext(ctx, fc) 955 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 956 | ctx = rctx // use context from middleware stack in children 957 | return obj.QueryType(), nil 958 | }) 959 | if err != nil { 960 | ec.Error(ctx, err) 961 | return graphql.Null 962 | } 963 | if resTmp == nil { 964 | if !graphql.HasFieldError(ctx, fc) { 965 | ec.Errorf(ctx, "must not be null") 966 | } 967 | return graphql.Null 968 | } 969 | res := resTmp.(*introspection.Type) 970 | fc.Result = res 971 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 972 | } 973 | 974 | func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 975 | defer func() { 976 | if r := recover(); r != nil { 977 | ec.Error(ctx, ec.Recover(ctx, r)) 978 | ret = graphql.Null 979 | } 980 | }() 981 | fc := &graphql.FieldContext{ 982 | Object: "__Schema", 983 | Field: field, 984 | Args: nil, 985 | IsMethod: true, 986 | IsResolver: false, 987 | } 988 | 989 | ctx = graphql.WithFieldContext(ctx, fc) 990 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 991 | ctx = rctx // use context from middleware stack in children 992 | return obj.MutationType(), nil 993 | }) 994 | if err != nil { 995 | ec.Error(ctx, err) 996 | return graphql.Null 997 | } 998 | if resTmp == nil { 999 | return graphql.Null 1000 | } 1001 | res := resTmp.(*introspection.Type) 1002 | fc.Result = res 1003 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1004 | } 1005 | 1006 | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 1007 | defer func() { 1008 | if r := recover(); r != nil { 1009 | ec.Error(ctx, ec.Recover(ctx, r)) 1010 | ret = graphql.Null 1011 | } 1012 | }() 1013 | fc := &graphql.FieldContext{ 1014 | Object: "__Schema", 1015 | Field: field, 1016 | Args: nil, 1017 | IsMethod: true, 1018 | IsResolver: false, 1019 | } 1020 | 1021 | ctx = graphql.WithFieldContext(ctx, fc) 1022 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1023 | ctx = rctx // use context from middleware stack in children 1024 | return obj.SubscriptionType(), nil 1025 | }) 1026 | if err != nil { 1027 | ec.Error(ctx, err) 1028 | return graphql.Null 1029 | } 1030 | if resTmp == nil { 1031 | return graphql.Null 1032 | } 1033 | res := resTmp.(*introspection.Type) 1034 | fc.Result = res 1035 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1036 | } 1037 | 1038 | func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 1039 | defer func() { 1040 | if r := recover(); r != nil { 1041 | ec.Error(ctx, ec.Recover(ctx, r)) 1042 | ret = graphql.Null 1043 | } 1044 | }() 1045 | fc := &graphql.FieldContext{ 1046 | Object: "__Schema", 1047 | Field: field, 1048 | Args: nil, 1049 | IsMethod: true, 1050 | IsResolver: false, 1051 | } 1052 | 1053 | ctx = graphql.WithFieldContext(ctx, fc) 1054 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1055 | ctx = rctx // use context from middleware stack in children 1056 | return obj.Directives(), nil 1057 | }) 1058 | if err != nil { 1059 | ec.Error(ctx, err) 1060 | return graphql.Null 1061 | } 1062 | if resTmp == nil { 1063 | if !graphql.HasFieldError(ctx, fc) { 1064 | ec.Errorf(ctx, "must not be null") 1065 | } 1066 | return graphql.Null 1067 | } 1068 | res := resTmp.([]introspection.Directive) 1069 | fc.Result = res 1070 | return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) 1071 | } 1072 | 1073 | func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1074 | defer func() { 1075 | if r := recover(); r != nil { 1076 | ec.Error(ctx, ec.Recover(ctx, r)) 1077 | ret = graphql.Null 1078 | } 1079 | }() 1080 | fc := &graphql.FieldContext{ 1081 | Object: "__Type", 1082 | Field: field, 1083 | Args: nil, 1084 | IsMethod: true, 1085 | IsResolver: false, 1086 | } 1087 | 1088 | ctx = graphql.WithFieldContext(ctx, fc) 1089 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1090 | ctx = rctx // use context from middleware stack in children 1091 | return obj.Kind(), nil 1092 | }) 1093 | if err != nil { 1094 | ec.Error(ctx, err) 1095 | return graphql.Null 1096 | } 1097 | if resTmp == nil { 1098 | if !graphql.HasFieldError(ctx, fc) { 1099 | ec.Errorf(ctx, "must not be null") 1100 | } 1101 | return graphql.Null 1102 | } 1103 | res := resTmp.(string) 1104 | fc.Result = res 1105 | return ec.marshalN__TypeKind2string(ctx, field.Selections, res) 1106 | } 1107 | 1108 | func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1109 | defer func() { 1110 | if r := recover(); r != nil { 1111 | ec.Error(ctx, ec.Recover(ctx, r)) 1112 | ret = graphql.Null 1113 | } 1114 | }() 1115 | fc := &graphql.FieldContext{ 1116 | Object: "__Type", 1117 | Field: field, 1118 | Args: nil, 1119 | IsMethod: true, 1120 | IsResolver: false, 1121 | } 1122 | 1123 | ctx = graphql.WithFieldContext(ctx, fc) 1124 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1125 | ctx = rctx // use context from middleware stack in children 1126 | return obj.Name(), nil 1127 | }) 1128 | if err != nil { 1129 | ec.Error(ctx, err) 1130 | return graphql.Null 1131 | } 1132 | if resTmp == nil { 1133 | return graphql.Null 1134 | } 1135 | res := resTmp.(*string) 1136 | fc.Result = res 1137 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1138 | } 1139 | 1140 | func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1141 | defer func() { 1142 | if r := recover(); r != nil { 1143 | ec.Error(ctx, ec.Recover(ctx, r)) 1144 | ret = graphql.Null 1145 | } 1146 | }() 1147 | fc := &graphql.FieldContext{ 1148 | Object: "__Type", 1149 | Field: field, 1150 | Args: nil, 1151 | IsMethod: true, 1152 | IsResolver: false, 1153 | } 1154 | 1155 | ctx = graphql.WithFieldContext(ctx, fc) 1156 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1157 | ctx = rctx // use context from middleware stack in children 1158 | return obj.Description(), nil 1159 | }) 1160 | if err != nil { 1161 | ec.Error(ctx, err) 1162 | return graphql.Null 1163 | } 1164 | if resTmp == nil { 1165 | return graphql.Null 1166 | } 1167 | res := resTmp.(string) 1168 | fc.Result = res 1169 | return ec.marshalOString2string(ctx, field.Selections, res) 1170 | } 1171 | 1172 | func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1173 | defer func() { 1174 | if r := recover(); r != nil { 1175 | ec.Error(ctx, ec.Recover(ctx, r)) 1176 | ret = graphql.Null 1177 | } 1178 | }() 1179 | fc := &graphql.FieldContext{ 1180 | Object: "__Type", 1181 | Field: field, 1182 | Args: nil, 1183 | IsMethod: true, 1184 | IsResolver: false, 1185 | } 1186 | 1187 | ctx = graphql.WithFieldContext(ctx, fc) 1188 | rawArgs := field.ArgumentMap(ec.Variables) 1189 | args, err := ec.field___Type_fields_args(ctx, rawArgs) 1190 | if err != nil { 1191 | ec.Error(ctx, err) 1192 | return graphql.Null 1193 | } 1194 | fc.Args = args 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.Fields(args["includeDeprecated"].(bool)), 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.([]introspection.Field) 1207 | fc.Result = res 1208 | return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) 1209 | } 1210 | 1211 | func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (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: "__Type", 1220 | Field: field, 1221 | Args: nil, 1222 | IsMethod: true, 1223 | IsResolver: false, 1224 | } 1225 | 1226 | ctx = graphql.WithFieldContext(ctx, fc) 1227 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1228 | ctx = rctx // use context from middleware stack in children 1229 | return obj.Interfaces(), nil 1230 | }) 1231 | if err != nil { 1232 | ec.Error(ctx, err) 1233 | return graphql.Null 1234 | } 1235 | if resTmp == nil { 1236 | return graphql.Null 1237 | } 1238 | res := resTmp.([]introspection.Type) 1239 | fc.Result = res 1240 | return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 1241 | } 1242 | 1243 | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1244 | defer func() { 1245 | if r := recover(); r != nil { 1246 | ec.Error(ctx, ec.Recover(ctx, r)) 1247 | ret = graphql.Null 1248 | } 1249 | }() 1250 | fc := &graphql.FieldContext{ 1251 | Object: "__Type", 1252 | Field: field, 1253 | Args: nil, 1254 | IsMethod: true, 1255 | IsResolver: false, 1256 | } 1257 | 1258 | ctx = graphql.WithFieldContext(ctx, fc) 1259 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1260 | ctx = rctx // use context from middleware stack in children 1261 | return obj.PossibleTypes(), nil 1262 | }) 1263 | if err != nil { 1264 | ec.Error(ctx, err) 1265 | return graphql.Null 1266 | } 1267 | if resTmp == nil { 1268 | return graphql.Null 1269 | } 1270 | res := resTmp.([]introspection.Type) 1271 | fc.Result = res 1272 | return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 1273 | } 1274 | 1275 | func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1276 | defer func() { 1277 | if r := recover(); r != nil { 1278 | ec.Error(ctx, ec.Recover(ctx, r)) 1279 | ret = graphql.Null 1280 | } 1281 | }() 1282 | fc := &graphql.FieldContext{ 1283 | Object: "__Type", 1284 | Field: field, 1285 | Args: nil, 1286 | IsMethod: true, 1287 | IsResolver: false, 1288 | } 1289 | 1290 | ctx = graphql.WithFieldContext(ctx, fc) 1291 | rawArgs := field.ArgumentMap(ec.Variables) 1292 | args, err := ec.field___Type_enumValues_args(ctx, rawArgs) 1293 | if err != nil { 1294 | ec.Error(ctx, err) 1295 | return graphql.Null 1296 | } 1297 | fc.Args = args 1298 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1299 | ctx = rctx // use context from middleware stack in children 1300 | return obj.EnumValues(args["includeDeprecated"].(bool)), nil 1301 | }) 1302 | if err != nil { 1303 | ec.Error(ctx, err) 1304 | return graphql.Null 1305 | } 1306 | if resTmp == nil { 1307 | return graphql.Null 1308 | } 1309 | res := resTmp.([]introspection.EnumValue) 1310 | fc.Result = res 1311 | return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) 1312 | } 1313 | 1314 | func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1315 | defer func() { 1316 | if r := recover(); r != nil { 1317 | ec.Error(ctx, ec.Recover(ctx, r)) 1318 | ret = graphql.Null 1319 | } 1320 | }() 1321 | fc := &graphql.FieldContext{ 1322 | Object: "__Type", 1323 | Field: field, 1324 | Args: nil, 1325 | IsMethod: true, 1326 | IsResolver: false, 1327 | } 1328 | 1329 | ctx = graphql.WithFieldContext(ctx, fc) 1330 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1331 | ctx = rctx // use context from middleware stack in children 1332 | return obj.InputFields(), nil 1333 | }) 1334 | if err != nil { 1335 | ec.Error(ctx, err) 1336 | return graphql.Null 1337 | } 1338 | if resTmp == nil { 1339 | return graphql.Null 1340 | } 1341 | res := resTmp.([]introspection.InputValue) 1342 | fc.Result = res 1343 | return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 1344 | } 1345 | 1346 | func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1347 | defer func() { 1348 | if r := recover(); r != nil { 1349 | ec.Error(ctx, ec.Recover(ctx, r)) 1350 | ret = graphql.Null 1351 | } 1352 | }() 1353 | fc := &graphql.FieldContext{ 1354 | Object: "__Type", 1355 | Field: field, 1356 | Args: nil, 1357 | IsMethod: true, 1358 | IsResolver: false, 1359 | } 1360 | 1361 | ctx = graphql.WithFieldContext(ctx, fc) 1362 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1363 | ctx = rctx // use context from middleware stack in children 1364 | return obj.OfType(), nil 1365 | }) 1366 | if err != nil { 1367 | ec.Error(ctx, err) 1368 | return graphql.Null 1369 | } 1370 | if resTmp == nil { 1371 | return graphql.Null 1372 | } 1373 | res := resTmp.(*introspection.Type) 1374 | fc.Result = res 1375 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1376 | } 1377 | 1378 | // endregion **************************** field.gotpl ***************************** 1379 | 1380 | // region **************************** input.gotpl ***************************** 1381 | 1382 | // endregion **************************** input.gotpl ***************************** 1383 | 1384 | // region ************************** interface.gotpl *************************** 1385 | 1386 | // endregion ************************** interface.gotpl *************************** 1387 | 1388 | // region **************************** object.gotpl **************************** 1389 | 1390 | var queryImplementors = []string{"Query"} 1391 | 1392 | func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { 1393 | fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) 1394 | 1395 | ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ 1396 | Object: "Query", 1397 | }) 1398 | 1399 | out := graphql.NewFieldSet(fields) 1400 | var invalids uint32 1401 | for i, field := range fields { 1402 | switch field.Name { 1403 | case "__typename": 1404 | out.Values[i] = graphql.MarshalString("Query") 1405 | case "hello": 1406 | field := field 1407 | out.Concurrently(i, func() (res graphql.Marshaler) { 1408 | defer func() { 1409 | if r := recover(); r != nil { 1410 | ec.Error(ctx, ec.Recover(ctx, r)) 1411 | } 1412 | }() 1413 | res = ec._Query_hello(ctx, field) 1414 | if res == graphql.Null { 1415 | atomic.AddUint32(&invalids, 1) 1416 | } 1417 | return res 1418 | }) 1419 | case "__type": 1420 | out.Values[i] = ec._Query___type(ctx, field) 1421 | case "__schema": 1422 | out.Values[i] = ec._Query___schema(ctx, field) 1423 | default: 1424 | panic("unknown field " + strconv.Quote(field.Name)) 1425 | } 1426 | } 1427 | out.Dispatch() 1428 | if invalids > 0 { 1429 | return graphql.Null 1430 | } 1431 | return out 1432 | } 1433 | 1434 | var __DirectiveImplementors = []string{"__Directive"} 1435 | 1436 | func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { 1437 | fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) 1438 | 1439 | out := graphql.NewFieldSet(fields) 1440 | var invalids uint32 1441 | for i, field := range fields { 1442 | switch field.Name { 1443 | case "__typename": 1444 | out.Values[i] = graphql.MarshalString("__Directive") 1445 | case "name": 1446 | out.Values[i] = ec.___Directive_name(ctx, field, obj) 1447 | if out.Values[i] == graphql.Null { 1448 | invalids++ 1449 | } 1450 | case "description": 1451 | out.Values[i] = ec.___Directive_description(ctx, field, obj) 1452 | case "locations": 1453 | out.Values[i] = ec.___Directive_locations(ctx, field, obj) 1454 | if out.Values[i] == graphql.Null { 1455 | invalids++ 1456 | } 1457 | case "args": 1458 | out.Values[i] = ec.___Directive_args(ctx, field, obj) 1459 | if out.Values[i] == graphql.Null { 1460 | invalids++ 1461 | } 1462 | default: 1463 | panic("unknown field " + strconv.Quote(field.Name)) 1464 | } 1465 | } 1466 | out.Dispatch() 1467 | if invalids > 0 { 1468 | return graphql.Null 1469 | } 1470 | return out 1471 | } 1472 | 1473 | var __EnumValueImplementors = []string{"__EnumValue"} 1474 | 1475 | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { 1476 | fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) 1477 | 1478 | out := graphql.NewFieldSet(fields) 1479 | var invalids uint32 1480 | for i, field := range fields { 1481 | switch field.Name { 1482 | case "__typename": 1483 | out.Values[i] = graphql.MarshalString("__EnumValue") 1484 | case "name": 1485 | out.Values[i] = ec.___EnumValue_name(ctx, field, obj) 1486 | if out.Values[i] == graphql.Null { 1487 | invalids++ 1488 | } 1489 | case "description": 1490 | out.Values[i] = ec.___EnumValue_description(ctx, field, obj) 1491 | case "isDeprecated": 1492 | out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) 1493 | if out.Values[i] == graphql.Null { 1494 | invalids++ 1495 | } 1496 | case "deprecationReason": 1497 | out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) 1498 | default: 1499 | panic("unknown field " + strconv.Quote(field.Name)) 1500 | } 1501 | } 1502 | out.Dispatch() 1503 | if invalids > 0 { 1504 | return graphql.Null 1505 | } 1506 | return out 1507 | } 1508 | 1509 | var __FieldImplementors = []string{"__Field"} 1510 | 1511 | func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { 1512 | fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) 1513 | 1514 | out := graphql.NewFieldSet(fields) 1515 | var invalids uint32 1516 | for i, field := range fields { 1517 | switch field.Name { 1518 | case "__typename": 1519 | out.Values[i] = graphql.MarshalString("__Field") 1520 | case "name": 1521 | out.Values[i] = ec.___Field_name(ctx, field, obj) 1522 | if out.Values[i] == graphql.Null { 1523 | invalids++ 1524 | } 1525 | case "description": 1526 | out.Values[i] = ec.___Field_description(ctx, field, obj) 1527 | case "args": 1528 | out.Values[i] = ec.___Field_args(ctx, field, obj) 1529 | if out.Values[i] == graphql.Null { 1530 | invalids++ 1531 | } 1532 | case "type": 1533 | out.Values[i] = ec.___Field_type(ctx, field, obj) 1534 | if out.Values[i] == graphql.Null { 1535 | invalids++ 1536 | } 1537 | case "isDeprecated": 1538 | out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) 1539 | if out.Values[i] == graphql.Null { 1540 | invalids++ 1541 | } 1542 | case "deprecationReason": 1543 | out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) 1544 | default: 1545 | panic("unknown field " + strconv.Quote(field.Name)) 1546 | } 1547 | } 1548 | out.Dispatch() 1549 | if invalids > 0 { 1550 | return graphql.Null 1551 | } 1552 | return out 1553 | } 1554 | 1555 | var __InputValueImplementors = []string{"__InputValue"} 1556 | 1557 | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { 1558 | fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) 1559 | 1560 | out := graphql.NewFieldSet(fields) 1561 | var invalids uint32 1562 | for i, field := range fields { 1563 | switch field.Name { 1564 | case "__typename": 1565 | out.Values[i] = graphql.MarshalString("__InputValue") 1566 | case "name": 1567 | out.Values[i] = ec.___InputValue_name(ctx, field, obj) 1568 | if out.Values[i] == graphql.Null { 1569 | invalids++ 1570 | } 1571 | case "description": 1572 | out.Values[i] = ec.___InputValue_description(ctx, field, obj) 1573 | case "type": 1574 | out.Values[i] = ec.___InputValue_type(ctx, field, obj) 1575 | if out.Values[i] == graphql.Null { 1576 | invalids++ 1577 | } 1578 | case "defaultValue": 1579 | out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) 1580 | default: 1581 | panic("unknown field " + strconv.Quote(field.Name)) 1582 | } 1583 | } 1584 | out.Dispatch() 1585 | if invalids > 0 { 1586 | return graphql.Null 1587 | } 1588 | return out 1589 | } 1590 | 1591 | var __SchemaImplementors = []string{"__Schema"} 1592 | 1593 | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { 1594 | fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) 1595 | 1596 | out := graphql.NewFieldSet(fields) 1597 | var invalids uint32 1598 | for i, field := range fields { 1599 | switch field.Name { 1600 | case "__typename": 1601 | out.Values[i] = graphql.MarshalString("__Schema") 1602 | case "types": 1603 | out.Values[i] = ec.___Schema_types(ctx, field, obj) 1604 | if out.Values[i] == graphql.Null { 1605 | invalids++ 1606 | } 1607 | case "queryType": 1608 | out.Values[i] = ec.___Schema_queryType(ctx, field, obj) 1609 | if out.Values[i] == graphql.Null { 1610 | invalids++ 1611 | } 1612 | case "mutationType": 1613 | out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) 1614 | case "subscriptionType": 1615 | out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) 1616 | case "directives": 1617 | out.Values[i] = ec.___Schema_directives(ctx, field, obj) 1618 | if out.Values[i] == graphql.Null { 1619 | invalids++ 1620 | } 1621 | default: 1622 | panic("unknown field " + strconv.Quote(field.Name)) 1623 | } 1624 | } 1625 | out.Dispatch() 1626 | if invalids > 0 { 1627 | return graphql.Null 1628 | } 1629 | return out 1630 | } 1631 | 1632 | var __TypeImplementors = []string{"__Type"} 1633 | 1634 | func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { 1635 | fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) 1636 | 1637 | out := graphql.NewFieldSet(fields) 1638 | var invalids uint32 1639 | for i, field := range fields { 1640 | switch field.Name { 1641 | case "__typename": 1642 | out.Values[i] = graphql.MarshalString("__Type") 1643 | case "kind": 1644 | out.Values[i] = ec.___Type_kind(ctx, field, obj) 1645 | if out.Values[i] == graphql.Null { 1646 | invalids++ 1647 | } 1648 | case "name": 1649 | out.Values[i] = ec.___Type_name(ctx, field, obj) 1650 | case "description": 1651 | out.Values[i] = ec.___Type_description(ctx, field, obj) 1652 | case "fields": 1653 | out.Values[i] = ec.___Type_fields(ctx, field, obj) 1654 | case "interfaces": 1655 | out.Values[i] = ec.___Type_interfaces(ctx, field, obj) 1656 | case "possibleTypes": 1657 | out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) 1658 | case "enumValues": 1659 | out.Values[i] = ec.___Type_enumValues(ctx, field, obj) 1660 | case "inputFields": 1661 | out.Values[i] = ec.___Type_inputFields(ctx, field, obj) 1662 | case "ofType": 1663 | out.Values[i] = ec.___Type_ofType(ctx, field, obj) 1664 | default: 1665 | panic("unknown field " + strconv.Quote(field.Name)) 1666 | } 1667 | } 1668 | out.Dispatch() 1669 | if invalids > 0 { 1670 | return graphql.Null 1671 | } 1672 | return out 1673 | } 1674 | 1675 | // endregion **************************** object.gotpl **************************** 1676 | 1677 | // region ***************************** type.gotpl ***************************** 1678 | 1679 | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { 1680 | res, err := graphql.UnmarshalBoolean(v) 1681 | return res, graphql.ErrorOnPath(ctx, err) 1682 | } 1683 | 1684 | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { 1685 | res := graphql.MarshalBoolean(v) 1686 | if res == graphql.Null { 1687 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1688 | ec.Errorf(ctx, "must not be null") 1689 | } 1690 | } 1691 | return res 1692 | } 1693 | 1694 | func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { 1695 | res, err := graphql.UnmarshalString(v) 1696 | return res, graphql.ErrorOnPath(ctx, err) 1697 | } 1698 | 1699 | func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 1700 | res := graphql.MarshalString(v) 1701 | if res == graphql.Null { 1702 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1703 | ec.Errorf(ctx, "must not be null") 1704 | } 1705 | } 1706 | return res 1707 | } 1708 | 1709 | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { 1710 | return ec.___Directive(ctx, sel, &v) 1711 | } 1712 | 1713 | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { 1714 | ret := make(graphql.Array, len(v)) 1715 | var wg sync.WaitGroup 1716 | isLen1 := len(v) == 1 1717 | if !isLen1 { 1718 | wg.Add(len(v)) 1719 | } 1720 | for i := range v { 1721 | i := i 1722 | fc := &graphql.FieldContext{ 1723 | Index: &i, 1724 | Result: &v[i], 1725 | } 1726 | ctx := graphql.WithFieldContext(ctx, fc) 1727 | f := func(i int) { 1728 | defer func() { 1729 | if r := recover(); r != nil { 1730 | ec.Error(ctx, ec.Recover(ctx, r)) 1731 | ret = nil 1732 | } 1733 | }() 1734 | if !isLen1 { 1735 | defer wg.Done() 1736 | } 1737 | ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) 1738 | } 1739 | if isLen1 { 1740 | f(i) 1741 | } else { 1742 | go f(i) 1743 | } 1744 | 1745 | } 1746 | wg.Wait() 1747 | return ret 1748 | } 1749 | 1750 | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { 1751 | res, err := graphql.UnmarshalString(v) 1752 | return res, graphql.ErrorOnPath(ctx, err) 1753 | } 1754 | 1755 | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 1756 | res := graphql.MarshalString(v) 1757 | if res == graphql.Null { 1758 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1759 | ec.Errorf(ctx, "must not be null") 1760 | } 1761 | } 1762 | return res 1763 | } 1764 | 1765 | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { 1766 | var vSlice []interface{} 1767 | if v != nil { 1768 | if tmp1, ok := v.([]interface{}); ok { 1769 | vSlice = tmp1 1770 | } else { 1771 | vSlice = []interface{}{v} 1772 | } 1773 | } 1774 | var err error 1775 | res := make([]string, len(vSlice)) 1776 | for i := range vSlice { 1777 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) 1778 | res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) 1779 | if err != nil { 1780 | return nil, err 1781 | } 1782 | } 1783 | return res, nil 1784 | } 1785 | 1786 | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { 1787 | ret := make(graphql.Array, len(v)) 1788 | var wg sync.WaitGroup 1789 | isLen1 := len(v) == 1 1790 | if !isLen1 { 1791 | wg.Add(len(v)) 1792 | } 1793 | for i := range v { 1794 | i := i 1795 | fc := &graphql.FieldContext{ 1796 | Index: &i, 1797 | Result: &v[i], 1798 | } 1799 | ctx := graphql.WithFieldContext(ctx, fc) 1800 | f := func(i int) { 1801 | defer func() { 1802 | if r := recover(); r != nil { 1803 | ec.Error(ctx, ec.Recover(ctx, r)) 1804 | ret = nil 1805 | } 1806 | }() 1807 | if !isLen1 { 1808 | defer wg.Done() 1809 | } 1810 | ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) 1811 | } 1812 | if isLen1 { 1813 | f(i) 1814 | } else { 1815 | go f(i) 1816 | } 1817 | 1818 | } 1819 | wg.Wait() 1820 | return ret 1821 | } 1822 | 1823 | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { 1824 | return ec.___EnumValue(ctx, sel, &v) 1825 | } 1826 | 1827 | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { 1828 | return ec.___Field(ctx, sel, &v) 1829 | } 1830 | 1831 | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { 1832 | return ec.___InputValue(ctx, sel, &v) 1833 | } 1834 | 1835 | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { 1836 | ret := make(graphql.Array, len(v)) 1837 | var wg sync.WaitGroup 1838 | isLen1 := len(v) == 1 1839 | if !isLen1 { 1840 | wg.Add(len(v)) 1841 | } 1842 | for i := range v { 1843 | i := i 1844 | fc := &graphql.FieldContext{ 1845 | Index: &i, 1846 | Result: &v[i], 1847 | } 1848 | ctx := graphql.WithFieldContext(ctx, fc) 1849 | f := func(i int) { 1850 | defer func() { 1851 | if r := recover(); r != nil { 1852 | ec.Error(ctx, ec.Recover(ctx, r)) 1853 | ret = nil 1854 | } 1855 | }() 1856 | if !isLen1 { 1857 | defer wg.Done() 1858 | } 1859 | ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) 1860 | } 1861 | if isLen1 { 1862 | f(i) 1863 | } else { 1864 | go f(i) 1865 | } 1866 | 1867 | } 1868 | wg.Wait() 1869 | return ret 1870 | } 1871 | 1872 | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { 1873 | return ec.___Type(ctx, sel, &v) 1874 | } 1875 | 1876 | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { 1877 | ret := make(graphql.Array, len(v)) 1878 | var wg sync.WaitGroup 1879 | isLen1 := len(v) == 1 1880 | if !isLen1 { 1881 | wg.Add(len(v)) 1882 | } 1883 | for i := range v { 1884 | i := i 1885 | fc := &graphql.FieldContext{ 1886 | Index: &i, 1887 | Result: &v[i], 1888 | } 1889 | ctx := graphql.WithFieldContext(ctx, fc) 1890 | f := func(i int) { 1891 | defer func() { 1892 | if r := recover(); r != nil { 1893 | ec.Error(ctx, ec.Recover(ctx, r)) 1894 | ret = nil 1895 | } 1896 | }() 1897 | if !isLen1 { 1898 | defer wg.Done() 1899 | } 1900 | ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) 1901 | } 1902 | if isLen1 { 1903 | f(i) 1904 | } else { 1905 | go f(i) 1906 | } 1907 | 1908 | } 1909 | wg.Wait() 1910 | return ret 1911 | } 1912 | 1913 | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { 1914 | if v == nil { 1915 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1916 | ec.Errorf(ctx, "must not be null") 1917 | } 1918 | return graphql.Null 1919 | } 1920 | return ec.___Type(ctx, sel, v) 1921 | } 1922 | 1923 | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { 1924 | res, err := graphql.UnmarshalString(v) 1925 | return res, graphql.ErrorOnPath(ctx, err) 1926 | } 1927 | 1928 | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 1929 | res := graphql.MarshalString(v) 1930 | if res == graphql.Null { 1931 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1932 | ec.Errorf(ctx, "must not be null") 1933 | } 1934 | } 1935 | return res 1936 | } 1937 | 1938 | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { 1939 | res, err := graphql.UnmarshalBoolean(v) 1940 | return res, graphql.ErrorOnPath(ctx, err) 1941 | } 1942 | 1943 | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { 1944 | return graphql.MarshalBoolean(v) 1945 | } 1946 | 1947 | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { 1948 | if v == nil { 1949 | return nil, nil 1950 | } 1951 | res, err := graphql.UnmarshalBoolean(v) 1952 | return &res, graphql.ErrorOnPath(ctx, err) 1953 | } 1954 | 1955 | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { 1956 | if v == nil { 1957 | return graphql.Null 1958 | } 1959 | return graphql.MarshalBoolean(*v) 1960 | } 1961 | 1962 | func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { 1963 | res, err := graphql.UnmarshalString(v) 1964 | return res, graphql.ErrorOnPath(ctx, err) 1965 | } 1966 | 1967 | func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 1968 | return graphql.MarshalString(v) 1969 | } 1970 | 1971 | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { 1972 | if v == nil { 1973 | return nil, nil 1974 | } 1975 | res, err := graphql.UnmarshalString(v) 1976 | return &res, graphql.ErrorOnPath(ctx, err) 1977 | } 1978 | 1979 | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { 1980 | if v == nil { 1981 | return graphql.Null 1982 | } 1983 | return graphql.MarshalString(*v) 1984 | } 1985 | 1986 | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { 1987 | if v == nil { 1988 | return graphql.Null 1989 | } 1990 | ret := make(graphql.Array, len(v)) 1991 | var wg sync.WaitGroup 1992 | isLen1 := len(v) == 1 1993 | if !isLen1 { 1994 | wg.Add(len(v)) 1995 | } 1996 | for i := range v { 1997 | i := i 1998 | fc := &graphql.FieldContext{ 1999 | Index: &i, 2000 | Result: &v[i], 2001 | } 2002 | ctx := graphql.WithFieldContext(ctx, fc) 2003 | f := func(i int) { 2004 | defer func() { 2005 | if r := recover(); r != nil { 2006 | ec.Error(ctx, ec.Recover(ctx, r)) 2007 | ret = nil 2008 | } 2009 | }() 2010 | if !isLen1 { 2011 | defer wg.Done() 2012 | } 2013 | ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) 2014 | } 2015 | if isLen1 { 2016 | f(i) 2017 | } else { 2018 | go f(i) 2019 | } 2020 | 2021 | } 2022 | wg.Wait() 2023 | return ret 2024 | } 2025 | 2026 | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { 2027 | if v == nil { 2028 | return graphql.Null 2029 | } 2030 | ret := make(graphql.Array, len(v)) 2031 | var wg sync.WaitGroup 2032 | isLen1 := len(v) == 1 2033 | if !isLen1 { 2034 | wg.Add(len(v)) 2035 | } 2036 | for i := range v { 2037 | i := i 2038 | fc := &graphql.FieldContext{ 2039 | Index: &i, 2040 | Result: &v[i], 2041 | } 2042 | ctx := graphql.WithFieldContext(ctx, fc) 2043 | f := func(i int) { 2044 | defer func() { 2045 | if r := recover(); r != nil { 2046 | ec.Error(ctx, ec.Recover(ctx, r)) 2047 | ret = nil 2048 | } 2049 | }() 2050 | if !isLen1 { 2051 | defer wg.Done() 2052 | } 2053 | ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) 2054 | } 2055 | if isLen1 { 2056 | f(i) 2057 | } else { 2058 | go f(i) 2059 | } 2060 | 2061 | } 2062 | wg.Wait() 2063 | return ret 2064 | } 2065 | 2066 | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { 2067 | if v == nil { 2068 | return graphql.Null 2069 | } 2070 | ret := make(graphql.Array, len(v)) 2071 | var wg sync.WaitGroup 2072 | isLen1 := len(v) == 1 2073 | if !isLen1 { 2074 | wg.Add(len(v)) 2075 | } 2076 | for i := range v { 2077 | i := i 2078 | fc := &graphql.FieldContext{ 2079 | Index: &i, 2080 | Result: &v[i], 2081 | } 2082 | ctx := graphql.WithFieldContext(ctx, fc) 2083 | f := func(i int) { 2084 | defer func() { 2085 | if r := recover(); r != nil { 2086 | ec.Error(ctx, ec.Recover(ctx, r)) 2087 | ret = nil 2088 | } 2089 | }() 2090 | if !isLen1 { 2091 | defer wg.Done() 2092 | } 2093 | ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) 2094 | } 2095 | if isLen1 { 2096 | f(i) 2097 | } else { 2098 | go f(i) 2099 | } 2100 | 2101 | } 2102 | wg.Wait() 2103 | return ret 2104 | } 2105 | 2106 | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { 2107 | if v == nil { 2108 | return graphql.Null 2109 | } 2110 | return ec.___Schema(ctx, sel, v) 2111 | } 2112 | 2113 | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { 2114 | if v == nil { 2115 | return graphql.Null 2116 | } 2117 | ret := make(graphql.Array, len(v)) 2118 | var wg sync.WaitGroup 2119 | isLen1 := len(v) == 1 2120 | if !isLen1 { 2121 | wg.Add(len(v)) 2122 | } 2123 | for i := range v { 2124 | i := i 2125 | fc := &graphql.FieldContext{ 2126 | Index: &i, 2127 | Result: &v[i], 2128 | } 2129 | ctx := graphql.WithFieldContext(ctx, fc) 2130 | f := func(i int) { 2131 | defer func() { 2132 | if r := recover(); r != nil { 2133 | ec.Error(ctx, ec.Recover(ctx, r)) 2134 | ret = nil 2135 | } 2136 | }() 2137 | if !isLen1 { 2138 | defer wg.Done() 2139 | } 2140 | ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) 2141 | } 2142 | if isLen1 { 2143 | f(i) 2144 | } else { 2145 | go f(i) 2146 | } 2147 | 2148 | } 2149 | wg.Wait() 2150 | return ret 2151 | } 2152 | 2153 | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { 2154 | if v == nil { 2155 | return graphql.Null 2156 | } 2157 | return ec.___Type(ctx, sel, v) 2158 | } 2159 | 2160 | // endregion ***************************** type.gotpl ***************************** 2161 | -------------------------------------------------------------------------------- /golang/fastgqlgen/go.mod: -------------------------------------------------------------------------------- 1 | module golang-graphql-benchmark/fastgqlgn 2 | 3 | go 1.15 4 | 5 | replace github.com/99designs/gqlgen v0.13.0 => github.com/arsmn/gqlgen v0.13.2 6 | 7 | require ( 8 | github.com/99designs/gqlgen v0.13.0 9 | github.com/gofiber/fiber/v2 v2.0.6 10 | github.com/vektah/gqlparser/v2 v2.1.0 11 | github.com/valyala/fasthttp v1.16.0 12 | ) 13 | -------------------------------------------------------------------------------- /golang/fastgqlgen/go.sum: -------------------------------------------------------------------------------- 1 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 2 | github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= 3 | github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0= 4 | github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= 5 | github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= 6 | github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4= 7 | github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= 8 | github.com/appleboy/golang-graphql-benchmark v0.0.0-20200927150445-5a207ff8371a h1:ijiEnh7+//LMik8FplvJF9hIxhrwBsypKnXevcAxLSs= 9 | github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= 10 | github.com/arsmn/gqlgen v0.13.2 h1:TOwFTV1S3+vP80oBjMChaaoVzc1V4ckHC9Tc07VFBmo= 11 | github.com/arsmn/gqlgen v0.13.2/go.mod h1:8fP14/dpXCBGBACXFx/n2/l+MshB8jJHA0Vd5PIl+Qo= 12 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= 13 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 16 | github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= 17 | github.com/fasthttp/websocket v1.4.3 h1:qjhRJ/rTy4KB8oBxljEC00SDt6HUY9jLRfM601SUdS4= 18 | github.com/fasthttp/websocket v1.4.3/go.mod h1:5r4oKssgS7W6Zn6mPWap3NWzNPJNzUUh3baWTOhcYQk= 19 | github.com/gofiber/fiber/v2 v2.0.6 h1:eq1LGUM8arRCWxjQPvQzJJIRKDsc7Up/kxaSCUP6PIo= 20 | github.com/gofiber/fiber/v2 v2.0.6/go.mod h1:VyfrlfcUCW0TcO5uaLHVlxZ8N25BgwnP6YjkzJmJP24= 21 | github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 22 | github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= 23 | github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 24 | github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= 25 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 26 | github.com/klauspost/compress v1.10.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= 27 | github.com/klauspost/compress v1.10.7 h1:7rix8v8GpI3ZBb0nSozFRgbtXKv+hOe+qfEpZqybrAg= 28 | github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= 29 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 30 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 31 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 32 | github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= 33 | github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= 34 | github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= 35 | github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= 36 | github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5nrJJVjbXiDZcVhOBSzKn3o9LgRLLMRNuru8= 37 | github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 38 | github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= 39 | github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 40 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 41 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 42 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 43 | github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= 44 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 45 | github.com/savsgio/gotils v0.0.0-20200608150037-a5f6f5aef16c h1:2nF5+FZ4/qp7pZVL7fR6DEaSTzuDmNaFTyqp92/hwF8= 46 | github.com/savsgio/gotils v0.0.0-20200608150037-a5f6f5aef16c/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8= 47 | github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 48 | github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= 49 | github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= 50 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 51 | github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= 52 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 53 | github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 54 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 55 | github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k= 56 | github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= 57 | github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= 58 | github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= 59 | github.com/valyala/fasthttp v1.14.0/go.mod h1:ol1PCaL0dX20wC0htZ7sYCsvCYmrouYra0zHzaclZhE= 60 | github.com/valyala/fasthttp v1.16.0 h1:9zAqOYLl8Tuy3E5R6ckzGDJ1g8+pw15oQp2iL9Jl6gQ= 61 | github.com/valyala/fasthttp v1.16.0/go.mod h1:YOKImeEosDdBPnxc0gy7INqi3m1zK6A+xl6TwOBhHCA= 62 | github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a h1:0R4NLDRDZX6JcmhJgXi5E4b8Wg84ihbmUKp/GvSPEzc= 63 | github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= 64 | github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= 65 | github.com/vektah/gqlparser/v2 v2.1.0 h1:uiKJ+T5HMGGQM2kRKQ8Pxw8+Zq9qhhZhz/lieYvCMns= 66 | github.com/vektah/gqlparser/v2 v2.1.0/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= 67 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 68 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 69 | golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 70 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 71 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 72 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 73 | golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 74 | golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 75 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 76 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 77 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 78 | golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 79 | golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 80 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 81 | golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 82 | golang.org/x/sys v0.0.0-20200929083018-4d22bbb62b3c h1:/h0vtH0PyU0xAoZJVcRw1k0Ng+U0JAy3QDiFmppIlIE= 83 | golang.org/x/sys v0.0.0-20200929083018-4d22bbb62b3c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 84 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 85 | golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 86 | golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 87 | golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589 h1:rjUrONFu4kLchcZTfp3/96bR8bW8dIa8uz3cR5n0cgM= 88 | golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 89 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 90 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 91 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 92 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 93 | gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= 94 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 95 | sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= 96 | sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= 97 | -------------------------------------------------------------------------------- /golang/fastgqlgen/gqlgen.yml: -------------------------------------------------------------------------------- 1 | schema: 2 | - schema.graphql 3 | exec: 4 | filename: generated.go 5 | model: 6 | filename: models_gen.go 7 | resolver: 8 | filename: resolver.go 9 | type: Resolver -------------------------------------------------------------------------------- /golang/fastgqlgen/resolver.go: -------------------------------------------------------------------------------- 1 | package fastgqlgen 2 | 3 | // THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. 4 | 5 | import ( 6 | "context" 7 | ) 8 | 9 | type Resolver struct{} 10 | 11 | func (r *queryResolver) Hello(ctx context.Context) (string, error) { 12 | return "world", nil 13 | } 14 | 15 | // Query returns QueryResolver implementation. 16 | func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } 17 | 18 | type queryResolver struct{ *Resolver } 19 | -------------------------------------------------------------------------------- /golang/fastgqlgen/schema.graphql: -------------------------------------------------------------------------------- 1 | type Query { 2 | hello: String! 3 | } 4 | -------------------------------------------------------------------------------- /golang/gin-json/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "github.com/gin-gonic/gin" 8 | ) 9 | 10 | // Data Binding from JSON 11 | type Data struct { 12 | Hello string `form:"hello" json:"hello" xml:"hello" binding:"required"` 13 | } 14 | 15 | func main() { 16 | 17 | r := gin.New() 18 | r.POST("/graphql", func(c *gin.Context) { 19 | var json Data 20 | if err := c.ShouldBindJSON(&json); err != nil { 21 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) 22 | return 23 | } 24 | 25 | c.JSON(http.StatusOK, gin.H{ 26 | "data": gin.H{ 27 | "hello": json.Hello, 28 | }, 29 | }) 30 | }) 31 | 32 | fmt.Println("Now server is running on port 8080") 33 | r.Run() // listen and serve on 0.0.0.0:8080 34 | } 35 | -------------------------------------------------------------------------------- /golang/gqlgen/generated.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 | 3 | package gqlgen 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 | gqlparser "github.com/vektah/gqlparser/v2" 16 | "github.com/vektah/gqlparser/v2/ast" 17 | ) 18 | 19 | // region ************************** generated!.gotpl ************************** 20 | 21 | // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. 22 | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { 23 | return &executableSchema{ 24 | resolvers: cfg.Resolvers, 25 | directives: cfg.Directives, 26 | complexity: cfg.Complexity, 27 | } 28 | } 29 | 30 | type Config struct { 31 | Resolvers ResolverRoot 32 | Directives DirectiveRoot 33 | Complexity ComplexityRoot 34 | } 35 | 36 | type ResolverRoot interface { 37 | Query() QueryResolver 38 | } 39 | 40 | type DirectiveRoot struct { 41 | } 42 | 43 | type ComplexityRoot struct { 44 | Query struct { 45 | Hello func(childComplexity int) int 46 | } 47 | } 48 | 49 | type QueryResolver interface { 50 | Hello(ctx context.Context) (string, error) 51 | } 52 | 53 | type executableSchema struct { 54 | resolvers ResolverRoot 55 | directives DirectiveRoot 56 | complexity ComplexityRoot 57 | } 58 | 59 | func (e *executableSchema) Schema() *ast.Schema { 60 | return parsedSchema 61 | } 62 | 63 | func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { 64 | ec := executionContext{nil, e} 65 | _ = ec 66 | switch typeName + "." + field { 67 | 68 | case "Query.hello": 69 | if e.complexity.Query.Hello == nil { 70 | break 71 | } 72 | 73 | return e.complexity.Query.Hello(childComplexity), true 74 | 75 | } 76 | return 0, false 77 | } 78 | 79 | func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { 80 | rc := graphql.GetOperationContext(ctx) 81 | ec := executionContext{rc, e} 82 | first := true 83 | 84 | switch rc.Operation.Operation { 85 | case ast.Query: 86 | return func(ctx context.Context) *graphql.Response { 87 | if !first { 88 | return nil 89 | } 90 | first = false 91 | data := ec._Query(ctx, rc.Operation.SelectionSet) 92 | var buf bytes.Buffer 93 | data.MarshalGQL(&buf) 94 | 95 | return &graphql.Response{ 96 | Data: buf.Bytes(), 97 | } 98 | } 99 | 100 | default: 101 | return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) 102 | } 103 | } 104 | 105 | type executionContext struct { 106 | *graphql.OperationContext 107 | *executableSchema 108 | } 109 | 110 | func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { 111 | if ec.DisableIntrospection { 112 | return nil, errors.New("introspection disabled") 113 | } 114 | return introspection.WrapSchema(parsedSchema), nil 115 | } 116 | 117 | func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { 118 | if ec.DisableIntrospection { 119 | return nil, errors.New("introspection disabled") 120 | } 121 | return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil 122 | } 123 | 124 | var sources = []*ast.Source{ 125 | &ast.Source{Name: "schema.graphql", Input: `type Query { 126 | hello: String! 127 | } 128 | `, BuiltIn: false}, 129 | } 130 | var parsedSchema = gqlparser.MustLoadSchema(sources...) 131 | 132 | // endregion ************************** generated!.gotpl ************************** 133 | 134 | // region ***************************** args.gotpl ***************************** 135 | 136 | func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 137 | var err error 138 | args := map[string]interface{}{} 139 | var arg0 string 140 | if tmp, ok := rawArgs["name"]; ok { 141 | arg0, err = ec.unmarshalNString2string(ctx, tmp) 142 | if err != nil { 143 | return nil, err 144 | } 145 | } 146 | args["name"] = arg0 147 | return args, nil 148 | } 149 | 150 | func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 151 | var err error 152 | args := map[string]interface{}{} 153 | var arg0 bool 154 | if tmp, ok := rawArgs["includeDeprecated"]; ok { 155 | arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) 156 | if err != nil { 157 | return nil, err 158 | } 159 | } 160 | args["includeDeprecated"] = arg0 161 | return args, nil 162 | } 163 | 164 | func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 165 | var err error 166 | args := map[string]interface{}{} 167 | var arg0 bool 168 | if tmp, ok := rawArgs["includeDeprecated"]; ok { 169 | arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) 170 | if err != nil { 171 | return nil, err 172 | } 173 | } 174 | args["includeDeprecated"] = arg0 175 | return args, nil 176 | } 177 | 178 | // endregion ***************************** args.gotpl ***************************** 179 | 180 | // region ************************** directives.gotpl ************************** 181 | 182 | // endregion ************************** directives.gotpl ************************** 183 | 184 | // region **************************** field.gotpl ***************************** 185 | 186 | func (ec *executionContext) _Query_hello(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 187 | defer func() { 188 | if r := recover(); r != nil { 189 | ec.Error(ctx, ec.Recover(ctx, r)) 190 | ret = graphql.Null 191 | } 192 | }() 193 | fc := &graphql.FieldContext{ 194 | Object: "Query", 195 | Field: field, 196 | Args: nil, 197 | IsMethod: true, 198 | } 199 | 200 | ctx = graphql.WithFieldContext(ctx, fc) 201 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 202 | ctx = rctx // use context from middleware stack in children 203 | return ec.resolvers.Query().Hello(rctx) 204 | }) 205 | if err != nil { 206 | ec.Error(ctx, err) 207 | return graphql.Null 208 | } 209 | if resTmp == nil { 210 | if !graphql.HasFieldError(ctx, fc) { 211 | ec.Errorf(ctx, "must not be null") 212 | } 213 | return graphql.Null 214 | } 215 | res := resTmp.(string) 216 | fc.Result = res 217 | return ec.marshalNString2string(ctx, field.Selections, res) 218 | } 219 | 220 | func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 221 | defer func() { 222 | if r := recover(); r != nil { 223 | ec.Error(ctx, ec.Recover(ctx, r)) 224 | ret = graphql.Null 225 | } 226 | }() 227 | fc := &graphql.FieldContext{ 228 | Object: "Query", 229 | Field: field, 230 | Args: nil, 231 | IsMethod: true, 232 | } 233 | 234 | ctx = graphql.WithFieldContext(ctx, fc) 235 | rawArgs := field.ArgumentMap(ec.Variables) 236 | args, err := ec.field_Query___type_args(ctx, rawArgs) 237 | if err != nil { 238 | ec.Error(ctx, err) 239 | return graphql.Null 240 | } 241 | fc.Args = args 242 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 243 | ctx = rctx // use context from middleware stack in children 244 | return ec.introspectType(args["name"].(string)) 245 | }) 246 | if err != nil { 247 | ec.Error(ctx, err) 248 | return graphql.Null 249 | } 250 | if resTmp == nil { 251 | return graphql.Null 252 | } 253 | res := resTmp.(*introspection.Type) 254 | fc.Result = res 255 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 256 | } 257 | 258 | func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 259 | defer func() { 260 | if r := recover(); r != nil { 261 | ec.Error(ctx, ec.Recover(ctx, r)) 262 | ret = graphql.Null 263 | } 264 | }() 265 | fc := &graphql.FieldContext{ 266 | Object: "Query", 267 | Field: field, 268 | Args: nil, 269 | IsMethod: true, 270 | } 271 | 272 | ctx = graphql.WithFieldContext(ctx, fc) 273 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 274 | ctx = rctx // use context from middleware stack in children 275 | return ec.introspectSchema() 276 | }) 277 | if err != nil { 278 | ec.Error(ctx, err) 279 | return graphql.Null 280 | } 281 | if resTmp == nil { 282 | return graphql.Null 283 | } 284 | res := resTmp.(*introspection.Schema) 285 | fc.Result = res 286 | return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) 287 | } 288 | 289 | func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 290 | defer func() { 291 | if r := recover(); r != nil { 292 | ec.Error(ctx, ec.Recover(ctx, r)) 293 | ret = graphql.Null 294 | } 295 | }() 296 | fc := &graphql.FieldContext{ 297 | Object: "__Directive", 298 | Field: field, 299 | Args: nil, 300 | IsMethod: false, 301 | } 302 | 303 | ctx = graphql.WithFieldContext(ctx, fc) 304 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 305 | ctx = rctx // use context from middleware stack in children 306 | return obj.Name, nil 307 | }) 308 | if err != nil { 309 | ec.Error(ctx, err) 310 | return graphql.Null 311 | } 312 | if resTmp == nil { 313 | if !graphql.HasFieldError(ctx, fc) { 314 | ec.Errorf(ctx, "must not be null") 315 | } 316 | return graphql.Null 317 | } 318 | res := resTmp.(string) 319 | fc.Result = res 320 | return ec.marshalNString2string(ctx, field.Selections, res) 321 | } 322 | 323 | func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 324 | defer func() { 325 | if r := recover(); r != nil { 326 | ec.Error(ctx, ec.Recover(ctx, r)) 327 | ret = graphql.Null 328 | } 329 | }() 330 | fc := &graphql.FieldContext{ 331 | Object: "__Directive", 332 | Field: field, 333 | Args: nil, 334 | IsMethod: false, 335 | } 336 | 337 | ctx = graphql.WithFieldContext(ctx, fc) 338 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 339 | ctx = rctx // use context from middleware stack in children 340 | return obj.Description, nil 341 | }) 342 | if err != nil { 343 | ec.Error(ctx, err) 344 | return graphql.Null 345 | } 346 | if resTmp == nil { 347 | return graphql.Null 348 | } 349 | res := resTmp.(string) 350 | fc.Result = res 351 | return ec.marshalOString2string(ctx, field.Selections, res) 352 | } 353 | 354 | func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 355 | defer func() { 356 | if r := recover(); r != nil { 357 | ec.Error(ctx, ec.Recover(ctx, r)) 358 | ret = graphql.Null 359 | } 360 | }() 361 | fc := &graphql.FieldContext{ 362 | Object: "__Directive", 363 | Field: field, 364 | Args: nil, 365 | IsMethod: false, 366 | } 367 | 368 | ctx = graphql.WithFieldContext(ctx, fc) 369 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 370 | ctx = rctx // use context from middleware stack in children 371 | return obj.Locations, nil 372 | }) 373 | if err != nil { 374 | ec.Error(ctx, err) 375 | return graphql.Null 376 | } 377 | if resTmp == nil { 378 | if !graphql.HasFieldError(ctx, fc) { 379 | ec.Errorf(ctx, "must not be null") 380 | } 381 | return graphql.Null 382 | } 383 | res := resTmp.([]string) 384 | fc.Result = res 385 | return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) 386 | } 387 | 388 | func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 389 | defer func() { 390 | if r := recover(); r != nil { 391 | ec.Error(ctx, ec.Recover(ctx, r)) 392 | ret = graphql.Null 393 | } 394 | }() 395 | fc := &graphql.FieldContext{ 396 | Object: "__Directive", 397 | Field: field, 398 | Args: nil, 399 | IsMethod: false, 400 | } 401 | 402 | ctx = graphql.WithFieldContext(ctx, fc) 403 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 404 | ctx = rctx // use context from middleware stack in children 405 | return obj.Args, nil 406 | }) 407 | if err != nil { 408 | ec.Error(ctx, err) 409 | return graphql.Null 410 | } 411 | if resTmp == nil { 412 | if !graphql.HasFieldError(ctx, fc) { 413 | ec.Errorf(ctx, "must not be null") 414 | } 415 | return graphql.Null 416 | } 417 | res := resTmp.([]introspection.InputValue) 418 | fc.Result = res 419 | return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 420 | } 421 | 422 | func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 423 | defer func() { 424 | if r := recover(); r != nil { 425 | ec.Error(ctx, ec.Recover(ctx, r)) 426 | ret = graphql.Null 427 | } 428 | }() 429 | fc := &graphql.FieldContext{ 430 | Object: "__EnumValue", 431 | Field: field, 432 | Args: nil, 433 | IsMethod: false, 434 | } 435 | 436 | ctx = graphql.WithFieldContext(ctx, fc) 437 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 438 | ctx = rctx // use context from middleware stack in children 439 | return obj.Name, nil 440 | }) 441 | if err != nil { 442 | ec.Error(ctx, err) 443 | return graphql.Null 444 | } 445 | if resTmp == nil { 446 | if !graphql.HasFieldError(ctx, fc) { 447 | ec.Errorf(ctx, "must not be null") 448 | } 449 | return graphql.Null 450 | } 451 | res := resTmp.(string) 452 | fc.Result = res 453 | return ec.marshalNString2string(ctx, field.Selections, res) 454 | } 455 | 456 | func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 457 | defer func() { 458 | if r := recover(); r != nil { 459 | ec.Error(ctx, ec.Recover(ctx, r)) 460 | ret = graphql.Null 461 | } 462 | }() 463 | fc := &graphql.FieldContext{ 464 | Object: "__EnumValue", 465 | Field: field, 466 | Args: nil, 467 | IsMethod: false, 468 | } 469 | 470 | ctx = graphql.WithFieldContext(ctx, fc) 471 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 472 | ctx = rctx // use context from middleware stack in children 473 | return obj.Description, nil 474 | }) 475 | if err != nil { 476 | ec.Error(ctx, err) 477 | return graphql.Null 478 | } 479 | if resTmp == nil { 480 | return graphql.Null 481 | } 482 | res := resTmp.(string) 483 | fc.Result = res 484 | return ec.marshalOString2string(ctx, field.Selections, res) 485 | } 486 | 487 | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 488 | defer func() { 489 | if r := recover(); r != nil { 490 | ec.Error(ctx, ec.Recover(ctx, r)) 491 | ret = graphql.Null 492 | } 493 | }() 494 | fc := &graphql.FieldContext{ 495 | Object: "__EnumValue", 496 | Field: field, 497 | Args: nil, 498 | IsMethod: true, 499 | } 500 | 501 | ctx = graphql.WithFieldContext(ctx, fc) 502 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 503 | ctx = rctx // use context from middleware stack in children 504 | return obj.IsDeprecated(), nil 505 | }) 506 | if err != nil { 507 | ec.Error(ctx, err) 508 | return graphql.Null 509 | } 510 | if resTmp == nil { 511 | if !graphql.HasFieldError(ctx, fc) { 512 | ec.Errorf(ctx, "must not be null") 513 | } 514 | return graphql.Null 515 | } 516 | res := resTmp.(bool) 517 | fc.Result = res 518 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 519 | } 520 | 521 | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 522 | defer func() { 523 | if r := recover(); r != nil { 524 | ec.Error(ctx, ec.Recover(ctx, r)) 525 | ret = graphql.Null 526 | } 527 | }() 528 | fc := &graphql.FieldContext{ 529 | Object: "__EnumValue", 530 | Field: field, 531 | Args: nil, 532 | IsMethod: true, 533 | } 534 | 535 | ctx = graphql.WithFieldContext(ctx, fc) 536 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 537 | ctx = rctx // use context from middleware stack in children 538 | return obj.DeprecationReason(), nil 539 | }) 540 | if err != nil { 541 | ec.Error(ctx, err) 542 | return graphql.Null 543 | } 544 | if resTmp == nil { 545 | return graphql.Null 546 | } 547 | res := resTmp.(*string) 548 | fc.Result = res 549 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 550 | } 551 | 552 | func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 553 | defer func() { 554 | if r := recover(); r != nil { 555 | ec.Error(ctx, ec.Recover(ctx, r)) 556 | ret = graphql.Null 557 | } 558 | }() 559 | fc := &graphql.FieldContext{ 560 | Object: "__Field", 561 | Field: field, 562 | Args: nil, 563 | IsMethod: false, 564 | } 565 | 566 | ctx = graphql.WithFieldContext(ctx, fc) 567 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 568 | ctx = rctx // use context from middleware stack in children 569 | return obj.Name, nil 570 | }) 571 | if err != nil { 572 | ec.Error(ctx, err) 573 | return graphql.Null 574 | } 575 | if resTmp == nil { 576 | if !graphql.HasFieldError(ctx, fc) { 577 | ec.Errorf(ctx, "must not be null") 578 | } 579 | return graphql.Null 580 | } 581 | res := resTmp.(string) 582 | fc.Result = res 583 | return ec.marshalNString2string(ctx, field.Selections, res) 584 | } 585 | 586 | func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 587 | defer func() { 588 | if r := recover(); r != nil { 589 | ec.Error(ctx, ec.Recover(ctx, r)) 590 | ret = graphql.Null 591 | } 592 | }() 593 | fc := &graphql.FieldContext{ 594 | Object: "__Field", 595 | Field: field, 596 | Args: nil, 597 | IsMethod: false, 598 | } 599 | 600 | ctx = graphql.WithFieldContext(ctx, fc) 601 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 602 | ctx = rctx // use context from middleware stack in children 603 | return obj.Description, nil 604 | }) 605 | if err != nil { 606 | ec.Error(ctx, err) 607 | return graphql.Null 608 | } 609 | if resTmp == nil { 610 | return graphql.Null 611 | } 612 | res := resTmp.(string) 613 | fc.Result = res 614 | return ec.marshalOString2string(ctx, field.Selections, res) 615 | } 616 | 617 | func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 618 | defer func() { 619 | if r := recover(); r != nil { 620 | ec.Error(ctx, ec.Recover(ctx, r)) 621 | ret = graphql.Null 622 | } 623 | }() 624 | fc := &graphql.FieldContext{ 625 | Object: "__Field", 626 | Field: field, 627 | Args: nil, 628 | IsMethod: false, 629 | } 630 | 631 | ctx = graphql.WithFieldContext(ctx, fc) 632 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 633 | ctx = rctx // use context from middleware stack in children 634 | return obj.Args, nil 635 | }) 636 | if err != nil { 637 | ec.Error(ctx, err) 638 | return graphql.Null 639 | } 640 | if resTmp == nil { 641 | if !graphql.HasFieldError(ctx, fc) { 642 | ec.Errorf(ctx, "must not be null") 643 | } 644 | return graphql.Null 645 | } 646 | res := resTmp.([]introspection.InputValue) 647 | fc.Result = res 648 | return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 649 | } 650 | 651 | func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 652 | defer func() { 653 | if r := recover(); r != nil { 654 | ec.Error(ctx, ec.Recover(ctx, r)) 655 | ret = graphql.Null 656 | } 657 | }() 658 | fc := &graphql.FieldContext{ 659 | Object: "__Field", 660 | Field: field, 661 | Args: nil, 662 | IsMethod: false, 663 | } 664 | 665 | ctx = graphql.WithFieldContext(ctx, fc) 666 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 667 | ctx = rctx // use context from middleware stack in children 668 | return obj.Type, nil 669 | }) 670 | if err != nil { 671 | ec.Error(ctx, err) 672 | return graphql.Null 673 | } 674 | if resTmp == nil { 675 | if !graphql.HasFieldError(ctx, fc) { 676 | ec.Errorf(ctx, "must not be null") 677 | } 678 | return graphql.Null 679 | } 680 | res := resTmp.(*introspection.Type) 681 | fc.Result = res 682 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 683 | } 684 | 685 | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 686 | defer func() { 687 | if r := recover(); r != nil { 688 | ec.Error(ctx, ec.Recover(ctx, r)) 689 | ret = graphql.Null 690 | } 691 | }() 692 | fc := &graphql.FieldContext{ 693 | Object: "__Field", 694 | Field: field, 695 | Args: nil, 696 | IsMethod: true, 697 | } 698 | 699 | ctx = graphql.WithFieldContext(ctx, fc) 700 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 701 | ctx = rctx // use context from middleware stack in children 702 | return obj.IsDeprecated(), nil 703 | }) 704 | if err != nil { 705 | ec.Error(ctx, err) 706 | return graphql.Null 707 | } 708 | if resTmp == nil { 709 | if !graphql.HasFieldError(ctx, fc) { 710 | ec.Errorf(ctx, "must not be null") 711 | } 712 | return graphql.Null 713 | } 714 | res := resTmp.(bool) 715 | fc.Result = res 716 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 717 | } 718 | 719 | func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 720 | defer func() { 721 | if r := recover(); r != nil { 722 | ec.Error(ctx, ec.Recover(ctx, r)) 723 | ret = graphql.Null 724 | } 725 | }() 726 | fc := &graphql.FieldContext{ 727 | Object: "__Field", 728 | Field: field, 729 | Args: nil, 730 | IsMethod: true, 731 | } 732 | 733 | ctx = graphql.WithFieldContext(ctx, fc) 734 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 735 | ctx = rctx // use context from middleware stack in children 736 | return obj.DeprecationReason(), nil 737 | }) 738 | if err != nil { 739 | ec.Error(ctx, err) 740 | return graphql.Null 741 | } 742 | if resTmp == nil { 743 | return graphql.Null 744 | } 745 | res := resTmp.(*string) 746 | fc.Result = res 747 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 748 | } 749 | 750 | func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 751 | defer func() { 752 | if r := recover(); r != nil { 753 | ec.Error(ctx, ec.Recover(ctx, r)) 754 | ret = graphql.Null 755 | } 756 | }() 757 | fc := &graphql.FieldContext{ 758 | Object: "__InputValue", 759 | Field: field, 760 | Args: nil, 761 | IsMethod: false, 762 | } 763 | 764 | ctx = graphql.WithFieldContext(ctx, fc) 765 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 766 | ctx = rctx // use context from middleware stack in children 767 | return obj.Name, nil 768 | }) 769 | if err != nil { 770 | ec.Error(ctx, err) 771 | return graphql.Null 772 | } 773 | if resTmp == nil { 774 | if !graphql.HasFieldError(ctx, fc) { 775 | ec.Errorf(ctx, "must not be null") 776 | } 777 | return graphql.Null 778 | } 779 | res := resTmp.(string) 780 | fc.Result = res 781 | return ec.marshalNString2string(ctx, field.Selections, res) 782 | } 783 | 784 | func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (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: "__InputValue", 793 | Field: field, 794 | Args: nil, 795 | IsMethod: false, 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 obj.Description, nil 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.(string) 811 | fc.Result = res 812 | return ec.marshalOString2string(ctx, field.Selections, res) 813 | } 814 | 815 | func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (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: "__InputValue", 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.Type, 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.(*introspection.Type) 845 | fc.Result = res 846 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 847 | } 848 | 849 | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (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: "__InputValue", 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.DefaultValue, nil 867 | }) 868 | if err != nil { 869 | ec.Error(ctx, err) 870 | return graphql.Null 871 | } 872 | if resTmp == nil { 873 | return graphql.Null 874 | } 875 | res := resTmp.(*string) 876 | fc.Result = res 877 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 878 | } 879 | 880 | func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 881 | defer func() { 882 | if r := recover(); r != nil { 883 | ec.Error(ctx, ec.Recover(ctx, r)) 884 | ret = graphql.Null 885 | } 886 | }() 887 | fc := &graphql.FieldContext{ 888 | Object: "__Schema", 889 | Field: field, 890 | Args: nil, 891 | IsMethod: true, 892 | } 893 | 894 | ctx = graphql.WithFieldContext(ctx, fc) 895 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 896 | ctx = rctx // use context from middleware stack in children 897 | return obj.Types(), nil 898 | }) 899 | if err != nil { 900 | ec.Error(ctx, err) 901 | return graphql.Null 902 | } 903 | if resTmp == nil { 904 | if !graphql.HasFieldError(ctx, fc) { 905 | ec.Errorf(ctx, "must not be null") 906 | } 907 | return graphql.Null 908 | } 909 | res := resTmp.([]introspection.Type) 910 | fc.Result = res 911 | return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 912 | } 913 | 914 | func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 915 | defer func() { 916 | if r := recover(); r != nil { 917 | ec.Error(ctx, ec.Recover(ctx, r)) 918 | ret = graphql.Null 919 | } 920 | }() 921 | fc := &graphql.FieldContext{ 922 | Object: "__Schema", 923 | Field: field, 924 | Args: nil, 925 | IsMethod: true, 926 | } 927 | 928 | ctx = graphql.WithFieldContext(ctx, fc) 929 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 930 | ctx = rctx // use context from middleware stack in children 931 | return obj.QueryType(), nil 932 | }) 933 | if err != nil { 934 | ec.Error(ctx, err) 935 | return graphql.Null 936 | } 937 | if resTmp == nil { 938 | if !graphql.HasFieldError(ctx, fc) { 939 | ec.Errorf(ctx, "must not be null") 940 | } 941 | return graphql.Null 942 | } 943 | res := resTmp.(*introspection.Type) 944 | fc.Result = res 945 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 946 | } 947 | 948 | func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (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: "__Schema", 957 | Field: field, 958 | Args: nil, 959 | IsMethod: true, 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.MutationType(), nil 966 | }) 967 | if err != nil { 968 | ec.Error(ctx, err) 969 | return graphql.Null 970 | } 971 | if resTmp == nil { 972 | return graphql.Null 973 | } 974 | res := resTmp.(*introspection.Type) 975 | fc.Result = res 976 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 977 | } 978 | 979 | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 980 | defer func() { 981 | if r := recover(); r != nil { 982 | ec.Error(ctx, ec.Recover(ctx, r)) 983 | ret = graphql.Null 984 | } 985 | }() 986 | fc := &graphql.FieldContext{ 987 | Object: "__Schema", 988 | Field: field, 989 | Args: nil, 990 | IsMethod: true, 991 | } 992 | 993 | ctx = graphql.WithFieldContext(ctx, fc) 994 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 995 | ctx = rctx // use context from middleware stack in children 996 | return obj.SubscriptionType(), nil 997 | }) 998 | if err != nil { 999 | ec.Error(ctx, err) 1000 | return graphql.Null 1001 | } 1002 | if resTmp == nil { 1003 | return graphql.Null 1004 | } 1005 | res := resTmp.(*introspection.Type) 1006 | fc.Result = res 1007 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1008 | } 1009 | 1010 | func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 1011 | defer func() { 1012 | if r := recover(); r != nil { 1013 | ec.Error(ctx, ec.Recover(ctx, r)) 1014 | ret = graphql.Null 1015 | } 1016 | }() 1017 | fc := &graphql.FieldContext{ 1018 | Object: "__Schema", 1019 | Field: field, 1020 | Args: nil, 1021 | IsMethod: true, 1022 | } 1023 | 1024 | ctx = graphql.WithFieldContext(ctx, fc) 1025 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1026 | ctx = rctx // use context from middleware stack in children 1027 | return obj.Directives(), nil 1028 | }) 1029 | if err != nil { 1030 | ec.Error(ctx, err) 1031 | return graphql.Null 1032 | } 1033 | if resTmp == nil { 1034 | if !graphql.HasFieldError(ctx, fc) { 1035 | ec.Errorf(ctx, "must not be null") 1036 | } 1037 | return graphql.Null 1038 | } 1039 | res := resTmp.([]introspection.Directive) 1040 | fc.Result = res 1041 | return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) 1042 | } 1043 | 1044 | func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1045 | defer func() { 1046 | if r := recover(); r != nil { 1047 | ec.Error(ctx, ec.Recover(ctx, r)) 1048 | ret = graphql.Null 1049 | } 1050 | }() 1051 | fc := &graphql.FieldContext{ 1052 | Object: "__Type", 1053 | Field: field, 1054 | Args: nil, 1055 | IsMethod: true, 1056 | } 1057 | 1058 | ctx = graphql.WithFieldContext(ctx, fc) 1059 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1060 | ctx = rctx // use context from middleware stack in children 1061 | return obj.Kind(), nil 1062 | }) 1063 | if err != nil { 1064 | ec.Error(ctx, err) 1065 | return graphql.Null 1066 | } 1067 | if resTmp == nil { 1068 | if !graphql.HasFieldError(ctx, fc) { 1069 | ec.Errorf(ctx, "must not be null") 1070 | } 1071 | return graphql.Null 1072 | } 1073 | res := resTmp.(string) 1074 | fc.Result = res 1075 | return ec.marshalN__TypeKind2string(ctx, field.Selections, res) 1076 | } 1077 | 1078 | func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1079 | defer func() { 1080 | if r := recover(); r != nil { 1081 | ec.Error(ctx, ec.Recover(ctx, r)) 1082 | ret = graphql.Null 1083 | } 1084 | }() 1085 | fc := &graphql.FieldContext{ 1086 | Object: "__Type", 1087 | Field: field, 1088 | Args: nil, 1089 | IsMethod: true, 1090 | } 1091 | 1092 | ctx = graphql.WithFieldContext(ctx, fc) 1093 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1094 | ctx = rctx // use context from middleware stack in children 1095 | return obj.Name(), nil 1096 | }) 1097 | if err != nil { 1098 | ec.Error(ctx, err) 1099 | return graphql.Null 1100 | } 1101 | if resTmp == nil { 1102 | return graphql.Null 1103 | } 1104 | res := resTmp.(*string) 1105 | fc.Result = res 1106 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1107 | } 1108 | 1109 | func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1110 | defer func() { 1111 | if r := recover(); r != nil { 1112 | ec.Error(ctx, ec.Recover(ctx, r)) 1113 | ret = graphql.Null 1114 | } 1115 | }() 1116 | fc := &graphql.FieldContext{ 1117 | Object: "__Type", 1118 | Field: field, 1119 | Args: nil, 1120 | IsMethod: true, 1121 | } 1122 | 1123 | ctx = graphql.WithFieldContext(ctx, fc) 1124 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1125 | ctx = rctx // use context from middleware stack in children 1126 | return obj.Description(), nil 1127 | }) 1128 | if err != nil { 1129 | ec.Error(ctx, err) 1130 | return graphql.Null 1131 | } 1132 | if resTmp == nil { 1133 | return graphql.Null 1134 | } 1135 | res := resTmp.(string) 1136 | fc.Result = res 1137 | return ec.marshalOString2string(ctx, field.Selections, res) 1138 | } 1139 | 1140 | func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1141 | defer func() { 1142 | if r := recover(); r != nil { 1143 | ec.Error(ctx, ec.Recover(ctx, r)) 1144 | ret = graphql.Null 1145 | } 1146 | }() 1147 | fc := &graphql.FieldContext{ 1148 | Object: "__Type", 1149 | Field: field, 1150 | Args: nil, 1151 | IsMethod: true, 1152 | } 1153 | 1154 | ctx = graphql.WithFieldContext(ctx, fc) 1155 | rawArgs := field.ArgumentMap(ec.Variables) 1156 | args, err := ec.field___Type_fields_args(ctx, rawArgs) 1157 | if err != nil { 1158 | ec.Error(ctx, err) 1159 | return graphql.Null 1160 | } 1161 | fc.Args = args 1162 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1163 | ctx = rctx // use context from middleware stack in children 1164 | return obj.Fields(args["includeDeprecated"].(bool)), nil 1165 | }) 1166 | if err != nil { 1167 | ec.Error(ctx, err) 1168 | return graphql.Null 1169 | } 1170 | if resTmp == nil { 1171 | return graphql.Null 1172 | } 1173 | res := resTmp.([]introspection.Field) 1174 | fc.Result = res 1175 | return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) 1176 | } 1177 | 1178 | func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1179 | defer func() { 1180 | if r := recover(); r != nil { 1181 | ec.Error(ctx, ec.Recover(ctx, r)) 1182 | ret = graphql.Null 1183 | } 1184 | }() 1185 | fc := &graphql.FieldContext{ 1186 | Object: "__Type", 1187 | Field: field, 1188 | Args: nil, 1189 | IsMethod: true, 1190 | } 1191 | 1192 | ctx = graphql.WithFieldContext(ctx, fc) 1193 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1194 | ctx = rctx // use context from middleware stack in children 1195 | return obj.Interfaces(), nil 1196 | }) 1197 | if err != nil { 1198 | ec.Error(ctx, err) 1199 | return graphql.Null 1200 | } 1201 | if resTmp == nil { 1202 | return graphql.Null 1203 | } 1204 | res := resTmp.([]introspection.Type) 1205 | fc.Result = res 1206 | return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 1207 | } 1208 | 1209 | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1210 | defer func() { 1211 | if r := recover(); r != nil { 1212 | ec.Error(ctx, ec.Recover(ctx, r)) 1213 | ret = graphql.Null 1214 | } 1215 | }() 1216 | fc := &graphql.FieldContext{ 1217 | Object: "__Type", 1218 | Field: field, 1219 | Args: nil, 1220 | IsMethod: true, 1221 | } 1222 | 1223 | ctx = graphql.WithFieldContext(ctx, fc) 1224 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1225 | ctx = rctx // use context from middleware stack in children 1226 | return obj.PossibleTypes(), nil 1227 | }) 1228 | if err != nil { 1229 | ec.Error(ctx, err) 1230 | return graphql.Null 1231 | } 1232 | if resTmp == nil { 1233 | return graphql.Null 1234 | } 1235 | res := resTmp.([]introspection.Type) 1236 | fc.Result = res 1237 | return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 1238 | } 1239 | 1240 | func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1241 | defer func() { 1242 | if r := recover(); r != nil { 1243 | ec.Error(ctx, ec.Recover(ctx, r)) 1244 | ret = graphql.Null 1245 | } 1246 | }() 1247 | fc := &graphql.FieldContext{ 1248 | Object: "__Type", 1249 | Field: field, 1250 | Args: nil, 1251 | IsMethod: true, 1252 | } 1253 | 1254 | ctx = graphql.WithFieldContext(ctx, fc) 1255 | rawArgs := field.ArgumentMap(ec.Variables) 1256 | args, err := ec.field___Type_enumValues_args(ctx, rawArgs) 1257 | if err != nil { 1258 | ec.Error(ctx, err) 1259 | return graphql.Null 1260 | } 1261 | fc.Args = args 1262 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1263 | ctx = rctx // use context from middleware stack in children 1264 | return obj.EnumValues(args["includeDeprecated"].(bool)), nil 1265 | }) 1266 | if err != nil { 1267 | ec.Error(ctx, err) 1268 | return graphql.Null 1269 | } 1270 | if resTmp == nil { 1271 | return graphql.Null 1272 | } 1273 | res := resTmp.([]introspection.EnumValue) 1274 | fc.Result = res 1275 | return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) 1276 | } 1277 | 1278 | func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1279 | defer func() { 1280 | if r := recover(); r != nil { 1281 | ec.Error(ctx, ec.Recover(ctx, r)) 1282 | ret = graphql.Null 1283 | } 1284 | }() 1285 | fc := &graphql.FieldContext{ 1286 | Object: "__Type", 1287 | Field: field, 1288 | Args: nil, 1289 | IsMethod: true, 1290 | } 1291 | 1292 | ctx = graphql.WithFieldContext(ctx, fc) 1293 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1294 | ctx = rctx // use context from middleware stack in children 1295 | return obj.InputFields(), nil 1296 | }) 1297 | if err != nil { 1298 | ec.Error(ctx, err) 1299 | return graphql.Null 1300 | } 1301 | if resTmp == nil { 1302 | return graphql.Null 1303 | } 1304 | res := resTmp.([]introspection.InputValue) 1305 | fc.Result = res 1306 | return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 1307 | } 1308 | 1309 | func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 1310 | defer func() { 1311 | if r := recover(); r != nil { 1312 | ec.Error(ctx, ec.Recover(ctx, r)) 1313 | ret = graphql.Null 1314 | } 1315 | }() 1316 | fc := &graphql.FieldContext{ 1317 | Object: "__Type", 1318 | Field: field, 1319 | Args: nil, 1320 | IsMethod: true, 1321 | } 1322 | 1323 | ctx = graphql.WithFieldContext(ctx, fc) 1324 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1325 | ctx = rctx // use context from middleware stack in children 1326 | return obj.OfType(), nil 1327 | }) 1328 | if err != nil { 1329 | ec.Error(ctx, err) 1330 | return graphql.Null 1331 | } 1332 | if resTmp == nil { 1333 | return graphql.Null 1334 | } 1335 | res := resTmp.(*introspection.Type) 1336 | fc.Result = res 1337 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1338 | } 1339 | 1340 | // endregion **************************** field.gotpl ***************************** 1341 | 1342 | // region **************************** input.gotpl ***************************** 1343 | 1344 | // endregion **************************** input.gotpl ***************************** 1345 | 1346 | // region ************************** interface.gotpl *************************** 1347 | 1348 | // endregion ************************** interface.gotpl *************************** 1349 | 1350 | // region **************************** object.gotpl **************************** 1351 | 1352 | var queryImplementors = []string{"Query"} 1353 | 1354 | func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { 1355 | fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) 1356 | 1357 | ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ 1358 | Object: "Query", 1359 | }) 1360 | 1361 | out := graphql.NewFieldSet(fields) 1362 | var invalids uint32 1363 | for i, field := range fields { 1364 | switch field.Name { 1365 | case "__typename": 1366 | out.Values[i] = graphql.MarshalString("Query") 1367 | case "hello": 1368 | field := field 1369 | out.Concurrently(i, func() (res graphql.Marshaler) { 1370 | defer func() { 1371 | if r := recover(); r != nil { 1372 | ec.Error(ctx, ec.Recover(ctx, r)) 1373 | } 1374 | }() 1375 | res = ec._Query_hello(ctx, field) 1376 | if res == graphql.Null { 1377 | atomic.AddUint32(&invalids, 1) 1378 | } 1379 | return res 1380 | }) 1381 | case "__type": 1382 | out.Values[i] = ec._Query___type(ctx, field) 1383 | case "__schema": 1384 | out.Values[i] = ec._Query___schema(ctx, field) 1385 | default: 1386 | panic("unknown field " + strconv.Quote(field.Name)) 1387 | } 1388 | } 1389 | out.Dispatch() 1390 | if invalids > 0 { 1391 | return graphql.Null 1392 | } 1393 | return out 1394 | } 1395 | 1396 | var __DirectiveImplementors = []string{"__Directive"} 1397 | 1398 | func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { 1399 | fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) 1400 | 1401 | out := graphql.NewFieldSet(fields) 1402 | var invalids uint32 1403 | for i, field := range fields { 1404 | switch field.Name { 1405 | case "__typename": 1406 | out.Values[i] = graphql.MarshalString("__Directive") 1407 | case "name": 1408 | out.Values[i] = ec.___Directive_name(ctx, field, obj) 1409 | if out.Values[i] == graphql.Null { 1410 | invalids++ 1411 | } 1412 | case "description": 1413 | out.Values[i] = ec.___Directive_description(ctx, field, obj) 1414 | case "locations": 1415 | out.Values[i] = ec.___Directive_locations(ctx, field, obj) 1416 | if out.Values[i] == graphql.Null { 1417 | invalids++ 1418 | } 1419 | case "args": 1420 | out.Values[i] = ec.___Directive_args(ctx, field, obj) 1421 | if out.Values[i] == graphql.Null { 1422 | invalids++ 1423 | } 1424 | default: 1425 | panic("unknown field " + strconv.Quote(field.Name)) 1426 | } 1427 | } 1428 | out.Dispatch() 1429 | if invalids > 0 { 1430 | return graphql.Null 1431 | } 1432 | return out 1433 | } 1434 | 1435 | var __EnumValueImplementors = []string{"__EnumValue"} 1436 | 1437 | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { 1438 | fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) 1439 | 1440 | out := graphql.NewFieldSet(fields) 1441 | var invalids uint32 1442 | for i, field := range fields { 1443 | switch field.Name { 1444 | case "__typename": 1445 | out.Values[i] = graphql.MarshalString("__EnumValue") 1446 | case "name": 1447 | out.Values[i] = ec.___EnumValue_name(ctx, field, obj) 1448 | if out.Values[i] == graphql.Null { 1449 | invalids++ 1450 | } 1451 | case "description": 1452 | out.Values[i] = ec.___EnumValue_description(ctx, field, obj) 1453 | case "isDeprecated": 1454 | out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) 1455 | if out.Values[i] == graphql.Null { 1456 | invalids++ 1457 | } 1458 | case "deprecationReason": 1459 | out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) 1460 | default: 1461 | panic("unknown field " + strconv.Quote(field.Name)) 1462 | } 1463 | } 1464 | out.Dispatch() 1465 | if invalids > 0 { 1466 | return graphql.Null 1467 | } 1468 | return out 1469 | } 1470 | 1471 | var __FieldImplementors = []string{"__Field"} 1472 | 1473 | func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { 1474 | fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) 1475 | 1476 | out := graphql.NewFieldSet(fields) 1477 | var invalids uint32 1478 | for i, field := range fields { 1479 | switch field.Name { 1480 | case "__typename": 1481 | out.Values[i] = graphql.MarshalString("__Field") 1482 | case "name": 1483 | out.Values[i] = ec.___Field_name(ctx, field, obj) 1484 | if out.Values[i] == graphql.Null { 1485 | invalids++ 1486 | } 1487 | case "description": 1488 | out.Values[i] = ec.___Field_description(ctx, field, obj) 1489 | case "args": 1490 | out.Values[i] = ec.___Field_args(ctx, field, obj) 1491 | if out.Values[i] == graphql.Null { 1492 | invalids++ 1493 | } 1494 | case "type": 1495 | out.Values[i] = ec.___Field_type(ctx, field, obj) 1496 | if out.Values[i] == graphql.Null { 1497 | invalids++ 1498 | } 1499 | case "isDeprecated": 1500 | out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) 1501 | if out.Values[i] == graphql.Null { 1502 | invalids++ 1503 | } 1504 | case "deprecationReason": 1505 | out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) 1506 | default: 1507 | panic("unknown field " + strconv.Quote(field.Name)) 1508 | } 1509 | } 1510 | out.Dispatch() 1511 | if invalids > 0 { 1512 | return graphql.Null 1513 | } 1514 | return out 1515 | } 1516 | 1517 | var __InputValueImplementors = []string{"__InputValue"} 1518 | 1519 | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { 1520 | fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) 1521 | 1522 | out := graphql.NewFieldSet(fields) 1523 | var invalids uint32 1524 | for i, field := range fields { 1525 | switch field.Name { 1526 | case "__typename": 1527 | out.Values[i] = graphql.MarshalString("__InputValue") 1528 | case "name": 1529 | out.Values[i] = ec.___InputValue_name(ctx, field, obj) 1530 | if out.Values[i] == graphql.Null { 1531 | invalids++ 1532 | } 1533 | case "description": 1534 | out.Values[i] = ec.___InputValue_description(ctx, field, obj) 1535 | case "type": 1536 | out.Values[i] = ec.___InputValue_type(ctx, field, obj) 1537 | if out.Values[i] == graphql.Null { 1538 | invalids++ 1539 | } 1540 | case "defaultValue": 1541 | out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) 1542 | default: 1543 | panic("unknown field " + strconv.Quote(field.Name)) 1544 | } 1545 | } 1546 | out.Dispatch() 1547 | if invalids > 0 { 1548 | return graphql.Null 1549 | } 1550 | return out 1551 | } 1552 | 1553 | var __SchemaImplementors = []string{"__Schema"} 1554 | 1555 | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { 1556 | fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) 1557 | 1558 | out := graphql.NewFieldSet(fields) 1559 | var invalids uint32 1560 | for i, field := range fields { 1561 | switch field.Name { 1562 | case "__typename": 1563 | out.Values[i] = graphql.MarshalString("__Schema") 1564 | case "types": 1565 | out.Values[i] = ec.___Schema_types(ctx, field, obj) 1566 | if out.Values[i] == graphql.Null { 1567 | invalids++ 1568 | } 1569 | case "queryType": 1570 | out.Values[i] = ec.___Schema_queryType(ctx, field, obj) 1571 | if out.Values[i] == graphql.Null { 1572 | invalids++ 1573 | } 1574 | case "mutationType": 1575 | out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) 1576 | case "subscriptionType": 1577 | out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) 1578 | case "directives": 1579 | out.Values[i] = ec.___Schema_directives(ctx, field, obj) 1580 | if out.Values[i] == graphql.Null { 1581 | invalids++ 1582 | } 1583 | default: 1584 | panic("unknown field " + strconv.Quote(field.Name)) 1585 | } 1586 | } 1587 | out.Dispatch() 1588 | if invalids > 0 { 1589 | return graphql.Null 1590 | } 1591 | return out 1592 | } 1593 | 1594 | var __TypeImplementors = []string{"__Type"} 1595 | 1596 | func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { 1597 | fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) 1598 | 1599 | out := graphql.NewFieldSet(fields) 1600 | var invalids uint32 1601 | for i, field := range fields { 1602 | switch field.Name { 1603 | case "__typename": 1604 | out.Values[i] = graphql.MarshalString("__Type") 1605 | case "kind": 1606 | out.Values[i] = ec.___Type_kind(ctx, field, obj) 1607 | if out.Values[i] == graphql.Null { 1608 | invalids++ 1609 | } 1610 | case "name": 1611 | out.Values[i] = ec.___Type_name(ctx, field, obj) 1612 | case "description": 1613 | out.Values[i] = ec.___Type_description(ctx, field, obj) 1614 | case "fields": 1615 | out.Values[i] = ec.___Type_fields(ctx, field, obj) 1616 | case "interfaces": 1617 | out.Values[i] = ec.___Type_interfaces(ctx, field, obj) 1618 | case "possibleTypes": 1619 | out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) 1620 | case "enumValues": 1621 | out.Values[i] = ec.___Type_enumValues(ctx, field, obj) 1622 | case "inputFields": 1623 | out.Values[i] = ec.___Type_inputFields(ctx, field, obj) 1624 | case "ofType": 1625 | out.Values[i] = ec.___Type_ofType(ctx, field, obj) 1626 | default: 1627 | panic("unknown field " + strconv.Quote(field.Name)) 1628 | } 1629 | } 1630 | out.Dispatch() 1631 | if invalids > 0 { 1632 | return graphql.Null 1633 | } 1634 | return out 1635 | } 1636 | 1637 | // endregion **************************** object.gotpl **************************** 1638 | 1639 | // region ***************************** type.gotpl ***************************** 1640 | 1641 | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { 1642 | return graphql.UnmarshalBoolean(v) 1643 | } 1644 | 1645 | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { 1646 | res := graphql.MarshalBoolean(v) 1647 | if res == graphql.Null { 1648 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1649 | ec.Errorf(ctx, "must not be null") 1650 | } 1651 | } 1652 | return res 1653 | } 1654 | 1655 | func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { 1656 | return graphql.UnmarshalString(v) 1657 | } 1658 | 1659 | func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 1660 | res := graphql.MarshalString(v) 1661 | if res == graphql.Null { 1662 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1663 | ec.Errorf(ctx, "must not be null") 1664 | } 1665 | } 1666 | return res 1667 | } 1668 | 1669 | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { 1670 | return ec.___Directive(ctx, sel, &v) 1671 | } 1672 | 1673 | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { 1674 | ret := make(graphql.Array, len(v)) 1675 | var wg sync.WaitGroup 1676 | isLen1 := len(v) == 1 1677 | if !isLen1 { 1678 | wg.Add(len(v)) 1679 | } 1680 | for i := range v { 1681 | i := i 1682 | fc := &graphql.FieldContext{ 1683 | Index: &i, 1684 | Result: &v[i], 1685 | } 1686 | ctx := graphql.WithFieldContext(ctx, fc) 1687 | f := func(i int) { 1688 | defer func() { 1689 | if r := recover(); r != nil { 1690 | ec.Error(ctx, ec.Recover(ctx, r)) 1691 | ret = nil 1692 | } 1693 | }() 1694 | if !isLen1 { 1695 | defer wg.Done() 1696 | } 1697 | ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) 1698 | } 1699 | if isLen1 { 1700 | f(i) 1701 | } else { 1702 | go f(i) 1703 | } 1704 | 1705 | } 1706 | wg.Wait() 1707 | return ret 1708 | } 1709 | 1710 | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { 1711 | return graphql.UnmarshalString(v) 1712 | } 1713 | 1714 | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 1715 | res := graphql.MarshalString(v) 1716 | if res == graphql.Null { 1717 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1718 | ec.Errorf(ctx, "must not be null") 1719 | } 1720 | } 1721 | return res 1722 | } 1723 | 1724 | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { 1725 | var vSlice []interface{} 1726 | if v != nil { 1727 | if tmp1, ok := v.([]interface{}); ok { 1728 | vSlice = tmp1 1729 | } else { 1730 | vSlice = []interface{}{v} 1731 | } 1732 | } 1733 | var err error 1734 | res := make([]string, len(vSlice)) 1735 | for i := range vSlice { 1736 | res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) 1737 | if err != nil { 1738 | return nil, err 1739 | } 1740 | } 1741 | return res, nil 1742 | } 1743 | 1744 | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { 1745 | ret := make(graphql.Array, len(v)) 1746 | var wg sync.WaitGroup 1747 | isLen1 := len(v) == 1 1748 | if !isLen1 { 1749 | wg.Add(len(v)) 1750 | } 1751 | for i := range v { 1752 | i := i 1753 | fc := &graphql.FieldContext{ 1754 | Index: &i, 1755 | Result: &v[i], 1756 | } 1757 | ctx := graphql.WithFieldContext(ctx, fc) 1758 | f := func(i int) { 1759 | defer func() { 1760 | if r := recover(); r != nil { 1761 | ec.Error(ctx, ec.Recover(ctx, r)) 1762 | ret = nil 1763 | } 1764 | }() 1765 | if !isLen1 { 1766 | defer wg.Done() 1767 | } 1768 | ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) 1769 | } 1770 | if isLen1 { 1771 | f(i) 1772 | } else { 1773 | go f(i) 1774 | } 1775 | 1776 | } 1777 | wg.Wait() 1778 | return ret 1779 | } 1780 | 1781 | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { 1782 | return ec.___EnumValue(ctx, sel, &v) 1783 | } 1784 | 1785 | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { 1786 | return ec.___Field(ctx, sel, &v) 1787 | } 1788 | 1789 | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { 1790 | return ec.___InputValue(ctx, sel, &v) 1791 | } 1792 | 1793 | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { 1794 | ret := make(graphql.Array, len(v)) 1795 | var wg sync.WaitGroup 1796 | isLen1 := len(v) == 1 1797 | if !isLen1 { 1798 | wg.Add(len(v)) 1799 | } 1800 | for i := range v { 1801 | i := i 1802 | fc := &graphql.FieldContext{ 1803 | Index: &i, 1804 | Result: &v[i], 1805 | } 1806 | ctx := graphql.WithFieldContext(ctx, fc) 1807 | f := func(i int) { 1808 | defer func() { 1809 | if r := recover(); r != nil { 1810 | ec.Error(ctx, ec.Recover(ctx, r)) 1811 | ret = nil 1812 | } 1813 | }() 1814 | if !isLen1 { 1815 | defer wg.Done() 1816 | } 1817 | ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) 1818 | } 1819 | if isLen1 { 1820 | f(i) 1821 | } else { 1822 | go f(i) 1823 | } 1824 | 1825 | } 1826 | wg.Wait() 1827 | return ret 1828 | } 1829 | 1830 | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { 1831 | return ec.___Type(ctx, sel, &v) 1832 | } 1833 | 1834 | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { 1835 | ret := make(graphql.Array, len(v)) 1836 | var wg sync.WaitGroup 1837 | isLen1 := len(v) == 1 1838 | if !isLen1 { 1839 | wg.Add(len(v)) 1840 | } 1841 | for i := range v { 1842 | i := i 1843 | fc := &graphql.FieldContext{ 1844 | Index: &i, 1845 | Result: &v[i], 1846 | } 1847 | ctx := graphql.WithFieldContext(ctx, fc) 1848 | f := func(i int) { 1849 | defer func() { 1850 | if r := recover(); r != nil { 1851 | ec.Error(ctx, ec.Recover(ctx, r)) 1852 | ret = nil 1853 | } 1854 | }() 1855 | if !isLen1 { 1856 | defer wg.Done() 1857 | } 1858 | ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) 1859 | } 1860 | if isLen1 { 1861 | f(i) 1862 | } else { 1863 | go f(i) 1864 | } 1865 | 1866 | } 1867 | wg.Wait() 1868 | return ret 1869 | } 1870 | 1871 | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { 1872 | if v == nil { 1873 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1874 | ec.Errorf(ctx, "must not be null") 1875 | } 1876 | return graphql.Null 1877 | } 1878 | return ec.___Type(ctx, sel, v) 1879 | } 1880 | 1881 | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { 1882 | return graphql.UnmarshalString(v) 1883 | } 1884 | 1885 | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 1886 | res := graphql.MarshalString(v) 1887 | if res == graphql.Null { 1888 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1889 | ec.Errorf(ctx, "must not be null") 1890 | } 1891 | } 1892 | return res 1893 | } 1894 | 1895 | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { 1896 | return graphql.UnmarshalBoolean(v) 1897 | } 1898 | 1899 | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { 1900 | return graphql.MarshalBoolean(v) 1901 | } 1902 | 1903 | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { 1904 | if v == nil { 1905 | return nil, nil 1906 | } 1907 | res, err := ec.unmarshalOBoolean2bool(ctx, v) 1908 | return &res, err 1909 | } 1910 | 1911 | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { 1912 | if v == nil { 1913 | return graphql.Null 1914 | } 1915 | return ec.marshalOBoolean2bool(ctx, sel, *v) 1916 | } 1917 | 1918 | func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { 1919 | return graphql.UnmarshalString(v) 1920 | } 1921 | 1922 | func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 1923 | return graphql.MarshalString(v) 1924 | } 1925 | 1926 | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { 1927 | if v == nil { 1928 | return nil, nil 1929 | } 1930 | res, err := ec.unmarshalOString2string(ctx, v) 1931 | return &res, err 1932 | } 1933 | 1934 | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { 1935 | if v == nil { 1936 | return graphql.Null 1937 | } 1938 | return ec.marshalOString2string(ctx, sel, *v) 1939 | } 1940 | 1941 | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { 1942 | if v == nil { 1943 | return graphql.Null 1944 | } 1945 | ret := make(graphql.Array, len(v)) 1946 | var wg sync.WaitGroup 1947 | isLen1 := len(v) == 1 1948 | if !isLen1 { 1949 | wg.Add(len(v)) 1950 | } 1951 | for i := range v { 1952 | i := i 1953 | fc := &graphql.FieldContext{ 1954 | Index: &i, 1955 | Result: &v[i], 1956 | } 1957 | ctx := graphql.WithFieldContext(ctx, fc) 1958 | f := func(i int) { 1959 | defer func() { 1960 | if r := recover(); r != nil { 1961 | ec.Error(ctx, ec.Recover(ctx, r)) 1962 | ret = nil 1963 | } 1964 | }() 1965 | if !isLen1 { 1966 | defer wg.Done() 1967 | } 1968 | ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) 1969 | } 1970 | if isLen1 { 1971 | f(i) 1972 | } else { 1973 | go f(i) 1974 | } 1975 | 1976 | } 1977 | wg.Wait() 1978 | return ret 1979 | } 1980 | 1981 | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { 1982 | if v == nil { 1983 | return graphql.Null 1984 | } 1985 | ret := make(graphql.Array, len(v)) 1986 | var wg sync.WaitGroup 1987 | isLen1 := len(v) == 1 1988 | if !isLen1 { 1989 | wg.Add(len(v)) 1990 | } 1991 | for i := range v { 1992 | i := i 1993 | fc := &graphql.FieldContext{ 1994 | Index: &i, 1995 | Result: &v[i], 1996 | } 1997 | ctx := graphql.WithFieldContext(ctx, fc) 1998 | f := func(i int) { 1999 | defer func() { 2000 | if r := recover(); r != nil { 2001 | ec.Error(ctx, ec.Recover(ctx, r)) 2002 | ret = nil 2003 | } 2004 | }() 2005 | if !isLen1 { 2006 | defer wg.Done() 2007 | } 2008 | ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) 2009 | } 2010 | if isLen1 { 2011 | f(i) 2012 | } else { 2013 | go f(i) 2014 | } 2015 | 2016 | } 2017 | wg.Wait() 2018 | return ret 2019 | } 2020 | 2021 | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { 2022 | if v == nil { 2023 | return graphql.Null 2024 | } 2025 | ret := make(graphql.Array, len(v)) 2026 | var wg sync.WaitGroup 2027 | isLen1 := len(v) == 1 2028 | if !isLen1 { 2029 | wg.Add(len(v)) 2030 | } 2031 | for i := range v { 2032 | i := i 2033 | fc := &graphql.FieldContext{ 2034 | Index: &i, 2035 | Result: &v[i], 2036 | } 2037 | ctx := graphql.WithFieldContext(ctx, fc) 2038 | f := func(i int) { 2039 | defer func() { 2040 | if r := recover(); r != nil { 2041 | ec.Error(ctx, ec.Recover(ctx, r)) 2042 | ret = nil 2043 | } 2044 | }() 2045 | if !isLen1 { 2046 | defer wg.Done() 2047 | } 2048 | ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) 2049 | } 2050 | if isLen1 { 2051 | f(i) 2052 | } else { 2053 | go f(i) 2054 | } 2055 | 2056 | } 2057 | wg.Wait() 2058 | return ret 2059 | } 2060 | 2061 | func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { 2062 | return ec.___Schema(ctx, sel, &v) 2063 | } 2064 | 2065 | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { 2066 | if v == nil { 2067 | return graphql.Null 2068 | } 2069 | return ec.___Schema(ctx, sel, v) 2070 | } 2071 | 2072 | func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { 2073 | return ec.___Type(ctx, sel, &v) 2074 | } 2075 | 2076 | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { 2077 | if v == nil { 2078 | return graphql.Null 2079 | } 2080 | ret := make(graphql.Array, len(v)) 2081 | var wg sync.WaitGroup 2082 | isLen1 := len(v) == 1 2083 | if !isLen1 { 2084 | wg.Add(len(v)) 2085 | } 2086 | for i := range v { 2087 | i := i 2088 | fc := &graphql.FieldContext{ 2089 | Index: &i, 2090 | Result: &v[i], 2091 | } 2092 | ctx := graphql.WithFieldContext(ctx, fc) 2093 | f := func(i int) { 2094 | defer func() { 2095 | if r := recover(); r != nil { 2096 | ec.Error(ctx, ec.Recover(ctx, r)) 2097 | ret = nil 2098 | } 2099 | }() 2100 | if !isLen1 { 2101 | defer wg.Done() 2102 | } 2103 | ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) 2104 | } 2105 | if isLen1 { 2106 | f(i) 2107 | } else { 2108 | go f(i) 2109 | } 2110 | 2111 | } 2112 | wg.Wait() 2113 | return ret 2114 | } 2115 | 2116 | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { 2117 | if v == nil { 2118 | return graphql.Null 2119 | } 2120 | return ec.___Type(ctx, sel, v) 2121 | } 2122 | 2123 | // endregion ***************************** type.gotpl ***************************** 2124 | -------------------------------------------------------------------------------- /golang/gqlgen/gin-server/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/99designs/gqlgen/handler" 7 | "github.com/appleboy/golang-graphql-benchmark/golang/gqlgen" 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | // Handler initializes the graphql middleware. 12 | func Handler() gin.HandlerFunc { 13 | // Creates a GraphQL-go HTTP handler with the defined schema 14 | h := handler.GraphQL(gqlgen.NewExecutableSchema(gqlgen.Config{Resolvers: &gqlgen.Resolver{}})) 15 | 16 | return func(c *gin.Context) { 17 | h.ServeHTTP(c.Writer, c.Request) 18 | } 19 | } 20 | 21 | func main() { 22 | r := gin.New() 23 | r.POST("/graphql", Handler()) 24 | 25 | fmt.Println("Now server is running on port 8080") 26 | fmt.Println("Test with POST : curl -g --request POST 'http://localhost:8080/graphql?query={hello}'") 27 | r.Run() 28 | } 29 | -------------------------------------------------------------------------------- /golang/gqlgen/gqlgen.yml: -------------------------------------------------------------------------------- 1 | # .gqlgen.yml example 2 | # 3 | # Refer to https://gqlgen.com/config/ 4 | # for detailed .gqlgen.yml documentation. 5 | 6 | schema: 7 | - schema.graphql 8 | exec: 9 | filename: generated.go 10 | model: 11 | filename: models_gen.go 12 | resolver: 13 | filename: resolver.go 14 | type: Resolver 15 | -------------------------------------------------------------------------------- /golang/gqlgen/httpd-server/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | 8 | "github.com/99designs/gqlgen/handler" 9 | "github.com/appleboy/golang-graphql-benchmark/golang/gqlgen" 10 | ) 11 | 12 | func main() { 13 | h := handler.GraphQL(gqlgen.NewExecutableSchema(gqlgen.Config{Resolvers: &gqlgen.Resolver{}})) 14 | http.Handle("/graphql", h) 15 | 16 | fmt.Println("Now server is running on port 8080") 17 | fmt.Println("Test with GET : curl -g --request GET 'http://localhost:8080/graphql?query={hello}'") 18 | 19 | log.Fatal(http.ListenAndServe(":8080", nil)) 20 | } 21 | -------------------------------------------------------------------------------- /golang/gqlgen/resolver.go: -------------------------------------------------------------------------------- 1 | //go:generate go run github.com/99designs/gqlgen 2 | 3 | package gqlgen 4 | 5 | import ( 6 | "context" 7 | ) 8 | 9 | type Resolver struct{} 10 | 11 | func (r *Resolver) Query() QueryResolver { 12 | return &queryResolver{r} 13 | } 14 | 15 | type queryResolver struct{ *Resolver } 16 | 17 | func (r *queryResolver) Hello(ctx context.Context) (string, error) { 18 | return "world", nil 19 | } 20 | -------------------------------------------------------------------------------- /golang/gqlgen/schema.graphql: -------------------------------------------------------------------------------- 1 | type Query { 2 | hello: String! 3 | } 4 | -------------------------------------------------------------------------------- /golang/gqlgen/scripts/gqlgen.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import "github.com/99designs/gqlgen/cmd" 6 | 7 | func main() { 8 | cmd.Execute() 9 | } 10 | -------------------------------------------------------------------------------- /golang/graph-gophers/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/gin-gonic/gin" 7 | graphql "github.com/graph-gophers/graphql-go" 8 | "github.com/graph-gophers/graphql-go/relay" 9 | ) 10 | 11 | type gopherHelloWorldResolver struct{} 12 | 13 | func (r *gopherHelloWorldResolver) Hello() string { 14 | return "world" 15 | } 16 | 17 | var gopherSchema = graphql.MustParseSchema(` 18 | schema { 19 | query: Query 20 | } 21 | type Query { 22 | hello: String! 23 | } 24 | `, &gopherHelloWorldResolver{}) 25 | 26 | func gophersGraphQLHandler() gin.HandlerFunc { 27 | r := &relay.Handler{Schema: gopherSchema} 28 | 29 | return func(c *gin.Context) { 30 | r.ServeHTTP(c.Writer, c.Request) 31 | } 32 | } 33 | 34 | func main() { 35 | 36 | r := gin.New() 37 | r.POST("/graphql", gophersGraphQLHandler()) 38 | 39 | fmt.Println("Now server is running on port 8080") 40 | fmt.Println("Test with POST : curl -g --request POST 'http://localhost:8080/graphql?query={hello}'") 41 | r.Run() // listen and serve on 0.0.0.0:8080 42 | } 43 | -------------------------------------------------------------------------------- /golang/graphql-go/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/gin-gonic/gin" 7 | "github.com/graphql-go/graphql" 8 | "github.com/graphql-go/handler" 9 | ) 10 | 11 | // Schema 12 | var fields = graphql.Fields{ 13 | "hello": &graphql.Field{ 14 | Type: graphql.String, 15 | Resolve: func(p graphql.ResolveParams) (interface{}, error) { 16 | return "world", nil 17 | }, 18 | }, 19 | } 20 | var rootQuery = graphql.ObjectConfig{Name: "RootQuery", Fields: fields} 21 | var schemaConfig = graphql.SchemaConfig{Query: graphql.NewObject(rootQuery)} 22 | var schema, _ = graphql.NewSchema(schemaConfig) 23 | 24 | func executeQuery(query string, schema graphql.Schema) *graphql.Result { 25 | result := graphql.Do(graphql.Params{ 26 | Schema: schema, 27 | RequestString: query, 28 | }) 29 | if len(result.Errors) > 0 { 30 | fmt.Printf("wrong result, unexpected errors: %v", result.Errors) 31 | } 32 | return result 33 | } 34 | 35 | // Handler initializes the graphql middleware. 36 | func Handler() gin.HandlerFunc { 37 | // Creates a GraphQL-go HTTP handler with the defined schema 38 | h := handler.New(&handler.Config{ 39 | Schema: &schema, 40 | Pretty: false, 41 | GraphiQL: false, 42 | }) 43 | 44 | return func(c *gin.Context) { 45 | h.ServeHTTP(c.Writer, c.Request) 46 | } 47 | } 48 | 49 | func main() { 50 | 51 | r := gin.New() 52 | r.POST("/graphql", Handler()) 53 | 54 | fmt.Println("Now server is running on port 8080") 55 | fmt.Println("Test with POST : curl -g --request POST 'http://localhost:8080/graphql?query={hello}'") 56 | r.Run() // listen and serve on 0.0.0.0:8080 57 | } 58 | -------------------------------------------------------------------------------- /golang/json.lua: -------------------------------------------------------------------------------- 1 | wrk.method = "POST" 2 | wrk.headers["Content-Type"] = "application/json" 3 | wrk.body = "{\"hello\":\"world\"}" 4 | -------------------------------------------------------------------------------- /golang/post.lua: -------------------------------------------------------------------------------- 1 | wrk.method = "POST" 2 | wrk.headers["Content-Type"] = "application/json" 3 | wrk.body = "{\"query\":\"{ hello }\", \"operationName\":\"\", \"variables\": null}" 4 | -------------------------------------------------------------------------------- /golang/thunder/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/gin-gonic/gin" 7 | "github.com/samsarahq/thunder/graphql" 8 | "github.com/samsarahq/thunder/graphql/introspection" 9 | "github.com/samsarahq/thunder/graphql/schemabuilder" 10 | ) 11 | 12 | type thunderServer struct{} 13 | 14 | // registerQuery registers the root query type. 15 | func (s *thunderServer) registerQuery(schema *schemabuilder.Schema) { 16 | obj := schema.Query() 17 | obj.FieldFunc("hello", func() string { 18 | return "world" 19 | }) 20 | } 21 | 22 | func (s *thunderServer) schema() *graphql.Schema { 23 | builder := schemabuilder.NewSchema() 24 | s.registerQuery(builder) 25 | return builder.MustBuild() 26 | } 27 | 28 | func thunderGraphQLHandler() gin.HandlerFunc { 29 | server := &thunderServer{} 30 | thunderSchema := server.schema() 31 | introspection.AddIntrospectionToSchema(thunderSchema) 32 | r := graphql.HTTPHandler(thunderSchema) 33 | 34 | return func(c *gin.Context) { 35 | r.ServeHTTP(c.Writer, c.Request) 36 | } 37 | } 38 | 39 | func main() { 40 | 41 | r := gin.New() 42 | r.POST("/graphql", thunderGraphQLHandler()) 43 | 44 | fmt.Println("Now server is running on port 8080") 45 | fmt.Println("Test with POST : curl -g --request POST 'http://localhost:8080/graphql?query={hello}'") 46 | r.Run() // listen and serve on 0.0.0.0:8080 47 | } 48 | -------------------------------------------------------------------------------- /graphqlHttp_test.go: -------------------------------------------------------------------------------- 1 | package graphqlbenchmark 2 | 3 | import ( 4 | "io/ioutil" 5 | "net/http" 6 | "net/http/httptest" 7 | "strings" 8 | "testing" 9 | 10 | "github.com/appleboy/golang-graphql-benchmark/golang/gqlgen" 11 | 12 | gqlH "github.com/99designs/gqlgen/handler" 13 | "github.com/gin-gonic/gin" 14 | "github.com/graph-gophers/graphql-go/relay" 15 | "github.com/graphql-go/handler" 16 | thql "github.com/samsarahq/thunder/graphql" 17 | "github.com/samsarahq/thunder/graphql/introspection" 18 | ) 19 | 20 | func runRequest(B *testing.B, r *gin.Engine, method, path string) { 21 | // create fake request 22 | req, err := http.NewRequest(method, path, strings.NewReader(`{"query":"{ hello }", "operationName":"", "variables": null}`)) 23 | if err != nil { 24 | panic(err) 25 | } 26 | w := httptest.NewRecorder() 27 | B.ReportAllocs() 28 | B.ResetTimer() 29 | for i := 0; i < B.N; i++ { 30 | r.ServeHTTP(w, req) 31 | } 32 | } 33 | 34 | func goGraphQLHandler() gin.HandlerFunc { 35 | h := handler.New(&handler.Config{ 36 | Schema: &graphQLGoSchema, 37 | }) 38 | 39 | return func(c *gin.Context) { 40 | h.ServeHTTP(c.Writer, c.Request) 41 | } 42 | } 43 | 44 | func gophersGraphQLHandler() gin.HandlerFunc { 45 | r := &relay.Handler{Schema: gopherSchema} 46 | 47 | return func(c *gin.Context) { 48 | r.ServeHTTP(c.Writer, c.Request) 49 | } 50 | } 51 | 52 | func thunderGraphQLHandler() gin.HandlerFunc { 53 | server := &thunderServer{} 54 | thunderSchema := server.schema() 55 | introspection.AddIntrospectionToSchema(thunderSchema) 56 | r := thql.HTTPHandler(thunderSchema) 57 | 58 | return func(c *gin.Context) { 59 | r.ServeHTTP(c.Writer, c.Request) 60 | } 61 | } 62 | 63 | func BenchmarkGinHttpRoute(B *testing.B) { 64 | gin.SetMode(gin.ReleaseMode) 65 | gin.DefaultWriter = ioutil.Discard 66 | router := gin.New() 67 | router.POST("/hello", func(c *gin.Context) { 68 | c.JSON( 69 | http.StatusOK, 70 | gin.H{ 71 | "data": gin.H{"hello": "world"}, 72 | }, 73 | ) 74 | }) 75 | runRequest(B, router, "POST", "/hello") 76 | } 77 | 78 | func goGQLGenHandler() gin.HandlerFunc { 79 | // Creates a GraphQL-go HTTP handler with the defined schema 80 | h := gqlH.GraphQL(gqlgen.NewExecutableSchema(gqlgen.Config{Resolvers: &gqlgen.Resolver{}})) 81 | 82 | return func(c *gin.Context) { 83 | h.ServeHTTP(c.Writer, c.Request) 84 | } 85 | } 86 | 87 | func BenchmarkGinGQLGenRoute(B *testing.B) { 88 | gin.SetMode(gin.ReleaseMode) 89 | gin.DefaultWriter = ioutil.Discard 90 | router := gin.New() 91 | router.POST("/graphql", goGQLGenHandler()) 92 | runRequest(B, router, "POST", "/graphql") 93 | } 94 | 95 | func BenchmarkGinGoGraphQLRoute(B *testing.B) { 96 | gin.SetMode(gin.ReleaseMode) 97 | gin.DefaultWriter = ioutil.Discard 98 | router := gin.New() 99 | router.POST("/graphql", goGraphQLHandler()) 100 | runRequest(B, router, "POST", "/graphql") 101 | } 102 | 103 | func BenchmarkGinGopherGraphQLRoute(B *testing.B) { 104 | gin.SetMode(gin.ReleaseMode) 105 | gin.DefaultWriter = ioutil.Discard 106 | router := gin.New() 107 | router.POST("/graphql", gophersGraphQLHandler()) 108 | runRequest(B, router, "POST", "/graphql") 109 | } 110 | 111 | func BenchmarkGinThunderGraphQLRoute(B *testing.B) { 112 | gin.SetMode(gin.ReleaseMode) 113 | gin.DefaultWriter = ioutil.Discard 114 | router := gin.New() 115 | router.POST("/graphql", thunderGraphQLHandler()) 116 | runRequest(B, router, "POST", "/graphql") 117 | } 118 | -------------------------------------------------------------------------------- /graphql_test.go: -------------------------------------------------------------------------------- 1 | package graphqlbenchmark 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/graphql-go/graphql" 8 | thunder "github.com/samsarahq/thunder/graphql" 9 | ) 10 | 11 | func BenchmarkGoGraphQLMaster(b *testing.B) { 12 | // Disable SpecifiedRules 13 | // graphql.SpecifiedRules = []graphql.ValidationRuleFn{} 14 | b.ResetTimer() 15 | for i := 0; i < b.N; i++ { 16 | graphql.Do(graphql.Params{ 17 | Schema: graphQLGoSchema, 18 | RequestString: "{hello}", 19 | }) 20 | } 21 | } 22 | 23 | func BenchmarkPlaylyfeGraphQLMaster(b *testing.B) { 24 | b.ResetTimer() 25 | for i := 0; i < b.N; i++ { 26 | context := map[string]interface{}{} 27 | variables := map[string]interface{}{} 28 | playlyfeExecutor.Execute(context, "{hello}", variables, "") 29 | } 30 | } 31 | 32 | func BenchmarkGophersGraphQLMaster(b *testing.B) { 33 | b.ResetTimer() 34 | for i := 0; i < b.N; i++ { 35 | ctx := context.Background() 36 | variables := map[string]interface{}{} 37 | gopherSchema.Exec(ctx, "{hello}", "", variables) 38 | } 39 | } 40 | 41 | func BenchmarkThunderGraphQLMaster(b *testing.B) { 42 | noArguments := func(json interface{}) (interface{}, error) { 43 | return nil, nil 44 | } 45 | var query = &thunder.Object{ 46 | Name: "Query", 47 | Fields: make(map[string]*thunder.Field), 48 | } 49 | 50 | query.Fields["hello"] = &thunder.Field{ 51 | Resolve: func(ctx context.Context, source, args interface{}, selectionSet *thunder.SelectionSet) (interface{}, error) { 52 | return "world", nil 53 | }, 54 | Type: &thunder.Scalar{Type: "string"}, 55 | ParseArguments: noArguments, 56 | } 57 | 58 | b.ResetTimer() 59 | for i := 0; i < b.N; i++ { 60 | q := thunder.MustParse(`{hello}`, map[string]interface{}{}) 61 | ctx := context.Background() 62 | e := thunder.Executor{} 63 | e.Execute(ctx, query, nil, q) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /schema.go: -------------------------------------------------------------------------------- 1 | package graphqlbenchmark 2 | 3 | import ( 4 | ggql "github.com/graph-gophers/graphql-go" 5 | "github.com/graphql-go/graphql" 6 | pgql "github.com/playlyfe/go-graphql" 7 | thql "github.com/samsarahq/thunder/graphql" 8 | "github.com/samsarahq/thunder/graphql/schemabuilder" 9 | ) 10 | 11 | var graphQLGoSchema, _ = graphql.NewSchema( 12 | graphql.SchemaConfig{ 13 | Query: graphql.NewObject( 14 | graphql.ObjectConfig{ 15 | Name: "RootQueryType", 16 | Fields: graphql.Fields{ 17 | "hello": &graphql.Field{ 18 | Type: graphql.String, 19 | Resolve: func(p graphql.ResolveParams) (interface{}, error) { 20 | return "world", nil 21 | }, 22 | }, 23 | }, 24 | }), 25 | }, 26 | ) 27 | 28 | var playlyfeSchema = ` 29 | type RootQueryType { 30 | hello: String 31 | } 32 | ` 33 | var playlyfeResolvers = map[string]interface{}{ 34 | "RootQueryType/hello": func(params *pgql.ResolveParams) (interface{}, error) { 35 | return "world", nil 36 | }, 37 | } 38 | var playlyfeExecutor, _ = pgql.NewExecutor(playlyfeSchema, "RootQueryType", "", playlyfeResolvers) 39 | 40 | type gopherHelloWorldResolver struct{} 41 | 42 | func (r *gopherHelloWorldResolver) Hello() string { 43 | return "world" 44 | } 45 | 46 | var gopherSchema = ggql.MustParseSchema(` 47 | schema { 48 | query: Query 49 | } 50 | type Query { 51 | hello: String! 52 | } 53 | `, &gopherHelloWorldResolver{}) 54 | 55 | type thunderServer struct{} 56 | 57 | // registerQuery registers the root query type. 58 | func (s *thunderServer) registerQuery(schema *schemabuilder.Schema) { 59 | obj := schema.Query() 60 | obj.FieldFunc("hello", func() string { 61 | return "world" 62 | }) 63 | } 64 | 65 | func (s *thunderServer) schema() *thql.Schema { 66 | builder := schemabuilder.NewSchema() 67 | s.registerQuery(builder) 68 | return builder.MustBuild() 69 | } 70 | --------------------------------------------------------------------------------