├── cmd └── server │ └── server.go ├── data.db ├── go.mod ├── go.sum ├── gqlgen.yml ├── graph ├── generated │ └── generated.go ├── model │ ├── category.go │ ├── course.go │ └── models_gen.go ├── resolver.go ├── schema.graphqls └── schema.resolvers.go ├── internal └── database │ ├── category.go │ └── course.go └── tools.go /cmd/server/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "database/sql" 5 | "log" 6 | "net/http" 7 | "os" 8 | 9 | "github.com/99designs/gqlgen/graphql/handler" 10 | "github.com/99designs/gqlgen/graphql/playground" 11 | "github.com/devfullcycle/13-GraphQL/graph" 12 | "github.com/devfullcycle/13-GraphQL/graph/generated" 13 | "github.com/devfullcycle/13-GraphQL/internal/database" 14 | _ "github.com/mattn/go-sqlite3" 15 | ) 16 | 17 | const defaultPort = "8080" 18 | 19 | func main() { 20 | db, err := sql.Open("sqlite3", "./data.db") 21 | if err != nil { 22 | log.Fatalf("failed to open database: %v", err) 23 | } 24 | defer db.Close() 25 | 26 | categoryDb := database.NewCategory(db) 27 | courseDb := database.NewCourse(db) 28 | 29 | port := os.Getenv("PORT") 30 | if port == "" { 31 | port = defaultPort 32 | } 33 | 34 | srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{ 35 | CategoryDB: categoryDb, 36 | CourseDB: courseDb, 37 | }})) 38 | 39 | http.Handle("/", playground.Handler("GraphQL playground", "/query")) 40 | http.Handle("/query", srv) 41 | 42 | log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) 43 | log.Fatal(http.ListenAndServe(":"+port, nil)) 44 | } 45 | -------------------------------------------------------------------------------- /data.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devfullcycle/13-GraphQL/eee2d41d46a16dcde99232950b6d13f33a893dcd/data.db -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/devfullcycle/13-GraphQL 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/99designs/gqlgen v0.17.20 7 | github.com/google/uuid v1.3.0 8 | github.com/mattn/go-sqlite3 v1.14.16 9 | github.com/vektah/gqlparser/v2 v2.5.1 10 | ) 11 | 12 | require ( 13 | github.com/agnivade/levenshtein v1.1.1 // indirect 14 | github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect 15 | github.com/gorilla/websocket v1.5.0 // indirect 16 | github.com/hashicorp/golang-lru v0.5.4 // indirect 17 | github.com/mitchellh/mapstructure v1.3.1 // indirect 18 | github.com/russross/blackfriday/v2 v2.1.0 // indirect 19 | github.com/urfave/cli/v2 v2.8.1 // indirect 20 | github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect 21 | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect 22 | golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect 23 | golang.org/x/text v0.3.7 // indirect 24 | golang.org/x/tools v0.1.12 // indirect 25 | gopkg.in/yaml.v3 v3.0.1 // indirect 26 | ) 27 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/99designs/gqlgen v0.17.20 h1:O7WzccIhKB1dm+7g6dhQcULINftfiLSBg2l/mwbpJMw= 2 | github.com/99designs/gqlgen v0.17.20/go.mod h1:Mja2HI23kWT1VRH09hvWshFgOzKswpO20o4ScpJIES4= 3 | github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= 4 | github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= 5 | github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= 6 | github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= 7 | github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= 8 | github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= 9 | github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= 10 | github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= 11 | github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU= 12 | github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= 13 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 14 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 15 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 16 | github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= 17 | github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= 18 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 19 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 20 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= 21 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 22 | github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= 23 | github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 24 | github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= 25 | github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= 26 | github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM= 27 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 28 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 29 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 30 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 31 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 32 | github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc= 33 | github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk= 34 | github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= 35 | github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= 36 | github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= 37 | github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= 38 | github.com/mitchellh/mapstructure v1.3.1 h1:cCBH2gTD2K0OtLlv/Y5H01VQCqmlDxz30kS5Y5bqfLA= 39 | github.com/mitchellh/mapstructure v1.3.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= 40 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 41 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 42 | github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= 43 | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 44 | github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= 45 | github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 46 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 47 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 48 | github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= 49 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 50 | github.com/urfave/cli/v2 v2.8.1 h1:CGuYNZF9IKZY/rfBe3lJpccSoIY1ytfvmgQT90cNOl4= 51 | github.com/urfave/cli/v2 v2.8.1/go.mod h1:Z41J9TPoffeoqP0Iza0YbAhGvymRdZAd2uPmZ5JxRdY= 52 | github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUOHcr4= 53 | github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs= 54 | github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= 55 | github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= 56 | github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 57 | github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= 58 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 59 | golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 60 | golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= 61 | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= 62 | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= 63 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 64 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 65 | golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 66 | golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= 67 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 68 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 69 | golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 70 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 71 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 72 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 73 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 74 | golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 75 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 76 | golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 77 | golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU= 78 | golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 79 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 80 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 81 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 82 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 83 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 84 | golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= 85 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 86 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 87 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 88 | golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= 89 | golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= 90 | golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= 91 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 92 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 93 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 94 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 95 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 96 | google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= 97 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 98 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= 99 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 100 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 101 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 102 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 103 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 104 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 105 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 106 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 107 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 108 | -------------------------------------------------------------------------------- /gqlgen.yml: -------------------------------------------------------------------------------- 1 | # Where are all the schema files located? globs are supported eg src/**/*.graphqls 2 | schema: 3 | - graph/*.graphqls 4 | 5 | # Where should the generated server code go? 6 | exec: 7 | filename: graph/generated/generated.go 8 | package: generated 9 | 10 | # Uncomment to enable federation 11 | # federation: 12 | # filename: graph/generated/federation.go 13 | # package: generated 14 | 15 | # Where should any generated models go? 16 | model: 17 | filename: graph/model/models_gen.go 18 | package: model 19 | 20 | # Where should the resolver implementations go? 21 | resolver: 22 | layout: follow-schema 23 | dir: graph 24 | package: graph 25 | 26 | # Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models 27 | # struct_tag: json 28 | 29 | # Optional: turn on to use []Thing instead of []*Thing 30 | # omit_slice_element_pointers: false 31 | 32 | # Optional: turn off to make struct-type struct fields not use pointers 33 | # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } 34 | # struct_fields_always_pointers: true 35 | 36 | # Optional: turn off to make resolvers return values instead of pointers for structs 37 | # resolvers_always_return_pointers: true 38 | 39 | # Optional: set to speed up generation time by not performing a final validation pass. 40 | # skip_validation: true 41 | 42 | # gqlgen will search for any type names in the schema in these go packages 43 | # if they match it will use them, otherwise it will generate them. 44 | autobind: 45 | # - "github.com/devfullcycle/13-GraphQL/graph/model" 46 | 47 | # This section declares type mapping between the GraphQL and go type systems 48 | # 49 | # The first line in each type will be used as defaults for resolver arguments and 50 | # modelgen, the others will be allowed when binding to fields. Configure them to 51 | # your liking 52 | models: 53 | Category: 54 | model: 55 | - github.com/devfullcycle/13-GraphQL/graph/model.Category 56 | Course: 57 | model: 58 | - github.com/devfullcycle/13-GraphQL/graph/model.Course 59 | ID: 60 | model: 61 | - github.com/99designs/gqlgen/graphql.ID 62 | - github.com/99designs/gqlgen/graphql.Int 63 | - github.com/99designs/gqlgen/graphql.Int64 64 | - github.com/99designs/gqlgen/graphql.Int32 65 | Int: 66 | model: 67 | - github.com/99designs/gqlgen/graphql.Int 68 | - github.com/99designs/gqlgen/graphql.Int64 69 | - github.com/99designs/gqlgen/graphql.Int32 70 | -------------------------------------------------------------------------------- /graph/generated/generated.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 | 3 | package generated 4 | 5 | import ( 6 | "bytes" 7 | "context" 8 | "errors" 9 | "fmt" 10 | "strconv" 11 | "sync" 12 | "sync/atomic" 13 | 14 | "github.com/99designs/gqlgen/graphql" 15 | "github.com/99designs/gqlgen/graphql/introspection" 16 | "github.com/devfullcycle/13-GraphQL/graph/model" 17 | gqlparser "github.com/vektah/gqlparser/v2" 18 | "github.com/vektah/gqlparser/v2/ast" 19 | ) 20 | 21 | // region ************************** generated!.gotpl ************************** 22 | 23 | // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. 24 | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { 25 | return &executableSchema{ 26 | resolvers: cfg.Resolvers, 27 | directives: cfg.Directives, 28 | complexity: cfg.Complexity, 29 | } 30 | } 31 | 32 | type Config struct { 33 | Resolvers ResolverRoot 34 | Directives DirectiveRoot 35 | Complexity ComplexityRoot 36 | } 37 | 38 | type ResolverRoot interface { 39 | Category() CategoryResolver 40 | Course() CourseResolver 41 | Mutation() MutationResolver 42 | Query() QueryResolver 43 | } 44 | 45 | type DirectiveRoot struct { 46 | } 47 | 48 | type ComplexityRoot struct { 49 | Category struct { 50 | Courses func(childComplexity int) int 51 | Description func(childComplexity int) int 52 | ID func(childComplexity int) int 53 | Name func(childComplexity int) int 54 | } 55 | 56 | Course struct { 57 | Category func(childComplexity int) int 58 | Description func(childComplexity int) int 59 | ID func(childComplexity int) int 60 | Name func(childComplexity int) int 61 | } 62 | 63 | Mutation struct { 64 | CreateCategory func(childComplexity int, input model.NewCategory) int 65 | CreateCourse func(childComplexity int, input model.NewCourse) int 66 | } 67 | 68 | Query struct { 69 | Categories func(childComplexity int) int 70 | Courses func(childComplexity int) int 71 | } 72 | } 73 | 74 | type CategoryResolver interface { 75 | Courses(ctx context.Context, obj *model.Category) ([]*model.Course, error) 76 | } 77 | type CourseResolver interface { 78 | Category(ctx context.Context, obj *model.Course) (*model.Category, error) 79 | } 80 | type MutationResolver interface { 81 | CreateCategory(ctx context.Context, input model.NewCategory) (*model.Category, error) 82 | CreateCourse(ctx context.Context, input model.NewCourse) (*model.Course, error) 83 | } 84 | type QueryResolver interface { 85 | Categories(ctx context.Context) ([]*model.Category, error) 86 | Courses(ctx context.Context) ([]*model.Course, error) 87 | } 88 | 89 | type executableSchema struct { 90 | resolvers ResolverRoot 91 | directives DirectiveRoot 92 | complexity ComplexityRoot 93 | } 94 | 95 | func (e *executableSchema) Schema() *ast.Schema { 96 | return parsedSchema 97 | } 98 | 99 | func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { 100 | ec := executionContext{nil, e} 101 | _ = ec 102 | switch typeName + "." + field { 103 | 104 | case "Category.courses": 105 | if e.complexity.Category.Courses == nil { 106 | break 107 | } 108 | 109 | return e.complexity.Category.Courses(childComplexity), true 110 | 111 | case "Category.description": 112 | if e.complexity.Category.Description == nil { 113 | break 114 | } 115 | 116 | return e.complexity.Category.Description(childComplexity), true 117 | 118 | case "Category.id": 119 | if e.complexity.Category.ID == nil { 120 | break 121 | } 122 | 123 | return e.complexity.Category.ID(childComplexity), true 124 | 125 | case "Category.name": 126 | if e.complexity.Category.Name == nil { 127 | break 128 | } 129 | 130 | return e.complexity.Category.Name(childComplexity), true 131 | 132 | case "Course.category": 133 | if e.complexity.Course.Category == nil { 134 | break 135 | } 136 | 137 | return e.complexity.Course.Category(childComplexity), true 138 | 139 | case "Course.description": 140 | if e.complexity.Course.Description == nil { 141 | break 142 | } 143 | 144 | return e.complexity.Course.Description(childComplexity), true 145 | 146 | case "Course.id": 147 | if e.complexity.Course.ID == nil { 148 | break 149 | } 150 | 151 | return e.complexity.Course.ID(childComplexity), true 152 | 153 | case "Course.name": 154 | if e.complexity.Course.Name == nil { 155 | break 156 | } 157 | 158 | return e.complexity.Course.Name(childComplexity), true 159 | 160 | case "Mutation.createCategory": 161 | if e.complexity.Mutation.CreateCategory == nil { 162 | break 163 | } 164 | 165 | args, err := ec.field_Mutation_createCategory_args(context.TODO(), rawArgs) 166 | if err != nil { 167 | return 0, false 168 | } 169 | 170 | return e.complexity.Mutation.CreateCategory(childComplexity, args["input"].(model.NewCategory)), true 171 | 172 | case "Mutation.createCourse": 173 | if e.complexity.Mutation.CreateCourse == nil { 174 | break 175 | } 176 | 177 | args, err := ec.field_Mutation_createCourse_args(context.TODO(), rawArgs) 178 | if err != nil { 179 | return 0, false 180 | } 181 | 182 | return e.complexity.Mutation.CreateCourse(childComplexity, args["input"].(model.NewCourse)), true 183 | 184 | case "Query.categories": 185 | if e.complexity.Query.Categories == nil { 186 | break 187 | } 188 | 189 | return e.complexity.Query.Categories(childComplexity), true 190 | 191 | case "Query.courses": 192 | if e.complexity.Query.Courses == nil { 193 | break 194 | } 195 | 196 | return e.complexity.Query.Courses(childComplexity), true 197 | 198 | } 199 | return 0, false 200 | } 201 | 202 | func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { 203 | rc := graphql.GetOperationContext(ctx) 204 | ec := executionContext{rc, e} 205 | inputUnmarshalMap := graphql.BuildUnmarshalerMap( 206 | ec.unmarshalInputNewCategory, 207 | ec.unmarshalInputNewCourse, 208 | ) 209 | first := true 210 | 211 | switch rc.Operation.Operation { 212 | case ast.Query: 213 | return func(ctx context.Context) *graphql.Response { 214 | if !first { 215 | return nil 216 | } 217 | first = false 218 | ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) 219 | data := ec._Query(ctx, rc.Operation.SelectionSet) 220 | var buf bytes.Buffer 221 | data.MarshalGQL(&buf) 222 | 223 | return &graphql.Response{ 224 | Data: buf.Bytes(), 225 | } 226 | } 227 | case ast.Mutation: 228 | return func(ctx context.Context) *graphql.Response { 229 | if !first { 230 | return nil 231 | } 232 | first = false 233 | ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) 234 | data := ec._Mutation(ctx, rc.Operation.SelectionSet) 235 | var buf bytes.Buffer 236 | data.MarshalGQL(&buf) 237 | 238 | return &graphql.Response{ 239 | Data: buf.Bytes(), 240 | } 241 | } 242 | 243 | default: 244 | return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) 245 | } 246 | } 247 | 248 | type executionContext struct { 249 | *graphql.OperationContext 250 | *executableSchema 251 | } 252 | 253 | func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { 254 | if ec.DisableIntrospection { 255 | return nil, errors.New("introspection disabled") 256 | } 257 | return introspection.WrapSchema(parsedSchema), nil 258 | } 259 | 260 | func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { 261 | if ec.DisableIntrospection { 262 | return nil, errors.New("introspection disabled") 263 | } 264 | return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil 265 | } 266 | 267 | var sources = []*ast.Source{ 268 | {Name: "../schema.graphqls", Input: `type Category { 269 | id: ID! 270 | name: String! 271 | description: String 272 | courses: [Course!]! 273 | } 274 | 275 | type Course { 276 | id: ID! 277 | name : String! 278 | description: String 279 | category: Category! 280 | } 281 | 282 | input NewCategory { 283 | name: String! 284 | description: String 285 | } 286 | 287 | input NewCourse { 288 | name: String! 289 | description: String 290 | categoryId: ID! 291 | } 292 | 293 | type Query { 294 | categories: [Category!]! 295 | courses: [Course!]! 296 | } 297 | 298 | type Mutation { 299 | createCategory(input: NewCategory!): Category! 300 | createCourse(input: NewCourse!): Course! 301 | }`, BuiltIn: false}, 302 | } 303 | var parsedSchema = gqlparser.MustLoadSchema(sources...) 304 | 305 | // endregion ************************** generated!.gotpl ************************** 306 | 307 | // region ***************************** args.gotpl ***************************** 308 | 309 | func (ec *executionContext) field_Mutation_createCategory_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 310 | var err error 311 | args := map[string]interface{}{} 312 | var arg0 model.NewCategory 313 | if tmp, ok := rawArgs["input"]; ok { 314 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) 315 | arg0, err = ec.unmarshalNNewCategory2githubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐNewCategory(ctx, tmp) 316 | if err != nil { 317 | return nil, err 318 | } 319 | } 320 | args["input"] = arg0 321 | return args, nil 322 | } 323 | 324 | func (ec *executionContext) field_Mutation_createCourse_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 325 | var err error 326 | args := map[string]interface{}{} 327 | var arg0 model.NewCourse 328 | if tmp, ok := rawArgs["input"]; ok { 329 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) 330 | arg0, err = ec.unmarshalNNewCourse2githubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐNewCourse(ctx, tmp) 331 | if err != nil { 332 | return nil, err 333 | } 334 | } 335 | args["input"] = arg0 336 | return args, nil 337 | } 338 | 339 | func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 340 | var err error 341 | args := map[string]interface{}{} 342 | var arg0 string 343 | if tmp, ok := rawArgs["name"]; ok { 344 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) 345 | arg0, err = ec.unmarshalNString2string(ctx, tmp) 346 | if err != nil { 347 | return nil, err 348 | } 349 | } 350 | args["name"] = arg0 351 | return args, nil 352 | } 353 | 354 | func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 355 | var err error 356 | args := map[string]interface{}{} 357 | var arg0 bool 358 | if tmp, ok := rawArgs["includeDeprecated"]; ok { 359 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) 360 | arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) 361 | if err != nil { 362 | return nil, err 363 | } 364 | } 365 | args["includeDeprecated"] = arg0 366 | return args, nil 367 | } 368 | 369 | func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 370 | var err error 371 | args := map[string]interface{}{} 372 | var arg0 bool 373 | if tmp, ok := rawArgs["includeDeprecated"]; ok { 374 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) 375 | arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) 376 | if err != nil { 377 | return nil, err 378 | } 379 | } 380 | args["includeDeprecated"] = arg0 381 | return args, nil 382 | } 383 | 384 | // endregion ***************************** args.gotpl ***************************** 385 | 386 | // region ************************** directives.gotpl ************************** 387 | 388 | // endregion ************************** directives.gotpl ************************** 389 | 390 | // region **************************** field.gotpl ***************************** 391 | 392 | func (ec *executionContext) _Category_id(ctx context.Context, field graphql.CollectedField, obj *model.Category) (ret graphql.Marshaler) { 393 | fc, err := ec.fieldContext_Category_id(ctx, field) 394 | if err != nil { 395 | return graphql.Null 396 | } 397 | ctx = graphql.WithFieldContext(ctx, fc) 398 | defer func() { 399 | if r := recover(); r != nil { 400 | ec.Error(ctx, ec.Recover(ctx, r)) 401 | ret = graphql.Null 402 | } 403 | }() 404 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 405 | ctx = rctx // use context from middleware stack in children 406 | return obj.ID, nil 407 | }) 408 | if err != nil { 409 | ec.Error(ctx, err) 410 | return graphql.Null 411 | } 412 | if resTmp == nil { 413 | if !graphql.HasFieldError(ctx, fc) { 414 | ec.Errorf(ctx, "must not be null") 415 | } 416 | return graphql.Null 417 | } 418 | res := resTmp.(string) 419 | fc.Result = res 420 | return ec.marshalNID2string(ctx, field.Selections, res) 421 | } 422 | 423 | func (ec *executionContext) fieldContext_Category_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 424 | fc = &graphql.FieldContext{ 425 | Object: "Category", 426 | Field: field, 427 | IsMethod: false, 428 | IsResolver: false, 429 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 430 | return nil, errors.New("field of type ID does not have child fields") 431 | }, 432 | } 433 | return fc, nil 434 | } 435 | 436 | func (ec *executionContext) _Category_name(ctx context.Context, field graphql.CollectedField, obj *model.Category) (ret graphql.Marshaler) { 437 | fc, err := ec.fieldContext_Category_name(ctx, field) 438 | if err != nil { 439 | return graphql.Null 440 | } 441 | ctx = graphql.WithFieldContext(ctx, fc) 442 | defer func() { 443 | if r := recover(); r != nil { 444 | ec.Error(ctx, ec.Recover(ctx, r)) 445 | ret = graphql.Null 446 | } 447 | }() 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) fieldContext_Category_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 468 | fc = &graphql.FieldContext{ 469 | Object: "Category", 470 | Field: field, 471 | IsMethod: false, 472 | IsResolver: false, 473 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 474 | return nil, errors.New("field of type String does not have child fields") 475 | }, 476 | } 477 | return fc, nil 478 | } 479 | 480 | func (ec *executionContext) _Category_description(ctx context.Context, field graphql.CollectedField, obj *model.Category) (ret graphql.Marshaler) { 481 | fc, err := ec.fieldContext_Category_description(ctx, field) 482 | if err != nil { 483 | return graphql.Null 484 | } 485 | ctx = graphql.WithFieldContext(ctx, fc) 486 | defer func() { 487 | if r := recover(); r != nil { 488 | ec.Error(ctx, ec.Recover(ctx, r)) 489 | ret = graphql.Null 490 | } 491 | }() 492 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 493 | ctx = rctx // use context from middleware stack in children 494 | return obj.Description, nil 495 | }) 496 | if err != nil { 497 | ec.Error(ctx, err) 498 | return graphql.Null 499 | } 500 | if resTmp == nil { 501 | return graphql.Null 502 | } 503 | res := resTmp.(*string) 504 | fc.Result = res 505 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 506 | } 507 | 508 | func (ec *executionContext) fieldContext_Category_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 509 | fc = &graphql.FieldContext{ 510 | Object: "Category", 511 | Field: field, 512 | IsMethod: false, 513 | IsResolver: false, 514 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 515 | return nil, errors.New("field of type String does not have child fields") 516 | }, 517 | } 518 | return fc, nil 519 | } 520 | 521 | func (ec *executionContext) _Category_courses(ctx context.Context, field graphql.CollectedField, obj *model.Category) (ret graphql.Marshaler) { 522 | fc, err := ec.fieldContext_Category_courses(ctx, field) 523 | if err != nil { 524 | return graphql.Null 525 | } 526 | ctx = graphql.WithFieldContext(ctx, fc) 527 | defer func() { 528 | if r := recover(); r != nil { 529 | ec.Error(ctx, ec.Recover(ctx, r)) 530 | ret = graphql.Null 531 | } 532 | }() 533 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 534 | ctx = rctx // use context from middleware stack in children 535 | return ec.resolvers.Category().Courses(rctx, obj) 536 | }) 537 | if err != nil { 538 | ec.Error(ctx, err) 539 | return graphql.Null 540 | } 541 | if resTmp == nil { 542 | if !graphql.HasFieldError(ctx, fc) { 543 | ec.Errorf(ctx, "must not be null") 544 | } 545 | return graphql.Null 546 | } 547 | res := resTmp.([]*model.Course) 548 | fc.Result = res 549 | return ec.marshalNCourse2ᚕᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCourseᚄ(ctx, field.Selections, res) 550 | } 551 | 552 | func (ec *executionContext) fieldContext_Category_courses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 553 | fc = &graphql.FieldContext{ 554 | Object: "Category", 555 | Field: field, 556 | IsMethod: true, 557 | IsResolver: true, 558 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 559 | switch field.Name { 560 | case "id": 561 | return ec.fieldContext_Course_id(ctx, field) 562 | case "name": 563 | return ec.fieldContext_Course_name(ctx, field) 564 | case "description": 565 | return ec.fieldContext_Course_description(ctx, field) 566 | case "category": 567 | return ec.fieldContext_Course_category(ctx, field) 568 | } 569 | return nil, fmt.Errorf("no field named %q was found under type Course", field.Name) 570 | }, 571 | } 572 | return fc, nil 573 | } 574 | 575 | func (ec *executionContext) _Course_id(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { 576 | fc, err := ec.fieldContext_Course_id(ctx, field) 577 | if err != nil { 578 | return graphql.Null 579 | } 580 | ctx = graphql.WithFieldContext(ctx, fc) 581 | defer func() { 582 | if r := recover(); r != nil { 583 | ec.Error(ctx, ec.Recover(ctx, r)) 584 | ret = graphql.Null 585 | } 586 | }() 587 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 588 | ctx = rctx // use context from middleware stack in children 589 | return obj.ID, nil 590 | }) 591 | if err != nil { 592 | ec.Error(ctx, err) 593 | return graphql.Null 594 | } 595 | if resTmp == nil { 596 | if !graphql.HasFieldError(ctx, fc) { 597 | ec.Errorf(ctx, "must not be null") 598 | } 599 | return graphql.Null 600 | } 601 | res := resTmp.(string) 602 | fc.Result = res 603 | return ec.marshalNID2string(ctx, field.Selections, res) 604 | } 605 | 606 | func (ec *executionContext) fieldContext_Course_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 607 | fc = &graphql.FieldContext{ 608 | Object: "Course", 609 | Field: field, 610 | IsMethod: false, 611 | IsResolver: false, 612 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 613 | return nil, errors.New("field of type ID does not have child fields") 614 | }, 615 | } 616 | return fc, nil 617 | } 618 | 619 | func (ec *executionContext) _Course_name(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { 620 | fc, err := ec.fieldContext_Course_name(ctx, field) 621 | if err != nil { 622 | return graphql.Null 623 | } 624 | ctx = graphql.WithFieldContext(ctx, fc) 625 | defer func() { 626 | if r := recover(); r != nil { 627 | ec.Error(ctx, ec.Recover(ctx, r)) 628 | ret = graphql.Null 629 | } 630 | }() 631 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 632 | ctx = rctx // use context from middleware stack in children 633 | return obj.Name, nil 634 | }) 635 | if err != nil { 636 | ec.Error(ctx, err) 637 | return graphql.Null 638 | } 639 | if resTmp == nil { 640 | if !graphql.HasFieldError(ctx, fc) { 641 | ec.Errorf(ctx, "must not be null") 642 | } 643 | return graphql.Null 644 | } 645 | res := resTmp.(string) 646 | fc.Result = res 647 | return ec.marshalNString2string(ctx, field.Selections, res) 648 | } 649 | 650 | func (ec *executionContext) fieldContext_Course_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 651 | fc = &graphql.FieldContext{ 652 | Object: "Course", 653 | Field: field, 654 | IsMethod: false, 655 | IsResolver: false, 656 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 657 | return nil, errors.New("field of type String does not have child fields") 658 | }, 659 | } 660 | return fc, nil 661 | } 662 | 663 | func (ec *executionContext) _Course_description(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { 664 | fc, err := ec.fieldContext_Course_description(ctx, field) 665 | if err != nil { 666 | return graphql.Null 667 | } 668 | ctx = graphql.WithFieldContext(ctx, fc) 669 | defer func() { 670 | if r := recover(); r != nil { 671 | ec.Error(ctx, ec.Recover(ctx, r)) 672 | ret = graphql.Null 673 | } 674 | }() 675 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 676 | ctx = rctx // use context from middleware stack in children 677 | return obj.Description, nil 678 | }) 679 | if err != nil { 680 | ec.Error(ctx, err) 681 | return graphql.Null 682 | } 683 | if resTmp == nil { 684 | return graphql.Null 685 | } 686 | res := resTmp.(*string) 687 | fc.Result = res 688 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 689 | } 690 | 691 | func (ec *executionContext) fieldContext_Course_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 692 | fc = &graphql.FieldContext{ 693 | Object: "Course", 694 | Field: field, 695 | IsMethod: false, 696 | IsResolver: false, 697 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 698 | return nil, errors.New("field of type String does not have child fields") 699 | }, 700 | } 701 | return fc, nil 702 | } 703 | 704 | func (ec *executionContext) _Course_category(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { 705 | fc, err := ec.fieldContext_Course_category(ctx, field) 706 | if err != nil { 707 | return graphql.Null 708 | } 709 | ctx = graphql.WithFieldContext(ctx, fc) 710 | defer func() { 711 | if r := recover(); r != nil { 712 | ec.Error(ctx, ec.Recover(ctx, r)) 713 | ret = graphql.Null 714 | } 715 | }() 716 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 717 | ctx = rctx // use context from middleware stack in children 718 | return ec.resolvers.Course().Category(rctx, obj) 719 | }) 720 | if err != nil { 721 | ec.Error(ctx, err) 722 | return graphql.Null 723 | } 724 | if resTmp == nil { 725 | if !graphql.HasFieldError(ctx, fc) { 726 | ec.Errorf(ctx, "must not be null") 727 | } 728 | return graphql.Null 729 | } 730 | res := resTmp.(*model.Category) 731 | fc.Result = res 732 | return ec.marshalNCategory2ᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCategory(ctx, field.Selections, res) 733 | } 734 | 735 | func (ec *executionContext) fieldContext_Course_category(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 736 | fc = &graphql.FieldContext{ 737 | Object: "Course", 738 | Field: field, 739 | IsMethod: true, 740 | IsResolver: true, 741 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 742 | switch field.Name { 743 | case "id": 744 | return ec.fieldContext_Category_id(ctx, field) 745 | case "name": 746 | return ec.fieldContext_Category_name(ctx, field) 747 | case "description": 748 | return ec.fieldContext_Category_description(ctx, field) 749 | case "courses": 750 | return ec.fieldContext_Category_courses(ctx, field) 751 | } 752 | return nil, fmt.Errorf("no field named %q was found under type Category", field.Name) 753 | }, 754 | } 755 | return fc, nil 756 | } 757 | 758 | func (ec *executionContext) _Mutation_createCategory(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 759 | fc, err := ec.fieldContext_Mutation_createCategory(ctx, field) 760 | if err != nil { 761 | return graphql.Null 762 | } 763 | ctx = graphql.WithFieldContext(ctx, fc) 764 | defer func() { 765 | if r := recover(); r != nil { 766 | ec.Error(ctx, ec.Recover(ctx, r)) 767 | ret = graphql.Null 768 | } 769 | }() 770 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 771 | ctx = rctx // use context from middleware stack in children 772 | return ec.resolvers.Mutation().CreateCategory(rctx, fc.Args["input"].(model.NewCategory)) 773 | }) 774 | if err != nil { 775 | ec.Error(ctx, err) 776 | return graphql.Null 777 | } 778 | if resTmp == nil { 779 | if !graphql.HasFieldError(ctx, fc) { 780 | ec.Errorf(ctx, "must not be null") 781 | } 782 | return graphql.Null 783 | } 784 | res := resTmp.(*model.Category) 785 | fc.Result = res 786 | return ec.marshalNCategory2ᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCategory(ctx, field.Selections, res) 787 | } 788 | 789 | func (ec *executionContext) fieldContext_Mutation_createCategory(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 790 | fc = &graphql.FieldContext{ 791 | Object: "Mutation", 792 | Field: field, 793 | IsMethod: true, 794 | IsResolver: true, 795 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 796 | switch field.Name { 797 | case "id": 798 | return ec.fieldContext_Category_id(ctx, field) 799 | case "name": 800 | return ec.fieldContext_Category_name(ctx, field) 801 | case "description": 802 | return ec.fieldContext_Category_description(ctx, field) 803 | case "courses": 804 | return ec.fieldContext_Category_courses(ctx, field) 805 | } 806 | return nil, fmt.Errorf("no field named %q was found under type Category", field.Name) 807 | }, 808 | } 809 | defer func() { 810 | if r := recover(); r != nil { 811 | err = ec.Recover(ctx, r) 812 | ec.Error(ctx, err) 813 | } 814 | }() 815 | ctx = graphql.WithFieldContext(ctx, fc) 816 | if fc.Args, err = ec.field_Mutation_createCategory_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { 817 | ec.Error(ctx, err) 818 | return 819 | } 820 | return fc, nil 821 | } 822 | 823 | func (ec *executionContext) _Mutation_createCourse(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 824 | fc, err := ec.fieldContext_Mutation_createCourse(ctx, field) 825 | if err != nil { 826 | return graphql.Null 827 | } 828 | ctx = graphql.WithFieldContext(ctx, fc) 829 | defer func() { 830 | if r := recover(); r != nil { 831 | ec.Error(ctx, ec.Recover(ctx, r)) 832 | ret = graphql.Null 833 | } 834 | }() 835 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 836 | ctx = rctx // use context from middleware stack in children 837 | return ec.resolvers.Mutation().CreateCourse(rctx, fc.Args["input"].(model.NewCourse)) 838 | }) 839 | if err != nil { 840 | ec.Error(ctx, err) 841 | return graphql.Null 842 | } 843 | if resTmp == nil { 844 | if !graphql.HasFieldError(ctx, fc) { 845 | ec.Errorf(ctx, "must not be null") 846 | } 847 | return graphql.Null 848 | } 849 | res := resTmp.(*model.Course) 850 | fc.Result = res 851 | return ec.marshalNCourse2ᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCourse(ctx, field.Selections, res) 852 | } 853 | 854 | func (ec *executionContext) fieldContext_Mutation_createCourse(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 855 | fc = &graphql.FieldContext{ 856 | Object: "Mutation", 857 | Field: field, 858 | IsMethod: true, 859 | IsResolver: true, 860 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 861 | switch field.Name { 862 | case "id": 863 | return ec.fieldContext_Course_id(ctx, field) 864 | case "name": 865 | return ec.fieldContext_Course_name(ctx, field) 866 | case "description": 867 | return ec.fieldContext_Course_description(ctx, field) 868 | case "category": 869 | return ec.fieldContext_Course_category(ctx, field) 870 | } 871 | return nil, fmt.Errorf("no field named %q was found under type Course", field.Name) 872 | }, 873 | } 874 | defer func() { 875 | if r := recover(); r != nil { 876 | err = ec.Recover(ctx, r) 877 | ec.Error(ctx, err) 878 | } 879 | }() 880 | ctx = graphql.WithFieldContext(ctx, fc) 881 | if fc.Args, err = ec.field_Mutation_createCourse_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { 882 | ec.Error(ctx, err) 883 | return 884 | } 885 | return fc, nil 886 | } 887 | 888 | func (ec *executionContext) _Query_categories(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 889 | fc, err := ec.fieldContext_Query_categories(ctx, field) 890 | if err != nil { 891 | return graphql.Null 892 | } 893 | ctx = graphql.WithFieldContext(ctx, fc) 894 | defer func() { 895 | if r := recover(); r != nil { 896 | ec.Error(ctx, ec.Recover(ctx, r)) 897 | ret = graphql.Null 898 | } 899 | }() 900 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 901 | ctx = rctx // use context from middleware stack in children 902 | return ec.resolvers.Query().Categories(rctx) 903 | }) 904 | if err != nil { 905 | ec.Error(ctx, err) 906 | return graphql.Null 907 | } 908 | if resTmp == nil { 909 | if !graphql.HasFieldError(ctx, fc) { 910 | ec.Errorf(ctx, "must not be null") 911 | } 912 | return graphql.Null 913 | } 914 | res := resTmp.([]*model.Category) 915 | fc.Result = res 916 | return ec.marshalNCategory2ᚕᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCategoryᚄ(ctx, field.Selections, res) 917 | } 918 | 919 | func (ec *executionContext) fieldContext_Query_categories(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 920 | fc = &graphql.FieldContext{ 921 | Object: "Query", 922 | Field: field, 923 | IsMethod: true, 924 | IsResolver: true, 925 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 926 | switch field.Name { 927 | case "id": 928 | return ec.fieldContext_Category_id(ctx, field) 929 | case "name": 930 | return ec.fieldContext_Category_name(ctx, field) 931 | case "description": 932 | return ec.fieldContext_Category_description(ctx, field) 933 | case "courses": 934 | return ec.fieldContext_Category_courses(ctx, field) 935 | } 936 | return nil, fmt.Errorf("no field named %q was found under type Category", field.Name) 937 | }, 938 | } 939 | return fc, nil 940 | } 941 | 942 | func (ec *executionContext) _Query_courses(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 943 | fc, err := ec.fieldContext_Query_courses(ctx, field) 944 | if err != nil { 945 | return graphql.Null 946 | } 947 | ctx = graphql.WithFieldContext(ctx, fc) 948 | defer func() { 949 | if r := recover(); r != nil { 950 | ec.Error(ctx, ec.Recover(ctx, r)) 951 | ret = graphql.Null 952 | } 953 | }() 954 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 955 | ctx = rctx // use context from middleware stack in children 956 | return ec.resolvers.Query().Courses(rctx) 957 | }) 958 | if err != nil { 959 | ec.Error(ctx, err) 960 | return graphql.Null 961 | } 962 | if resTmp == nil { 963 | if !graphql.HasFieldError(ctx, fc) { 964 | ec.Errorf(ctx, "must not be null") 965 | } 966 | return graphql.Null 967 | } 968 | res := resTmp.([]*model.Course) 969 | fc.Result = res 970 | return ec.marshalNCourse2ᚕᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCourseᚄ(ctx, field.Selections, res) 971 | } 972 | 973 | func (ec *executionContext) fieldContext_Query_courses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 974 | fc = &graphql.FieldContext{ 975 | Object: "Query", 976 | Field: field, 977 | IsMethod: true, 978 | IsResolver: true, 979 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 980 | switch field.Name { 981 | case "id": 982 | return ec.fieldContext_Course_id(ctx, field) 983 | case "name": 984 | return ec.fieldContext_Course_name(ctx, field) 985 | case "description": 986 | return ec.fieldContext_Course_description(ctx, field) 987 | case "category": 988 | return ec.fieldContext_Course_category(ctx, field) 989 | } 990 | return nil, fmt.Errorf("no field named %q was found under type Course", field.Name) 991 | }, 992 | } 993 | return fc, nil 994 | } 995 | 996 | func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 997 | fc, err := ec.fieldContext_Query___type(ctx, field) 998 | if err != nil { 999 | return graphql.Null 1000 | } 1001 | ctx = graphql.WithFieldContext(ctx, fc) 1002 | defer func() { 1003 | if r := recover(); r != nil { 1004 | ec.Error(ctx, ec.Recover(ctx, r)) 1005 | ret = graphql.Null 1006 | } 1007 | }() 1008 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1009 | ctx = rctx // use context from middleware stack in children 1010 | return ec.introspectType(fc.Args["name"].(string)) 1011 | }) 1012 | if err != nil { 1013 | ec.Error(ctx, err) 1014 | return graphql.Null 1015 | } 1016 | if resTmp == nil { 1017 | return graphql.Null 1018 | } 1019 | res := resTmp.(*introspection.Type) 1020 | fc.Result = res 1021 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1022 | } 1023 | 1024 | func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1025 | fc = &graphql.FieldContext{ 1026 | Object: "Query", 1027 | Field: field, 1028 | IsMethod: true, 1029 | IsResolver: false, 1030 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1031 | switch field.Name { 1032 | case "kind": 1033 | return ec.fieldContext___Type_kind(ctx, field) 1034 | case "name": 1035 | return ec.fieldContext___Type_name(ctx, field) 1036 | case "description": 1037 | return ec.fieldContext___Type_description(ctx, field) 1038 | case "fields": 1039 | return ec.fieldContext___Type_fields(ctx, field) 1040 | case "interfaces": 1041 | return ec.fieldContext___Type_interfaces(ctx, field) 1042 | case "possibleTypes": 1043 | return ec.fieldContext___Type_possibleTypes(ctx, field) 1044 | case "enumValues": 1045 | return ec.fieldContext___Type_enumValues(ctx, field) 1046 | case "inputFields": 1047 | return ec.fieldContext___Type_inputFields(ctx, field) 1048 | case "ofType": 1049 | return ec.fieldContext___Type_ofType(ctx, field) 1050 | case "specifiedByURL": 1051 | return ec.fieldContext___Type_specifiedByURL(ctx, field) 1052 | } 1053 | return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) 1054 | }, 1055 | } 1056 | defer func() { 1057 | if r := recover(); r != nil { 1058 | err = ec.Recover(ctx, r) 1059 | ec.Error(ctx, err) 1060 | } 1061 | }() 1062 | ctx = graphql.WithFieldContext(ctx, fc) 1063 | if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { 1064 | ec.Error(ctx, err) 1065 | return 1066 | } 1067 | return fc, nil 1068 | } 1069 | 1070 | func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 1071 | fc, err := ec.fieldContext_Query___schema(ctx, field) 1072 | if err != nil { 1073 | return graphql.Null 1074 | } 1075 | ctx = graphql.WithFieldContext(ctx, fc) 1076 | defer func() { 1077 | if r := recover(); r != nil { 1078 | ec.Error(ctx, ec.Recover(ctx, r)) 1079 | ret = graphql.Null 1080 | } 1081 | }() 1082 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1083 | ctx = rctx // use context from middleware stack in children 1084 | return ec.introspectSchema() 1085 | }) 1086 | if err != nil { 1087 | ec.Error(ctx, err) 1088 | return graphql.Null 1089 | } 1090 | if resTmp == nil { 1091 | return graphql.Null 1092 | } 1093 | res := resTmp.(*introspection.Schema) 1094 | fc.Result = res 1095 | return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) 1096 | } 1097 | 1098 | func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1099 | fc = &graphql.FieldContext{ 1100 | Object: "Query", 1101 | Field: field, 1102 | IsMethod: true, 1103 | IsResolver: false, 1104 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1105 | switch field.Name { 1106 | case "description": 1107 | return ec.fieldContext___Schema_description(ctx, field) 1108 | case "types": 1109 | return ec.fieldContext___Schema_types(ctx, field) 1110 | case "queryType": 1111 | return ec.fieldContext___Schema_queryType(ctx, field) 1112 | case "mutationType": 1113 | return ec.fieldContext___Schema_mutationType(ctx, field) 1114 | case "subscriptionType": 1115 | return ec.fieldContext___Schema_subscriptionType(ctx, field) 1116 | case "directives": 1117 | return ec.fieldContext___Schema_directives(ctx, field) 1118 | } 1119 | return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) 1120 | }, 1121 | } 1122 | return fc, nil 1123 | } 1124 | 1125 | func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 1126 | fc, err := ec.fieldContext___Directive_name(ctx, field) 1127 | if err != nil { 1128 | return graphql.Null 1129 | } 1130 | ctx = graphql.WithFieldContext(ctx, fc) 1131 | defer func() { 1132 | if r := recover(); r != nil { 1133 | ec.Error(ctx, ec.Recover(ctx, r)) 1134 | ret = graphql.Null 1135 | } 1136 | }() 1137 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1138 | ctx = rctx // use context from middleware stack in children 1139 | return obj.Name, nil 1140 | }) 1141 | if err != nil { 1142 | ec.Error(ctx, err) 1143 | return graphql.Null 1144 | } 1145 | if resTmp == nil { 1146 | if !graphql.HasFieldError(ctx, fc) { 1147 | ec.Errorf(ctx, "must not be null") 1148 | } 1149 | return graphql.Null 1150 | } 1151 | res := resTmp.(string) 1152 | fc.Result = res 1153 | return ec.marshalNString2string(ctx, field.Selections, res) 1154 | } 1155 | 1156 | func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1157 | fc = &graphql.FieldContext{ 1158 | Object: "__Directive", 1159 | Field: field, 1160 | IsMethod: false, 1161 | IsResolver: false, 1162 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1163 | return nil, errors.New("field of type String does not have child fields") 1164 | }, 1165 | } 1166 | return fc, nil 1167 | } 1168 | 1169 | func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 1170 | fc, err := ec.fieldContext___Directive_description(ctx, field) 1171 | if err != nil { 1172 | return graphql.Null 1173 | } 1174 | ctx = graphql.WithFieldContext(ctx, fc) 1175 | defer func() { 1176 | if r := recover(); r != nil { 1177 | ec.Error(ctx, ec.Recover(ctx, r)) 1178 | ret = graphql.Null 1179 | } 1180 | }() 1181 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1182 | ctx = rctx // use context from middleware stack in children 1183 | return obj.Description(), nil 1184 | }) 1185 | if err != nil { 1186 | ec.Error(ctx, err) 1187 | return graphql.Null 1188 | } 1189 | if resTmp == nil { 1190 | return graphql.Null 1191 | } 1192 | res := resTmp.(*string) 1193 | fc.Result = res 1194 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1195 | } 1196 | 1197 | func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1198 | fc = &graphql.FieldContext{ 1199 | Object: "__Directive", 1200 | Field: field, 1201 | IsMethod: true, 1202 | IsResolver: false, 1203 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1204 | return nil, errors.New("field of type String does not have child fields") 1205 | }, 1206 | } 1207 | return fc, nil 1208 | } 1209 | 1210 | func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 1211 | fc, err := ec.fieldContext___Directive_locations(ctx, field) 1212 | if err != nil { 1213 | return graphql.Null 1214 | } 1215 | ctx = graphql.WithFieldContext(ctx, fc) 1216 | defer func() { 1217 | if r := recover(); r != nil { 1218 | ec.Error(ctx, ec.Recover(ctx, r)) 1219 | ret = graphql.Null 1220 | } 1221 | }() 1222 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1223 | ctx = rctx // use context from middleware stack in children 1224 | return obj.Locations, nil 1225 | }) 1226 | if err != nil { 1227 | ec.Error(ctx, err) 1228 | return graphql.Null 1229 | } 1230 | if resTmp == nil { 1231 | if !graphql.HasFieldError(ctx, fc) { 1232 | ec.Errorf(ctx, "must not be null") 1233 | } 1234 | return graphql.Null 1235 | } 1236 | res := resTmp.([]string) 1237 | fc.Result = res 1238 | return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) 1239 | } 1240 | 1241 | func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1242 | fc = &graphql.FieldContext{ 1243 | Object: "__Directive", 1244 | Field: field, 1245 | IsMethod: false, 1246 | IsResolver: false, 1247 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1248 | return nil, errors.New("field of type __DirectiveLocation does not have child fields") 1249 | }, 1250 | } 1251 | return fc, nil 1252 | } 1253 | 1254 | func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 1255 | fc, err := ec.fieldContext___Directive_args(ctx, field) 1256 | if err != nil { 1257 | return graphql.Null 1258 | } 1259 | ctx = graphql.WithFieldContext(ctx, fc) 1260 | defer func() { 1261 | if r := recover(); r != nil { 1262 | ec.Error(ctx, ec.Recover(ctx, r)) 1263 | ret = graphql.Null 1264 | } 1265 | }() 1266 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1267 | ctx = rctx // use context from middleware stack in children 1268 | return obj.Args, nil 1269 | }) 1270 | if err != nil { 1271 | ec.Error(ctx, err) 1272 | return graphql.Null 1273 | } 1274 | if resTmp == nil { 1275 | if !graphql.HasFieldError(ctx, fc) { 1276 | ec.Errorf(ctx, "must not be null") 1277 | } 1278 | return graphql.Null 1279 | } 1280 | res := resTmp.([]introspection.InputValue) 1281 | fc.Result = res 1282 | return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 1283 | } 1284 | 1285 | func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1286 | fc = &graphql.FieldContext{ 1287 | Object: "__Directive", 1288 | Field: field, 1289 | IsMethod: false, 1290 | IsResolver: false, 1291 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1292 | switch field.Name { 1293 | case "name": 1294 | return ec.fieldContext___InputValue_name(ctx, field) 1295 | case "description": 1296 | return ec.fieldContext___InputValue_description(ctx, field) 1297 | case "type": 1298 | return ec.fieldContext___InputValue_type(ctx, field) 1299 | case "defaultValue": 1300 | return ec.fieldContext___InputValue_defaultValue(ctx, field) 1301 | } 1302 | return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) 1303 | }, 1304 | } 1305 | return fc, nil 1306 | } 1307 | 1308 | func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 1309 | fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) 1310 | if err != nil { 1311 | return graphql.Null 1312 | } 1313 | ctx = graphql.WithFieldContext(ctx, fc) 1314 | defer func() { 1315 | if r := recover(); r != nil { 1316 | ec.Error(ctx, ec.Recover(ctx, r)) 1317 | ret = graphql.Null 1318 | } 1319 | }() 1320 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1321 | ctx = rctx // use context from middleware stack in children 1322 | return obj.IsRepeatable, nil 1323 | }) 1324 | if err != nil { 1325 | ec.Error(ctx, err) 1326 | return graphql.Null 1327 | } 1328 | if resTmp == nil { 1329 | if !graphql.HasFieldError(ctx, fc) { 1330 | ec.Errorf(ctx, "must not be null") 1331 | } 1332 | return graphql.Null 1333 | } 1334 | res := resTmp.(bool) 1335 | fc.Result = res 1336 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 1337 | } 1338 | 1339 | func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1340 | fc = &graphql.FieldContext{ 1341 | Object: "__Directive", 1342 | Field: field, 1343 | IsMethod: false, 1344 | IsResolver: false, 1345 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1346 | return nil, errors.New("field of type Boolean does not have child fields") 1347 | }, 1348 | } 1349 | return fc, nil 1350 | } 1351 | 1352 | func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1353 | fc, err := ec.fieldContext___EnumValue_name(ctx, field) 1354 | if err != nil { 1355 | return graphql.Null 1356 | } 1357 | ctx = graphql.WithFieldContext(ctx, fc) 1358 | defer func() { 1359 | if r := recover(); r != nil { 1360 | ec.Error(ctx, ec.Recover(ctx, r)) 1361 | ret = graphql.Null 1362 | } 1363 | }() 1364 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1365 | ctx = rctx // use context from middleware stack in children 1366 | return obj.Name, nil 1367 | }) 1368 | if err != nil { 1369 | ec.Error(ctx, err) 1370 | return graphql.Null 1371 | } 1372 | if resTmp == nil { 1373 | if !graphql.HasFieldError(ctx, fc) { 1374 | ec.Errorf(ctx, "must not be null") 1375 | } 1376 | return graphql.Null 1377 | } 1378 | res := resTmp.(string) 1379 | fc.Result = res 1380 | return ec.marshalNString2string(ctx, field.Selections, res) 1381 | } 1382 | 1383 | func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1384 | fc = &graphql.FieldContext{ 1385 | Object: "__EnumValue", 1386 | Field: field, 1387 | IsMethod: false, 1388 | IsResolver: false, 1389 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1390 | return nil, errors.New("field of type String does not have child fields") 1391 | }, 1392 | } 1393 | return fc, nil 1394 | } 1395 | 1396 | func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1397 | fc, err := ec.fieldContext___EnumValue_description(ctx, field) 1398 | if err != nil { 1399 | return graphql.Null 1400 | } 1401 | ctx = graphql.WithFieldContext(ctx, fc) 1402 | defer func() { 1403 | if r := recover(); r != nil { 1404 | ec.Error(ctx, ec.Recover(ctx, r)) 1405 | ret = graphql.Null 1406 | } 1407 | }() 1408 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1409 | ctx = rctx // use context from middleware stack in children 1410 | return obj.Description(), nil 1411 | }) 1412 | if err != nil { 1413 | ec.Error(ctx, err) 1414 | return graphql.Null 1415 | } 1416 | if resTmp == nil { 1417 | return graphql.Null 1418 | } 1419 | res := resTmp.(*string) 1420 | fc.Result = res 1421 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1422 | } 1423 | 1424 | func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1425 | fc = &graphql.FieldContext{ 1426 | Object: "__EnumValue", 1427 | Field: field, 1428 | IsMethod: true, 1429 | IsResolver: false, 1430 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1431 | return nil, errors.New("field of type String does not have child fields") 1432 | }, 1433 | } 1434 | return fc, nil 1435 | } 1436 | 1437 | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1438 | fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) 1439 | if err != nil { 1440 | return graphql.Null 1441 | } 1442 | ctx = graphql.WithFieldContext(ctx, fc) 1443 | defer func() { 1444 | if r := recover(); r != nil { 1445 | ec.Error(ctx, ec.Recover(ctx, r)) 1446 | ret = graphql.Null 1447 | } 1448 | }() 1449 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1450 | ctx = rctx // use context from middleware stack in children 1451 | return obj.IsDeprecated(), nil 1452 | }) 1453 | if err != nil { 1454 | ec.Error(ctx, err) 1455 | return graphql.Null 1456 | } 1457 | if resTmp == nil { 1458 | if !graphql.HasFieldError(ctx, fc) { 1459 | ec.Errorf(ctx, "must not be null") 1460 | } 1461 | return graphql.Null 1462 | } 1463 | res := resTmp.(bool) 1464 | fc.Result = res 1465 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 1466 | } 1467 | 1468 | func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1469 | fc = &graphql.FieldContext{ 1470 | Object: "__EnumValue", 1471 | Field: field, 1472 | IsMethod: true, 1473 | IsResolver: false, 1474 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1475 | return nil, errors.New("field of type Boolean does not have child fields") 1476 | }, 1477 | } 1478 | return fc, nil 1479 | } 1480 | 1481 | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { 1482 | fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) 1483 | if err != nil { 1484 | return graphql.Null 1485 | } 1486 | ctx = graphql.WithFieldContext(ctx, fc) 1487 | defer func() { 1488 | if r := recover(); r != nil { 1489 | ec.Error(ctx, ec.Recover(ctx, r)) 1490 | ret = graphql.Null 1491 | } 1492 | }() 1493 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1494 | ctx = rctx // use context from middleware stack in children 1495 | return obj.DeprecationReason(), nil 1496 | }) 1497 | if err != nil { 1498 | ec.Error(ctx, err) 1499 | return graphql.Null 1500 | } 1501 | if resTmp == nil { 1502 | return graphql.Null 1503 | } 1504 | res := resTmp.(*string) 1505 | fc.Result = res 1506 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1507 | } 1508 | 1509 | func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1510 | fc = &graphql.FieldContext{ 1511 | Object: "__EnumValue", 1512 | Field: field, 1513 | IsMethod: true, 1514 | IsResolver: false, 1515 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1516 | return nil, errors.New("field of type String does not have child fields") 1517 | }, 1518 | } 1519 | return fc, nil 1520 | } 1521 | 1522 | func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1523 | fc, err := ec.fieldContext___Field_name(ctx, field) 1524 | if err != nil { 1525 | return graphql.Null 1526 | } 1527 | ctx = graphql.WithFieldContext(ctx, fc) 1528 | defer func() { 1529 | if r := recover(); r != nil { 1530 | ec.Error(ctx, ec.Recover(ctx, r)) 1531 | ret = graphql.Null 1532 | } 1533 | }() 1534 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1535 | ctx = rctx // use context from middleware stack in children 1536 | return obj.Name, nil 1537 | }) 1538 | if err != nil { 1539 | ec.Error(ctx, err) 1540 | return graphql.Null 1541 | } 1542 | if resTmp == nil { 1543 | if !graphql.HasFieldError(ctx, fc) { 1544 | ec.Errorf(ctx, "must not be null") 1545 | } 1546 | return graphql.Null 1547 | } 1548 | res := resTmp.(string) 1549 | fc.Result = res 1550 | return ec.marshalNString2string(ctx, field.Selections, res) 1551 | } 1552 | 1553 | func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1554 | fc = &graphql.FieldContext{ 1555 | Object: "__Field", 1556 | Field: field, 1557 | IsMethod: false, 1558 | IsResolver: false, 1559 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1560 | return nil, errors.New("field of type String does not have child fields") 1561 | }, 1562 | } 1563 | return fc, nil 1564 | } 1565 | 1566 | func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1567 | fc, err := ec.fieldContext___Field_description(ctx, field) 1568 | if err != nil { 1569 | return graphql.Null 1570 | } 1571 | ctx = graphql.WithFieldContext(ctx, fc) 1572 | defer func() { 1573 | if r := recover(); r != nil { 1574 | ec.Error(ctx, ec.Recover(ctx, r)) 1575 | ret = graphql.Null 1576 | } 1577 | }() 1578 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1579 | ctx = rctx // use context from middleware stack in children 1580 | return obj.Description(), nil 1581 | }) 1582 | if err != nil { 1583 | ec.Error(ctx, err) 1584 | return graphql.Null 1585 | } 1586 | if resTmp == nil { 1587 | return graphql.Null 1588 | } 1589 | res := resTmp.(*string) 1590 | fc.Result = res 1591 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1592 | } 1593 | 1594 | func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1595 | fc = &graphql.FieldContext{ 1596 | Object: "__Field", 1597 | Field: field, 1598 | IsMethod: true, 1599 | IsResolver: false, 1600 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1601 | return nil, errors.New("field of type String does not have child fields") 1602 | }, 1603 | } 1604 | return fc, nil 1605 | } 1606 | 1607 | func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1608 | fc, err := ec.fieldContext___Field_args(ctx, field) 1609 | if err != nil { 1610 | return graphql.Null 1611 | } 1612 | ctx = graphql.WithFieldContext(ctx, fc) 1613 | defer func() { 1614 | if r := recover(); r != nil { 1615 | ec.Error(ctx, ec.Recover(ctx, r)) 1616 | ret = graphql.Null 1617 | } 1618 | }() 1619 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1620 | ctx = rctx // use context from middleware stack in children 1621 | return obj.Args, nil 1622 | }) 1623 | if err != nil { 1624 | ec.Error(ctx, err) 1625 | return graphql.Null 1626 | } 1627 | if resTmp == nil { 1628 | if !graphql.HasFieldError(ctx, fc) { 1629 | ec.Errorf(ctx, "must not be null") 1630 | } 1631 | return graphql.Null 1632 | } 1633 | res := resTmp.([]introspection.InputValue) 1634 | fc.Result = res 1635 | return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 1636 | } 1637 | 1638 | func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1639 | fc = &graphql.FieldContext{ 1640 | Object: "__Field", 1641 | Field: field, 1642 | IsMethod: false, 1643 | IsResolver: false, 1644 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1645 | switch field.Name { 1646 | case "name": 1647 | return ec.fieldContext___InputValue_name(ctx, field) 1648 | case "description": 1649 | return ec.fieldContext___InputValue_description(ctx, field) 1650 | case "type": 1651 | return ec.fieldContext___InputValue_type(ctx, field) 1652 | case "defaultValue": 1653 | return ec.fieldContext___InputValue_defaultValue(ctx, field) 1654 | } 1655 | return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) 1656 | }, 1657 | } 1658 | return fc, nil 1659 | } 1660 | 1661 | func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1662 | fc, err := ec.fieldContext___Field_type(ctx, field) 1663 | if err != nil { 1664 | return graphql.Null 1665 | } 1666 | ctx = graphql.WithFieldContext(ctx, fc) 1667 | defer func() { 1668 | if r := recover(); r != nil { 1669 | ec.Error(ctx, ec.Recover(ctx, r)) 1670 | ret = graphql.Null 1671 | } 1672 | }() 1673 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1674 | ctx = rctx // use context from middleware stack in children 1675 | return obj.Type, nil 1676 | }) 1677 | if err != nil { 1678 | ec.Error(ctx, err) 1679 | return graphql.Null 1680 | } 1681 | if resTmp == nil { 1682 | if !graphql.HasFieldError(ctx, fc) { 1683 | ec.Errorf(ctx, "must not be null") 1684 | } 1685 | return graphql.Null 1686 | } 1687 | res := resTmp.(*introspection.Type) 1688 | fc.Result = res 1689 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1690 | } 1691 | 1692 | func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1693 | fc = &graphql.FieldContext{ 1694 | Object: "__Field", 1695 | Field: field, 1696 | IsMethod: false, 1697 | IsResolver: false, 1698 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1699 | switch field.Name { 1700 | case "kind": 1701 | return ec.fieldContext___Type_kind(ctx, field) 1702 | case "name": 1703 | return ec.fieldContext___Type_name(ctx, field) 1704 | case "description": 1705 | return ec.fieldContext___Type_description(ctx, field) 1706 | case "fields": 1707 | return ec.fieldContext___Type_fields(ctx, field) 1708 | case "interfaces": 1709 | return ec.fieldContext___Type_interfaces(ctx, field) 1710 | case "possibleTypes": 1711 | return ec.fieldContext___Type_possibleTypes(ctx, field) 1712 | case "enumValues": 1713 | return ec.fieldContext___Type_enumValues(ctx, field) 1714 | case "inputFields": 1715 | return ec.fieldContext___Type_inputFields(ctx, field) 1716 | case "ofType": 1717 | return ec.fieldContext___Type_ofType(ctx, field) 1718 | case "specifiedByURL": 1719 | return ec.fieldContext___Type_specifiedByURL(ctx, field) 1720 | } 1721 | return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) 1722 | }, 1723 | } 1724 | return fc, nil 1725 | } 1726 | 1727 | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1728 | fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) 1729 | if err != nil { 1730 | return graphql.Null 1731 | } 1732 | ctx = graphql.WithFieldContext(ctx, fc) 1733 | defer func() { 1734 | if r := recover(); r != nil { 1735 | ec.Error(ctx, ec.Recover(ctx, r)) 1736 | ret = graphql.Null 1737 | } 1738 | }() 1739 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1740 | ctx = rctx // use context from middleware stack in children 1741 | return obj.IsDeprecated(), nil 1742 | }) 1743 | if err != nil { 1744 | ec.Error(ctx, err) 1745 | return graphql.Null 1746 | } 1747 | if resTmp == nil { 1748 | if !graphql.HasFieldError(ctx, fc) { 1749 | ec.Errorf(ctx, "must not be null") 1750 | } 1751 | return graphql.Null 1752 | } 1753 | res := resTmp.(bool) 1754 | fc.Result = res 1755 | return ec.marshalNBoolean2bool(ctx, field.Selections, res) 1756 | } 1757 | 1758 | func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1759 | fc = &graphql.FieldContext{ 1760 | Object: "__Field", 1761 | Field: field, 1762 | IsMethod: true, 1763 | IsResolver: false, 1764 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1765 | return nil, errors.New("field of type Boolean does not have child fields") 1766 | }, 1767 | } 1768 | return fc, nil 1769 | } 1770 | 1771 | func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { 1772 | fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) 1773 | if err != nil { 1774 | return graphql.Null 1775 | } 1776 | ctx = graphql.WithFieldContext(ctx, fc) 1777 | defer func() { 1778 | if r := recover(); r != nil { 1779 | ec.Error(ctx, ec.Recover(ctx, r)) 1780 | ret = graphql.Null 1781 | } 1782 | }() 1783 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1784 | ctx = rctx // use context from middleware stack in children 1785 | return obj.DeprecationReason(), nil 1786 | }) 1787 | if err != nil { 1788 | ec.Error(ctx, err) 1789 | return graphql.Null 1790 | } 1791 | if resTmp == nil { 1792 | return graphql.Null 1793 | } 1794 | res := resTmp.(*string) 1795 | fc.Result = res 1796 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1797 | } 1798 | 1799 | func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1800 | fc = &graphql.FieldContext{ 1801 | Object: "__Field", 1802 | Field: field, 1803 | IsMethod: true, 1804 | IsResolver: false, 1805 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1806 | return nil, errors.New("field of type String does not have child fields") 1807 | }, 1808 | } 1809 | return fc, nil 1810 | } 1811 | 1812 | func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 1813 | fc, err := ec.fieldContext___InputValue_name(ctx, field) 1814 | if err != nil { 1815 | return graphql.Null 1816 | } 1817 | ctx = graphql.WithFieldContext(ctx, fc) 1818 | defer func() { 1819 | if r := recover(); r != nil { 1820 | ec.Error(ctx, ec.Recover(ctx, r)) 1821 | ret = graphql.Null 1822 | } 1823 | }() 1824 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1825 | ctx = rctx // use context from middleware stack in children 1826 | return obj.Name, nil 1827 | }) 1828 | if err != nil { 1829 | ec.Error(ctx, err) 1830 | return graphql.Null 1831 | } 1832 | if resTmp == nil { 1833 | if !graphql.HasFieldError(ctx, fc) { 1834 | ec.Errorf(ctx, "must not be null") 1835 | } 1836 | return graphql.Null 1837 | } 1838 | res := resTmp.(string) 1839 | fc.Result = res 1840 | return ec.marshalNString2string(ctx, field.Selections, res) 1841 | } 1842 | 1843 | func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1844 | fc = &graphql.FieldContext{ 1845 | Object: "__InputValue", 1846 | Field: field, 1847 | IsMethod: false, 1848 | IsResolver: false, 1849 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1850 | return nil, errors.New("field of type String does not have child fields") 1851 | }, 1852 | } 1853 | return fc, nil 1854 | } 1855 | 1856 | func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 1857 | fc, err := ec.fieldContext___InputValue_description(ctx, field) 1858 | if err != nil { 1859 | return graphql.Null 1860 | } 1861 | ctx = graphql.WithFieldContext(ctx, fc) 1862 | defer func() { 1863 | if r := recover(); r != nil { 1864 | ec.Error(ctx, ec.Recover(ctx, r)) 1865 | ret = graphql.Null 1866 | } 1867 | }() 1868 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1869 | ctx = rctx // use context from middleware stack in children 1870 | return obj.Description(), nil 1871 | }) 1872 | if err != nil { 1873 | ec.Error(ctx, err) 1874 | return graphql.Null 1875 | } 1876 | if resTmp == nil { 1877 | return graphql.Null 1878 | } 1879 | res := resTmp.(*string) 1880 | fc.Result = res 1881 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1882 | } 1883 | 1884 | func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1885 | fc = &graphql.FieldContext{ 1886 | Object: "__InputValue", 1887 | Field: field, 1888 | IsMethod: true, 1889 | IsResolver: false, 1890 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1891 | return nil, errors.New("field of type String does not have child fields") 1892 | }, 1893 | } 1894 | return fc, nil 1895 | } 1896 | 1897 | func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 1898 | fc, err := ec.fieldContext___InputValue_type(ctx, field) 1899 | if err != nil { 1900 | return graphql.Null 1901 | } 1902 | ctx = graphql.WithFieldContext(ctx, fc) 1903 | defer func() { 1904 | if r := recover(); r != nil { 1905 | ec.Error(ctx, ec.Recover(ctx, r)) 1906 | ret = graphql.Null 1907 | } 1908 | }() 1909 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1910 | ctx = rctx // use context from middleware stack in children 1911 | return obj.Type, nil 1912 | }) 1913 | if err != nil { 1914 | ec.Error(ctx, err) 1915 | return graphql.Null 1916 | } 1917 | if resTmp == nil { 1918 | if !graphql.HasFieldError(ctx, fc) { 1919 | ec.Errorf(ctx, "must not be null") 1920 | } 1921 | return graphql.Null 1922 | } 1923 | res := resTmp.(*introspection.Type) 1924 | fc.Result = res 1925 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 1926 | } 1927 | 1928 | func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1929 | fc = &graphql.FieldContext{ 1930 | Object: "__InputValue", 1931 | Field: field, 1932 | IsMethod: false, 1933 | IsResolver: false, 1934 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1935 | switch field.Name { 1936 | case "kind": 1937 | return ec.fieldContext___Type_kind(ctx, field) 1938 | case "name": 1939 | return ec.fieldContext___Type_name(ctx, field) 1940 | case "description": 1941 | return ec.fieldContext___Type_description(ctx, field) 1942 | case "fields": 1943 | return ec.fieldContext___Type_fields(ctx, field) 1944 | case "interfaces": 1945 | return ec.fieldContext___Type_interfaces(ctx, field) 1946 | case "possibleTypes": 1947 | return ec.fieldContext___Type_possibleTypes(ctx, field) 1948 | case "enumValues": 1949 | return ec.fieldContext___Type_enumValues(ctx, field) 1950 | case "inputFields": 1951 | return ec.fieldContext___Type_inputFields(ctx, field) 1952 | case "ofType": 1953 | return ec.fieldContext___Type_ofType(ctx, field) 1954 | case "specifiedByURL": 1955 | return ec.fieldContext___Type_specifiedByURL(ctx, field) 1956 | } 1957 | return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) 1958 | }, 1959 | } 1960 | return fc, nil 1961 | } 1962 | 1963 | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { 1964 | fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) 1965 | if err != nil { 1966 | return graphql.Null 1967 | } 1968 | ctx = graphql.WithFieldContext(ctx, fc) 1969 | defer func() { 1970 | if r := recover(); r != nil { 1971 | ec.Error(ctx, ec.Recover(ctx, r)) 1972 | ret = graphql.Null 1973 | } 1974 | }() 1975 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 1976 | ctx = rctx // use context from middleware stack in children 1977 | return obj.DefaultValue, nil 1978 | }) 1979 | if err != nil { 1980 | ec.Error(ctx, err) 1981 | return graphql.Null 1982 | } 1983 | if resTmp == nil { 1984 | return graphql.Null 1985 | } 1986 | res := resTmp.(*string) 1987 | fc.Result = res 1988 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 1989 | } 1990 | 1991 | func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1992 | fc = &graphql.FieldContext{ 1993 | Object: "__InputValue", 1994 | Field: field, 1995 | IsMethod: false, 1996 | IsResolver: false, 1997 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1998 | return nil, errors.New("field of type String does not have child fields") 1999 | }, 2000 | } 2001 | return fc, nil 2002 | } 2003 | 2004 | func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 2005 | fc, err := ec.fieldContext___Schema_description(ctx, field) 2006 | if err != nil { 2007 | return graphql.Null 2008 | } 2009 | ctx = graphql.WithFieldContext(ctx, fc) 2010 | defer func() { 2011 | if r := recover(); r != nil { 2012 | ec.Error(ctx, ec.Recover(ctx, r)) 2013 | ret = graphql.Null 2014 | } 2015 | }() 2016 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2017 | ctx = rctx // use context from middleware stack in children 2018 | return obj.Description(), nil 2019 | }) 2020 | if err != nil { 2021 | ec.Error(ctx, err) 2022 | return graphql.Null 2023 | } 2024 | if resTmp == nil { 2025 | return graphql.Null 2026 | } 2027 | res := resTmp.(*string) 2028 | fc.Result = res 2029 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 2030 | } 2031 | 2032 | func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2033 | fc = &graphql.FieldContext{ 2034 | Object: "__Schema", 2035 | Field: field, 2036 | IsMethod: true, 2037 | IsResolver: false, 2038 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2039 | return nil, errors.New("field of type String does not have child fields") 2040 | }, 2041 | } 2042 | return fc, nil 2043 | } 2044 | 2045 | func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 2046 | fc, err := ec.fieldContext___Schema_types(ctx, field) 2047 | if err != nil { 2048 | return graphql.Null 2049 | } 2050 | ctx = graphql.WithFieldContext(ctx, fc) 2051 | defer func() { 2052 | if r := recover(); r != nil { 2053 | ec.Error(ctx, ec.Recover(ctx, r)) 2054 | ret = graphql.Null 2055 | } 2056 | }() 2057 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2058 | ctx = rctx // use context from middleware stack in children 2059 | return obj.Types(), nil 2060 | }) 2061 | if err != nil { 2062 | ec.Error(ctx, err) 2063 | return graphql.Null 2064 | } 2065 | if resTmp == nil { 2066 | if !graphql.HasFieldError(ctx, fc) { 2067 | ec.Errorf(ctx, "must not be null") 2068 | } 2069 | return graphql.Null 2070 | } 2071 | res := resTmp.([]introspection.Type) 2072 | fc.Result = res 2073 | return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 2074 | } 2075 | 2076 | func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2077 | fc = &graphql.FieldContext{ 2078 | Object: "__Schema", 2079 | Field: field, 2080 | IsMethod: true, 2081 | IsResolver: false, 2082 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2083 | switch field.Name { 2084 | case "kind": 2085 | return ec.fieldContext___Type_kind(ctx, field) 2086 | case "name": 2087 | return ec.fieldContext___Type_name(ctx, field) 2088 | case "description": 2089 | return ec.fieldContext___Type_description(ctx, field) 2090 | case "fields": 2091 | return ec.fieldContext___Type_fields(ctx, field) 2092 | case "interfaces": 2093 | return ec.fieldContext___Type_interfaces(ctx, field) 2094 | case "possibleTypes": 2095 | return ec.fieldContext___Type_possibleTypes(ctx, field) 2096 | case "enumValues": 2097 | return ec.fieldContext___Type_enumValues(ctx, field) 2098 | case "inputFields": 2099 | return ec.fieldContext___Type_inputFields(ctx, field) 2100 | case "ofType": 2101 | return ec.fieldContext___Type_ofType(ctx, field) 2102 | case "specifiedByURL": 2103 | return ec.fieldContext___Type_specifiedByURL(ctx, field) 2104 | } 2105 | return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) 2106 | }, 2107 | } 2108 | return fc, nil 2109 | } 2110 | 2111 | func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 2112 | fc, err := ec.fieldContext___Schema_queryType(ctx, field) 2113 | if err != nil { 2114 | return graphql.Null 2115 | } 2116 | ctx = graphql.WithFieldContext(ctx, fc) 2117 | defer func() { 2118 | if r := recover(); r != nil { 2119 | ec.Error(ctx, ec.Recover(ctx, r)) 2120 | ret = graphql.Null 2121 | } 2122 | }() 2123 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2124 | ctx = rctx // use context from middleware stack in children 2125 | return obj.QueryType(), nil 2126 | }) 2127 | if err != nil { 2128 | ec.Error(ctx, err) 2129 | return graphql.Null 2130 | } 2131 | if resTmp == nil { 2132 | if !graphql.HasFieldError(ctx, fc) { 2133 | ec.Errorf(ctx, "must not be null") 2134 | } 2135 | return graphql.Null 2136 | } 2137 | res := resTmp.(*introspection.Type) 2138 | fc.Result = res 2139 | return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 2140 | } 2141 | 2142 | func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2143 | fc = &graphql.FieldContext{ 2144 | Object: "__Schema", 2145 | Field: field, 2146 | IsMethod: true, 2147 | IsResolver: false, 2148 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2149 | switch field.Name { 2150 | case "kind": 2151 | return ec.fieldContext___Type_kind(ctx, field) 2152 | case "name": 2153 | return ec.fieldContext___Type_name(ctx, field) 2154 | case "description": 2155 | return ec.fieldContext___Type_description(ctx, field) 2156 | case "fields": 2157 | return ec.fieldContext___Type_fields(ctx, field) 2158 | case "interfaces": 2159 | return ec.fieldContext___Type_interfaces(ctx, field) 2160 | case "possibleTypes": 2161 | return ec.fieldContext___Type_possibleTypes(ctx, field) 2162 | case "enumValues": 2163 | return ec.fieldContext___Type_enumValues(ctx, field) 2164 | case "inputFields": 2165 | return ec.fieldContext___Type_inputFields(ctx, field) 2166 | case "ofType": 2167 | return ec.fieldContext___Type_ofType(ctx, field) 2168 | case "specifiedByURL": 2169 | return ec.fieldContext___Type_specifiedByURL(ctx, field) 2170 | } 2171 | return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) 2172 | }, 2173 | } 2174 | return fc, nil 2175 | } 2176 | 2177 | func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 2178 | fc, err := ec.fieldContext___Schema_mutationType(ctx, field) 2179 | if err != nil { 2180 | return graphql.Null 2181 | } 2182 | ctx = graphql.WithFieldContext(ctx, fc) 2183 | defer func() { 2184 | if r := recover(); r != nil { 2185 | ec.Error(ctx, ec.Recover(ctx, r)) 2186 | ret = graphql.Null 2187 | } 2188 | }() 2189 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2190 | ctx = rctx // use context from middleware stack in children 2191 | return obj.MutationType(), nil 2192 | }) 2193 | if err != nil { 2194 | ec.Error(ctx, err) 2195 | return graphql.Null 2196 | } 2197 | if resTmp == nil { 2198 | return graphql.Null 2199 | } 2200 | res := resTmp.(*introspection.Type) 2201 | fc.Result = res 2202 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 2203 | } 2204 | 2205 | func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2206 | fc = &graphql.FieldContext{ 2207 | Object: "__Schema", 2208 | Field: field, 2209 | IsMethod: true, 2210 | IsResolver: false, 2211 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2212 | switch field.Name { 2213 | case "kind": 2214 | return ec.fieldContext___Type_kind(ctx, field) 2215 | case "name": 2216 | return ec.fieldContext___Type_name(ctx, field) 2217 | case "description": 2218 | return ec.fieldContext___Type_description(ctx, field) 2219 | case "fields": 2220 | return ec.fieldContext___Type_fields(ctx, field) 2221 | case "interfaces": 2222 | return ec.fieldContext___Type_interfaces(ctx, field) 2223 | case "possibleTypes": 2224 | return ec.fieldContext___Type_possibleTypes(ctx, field) 2225 | case "enumValues": 2226 | return ec.fieldContext___Type_enumValues(ctx, field) 2227 | case "inputFields": 2228 | return ec.fieldContext___Type_inputFields(ctx, field) 2229 | case "ofType": 2230 | return ec.fieldContext___Type_ofType(ctx, field) 2231 | case "specifiedByURL": 2232 | return ec.fieldContext___Type_specifiedByURL(ctx, field) 2233 | } 2234 | return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) 2235 | }, 2236 | } 2237 | return fc, nil 2238 | } 2239 | 2240 | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 2241 | fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) 2242 | if err != nil { 2243 | return graphql.Null 2244 | } 2245 | ctx = graphql.WithFieldContext(ctx, fc) 2246 | defer func() { 2247 | if r := recover(); r != nil { 2248 | ec.Error(ctx, ec.Recover(ctx, r)) 2249 | ret = graphql.Null 2250 | } 2251 | }() 2252 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2253 | ctx = rctx // use context from middleware stack in children 2254 | return obj.SubscriptionType(), nil 2255 | }) 2256 | if err != nil { 2257 | ec.Error(ctx, err) 2258 | return graphql.Null 2259 | } 2260 | if resTmp == nil { 2261 | return graphql.Null 2262 | } 2263 | res := resTmp.(*introspection.Type) 2264 | fc.Result = res 2265 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 2266 | } 2267 | 2268 | func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2269 | fc = &graphql.FieldContext{ 2270 | Object: "__Schema", 2271 | Field: field, 2272 | IsMethod: true, 2273 | IsResolver: false, 2274 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2275 | switch field.Name { 2276 | case "kind": 2277 | return ec.fieldContext___Type_kind(ctx, field) 2278 | case "name": 2279 | return ec.fieldContext___Type_name(ctx, field) 2280 | case "description": 2281 | return ec.fieldContext___Type_description(ctx, field) 2282 | case "fields": 2283 | return ec.fieldContext___Type_fields(ctx, field) 2284 | case "interfaces": 2285 | return ec.fieldContext___Type_interfaces(ctx, field) 2286 | case "possibleTypes": 2287 | return ec.fieldContext___Type_possibleTypes(ctx, field) 2288 | case "enumValues": 2289 | return ec.fieldContext___Type_enumValues(ctx, field) 2290 | case "inputFields": 2291 | return ec.fieldContext___Type_inputFields(ctx, field) 2292 | case "ofType": 2293 | return ec.fieldContext___Type_ofType(ctx, field) 2294 | case "specifiedByURL": 2295 | return ec.fieldContext___Type_specifiedByURL(ctx, field) 2296 | } 2297 | return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) 2298 | }, 2299 | } 2300 | return fc, nil 2301 | } 2302 | 2303 | func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { 2304 | fc, err := ec.fieldContext___Schema_directives(ctx, field) 2305 | if err != nil { 2306 | return graphql.Null 2307 | } 2308 | ctx = graphql.WithFieldContext(ctx, fc) 2309 | defer func() { 2310 | if r := recover(); r != nil { 2311 | ec.Error(ctx, ec.Recover(ctx, r)) 2312 | ret = graphql.Null 2313 | } 2314 | }() 2315 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2316 | ctx = rctx // use context from middleware stack in children 2317 | return obj.Directives(), nil 2318 | }) 2319 | if err != nil { 2320 | ec.Error(ctx, err) 2321 | return graphql.Null 2322 | } 2323 | if resTmp == nil { 2324 | if !graphql.HasFieldError(ctx, fc) { 2325 | ec.Errorf(ctx, "must not be null") 2326 | } 2327 | return graphql.Null 2328 | } 2329 | res := resTmp.([]introspection.Directive) 2330 | fc.Result = res 2331 | return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) 2332 | } 2333 | 2334 | func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2335 | fc = &graphql.FieldContext{ 2336 | Object: "__Schema", 2337 | Field: field, 2338 | IsMethod: true, 2339 | IsResolver: false, 2340 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2341 | switch field.Name { 2342 | case "name": 2343 | return ec.fieldContext___Directive_name(ctx, field) 2344 | case "description": 2345 | return ec.fieldContext___Directive_description(ctx, field) 2346 | case "locations": 2347 | return ec.fieldContext___Directive_locations(ctx, field) 2348 | case "args": 2349 | return ec.fieldContext___Directive_args(ctx, field) 2350 | case "isRepeatable": 2351 | return ec.fieldContext___Directive_isRepeatable(ctx, field) 2352 | } 2353 | return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) 2354 | }, 2355 | } 2356 | return fc, nil 2357 | } 2358 | 2359 | func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2360 | fc, err := ec.fieldContext___Type_kind(ctx, field) 2361 | if err != nil { 2362 | return graphql.Null 2363 | } 2364 | ctx = graphql.WithFieldContext(ctx, fc) 2365 | defer func() { 2366 | if r := recover(); r != nil { 2367 | ec.Error(ctx, ec.Recover(ctx, r)) 2368 | ret = graphql.Null 2369 | } 2370 | }() 2371 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2372 | ctx = rctx // use context from middleware stack in children 2373 | return obj.Kind(), nil 2374 | }) 2375 | if err != nil { 2376 | ec.Error(ctx, err) 2377 | return graphql.Null 2378 | } 2379 | if resTmp == nil { 2380 | if !graphql.HasFieldError(ctx, fc) { 2381 | ec.Errorf(ctx, "must not be null") 2382 | } 2383 | return graphql.Null 2384 | } 2385 | res := resTmp.(string) 2386 | fc.Result = res 2387 | return ec.marshalN__TypeKind2string(ctx, field.Selections, res) 2388 | } 2389 | 2390 | func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2391 | fc = &graphql.FieldContext{ 2392 | Object: "__Type", 2393 | Field: field, 2394 | IsMethod: true, 2395 | IsResolver: false, 2396 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2397 | return nil, errors.New("field of type __TypeKind does not have child fields") 2398 | }, 2399 | } 2400 | return fc, nil 2401 | } 2402 | 2403 | func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2404 | fc, err := ec.fieldContext___Type_name(ctx, field) 2405 | if err != nil { 2406 | return graphql.Null 2407 | } 2408 | ctx = graphql.WithFieldContext(ctx, fc) 2409 | defer func() { 2410 | if r := recover(); r != nil { 2411 | ec.Error(ctx, ec.Recover(ctx, r)) 2412 | ret = graphql.Null 2413 | } 2414 | }() 2415 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2416 | ctx = rctx // use context from middleware stack in children 2417 | return obj.Name(), nil 2418 | }) 2419 | if err != nil { 2420 | ec.Error(ctx, err) 2421 | return graphql.Null 2422 | } 2423 | if resTmp == nil { 2424 | return graphql.Null 2425 | } 2426 | res := resTmp.(*string) 2427 | fc.Result = res 2428 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 2429 | } 2430 | 2431 | func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2432 | fc = &graphql.FieldContext{ 2433 | Object: "__Type", 2434 | Field: field, 2435 | IsMethod: true, 2436 | IsResolver: false, 2437 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2438 | return nil, errors.New("field of type String does not have child fields") 2439 | }, 2440 | } 2441 | return fc, nil 2442 | } 2443 | 2444 | func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2445 | fc, err := ec.fieldContext___Type_description(ctx, field) 2446 | if err != nil { 2447 | return graphql.Null 2448 | } 2449 | ctx = graphql.WithFieldContext(ctx, fc) 2450 | defer func() { 2451 | if r := recover(); r != nil { 2452 | ec.Error(ctx, ec.Recover(ctx, r)) 2453 | ret = graphql.Null 2454 | } 2455 | }() 2456 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2457 | ctx = rctx // use context from middleware stack in children 2458 | return obj.Description(), nil 2459 | }) 2460 | if err != nil { 2461 | ec.Error(ctx, err) 2462 | return graphql.Null 2463 | } 2464 | if resTmp == nil { 2465 | return graphql.Null 2466 | } 2467 | res := resTmp.(*string) 2468 | fc.Result = res 2469 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 2470 | } 2471 | 2472 | func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2473 | fc = &graphql.FieldContext{ 2474 | Object: "__Type", 2475 | Field: field, 2476 | IsMethod: true, 2477 | IsResolver: false, 2478 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2479 | return nil, errors.New("field of type String does not have child fields") 2480 | }, 2481 | } 2482 | return fc, nil 2483 | } 2484 | 2485 | func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2486 | fc, err := ec.fieldContext___Type_fields(ctx, field) 2487 | if err != nil { 2488 | return graphql.Null 2489 | } 2490 | ctx = graphql.WithFieldContext(ctx, fc) 2491 | defer func() { 2492 | if r := recover(); r != nil { 2493 | ec.Error(ctx, ec.Recover(ctx, r)) 2494 | ret = graphql.Null 2495 | } 2496 | }() 2497 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2498 | ctx = rctx // use context from middleware stack in children 2499 | return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil 2500 | }) 2501 | if err != nil { 2502 | ec.Error(ctx, err) 2503 | return graphql.Null 2504 | } 2505 | if resTmp == nil { 2506 | return graphql.Null 2507 | } 2508 | res := resTmp.([]introspection.Field) 2509 | fc.Result = res 2510 | return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) 2511 | } 2512 | 2513 | func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2514 | fc = &graphql.FieldContext{ 2515 | Object: "__Type", 2516 | Field: field, 2517 | IsMethod: true, 2518 | IsResolver: false, 2519 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2520 | switch field.Name { 2521 | case "name": 2522 | return ec.fieldContext___Field_name(ctx, field) 2523 | case "description": 2524 | return ec.fieldContext___Field_description(ctx, field) 2525 | case "args": 2526 | return ec.fieldContext___Field_args(ctx, field) 2527 | case "type": 2528 | return ec.fieldContext___Field_type(ctx, field) 2529 | case "isDeprecated": 2530 | return ec.fieldContext___Field_isDeprecated(ctx, field) 2531 | case "deprecationReason": 2532 | return ec.fieldContext___Field_deprecationReason(ctx, field) 2533 | } 2534 | return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) 2535 | }, 2536 | } 2537 | defer func() { 2538 | if r := recover(); r != nil { 2539 | err = ec.Recover(ctx, r) 2540 | ec.Error(ctx, err) 2541 | } 2542 | }() 2543 | ctx = graphql.WithFieldContext(ctx, fc) 2544 | if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { 2545 | ec.Error(ctx, err) 2546 | return 2547 | } 2548 | return fc, nil 2549 | } 2550 | 2551 | func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2552 | fc, err := ec.fieldContext___Type_interfaces(ctx, field) 2553 | if err != nil { 2554 | return graphql.Null 2555 | } 2556 | ctx = graphql.WithFieldContext(ctx, fc) 2557 | defer func() { 2558 | if r := recover(); r != nil { 2559 | ec.Error(ctx, ec.Recover(ctx, r)) 2560 | ret = graphql.Null 2561 | } 2562 | }() 2563 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2564 | ctx = rctx // use context from middleware stack in children 2565 | return obj.Interfaces(), nil 2566 | }) 2567 | if err != nil { 2568 | ec.Error(ctx, err) 2569 | return graphql.Null 2570 | } 2571 | if resTmp == nil { 2572 | return graphql.Null 2573 | } 2574 | res := resTmp.([]introspection.Type) 2575 | fc.Result = res 2576 | return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 2577 | } 2578 | 2579 | func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2580 | fc = &graphql.FieldContext{ 2581 | Object: "__Type", 2582 | Field: field, 2583 | IsMethod: true, 2584 | IsResolver: false, 2585 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2586 | switch field.Name { 2587 | case "kind": 2588 | return ec.fieldContext___Type_kind(ctx, field) 2589 | case "name": 2590 | return ec.fieldContext___Type_name(ctx, field) 2591 | case "description": 2592 | return ec.fieldContext___Type_description(ctx, field) 2593 | case "fields": 2594 | return ec.fieldContext___Type_fields(ctx, field) 2595 | case "interfaces": 2596 | return ec.fieldContext___Type_interfaces(ctx, field) 2597 | case "possibleTypes": 2598 | return ec.fieldContext___Type_possibleTypes(ctx, field) 2599 | case "enumValues": 2600 | return ec.fieldContext___Type_enumValues(ctx, field) 2601 | case "inputFields": 2602 | return ec.fieldContext___Type_inputFields(ctx, field) 2603 | case "ofType": 2604 | return ec.fieldContext___Type_ofType(ctx, field) 2605 | case "specifiedByURL": 2606 | return ec.fieldContext___Type_specifiedByURL(ctx, field) 2607 | } 2608 | return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) 2609 | }, 2610 | } 2611 | return fc, nil 2612 | } 2613 | 2614 | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2615 | fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) 2616 | if err != nil { 2617 | return graphql.Null 2618 | } 2619 | ctx = graphql.WithFieldContext(ctx, fc) 2620 | defer func() { 2621 | if r := recover(); r != nil { 2622 | ec.Error(ctx, ec.Recover(ctx, r)) 2623 | ret = graphql.Null 2624 | } 2625 | }() 2626 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2627 | ctx = rctx // use context from middleware stack in children 2628 | return obj.PossibleTypes(), nil 2629 | }) 2630 | if err != nil { 2631 | ec.Error(ctx, err) 2632 | return graphql.Null 2633 | } 2634 | if resTmp == nil { 2635 | return graphql.Null 2636 | } 2637 | res := resTmp.([]introspection.Type) 2638 | fc.Result = res 2639 | return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) 2640 | } 2641 | 2642 | func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2643 | fc = &graphql.FieldContext{ 2644 | Object: "__Type", 2645 | Field: field, 2646 | IsMethod: true, 2647 | IsResolver: false, 2648 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2649 | switch field.Name { 2650 | case "kind": 2651 | return ec.fieldContext___Type_kind(ctx, field) 2652 | case "name": 2653 | return ec.fieldContext___Type_name(ctx, field) 2654 | case "description": 2655 | return ec.fieldContext___Type_description(ctx, field) 2656 | case "fields": 2657 | return ec.fieldContext___Type_fields(ctx, field) 2658 | case "interfaces": 2659 | return ec.fieldContext___Type_interfaces(ctx, field) 2660 | case "possibleTypes": 2661 | return ec.fieldContext___Type_possibleTypes(ctx, field) 2662 | case "enumValues": 2663 | return ec.fieldContext___Type_enumValues(ctx, field) 2664 | case "inputFields": 2665 | return ec.fieldContext___Type_inputFields(ctx, field) 2666 | case "ofType": 2667 | return ec.fieldContext___Type_ofType(ctx, field) 2668 | case "specifiedByURL": 2669 | return ec.fieldContext___Type_specifiedByURL(ctx, field) 2670 | } 2671 | return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) 2672 | }, 2673 | } 2674 | return fc, nil 2675 | } 2676 | 2677 | func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2678 | fc, err := ec.fieldContext___Type_enumValues(ctx, field) 2679 | if err != nil { 2680 | return graphql.Null 2681 | } 2682 | ctx = graphql.WithFieldContext(ctx, fc) 2683 | defer func() { 2684 | if r := recover(); r != nil { 2685 | ec.Error(ctx, ec.Recover(ctx, r)) 2686 | ret = graphql.Null 2687 | } 2688 | }() 2689 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2690 | ctx = rctx // use context from middleware stack in children 2691 | return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil 2692 | }) 2693 | if err != nil { 2694 | ec.Error(ctx, err) 2695 | return graphql.Null 2696 | } 2697 | if resTmp == nil { 2698 | return graphql.Null 2699 | } 2700 | res := resTmp.([]introspection.EnumValue) 2701 | fc.Result = res 2702 | return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) 2703 | } 2704 | 2705 | func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2706 | fc = &graphql.FieldContext{ 2707 | Object: "__Type", 2708 | Field: field, 2709 | IsMethod: true, 2710 | IsResolver: false, 2711 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2712 | switch field.Name { 2713 | case "name": 2714 | return ec.fieldContext___EnumValue_name(ctx, field) 2715 | case "description": 2716 | return ec.fieldContext___EnumValue_description(ctx, field) 2717 | case "isDeprecated": 2718 | return ec.fieldContext___EnumValue_isDeprecated(ctx, field) 2719 | case "deprecationReason": 2720 | return ec.fieldContext___EnumValue_deprecationReason(ctx, field) 2721 | } 2722 | return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) 2723 | }, 2724 | } 2725 | defer func() { 2726 | if r := recover(); r != nil { 2727 | err = ec.Recover(ctx, r) 2728 | ec.Error(ctx, err) 2729 | } 2730 | }() 2731 | ctx = graphql.WithFieldContext(ctx, fc) 2732 | if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { 2733 | ec.Error(ctx, err) 2734 | return 2735 | } 2736 | return fc, nil 2737 | } 2738 | 2739 | func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2740 | fc, err := ec.fieldContext___Type_inputFields(ctx, field) 2741 | if err != nil { 2742 | return graphql.Null 2743 | } 2744 | ctx = graphql.WithFieldContext(ctx, fc) 2745 | defer func() { 2746 | if r := recover(); r != nil { 2747 | ec.Error(ctx, ec.Recover(ctx, r)) 2748 | ret = graphql.Null 2749 | } 2750 | }() 2751 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2752 | ctx = rctx // use context from middleware stack in children 2753 | return obj.InputFields(), nil 2754 | }) 2755 | if err != nil { 2756 | ec.Error(ctx, err) 2757 | return graphql.Null 2758 | } 2759 | if resTmp == nil { 2760 | return graphql.Null 2761 | } 2762 | res := resTmp.([]introspection.InputValue) 2763 | fc.Result = res 2764 | return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) 2765 | } 2766 | 2767 | func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2768 | fc = &graphql.FieldContext{ 2769 | Object: "__Type", 2770 | Field: field, 2771 | IsMethod: true, 2772 | IsResolver: false, 2773 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2774 | switch field.Name { 2775 | case "name": 2776 | return ec.fieldContext___InputValue_name(ctx, field) 2777 | case "description": 2778 | return ec.fieldContext___InputValue_description(ctx, field) 2779 | case "type": 2780 | return ec.fieldContext___InputValue_type(ctx, field) 2781 | case "defaultValue": 2782 | return ec.fieldContext___InputValue_defaultValue(ctx, field) 2783 | } 2784 | return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) 2785 | }, 2786 | } 2787 | return fc, nil 2788 | } 2789 | 2790 | func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2791 | fc, err := ec.fieldContext___Type_ofType(ctx, field) 2792 | if err != nil { 2793 | return graphql.Null 2794 | } 2795 | ctx = graphql.WithFieldContext(ctx, fc) 2796 | defer func() { 2797 | if r := recover(); r != nil { 2798 | ec.Error(ctx, ec.Recover(ctx, r)) 2799 | ret = graphql.Null 2800 | } 2801 | }() 2802 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2803 | ctx = rctx // use context from middleware stack in children 2804 | return obj.OfType(), nil 2805 | }) 2806 | if err != nil { 2807 | ec.Error(ctx, err) 2808 | return graphql.Null 2809 | } 2810 | if resTmp == nil { 2811 | return graphql.Null 2812 | } 2813 | res := resTmp.(*introspection.Type) 2814 | fc.Result = res 2815 | return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) 2816 | } 2817 | 2818 | func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2819 | fc = &graphql.FieldContext{ 2820 | Object: "__Type", 2821 | Field: field, 2822 | IsMethod: true, 2823 | IsResolver: false, 2824 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2825 | switch field.Name { 2826 | case "kind": 2827 | return ec.fieldContext___Type_kind(ctx, field) 2828 | case "name": 2829 | return ec.fieldContext___Type_name(ctx, field) 2830 | case "description": 2831 | return ec.fieldContext___Type_description(ctx, field) 2832 | case "fields": 2833 | return ec.fieldContext___Type_fields(ctx, field) 2834 | case "interfaces": 2835 | return ec.fieldContext___Type_interfaces(ctx, field) 2836 | case "possibleTypes": 2837 | return ec.fieldContext___Type_possibleTypes(ctx, field) 2838 | case "enumValues": 2839 | return ec.fieldContext___Type_enumValues(ctx, field) 2840 | case "inputFields": 2841 | return ec.fieldContext___Type_inputFields(ctx, field) 2842 | case "ofType": 2843 | return ec.fieldContext___Type_ofType(ctx, field) 2844 | case "specifiedByURL": 2845 | return ec.fieldContext___Type_specifiedByURL(ctx, field) 2846 | } 2847 | return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) 2848 | }, 2849 | } 2850 | return fc, nil 2851 | } 2852 | 2853 | func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { 2854 | fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) 2855 | if err != nil { 2856 | return graphql.Null 2857 | } 2858 | ctx = graphql.WithFieldContext(ctx, fc) 2859 | defer func() { 2860 | if r := recover(); r != nil { 2861 | ec.Error(ctx, ec.Recover(ctx, r)) 2862 | ret = graphql.Null 2863 | } 2864 | }() 2865 | resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { 2866 | ctx = rctx // use context from middleware stack in children 2867 | return obj.SpecifiedByURL(), nil 2868 | }) 2869 | if err != nil { 2870 | ec.Error(ctx, err) 2871 | return graphql.Null 2872 | } 2873 | if resTmp == nil { 2874 | return graphql.Null 2875 | } 2876 | res := resTmp.(*string) 2877 | fc.Result = res 2878 | return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 2879 | } 2880 | 2881 | func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 2882 | fc = &graphql.FieldContext{ 2883 | Object: "__Type", 2884 | Field: field, 2885 | IsMethod: true, 2886 | IsResolver: false, 2887 | Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 2888 | return nil, errors.New("field of type String does not have child fields") 2889 | }, 2890 | } 2891 | return fc, nil 2892 | } 2893 | 2894 | // endregion **************************** field.gotpl ***************************** 2895 | 2896 | // region **************************** input.gotpl ***************************** 2897 | 2898 | func (ec *executionContext) unmarshalInputNewCategory(ctx context.Context, obj interface{}) (model.NewCategory, error) { 2899 | var it model.NewCategory 2900 | asMap := map[string]interface{}{} 2901 | for k, v := range obj.(map[string]interface{}) { 2902 | asMap[k] = v 2903 | } 2904 | 2905 | fieldsInOrder := [...]string{"name", "description"} 2906 | for _, k := range fieldsInOrder { 2907 | v, ok := asMap[k] 2908 | if !ok { 2909 | continue 2910 | } 2911 | switch k { 2912 | case "name": 2913 | var err error 2914 | 2915 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) 2916 | it.Name, err = ec.unmarshalNString2string(ctx, v) 2917 | if err != nil { 2918 | return it, err 2919 | } 2920 | case "description": 2921 | var err error 2922 | 2923 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) 2924 | it.Description, err = ec.unmarshalOString2ᚖstring(ctx, v) 2925 | if err != nil { 2926 | return it, err 2927 | } 2928 | } 2929 | } 2930 | 2931 | return it, nil 2932 | } 2933 | 2934 | func (ec *executionContext) unmarshalInputNewCourse(ctx context.Context, obj interface{}) (model.NewCourse, error) { 2935 | var it model.NewCourse 2936 | asMap := map[string]interface{}{} 2937 | for k, v := range obj.(map[string]interface{}) { 2938 | asMap[k] = v 2939 | } 2940 | 2941 | fieldsInOrder := [...]string{"name", "description", "categoryId"} 2942 | for _, k := range fieldsInOrder { 2943 | v, ok := asMap[k] 2944 | if !ok { 2945 | continue 2946 | } 2947 | switch k { 2948 | case "name": 2949 | var err error 2950 | 2951 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) 2952 | it.Name, err = ec.unmarshalNString2string(ctx, v) 2953 | if err != nil { 2954 | return it, err 2955 | } 2956 | case "description": 2957 | var err error 2958 | 2959 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) 2960 | it.Description, err = ec.unmarshalOString2ᚖstring(ctx, v) 2961 | if err != nil { 2962 | return it, err 2963 | } 2964 | case "categoryId": 2965 | var err error 2966 | 2967 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryId")) 2968 | it.CategoryID, err = ec.unmarshalNID2string(ctx, v) 2969 | if err != nil { 2970 | return it, err 2971 | } 2972 | } 2973 | } 2974 | 2975 | return it, nil 2976 | } 2977 | 2978 | // endregion **************************** input.gotpl ***************************** 2979 | 2980 | // region ************************** interface.gotpl *************************** 2981 | 2982 | // endregion ************************** interface.gotpl *************************** 2983 | 2984 | // region **************************** object.gotpl **************************** 2985 | 2986 | var categoryImplementors = []string{"Category"} 2987 | 2988 | func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, obj *model.Category) graphql.Marshaler { 2989 | fields := graphql.CollectFields(ec.OperationContext, sel, categoryImplementors) 2990 | out := graphql.NewFieldSet(fields) 2991 | var invalids uint32 2992 | for i, field := range fields { 2993 | switch field.Name { 2994 | case "__typename": 2995 | out.Values[i] = graphql.MarshalString("Category") 2996 | case "id": 2997 | 2998 | out.Values[i] = ec._Category_id(ctx, field, obj) 2999 | 3000 | if out.Values[i] == graphql.Null { 3001 | atomic.AddUint32(&invalids, 1) 3002 | } 3003 | case "name": 3004 | 3005 | out.Values[i] = ec._Category_name(ctx, field, obj) 3006 | 3007 | if out.Values[i] == graphql.Null { 3008 | atomic.AddUint32(&invalids, 1) 3009 | } 3010 | case "description": 3011 | 3012 | out.Values[i] = ec._Category_description(ctx, field, obj) 3013 | 3014 | case "courses": 3015 | field := field 3016 | 3017 | innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 3018 | defer func() { 3019 | if r := recover(); r != nil { 3020 | ec.Error(ctx, ec.Recover(ctx, r)) 3021 | } 3022 | }() 3023 | res = ec._Category_courses(ctx, field, obj) 3024 | if res == graphql.Null { 3025 | atomic.AddUint32(&invalids, 1) 3026 | } 3027 | return res 3028 | } 3029 | 3030 | out.Concurrently(i, func() graphql.Marshaler { 3031 | return innerFunc(ctx) 3032 | 3033 | }) 3034 | default: 3035 | panic("unknown field " + strconv.Quote(field.Name)) 3036 | } 3037 | } 3038 | out.Dispatch() 3039 | if invalids > 0 { 3040 | return graphql.Null 3041 | } 3042 | return out 3043 | } 3044 | 3045 | var courseImplementors = []string{"Course"} 3046 | 3047 | func (ec *executionContext) _Course(ctx context.Context, sel ast.SelectionSet, obj *model.Course) graphql.Marshaler { 3048 | fields := graphql.CollectFields(ec.OperationContext, sel, courseImplementors) 3049 | out := graphql.NewFieldSet(fields) 3050 | var invalids uint32 3051 | for i, field := range fields { 3052 | switch field.Name { 3053 | case "__typename": 3054 | out.Values[i] = graphql.MarshalString("Course") 3055 | case "id": 3056 | 3057 | out.Values[i] = ec._Course_id(ctx, field, obj) 3058 | 3059 | if out.Values[i] == graphql.Null { 3060 | atomic.AddUint32(&invalids, 1) 3061 | } 3062 | case "name": 3063 | 3064 | out.Values[i] = ec._Course_name(ctx, field, obj) 3065 | 3066 | if out.Values[i] == graphql.Null { 3067 | atomic.AddUint32(&invalids, 1) 3068 | } 3069 | case "description": 3070 | 3071 | out.Values[i] = ec._Course_description(ctx, field, obj) 3072 | 3073 | case "category": 3074 | field := field 3075 | 3076 | innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 3077 | defer func() { 3078 | if r := recover(); r != nil { 3079 | ec.Error(ctx, ec.Recover(ctx, r)) 3080 | } 3081 | }() 3082 | res = ec._Course_category(ctx, field, obj) 3083 | if res == graphql.Null { 3084 | atomic.AddUint32(&invalids, 1) 3085 | } 3086 | return res 3087 | } 3088 | 3089 | out.Concurrently(i, func() graphql.Marshaler { 3090 | return innerFunc(ctx) 3091 | 3092 | }) 3093 | default: 3094 | panic("unknown field " + strconv.Quote(field.Name)) 3095 | } 3096 | } 3097 | out.Dispatch() 3098 | if invalids > 0 { 3099 | return graphql.Null 3100 | } 3101 | return out 3102 | } 3103 | 3104 | var mutationImplementors = []string{"Mutation"} 3105 | 3106 | func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { 3107 | fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) 3108 | ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ 3109 | Object: "Mutation", 3110 | }) 3111 | 3112 | out := graphql.NewFieldSet(fields) 3113 | var invalids uint32 3114 | for i, field := range fields { 3115 | innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ 3116 | Object: field.Name, 3117 | Field: field, 3118 | }) 3119 | 3120 | switch field.Name { 3121 | case "__typename": 3122 | out.Values[i] = graphql.MarshalString("Mutation") 3123 | case "createCategory": 3124 | 3125 | out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { 3126 | return ec._Mutation_createCategory(ctx, field) 3127 | }) 3128 | 3129 | if out.Values[i] == graphql.Null { 3130 | invalids++ 3131 | } 3132 | case "createCourse": 3133 | 3134 | out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { 3135 | return ec._Mutation_createCourse(ctx, field) 3136 | }) 3137 | 3138 | if out.Values[i] == graphql.Null { 3139 | invalids++ 3140 | } 3141 | default: 3142 | panic("unknown field " + strconv.Quote(field.Name)) 3143 | } 3144 | } 3145 | out.Dispatch() 3146 | if invalids > 0 { 3147 | return graphql.Null 3148 | } 3149 | return out 3150 | } 3151 | 3152 | var queryImplementors = []string{"Query"} 3153 | 3154 | func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { 3155 | fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) 3156 | ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ 3157 | Object: "Query", 3158 | }) 3159 | 3160 | out := graphql.NewFieldSet(fields) 3161 | var invalids uint32 3162 | for i, field := range fields { 3163 | innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ 3164 | Object: field.Name, 3165 | Field: field, 3166 | }) 3167 | 3168 | switch field.Name { 3169 | case "__typename": 3170 | out.Values[i] = graphql.MarshalString("Query") 3171 | case "categories": 3172 | field := field 3173 | 3174 | innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 3175 | defer func() { 3176 | if r := recover(); r != nil { 3177 | ec.Error(ctx, ec.Recover(ctx, r)) 3178 | } 3179 | }() 3180 | res = ec._Query_categories(ctx, field) 3181 | if res == graphql.Null { 3182 | atomic.AddUint32(&invalids, 1) 3183 | } 3184 | return res 3185 | } 3186 | 3187 | rrm := func(ctx context.Context) graphql.Marshaler { 3188 | return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) 3189 | } 3190 | 3191 | out.Concurrently(i, func() graphql.Marshaler { 3192 | return rrm(innerCtx) 3193 | }) 3194 | case "courses": 3195 | field := field 3196 | 3197 | innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 3198 | defer func() { 3199 | if r := recover(); r != nil { 3200 | ec.Error(ctx, ec.Recover(ctx, r)) 3201 | } 3202 | }() 3203 | res = ec._Query_courses(ctx, field) 3204 | if res == graphql.Null { 3205 | atomic.AddUint32(&invalids, 1) 3206 | } 3207 | return res 3208 | } 3209 | 3210 | rrm := func(ctx context.Context) graphql.Marshaler { 3211 | return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) 3212 | } 3213 | 3214 | out.Concurrently(i, func() graphql.Marshaler { 3215 | return rrm(innerCtx) 3216 | }) 3217 | case "__type": 3218 | 3219 | out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { 3220 | return ec._Query___type(ctx, field) 3221 | }) 3222 | 3223 | case "__schema": 3224 | 3225 | out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { 3226 | return ec._Query___schema(ctx, field) 3227 | }) 3228 | 3229 | default: 3230 | panic("unknown field " + strconv.Quote(field.Name)) 3231 | } 3232 | } 3233 | out.Dispatch() 3234 | if invalids > 0 { 3235 | return graphql.Null 3236 | } 3237 | return out 3238 | } 3239 | 3240 | var __DirectiveImplementors = []string{"__Directive"} 3241 | 3242 | func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { 3243 | fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) 3244 | out := graphql.NewFieldSet(fields) 3245 | var invalids uint32 3246 | for i, field := range fields { 3247 | switch field.Name { 3248 | case "__typename": 3249 | out.Values[i] = graphql.MarshalString("__Directive") 3250 | case "name": 3251 | 3252 | out.Values[i] = ec.___Directive_name(ctx, field, obj) 3253 | 3254 | if out.Values[i] == graphql.Null { 3255 | invalids++ 3256 | } 3257 | case "description": 3258 | 3259 | out.Values[i] = ec.___Directive_description(ctx, field, obj) 3260 | 3261 | case "locations": 3262 | 3263 | out.Values[i] = ec.___Directive_locations(ctx, field, obj) 3264 | 3265 | if out.Values[i] == graphql.Null { 3266 | invalids++ 3267 | } 3268 | case "args": 3269 | 3270 | out.Values[i] = ec.___Directive_args(ctx, field, obj) 3271 | 3272 | if out.Values[i] == graphql.Null { 3273 | invalids++ 3274 | } 3275 | case "isRepeatable": 3276 | 3277 | out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) 3278 | 3279 | if out.Values[i] == graphql.Null { 3280 | invalids++ 3281 | } 3282 | default: 3283 | panic("unknown field " + strconv.Quote(field.Name)) 3284 | } 3285 | } 3286 | out.Dispatch() 3287 | if invalids > 0 { 3288 | return graphql.Null 3289 | } 3290 | return out 3291 | } 3292 | 3293 | var __EnumValueImplementors = []string{"__EnumValue"} 3294 | 3295 | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { 3296 | fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) 3297 | out := graphql.NewFieldSet(fields) 3298 | var invalids uint32 3299 | for i, field := range fields { 3300 | switch field.Name { 3301 | case "__typename": 3302 | out.Values[i] = graphql.MarshalString("__EnumValue") 3303 | case "name": 3304 | 3305 | out.Values[i] = ec.___EnumValue_name(ctx, field, obj) 3306 | 3307 | if out.Values[i] == graphql.Null { 3308 | invalids++ 3309 | } 3310 | case "description": 3311 | 3312 | out.Values[i] = ec.___EnumValue_description(ctx, field, obj) 3313 | 3314 | case "isDeprecated": 3315 | 3316 | out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) 3317 | 3318 | if out.Values[i] == graphql.Null { 3319 | invalids++ 3320 | } 3321 | case "deprecationReason": 3322 | 3323 | out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) 3324 | 3325 | default: 3326 | panic("unknown field " + strconv.Quote(field.Name)) 3327 | } 3328 | } 3329 | out.Dispatch() 3330 | if invalids > 0 { 3331 | return graphql.Null 3332 | } 3333 | return out 3334 | } 3335 | 3336 | var __FieldImplementors = []string{"__Field"} 3337 | 3338 | func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { 3339 | fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) 3340 | out := graphql.NewFieldSet(fields) 3341 | var invalids uint32 3342 | for i, field := range fields { 3343 | switch field.Name { 3344 | case "__typename": 3345 | out.Values[i] = graphql.MarshalString("__Field") 3346 | case "name": 3347 | 3348 | out.Values[i] = ec.___Field_name(ctx, field, obj) 3349 | 3350 | if out.Values[i] == graphql.Null { 3351 | invalids++ 3352 | } 3353 | case "description": 3354 | 3355 | out.Values[i] = ec.___Field_description(ctx, field, obj) 3356 | 3357 | case "args": 3358 | 3359 | out.Values[i] = ec.___Field_args(ctx, field, obj) 3360 | 3361 | if out.Values[i] == graphql.Null { 3362 | invalids++ 3363 | } 3364 | case "type": 3365 | 3366 | out.Values[i] = ec.___Field_type(ctx, field, obj) 3367 | 3368 | if out.Values[i] == graphql.Null { 3369 | invalids++ 3370 | } 3371 | case "isDeprecated": 3372 | 3373 | out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) 3374 | 3375 | if out.Values[i] == graphql.Null { 3376 | invalids++ 3377 | } 3378 | case "deprecationReason": 3379 | 3380 | out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) 3381 | 3382 | default: 3383 | panic("unknown field " + strconv.Quote(field.Name)) 3384 | } 3385 | } 3386 | out.Dispatch() 3387 | if invalids > 0 { 3388 | return graphql.Null 3389 | } 3390 | return out 3391 | } 3392 | 3393 | var __InputValueImplementors = []string{"__InputValue"} 3394 | 3395 | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { 3396 | fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) 3397 | out := graphql.NewFieldSet(fields) 3398 | var invalids uint32 3399 | for i, field := range fields { 3400 | switch field.Name { 3401 | case "__typename": 3402 | out.Values[i] = graphql.MarshalString("__InputValue") 3403 | case "name": 3404 | 3405 | out.Values[i] = ec.___InputValue_name(ctx, field, obj) 3406 | 3407 | if out.Values[i] == graphql.Null { 3408 | invalids++ 3409 | } 3410 | case "description": 3411 | 3412 | out.Values[i] = ec.___InputValue_description(ctx, field, obj) 3413 | 3414 | case "type": 3415 | 3416 | out.Values[i] = ec.___InputValue_type(ctx, field, obj) 3417 | 3418 | if out.Values[i] == graphql.Null { 3419 | invalids++ 3420 | } 3421 | case "defaultValue": 3422 | 3423 | out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) 3424 | 3425 | default: 3426 | panic("unknown field " + strconv.Quote(field.Name)) 3427 | } 3428 | } 3429 | out.Dispatch() 3430 | if invalids > 0 { 3431 | return graphql.Null 3432 | } 3433 | return out 3434 | } 3435 | 3436 | var __SchemaImplementors = []string{"__Schema"} 3437 | 3438 | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { 3439 | fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) 3440 | out := graphql.NewFieldSet(fields) 3441 | var invalids uint32 3442 | for i, field := range fields { 3443 | switch field.Name { 3444 | case "__typename": 3445 | out.Values[i] = graphql.MarshalString("__Schema") 3446 | case "description": 3447 | 3448 | out.Values[i] = ec.___Schema_description(ctx, field, obj) 3449 | 3450 | case "types": 3451 | 3452 | out.Values[i] = ec.___Schema_types(ctx, field, obj) 3453 | 3454 | if out.Values[i] == graphql.Null { 3455 | invalids++ 3456 | } 3457 | case "queryType": 3458 | 3459 | out.Values[i] = ec.___Schema_queryType(ctx, field, obj) 3460 | 3461 | if out.Values[i] == graphql.Null { 3462 | invalids++ 3463 | } 3464 | case "mutationType": 3465 | 3466 | out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) 3467 | 3468 | case "subscriptionType": 3469 | 3470 | out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) 3471 | 3472 | case "directives": 3473 | 3474 | out.Values[i] = ec.___Schema_directives(ctx, field, obj) 3475 | 3476 | if out.Values[i] == graphql.Null { 3477 | invalids++ 3478 | } 3479 | default: 3480 | panic("unknown field " + strconv.Quote(field.Name)) 3481 | } 3482 | } 3483 | out.Dispatch() 3484 | if invalids > 0 { 3485 | return graphql.Null 3486 | } 3487 | return out 3488 | } 3489 | 3490 | var __TypeImplementors = []string{"__Type"} 3491 | 3492 | func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { 3493 | fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) 3494 | out := graphql.NewFieldSet(fields) 3495 | var invalids uint32 3496 | for i, field := range fields { 3497 | switch field.Name { 3498 | case "__typename": 3499 | out.Values[i] = graphql.MarshalString("__Type") 3500 | case "kind": 3501 | 3502 | out.Values[i] = ec.___Type_kind(ctx, field, obj) 3503 | 3504 | if out.Values[i] == graphql.Null { 3505 | invalids++ 3506 | } 3507 | case "name": 3508 | 3509 | out.Values[i] = ec.___Type_name(ctx, field, obj) 3510 | 3511 | case "description": 3512 | 3513 | out.Values[i] = ec.___Type_description(ctx, field, obj) 3514 | 3515 | case "fields": 3516 | 3517 | out.Values[i] = ec.___Type_fields(ctx, field, obj) 3518 | 3519 | case "interfaces": 3520 | 3521 | out.Values[i] = ec.___Type_interfaces(ctx, field, obj) 3522 | 3523 | case "possibleTypes": 3524 | 3525 | out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) 3526 | 3527 | case "enumValues": 3528 | 3529 | out.Values[i] = ec.___Type_enumValues(ctx, field, obj) 3530 | 3531 | case "inputFields": 3532 | 3533 | out.Values[i] = ec.___Type_inputFields(ctx, field, obj) 3534 | 3535 | case "ofType": 3536 | 3537 | out.Values[i] = ec.___Type_ofType(ctx, field, obj) 3538 | 3539 | case "specifiedByURL": 3540 | 3541 | out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) 3542 | 3543 | default: 3544 | panic("unknown field " + strconv.Quote(field.Name)) 3545 | } 3546 | } 3547 | out.Dispatch() 3548 | if invalids > 0 { 3549 | return graphql.Null 3550 | } 3551 | return out 3552 | } 3553 | 3554 | // endregion **************************** object.gotpl **************************** 3555 | 3556 | // region ***************************** type.gotpl ***************************** 3557 | 3558 | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { 3559 | res, err := graphql.UnmarshalBoolean(v) 3560 | return res, graphql.ErrorOnPath(ctx, err) 3561 | } 3562 | 3563 | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { 3564 | res := graphql.MarshalBoolean(v) 3565 | if res == graphql.Null { 3566 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 3567 | ec.Errorf(ctx, "the requested element is null which the schema does not allow") 3568 | } 3569 | } 3570 | return res 3571 | } 3572 | 3573 | func (ec *executionContext) marshalNCategory2githubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCategory(ctx context.Context, sel ast.SelectionSet, v model.Category) graphql.Marshaler { 3574 | return ec._Category(ctx, sel, &v) 3575 | } 3576 | 3577 | func (ec *executionContext) marshalNCategory2ᚕᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCategoryᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Category) graphql.Marshaler { 3578 | ret := make(graphql.Array, len(v)) 3579 | var wg sync.WaitGroup 3580 | isLen1 := len(v) == 1 3581 | if !isLen1 { 3582 | wg.Add(len(v)) 3583 | } 3584 | for i := range v { 3585 | i := i 3586 | fc := &graphql.FieldContext{ 3587 | Index: &i, 3588 | Result: &v[i], 3589 | } 3590 | ctx := graphql.WithFieldContext(ctx, fc) 3591 | f := func(i int) { 3592 | defer func() { 3593 | if r := recover(); r != nil { 3594 | ec.Error(ctx, ec.Recover(ctx, r)) 3595 | ret = nil 3596 | } 3597 | }() 3598 | if !isLen1 { 3599 | defer wg.Done() 3600 | } 3601 | ret[i] = ec.marshalNCategory2ᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCategory(ctx, sel, v[i]) 3602 | } 3603 | if isLen1 { 3604 | f(i) 3605 | } else { 3606 | go f(i) 3607 | } 3608 | 3609 | } 3610 | wg.Wait() 3611 | 3612 | for _, e := range ret { 3613 | if e == graphql.Null { 3614 | return graphql.Null 3615 | } 3616 | } 3617 | 3618 | return ret 3619 | } 3620 | 3621 | func (ec *executionContext) marshalNCategory2ᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCategory(ctx context.Context, sel ast.SelectionSet, v *model.Category) graphql.Marshaler { 3622 | if v == nil { 3623 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 3624 | ec.Errorf(ctx, "the requested element is null which the schema does not allow") 3625 | } 3626 | return graphql.Null 3627 | } 3628 | return ec._Category(ctx, sel, v) 3629 | } 3630 | 3631 | func (ec *executionContext) marshalNCourse2githubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCourse(ctx context.Context, sel ast.SelectionSet, v model.Course) graphql.Marshaler { 3632 | return ec._Course(ctx, sel, &v) 3633 | } 3634 | 3635 | func (ec *executionContext) marshalNCourse2ᚕᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCourseᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Course) graphql.Marshaler { 3636 | ret := make(graphql.Array, len(v)) 3637 | var wg sync.WaitGroup 3638 | isLen1 := len(v) == 1 3639 | if !isLen1 { 3640 | wg.Add(len(v)) 3641 | } 3642 | for i := range v { 3643 | i := i 3644 | fc := &graphql.FieldContext{ 3645 | Index: &i, 3646 | Result: &v[i], 3647 | } 3648 | ctx := graphql.WithFieldContext(ctx, fc) 3649 | f := func(i int) { 3650 | defer func() { 3651 | if r := recover(); r != nil { 3652 | ec.Error(ctx, ec.Recover(ctx, r)) 3653 | ret = nil 3654 | } 3655 | }() 3656 | if !isLen1 { 3657 | defer wg.Done() 3658 | } 3659 | ret[i] = ec.marshalNCourse2ᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCourse(ctx, sel, v[i]) 3660 | } 3661 | if isLen1 { 3662 | f(i) 3663 | } else { 3664 | go f(i) 3665 | } 3666 | 3667 | } 3668 | wg.Wait() 3669 | 3670 | for _, e := range ret { 3671 | if e == graphql.Null { 3672 | return graphql.Null 3673 | } 3674 | } 3675 | 3676 | return ret 3677 | } 3678 | 3679 | func (ec *executionContext) marshalNCourse2ᚖgithubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐCourse(ctx context.Context, sel ast.SelectionSet, v *model.Course) graphql.Marshaler { 3680 | if v == nil { 3681 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 3682 | ec.Errorf(ctx, "the requested element is null which the schema does not allow") 3683 | } 3684 | return graphql.Null 3685 | } 3686 | return ec._Course(ctx, sel, v) 3687 | } 3688 | 3689 | func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { 3690 | res, err := graphql.UnmarshalID(v) 3691 | return res, graphql.ErrorOnPath(ctx, err) 3692 | } 3693 | 3694 | func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 3695 | res := graphql.MarshalID(v) 3696 | if res == graphql.Null { 3697 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 3698 | ec.Errorf(ctx, "the requested element is null which the schema does not allow") 3699 | } 3700 | } 3701 | return res 3702 | } 3703 | 3704 | func (ec *executionContext) unmarshalNNewCategory2githubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐNewCategory(ctx context.Context, v interface{}) (model.NewCategory, error) { 3705 | res, err := ec.unmarshalInputNewCategory(ctx, v) 3706 | return res, graphql.ErrorOnPath(ctx, err) 3707 | } 3708 | 3709 | func (ec *executionContext) unmarshalNNewCourse2githubᚗcomᚋdevfullcycleᚋ13ᚑGraphQLᚋgraphᚋmodelᚐNewCourse(ctx context.Context, v interface{}) (model.NewCourse, error) { 3710 | res, err := ec.unmarshalInputNewCourse(ctx, v) 3711 | return res, graphql.ErrorOnPath(ctx, err) 3712 | } 3713 | 3714 | func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { 3715 | res, err := graphql.UnmarshalString(v) 3716 | return res, graphql.ErrorOnPath(ctx, err) 3717 | } 3718 | 3719 | func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 3720 | res := graphql.MarshalString(v) 3721 | if res == graphql.Null { 3722 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 3723 | ec.Errorf(ctx, "the requested element is null which the schema does not allow") 3724 | } 3725 | } 3726 | return res 3727 | } 3728 | 3729 | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { 3730 | return ec.___Directive(ctx, sel, &v) 3731 | } 3732 | 3733 | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { 3734 | ret := make(graphql.Array, len(v)) 3735 | var wg sync.WaitGroup 3736 | isLen1 := len(v) == 1 3737 | if !isLen1 { 3738 | wg.Add(len(v)) 3739 | } 3740 | for i := range v { 3741 | i := i 3742 | fc := &graphql.FieldContext{ 3743 | Index: &i, 3744 | Result: &v[i], 3745 | } 3746 | ctx := graphql.WithFieldContext(ctx, fc) 3747 | f := func(i int) { 3748 | defer func() { 3749 | if r := recover(); r != nil { 3750 | ec.Error(ctx, ec.Recover(ctx, r)) 3751 | ret = nil 3752 | } 3753 | }() 3754 | if !isLen1 { 3755 | defer wg.Done() 3756 | } 3757 | ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) 3758 | } 3759 | if isLen1 { 3760 | f(i) 3761 | } else { 3762 | go f(i) 3763 | } 3764 | 3765 | } 3766 | wg.Wait() 3767 | 3768 | for _, e := range ret { 3769 | if e == graphql.Null { 3770 | return graphql.Null 3771 | } 3772 | } 3773 | 3774 | return ret 3775 | } 3776 | 3777 | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { 3778 | res, err := graphql.UnmarshalString(v) 3779 | return res, graphql.ErrorOnPath(ctx, err) 3780 | } 3781 | 3782 | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 3783 | res := graphql.MarshalString(v) 3784 | if res == graphql.Null { 3785 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 3786 | ec.Errorf(ctx, "the requested element is null which the schema does not allow") 3787 | } 3788 | } 3789 | return res 3790 | } 3791 | 3792 | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { 3793 | var vSlice []interface{} 3794 | if v != nil { 3795 | vSlice = graphql.CoerceList(v) 3796 | } 3797 | var err error 3798 | res := make([]string, len(vSlice)) 3799 | for i := range vSlice { 3800 | ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) 3801 | res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) 3802 | if err != nil { 3803 | return nil, err 3804 | } 3805 | } 3806 | return res, nil 3807 | } 3808 | 3809 | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { 3810 | ret := make(graphql.Array, len(v)) 3811 | var wg sync.WaitGroup 3812 | isLen1 := len(v) == 1 3813 | if !isLen1 { 3814 | wg.Add(len(v)) 3815 | } 3816 | for i := range v { 3817 | i := i 3818 | fc := &graphql.FieldContext{ 3819 | Index: &i, 3820 | Result: &v[i], 3821 | } 3822 | ctx := graphql.WithFieldContext(ctx, fc) 3823 | f := func(i int) { 3824 | defer func() { 3825 | if r := recover(); r != nil { 3826 | ec.Error(ctx, ec.Recover(ctx, r)) 3827 | ret = nil 3828 | } 3829 | }() 3830 | if !isLen1 { 3831 | defer wg.Done() 3832 | } 3833 | ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) 3834 | } 3835 | if isLen1 { 3836 | f(i) 3837 | } else { 3838 | go f(i) 3839 | } 3840 | 3841 | } 3842 | wg.Wait() 3843 | 3844 | for _, e := range ret { 3845 | if e == graphql.Null { 3846 | return graphql.Null 3847 | } 3848 | } 3849 | 3850 | return ret 3851 | } 3852 | 3853 | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { 3854 | return ec.___EnumValue(ctx, sel, &v) 3855 | } 3856 | 3857 | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { 3858 | return ec.___Field(ctx, sel, &v) 3859 | } 3860 | 3861 | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { 3862 | return ec.___InputValue(ctx, sel, &v) 3863 | } 3864 | 3865 | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { 3866 | ret := make(graphql.Array, len(v)) 3867 | var wg sync.WaitGroup 3868 | isLen1 := len(v) == 1 3869 | if !isLen1 { 3870 | wg.Add(len(v)) 3871 | } 3872 | for i := range v { 3873 | i := i 3874 | fc := &graphql.FieldContext{ 3875 | Index: &i, 3876 | Result: &v[i], 3877 | } 3878 | ctx := graphql.WithFieldContext(ctx, fc) 3879 | f := func(i int) { 3880 | defer func() { 3881 | if r := recover(); r != nil { 3882 | ec.Error(ctx, ec.Recover(ctx, r)) 3883 | ret = nil 3884 | } 3885 | }() 3886 | if !isLen1 { 3887 | defer wg.Done() 3888 | } 3889 | ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) 3890 | } 3891 | if isLen1 { 3892 | f(i) 3893 | } else { 3894 | go f(i) 3895 | } 3896 | 3897 | } 3898 | wg.Wait() 3899 | 3900 | for _, e := range ret { 3901 | if e == graphql.Null { 3902 | return graphql.Null 3903 | } 3904 | } 3905 | 3906 | return ret 3907 | } 3908 | 3909 | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { 3910 | return ec.___Type(ctx, sel, &v) 3911 | } 3912 | 3913 | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { 3914 | ret := make(graphql.Array, len(v)) 3915 | var wg sync.WaitGroup 3916 | isLen1 := len(v) == 1 3917 | if !isLen1 { 3918 | wg.Add(len(v)) 3919 | } 3920 | for i := range v { 3921 | i := i 3922 | fc := &graphql.FieldContext{ 3923 | Index: &i, 3924 | Result: &v[i], 3925 | } 3926 | ctx := graphql.WithFieldContext(ctx, fc) 3927 | f := func(i int) { 3928 | defer func() { 3929 | if r := recover(); r != nil { 3930 | ec.Error(ctx, ec.Recover(ctx, r)) 3931 | ret = nil 3932 | } 3933 | }() 3934 | if !isLen1 { 3935 | defer wg.Done() 3936 | } 3937 | ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) 3938 | } 3939 | if isLen1 { 3940 | f(i) 3941 | } else { 3942 | go f(i) 3943 | } 3944 | 3945 | } 3946 | wg.Wait() 3947 | 3948 | for _, e := range ret { 3949 | if e == graphql.Null { 3950 | return graphql.Null 3951 | } 3952 | } 3953 | 3954 | return ret 3955 | } 3956 | 3957 | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { 3958 | if v == nil { 3959 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 3960 | ec.Errorf(ctx, "the requested element is null which the schema does not allow") 3961 | } 3962 | return graphql.Null 3963 | } 3964 | return ec.___Type(ctx, sel, v) 3965 | } 3966 | 3967 | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { 3968 | res, err := graphql.UnmarshalString(v) 3969 | return res, graphql.ErrorOnPath(ctx, err) 3970 | } 3971 | 3972 | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 3973 | res := graphql.MarshalString(v) 3974 | if res == graphql.Null { 3975 | if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 3976 | ec.Errorf(ctx, "the requested element is null which the schema does not allow") 3977 | } 3978 | } 3979 | return res 3980 | } 3981 | 3982 | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { 3983 | res, err := graphql.UnmarshalBoolean(v) 3984 | return res, graphql.ErrorOnPath(ctx, err) 3985 | } 3986 | 3987 | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { 3988 | res := graphql.MarshalBoolean(v) 3989 | return res 3990 | } 3991 | 3992 | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { 3993 | if v == nil { 3994 | return nil, nil 3995 | } 3996 | res, err := graphql.UnmarshalBoolean(v) 3997 | return &res, graphql.ErrorOnPath(ctx, err) 3998 | } 3999 | 4000 | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { 4001 | if v == nil { 4002 | return graphql.Null 4003 | } 4004 | res := graphql.MarshalBoolean(*v) 4005 | return res 4006 | } 4007 | 4008 | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { 4009 | if v == nil { 4010 | return nil, nil 4011 | } 4012 | res, err := graphql.UnmarshalString(v) 4013 | return &res, graphql.ErrorOnPath(ctx, err) 4014 | } 4015 | 4016 | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { 4017 | if v == nil { 4018 | return graphql.Null 4019 | } 4020 | res := graphql.MarshalString(*v) 4021 | return res 4022 | } 4023 | 4024 | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { 4025 | if v == nil { 4026 | return graphql.Null 4027 | } 4028 | ret := make(graphql.Array, len(v)) 4029 | var wg sync.WaitGroup 4030 | isLen1 := len(v) == 1 4031 | if !isLen1 { 4032 | wg.Add(len(v)) 4033 | } 4034 | for i := range v { 4035 | i := i 4036 | fc := &graphql.FieldContext{ 4037 | Index: &i, 4038 | Result: &v[i], 4039 | } 4040 | ctx := graphql.WithFieldContext(ctx, fc) 4041 | f := func(i int) { 4042 | defer func() { 4043 | if r := recover(); r != nil { 4044 | ec.Error(ctx, ec.Recover(ctx, r)) 4045 | ret = nil 4046 | } 4047 | }() 4048 | if !isLen1 { 4049 | defer wg.Done() 4050 | } 4051 | ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) 4052 | } 4053 | if isLen1 { 4054 | f(i) 4055 | } else { 4056 | go f(i) 4057 | } 4058 | 4059 | } 4060 | wg.Wait() 4061 | 4062 | for _, e := range ret { 4063 | if e == graphql.Null { 4064 | return graphql.Null 4065 | } 4066 | } 4067 | 4068 | return ret 4069 | } 4070 | 4071 | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { 4072 | if v == nil { 4073 | return graphql.Null 4074 | } 4075 | ret := make(graphql.Array, len(v)) 4076 | var wg sync.WaitGroup 4077 | isLen1 := len(v) == 1 4078 | if !isLen1 { 4079 | wg.Add(len(v)) 4080 | } 4081 | for i := range v { 4082 | i := i 4083 | fc := &graphql.FieldContext{ 4084 | Index: &i, 4085 | Result: &v[i], 4086 | } 4087 | ctx := graphql.WithFieldContext(ctx, fc) 4088 | f := func(i int) { 4089 | defer func() { 4090 | if r := recover(); r != nil { 4091 | ec.Error(ctx, ec.Recover(ctx, r)) 4092 | ret = nil 4093 | } 4094 | }() 4095 | if !isLen1 { 4096 | defer wg.Done() 4097 | } 4098 | ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) 4099 | } 4100 | if isLen1 { 4101 | f(i) 4102 | } else { 4103 | go f(i) 4104 | } 4105 | 4106 | } 4107 | wg.Wait() 4108 | 4109 | for _, e := range ret { 4110 | if e == graphql.Null { 4111 | return graphql.Null 4112 | } 4113 | } 4114 | 4115 | return ret 4116 | } 4117 | 4118 | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { 4119 | if v == nil { 4120 | return graphql.Null 4121 | } 4122 | ret := make(graphql.Array, len(v)) 4123 | var wg sync.WaitGroup 4124 | isLen1 := len(v) == 1 4125 | if !isLen1 { 4126 | wg.Add(len(v)) 4127 | } 4128 | for i := range v { 4129 | i := i 4130 | fc := &graphql.FieldContext{ 4131 | Index: &i, 4132 | Result: &v[i], 4133 | } 4134 | ctx := graphql.WithFieldContext(ctx, fc) 4135 | f := func(i int) { 4136 | defer func() { 4137 | if r := recover(); r != nil { 4138 | ec.Error(ctx, ec.Recover(ctx, r)) 4139 | ret = nil 4140 | } 4141 | }() 4142 | if !isLen1 { 4143 | defer wg.Done() 4144 | } 4145 | ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) 4146 | } 4147 | if isLen1 { 4148 | f(i) 4149 | } else { 4150 | go f(i) 4151 | } 4152 | 4153 | } 4154 | wg.Wait() 4155 | 4156 | for _, e := range ret { 4157 | if e == graphql.Null { 4158 | return graphql.Null 4159 | } 4160 | } 4161 | 4162 | return ret 4163 | } 4164 | 4165 | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { 4166 | if v == nil { 4167 | return graphql.Null 4168 | } 4169 | return ec.___Schema(ctx, sel, v) 4170 | } 4171 | 4172 | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { 4173 | if v == nil { 4174 | return graphql.Null 4175 | } 4176 | ret := make(graphql.Array, len(v)) 4177 | var wg sync.WaitGroup 4178 | isLen1 := len(v) == 1 4179 | if !isLen1 { 4180 | wg.Add(len(v)) 4181 | } 4182 | for i := range v { 4183 | i := i 4184 | fc := &graphql.FieldContext{ 4185 | Index: &i, 4186 | Result: &v[i], 4187 | } 4188 | ctx := graphql.WithFieldContext(ctx, fc) 4189 | f := func(i int) { 4190 | defer func() { 4191 | if r := recover(); r != nil { 4192 | ec.Error(ctx, ec.Recover(ctx, r)) 4193 | ret = nil 4194 | } 4195 | }() 4196 | if !isLen1 { 4197 | defer wg.Done() 4198 | } 4199 | ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) 4200 | } 4201 | if isLen1 { 4202 | f(i) 4203 | } else { 4204 | go f(i) 4205 | } 4206 | 4207 | } 4208 | wg.Wait() 4209 | 4210 | for _, e := range ret { 4211 | if e == graphql.Null { 4212 | return graphql.Null 4213 | } 4214 | } 4215 | 4216 | return ret 4217 | } 4218 | 4219 | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { 4220 | if v == nil { 4221 | return graphql.Null 4222 | } 4223 | return ec.___Type(ctx, sel, v) 4224 | } 4225 | 4226 | // endregion ***************************** type.gotpl ***************************** 4227 | -------------------------------------------------------------------------------- /graph/model/category.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type Category struct { 4 | ID string `json:"id"` 5 | Name string `json:"name"` 6 | Description *string `json:"description"` 7 | } -------------------------------------------------------------------------------- /graph/model/course.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type Course struct { 4 | ID string `json:"id"` 5 | Name string `json:"name"` 6 | Description *string `json:"description"` 7 | } -------------------------------------------------------------------------------- /graph/model/models_gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 | 3 | package model 4 | 5 | type NewCategory struct { 6 | Name string `json:"name"` 7 | Description *string `json:"description"` 8 | } 9 | 10 | type NewCourse struct { 11 | Name string `json:"name"` 12 | Description *string `json:"description"` 13 | CategoryID string `json:"categoryId"` 14 | } 15 | -------------------------------------------------------------------------------- /graph/resolver.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | import "github.com/devfullcycle/13-GraphQL/internal/database" 4 | 5 | // This file will not be regenerated automatically. 6 | // 7 | // It serves as dependency injection for your app, add any dependencies you require here. 8 | 9 | type Resolver struct{ 10 | CategoryDB *database.Category 11 | CourseDB *database.Course 12 | } 13 | -------------------------------------------------------------------------------- /graph/schema.graphqls: -------------------------------------------------------------------------------- 1 | type Category { 2 | id: ID! 3 | name: String! 4 | description: String 5 | courses: [Course!]! 6 | } 7 | 8 | type Course { 9 | id: ID! 10 | name : String! 11 | description: String 12 | category: Category! 13 | } 14 | 15 | input NewCategory { 16 | name: String! 17 | description: String 18 | } 19 | 20 | input NewCourse { 21 | name: String! 22 | description: String 23 | categoryId: ID! 24 | } 25 | 26 | type Query { 27 | categories: [Category!]! 28 | courses: [Course!]! 29 | } 30 | 31 | type Mutation { 32 | createCategory(input: NewCategory!): Category! 33 | createCourse(input: NewCourse!): Course! 34 | } -------------------------------------------------------------------------------- /graph/schema.resolvers.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | // This file will be automatically regenerated based on the schema, any resolver implementations 4 | // will be copied through when generating and any unknown code will be moved to the end. 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/devfullcycle/13-GraphQL/graph/generated" 10 | "github.com/devfullcycle/13-GraphQL/graph/model" 11 | ) 12 | 13 | // Courses is the resolver for the courses field. 14 | func (r *categoryResolver) Courses(ctx context.Context, obj *model.Category) ([]*model.Course, error) { 15 | courses, err := r.CourseDB.FindByCategoryID(obj.ID) 16 | if err != nil { 17 | return nil, err 18 | } 19 | var coursesModel []*model.Course 20 | for _, course := range courses { 21 | coursesModel = append(coursesModel, &model.Course{ 22 | ID: course.ID, 23 | Name: course.Name, 24 | Description: course.Description, 25 | }) 26 | } 27 | return coursesModel, nil 28 | } 29 | 30 | // Category is the resolver for the category field. 31 | func (r *courseResolver) Category(ctx context.Context, obj *model.Course) (*model.Category, error) { 32 | category, err := r.CategoryDB.FindByCourseID(obj.ID) 33 | if err != nil { 34 | return nil, err 35 | } 36 | return &model.Category{ 37 | ID: category.ID, 38 | Name: category.Name, 39 | Description: category.Description, 40 | }, nil 41 | } 42 | 43 | // CreateCategory is the resolver for the createCategory field. 44 | func (r *mutationResolver) CreateCategory(ctx context.Context, input model.NewCategory) (*model.Category, error) { 45 | category, err := r.CategoryDB.Create(input.Name, *input.Description) 46 | if err != nil { 47 | return nil, err 48 | } 49 | return &model.Category{ 50 | ID: category.ID, 51 | Name: category.Name, 52 | Description: category.Description, 53 | }, nil 54 | } 55 | 56 | // CreateCourse is the resolver for the createCourse field. 57 | func (r *mutationResolver) CreateCourse(ctx context.Context, input model.NewCourse) (*model.Course, error) { 58 | course, err := r.CourseDB.Create(input.Name, *input.Description, input.CategoryID) 59 | if err != nil { 60 | return nil, err 61 | } 62 | return &model.Course{ 63 | ID: course.ID, 64 | Name: course.Name, 65 | Description: course.Description, 66 | }, nil 67 | } 68 | 69 | // Categories is the resolver for the categories field. 70 | func (r *queryResolver) Categories(ctx context.Context) ([]*model.Category, error) { 71 | categories, err := r.CategoryDB.FindAll() 72 | if err != nil { 73 | return nil, err 74 | } 75 | var categoriesModel []*model.Category 76 | for _, category := range categories { 77 | categoriesModel = append(categoriesModel, &model.Category{ 78 | ID: category.ID, 79 | Name: category.Name, 80 | Description: category.Description, 81 | }) 82 | } 83 | return categoriesModel, nil 84 | } 85 | 86 | // Courses is the resolver for the courses field. 87 | func (r *queryResolver) Courses(ctx context.Context) ([]*model.Course, error) { 88 | courses, err := r.CourseDB.FindAll() 89 | if err != nil { 90 | return nil, err 91 | } 92 | var coursesModel []*model.Course 93 | for _, course := range courses { 94 | coursesModel = append(coursesModel, &model.Course{ 95 | ID: course.ID, 96 | Name: course.Name, 97 | Description: course.Description, 98 | }) 99 | } 100 | return coursesModel, nil 101 | } 102 | 103 | // Category returns generated.CategoryResolver implementation. 104 | func (r *Resolver) Category() generated.CategoryResolver { return &categoryResolver{r} } 105 | 106 | // Course returns generated.CourseResolver implementation. 107 | func (r *Resolver) Course() generated.CourseResolver { return &courseResolver{r} } 108 | 109 | // Mutation returns generated.MutationResolver implementation. 110 | func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } 111 | 112 | // Query returns generated.QueryResolver implementation. 113 | func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } 114 | 115 | type categoryResolver struct{ *Resolver } 116 | type courseResolver struct{ *Resolver } 117 | type mutationResolver struct{ *Resolver } 118 | type queryResolver struct{ *Resolver } 119 | -------------------------------------------------------------------------------- /internal/database/category.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "database/sql" 5 | 6 | "github.com/google/uuid" 7 | ) 8 | 9 | type Category struct { 10 | db *sql.DB 11 | ID string 12 | Name string 13 | Description *string 14 | } 15 | 16 | func NewCategory(db *sql.DB) *Category { 17 | return &Category{db: db} 18 | } 19 | 20 | func (c *Category) Create(name string, description string) (Category, error) { 21 | id := uuid.New().String() 22 | _, err := c.db.Exec("INSERT INTO categories (id, name, description) VALUES ($1, $2, $3)", 23 | id, name, description) 24 | if err != nil { 25 | return Category{}, err 26 | } 27 | return Category{ID: id, Name: name, Description: &description}, nil 28 | } 29 | 30 | func (c *Category) FindAll() ([]Category, error) { 31 | rows, err := c.db.Query("SELECT id, name, description FROM categories") 32 | if err != nil { 33 | return nil, err 34 | } 35 | defer rows.Close() 36 | categories := []Category{} 37 | for rows.Next() { 38 | var id, name string 39 | var description sql.NullString 40 | if err := rows.Scan(&id, &name, &description); err != nil { 41 | return nil, err 42 | } 43 | var descriptionPtr *string 44 | 45 | if description.Valid { 46 | descriptionPtr = &description.String 47 | } else { 48 | descriptionPtr = nil 49 | } 50 | categories = append(categories, Category{ID: id, Name: name, Description: descriptionPtr}) 51 | } 52 | return categories, nil 53 | } 54 | 55 | func (c *Category) FindByCourseID(courseID string) (Category, error) { 56 | var id, name, description string 57 | err := c.db.QueryRow("SELECT c.id, c.name, c.description FROM categories c JOIN courses co ON c.id = co.category_id WHERE co.id = $1", courseID). 58 | Scan(&id, &name, &description) 59 | if err != nil { 60 | return Category{}, err 61 | } 62 | return Category{ID: id, Name: name, Description: &description}, nil 63 | } 64 | -------------------------------------------------------------------------------- /internal/database/course.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "database/sql" 5 | 6 | "github.com/google/uuid" 7 | ) 8 | 9 | type Course struct { 10 | db *sql.DB 11 | ID string 12 | Name string 13 | Description *string 14 | CategoryID string 15 | } 16 | 17 | func NewCourse(db *sql.DB) *Course { 18 | return &Course{db: db} 19 | } 20 | 21 | func (c *Course) Create(name, description, categoryID string) (*Course, error) { 22 | id := uuid.New().String() 23 | _, err := c.db.Exec("INSERT INTO courses (id, name, description, category_id) VALUES ($1, $2, $3, $4)", 24 | id, name, description, categoryID) 25 | if err != nil { 26 | return nil, err 27 | } 28 | return &Course{ 29 | ID: id, 30 | Name: name, 31 | Description: &description, 32 | CategoryID: categoryID, 33 | }, nil 34 | } 35 | 36 | func (c *Course) FindAll() ([]Course, error) { 37 | rows, err := c.db.Query("SELECT id, name, description, category_id FROM courses") 38 | if err != nil { 39 | return nil, err 40 | } 41 | defer rows.Close() 42 | courses := []Course{} 43 | for rows.Next() { 44 | var id, name, description, categoryID string 45 | if err := rows.Scan(&id, &name, &description, &categoryID); err != nil { 46 | return nil, err 47 | } 48 | courses = append(courses, Course{ID: id, Name: name, Description: &description, CategoryID: categoryID}) 49 | } 50 | return courses, nil 51 | } 52 | 53 | func (c *Course) FindByCategoryID(categoryID string) ([]Course, error) { 54 | rows, err := c.db.Query("SELECT id, name, description, category_id FROM courses WHERE category_id = $1", categoryID) 55 | if err != nil { 56 | return nil, err 57 | } 58 | defer rows.Close() 59 | courses := []Course{} 60 | for rows.Next() { 61 | var id, name, description, categoryID string 62 | if err := rows.Scan(&id, &name, &description, &categoryID); err != nil { 63 | return nil, err 64 | } 65 | courses = append(courses, Course{ID: id, Name: name, Description: &description, CategoryID: categoryID}) 66 | } 67 | return courses, nil 68 | } -------------------------------------------------------------------------------- /tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | // +build tools 3 | 4 | package tools 5 | 6 | import ( 7 | _ "github.com/99designs/gqlgen" 8 | _ "github.com/99designs/gqlgen/graphql/introspection" 9 | ) 10 | --------------------------------------------------------------------------------