diff --git a/.github/stale.yml b/.github/stale.yml
deleted file mode 100644
index 66470e7554c..00000000000
--- a/.github/stale.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-daysUntilStale: 90
-daysUntilClose: 7
-staleLabel: stale
-markComment: >
- This issue has been automatically marked as stale because it has not had
- recent activity. It will be closed if no further activity occurs. Thank you
- for your contributions.
-exemptLabels:
- - accepted
- - enhancement
diff --git a/.github/workflows/check-fmt b/.github/workflows/check-fmt
index cf68afec76e..de84fb0d7b4 100755
--- a/.github/workflows/check-fmt
+++ b/.github/workflows/check-fmt
@@ -3,6 +3,7 @@
set -euo pipefail
go fmt ./...
+cd example && go fmt ./...
if [[ $(git --no-pager diff) ]] ; then
echo "you need to run "go fmt" and commit the changes"
git --no-pager diff
diff --git a/.github/workflows/check-generate b/.github/workflows/check-generate
index 25bd59626dc..0832cc10e06 100755
--- a/.github/workflows/check-generate
+++ b/.github/workflows/check-generate
@@ -3,7 +3,7 @@
set -euo pipefail
go generate ./...
-
+cd example && go generate ./...
if [[ $(git --no-pager diff) ]] ; then
echo "you need to run "go generate ./..." and commit the changes"
git --no-pager diff
diff --git a/.github/workflows/check-init b/.github/workflows/check-init
new file mode 100755
index 00000000000..4197a5644e8
--- /dev/null
+++ b/.github/workflows/check-init
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -euo pipefail
+
+cd example/init
+
+go get -d github.com/99designs/gqlgen
+
+if { go run github.com/99designs/gqlgen init 2>&1 >&3 3>&- | grep '^' >&2; } 3>&1; then
+ echo "gqlgen init failed validation"
+ exit 125
+fi
diff --git a/.github/workflows/check-linting b/.github/workflows/check-linting
deleted file mode 100755
index b7b771bcb35..00000000000
--- a/.github/workflows/check-linting
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-set -euo pipefail
-
-mkdir /tmp/golangci
-curl -sL --fail https://github.com/golangci/golangci-lint/releases/download/v1.29.0/golangci-lint-1.29.0-linux-amd64.tar.gz | tar zxv --strip-components=1 --dir=/tmp/golangci
-
-/tmp/golangci/golangci-lint run
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index 273e4f5f4e8..7f0fb419433 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -5,7 +5,7 @@ jobs:
integration:
runs-on: ubuntu-latest
timeout-minutes: 3
- container: golang:1.13-alpine
+ container: golang:1.17-alpine
steps:
- uses: actions/checkout@v1
- run: apk add --no-cache --no-progress nodejs npm git bash
@@ -15,10 +15,18 @@ jobs:
federation:
runs-on: ubuntu-latest
- container: golang:1.13-alpine
+ container: golang:1.17-alpine
steps:
- uses: actions/checkout@v1
- run: apk add --no-cache --no-progress nodejs npm git bash
- run: go mod download
- run: cd example/federation ; npm install
- run: .github/workflows/check-federation
+
+ init:
+ runs-on: ubuntu-latest
+ container: golang:1.17-alpine
+ steps:
+ - uses: actions/checkout@v1
+ - run: apk add --no-cache --no-progress alpine-sdk bash
+ - run: .github/workflows/check-init
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 27b256b6f9f..0c2e46242fd 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -5,20 +5,21 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v1
+ - uses: actions/checkout@v2
- uses: actions/setup-go@v2
- with: { go-version: 1.14 }
+ with: { go-version: 1.17 }
- run: go mod download
- run: .github/workflows/check-fmt
- - run: .github/workflows/check-linting
- run: .github/workflows/check-generate
+ - name: golangci-lint
+ uses: golangci/golangci-lint-action@v2
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v2
- with: { go-version: 1.14 }
+ with: { go-version: 1.17 }
- run: go mod download
- run: .github/workflows/check-coverage
env:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 1df7ffaf751..53ced469708 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -5,7 +5,7 @@ jobs:
test:
strategy:
matrix:
- go: [1.13, 1.14]
+ go: [1.16, 1.17]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
@@ -14,5 +14,5 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- - run: go mod download
- - run: go test -race ./...
+ - run: go mod download && go test -race ./...
+ - run: cd example && go mod download && go test -race ./...
diff --git a/.gitignore b/.gitignore
index b918d6a6f20..a2017efe91e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@
/codegen/gen
/gen
+/.vscode
.idea/
*.test
*.out
diff --git a/.golangci.yml b/.golangci.yml
index 8d513868009..21099b69b05 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -21,12 +21,12 @@ linters:
- gosimple
- govet
- ineffassign
- - interfacer
- misspell
- nakedret
- prealloc
- staticcheck
- structcheck
+ - typecheck
- unconvert
- unused
- varcheck
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000000..8e19f19baaa
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,55 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [Unreleased]
+
+### Added
+
+### Changed
+
+### Fixed
+
+
+## v0.14.0 - 2021-09-08
+
+### Added
+
+* Added a changelog :-) Following the same style as [Apollo Client](https://github.com/apollographql/apollo-client) because that feels like it gives good thanks to the community contributors.
+By [@MichaelJCompton](https://github.com/MichaelJCompton) in [#1512](https://github.com/99designs/gqlgen/pull/1512)
+* Added support for methods returning `(v, ok)` shaped values to support Prisma Go client.
+By [@steebchen](https://github.com/steebchen) in [#1449](https://github.com/99designs/gqlgen/pull/1449)
+* Added a new API to finish an already validated config
+By [@benjaminjkraft](https://github.com/benjaminjkraft) in [#1387](https://github.com/99designs/gqlgen/pull/1387)
+
+### Changed
+
+* Updated to gqlparser to v2.2.0.
+By [@lwc](https://github.com/lwc) in [#1514](https://github.com/99designs/gqlgen/pull/1514)
+* GraphQL playground updated to 1.7.26.
+By [@ddouglas](https://github.com/ddouglas) in [#1436](https://github.com/99designs/gqlgen/pull/1436)
+
+### Fixed
+
+* Removed a data race by copying when input fields have default values.
+By [@skaji](https://github.com/skaji) in [#1456](https://github.com/99designs/gqlgen/pull/1456)
+* v0.12.2 broke the handling of pointers to slices by calling the custom Marshal and Unmarshal functions on the entire slice. It now correctly calls the custom Marshal and Unmarshal methods for each element in the slice.
+By [@ananyasaxena](https://github.com/ananyasaxena) in [#1363](https://github.com/99designs/gqlgen/pull/1363)
+* Changes in go1.16 that mean go.mod and go.sum aren't always up to date. Now `go mod tidy` is run after code generation.
+By [@lwc](https://github.com/lwc) in [#1501](https://github.com/99designs/gqlgen/pull/1501)
+* Errors in resolving non-nullable arrays were not correctly bubbling up to the next nullable field.
+By [@wilhelmeek](https://github.com/wilhelmeek) in [#1480](https://github.com/99designs/gqlgen/pull/1480)
+* Fixed a potential deadlock in calling error presenters.
+By [@vektah](https://github.com/vektah) in [#1399](https://github.com/99designs/gqlgen/pull/1399)
+* Fixed `collectFields` not correctly respecting alias fields in fragments.
+By [@vmrajas](https://github.com/vmrajas) in [#1341](https://github.com/99designs/gqlgen/pull/1341)
+* Return introspection document in stable order.
+* By [@nyergler](https://github.com/nyergler) in [#1497](https://github.com/99designs/gqlgen/pull/1497)
+
+## v0.13.0 - 2020-09-21
+
+Base version at which changelog was introduced.
+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 461709ecf8e..3919b2a4b83 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -4,7 +4,7 @@ Want to contribute to gqlgen? Here are some guidelines for how we accept help.
## Getting in Touch
-Our [gitter](https://gitter.im/gqlgen/Lobby) channel is the best place to ask questions or get advice on using gqlgen.
+Our [discord](https://discord.gg/DYEq3EMs4U) server is the best place to ask questions or get advice on using gqlgen.
## Reporting Bugs and Issues
diff --git a/README.md b/README.md
index 8e6ebdaac1d..fc039f8283c 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,11 @@
-# gqlgen [![Continuous Integration](https://github.com/99designs/gqlgen/workflows/Continuous%20Integration/badge.svg)](https://github.com/99designs/gqlgen/actions) [![Read the Docs](https://badgen.net/badge/docs/available/green)](http://gqlgen.com/) [![GoDoc](https://godoc.org/github.com/99designs/gqlgen?status.svg)](https://godoc.org/github.com/99designs/gqlgen)
+![gqlgen](https://user-images.githubusercontent.com/980499/133180111-d064b38c-6eb9-444b-a60f-7005a6e68222.png)
-![gqlgen](https://user-images.githubusercontent.com/46195831/89802919-0bb8ef00-db2a-11ea-8ba4-88e7a58b2fd2.png)
+
+# gqlgen [![Integration](https://github.com/99designs/gqlgen/actions/workflows/integration.yml/badge.svg)](https://github.com/99designs/gqlgen/actions) [![Coverage Status](https://coveralls.io/repos/github/99designs/gqlgen/badge.svg?branch=master)](https://coveralls.io/github/99designs/gqlgen?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/99designs/gqlgen)](https://goreportcard.com/report/github.com/99designs/gqlgen) [![Go Reference](https://pkg.go.dev/badge/github.com/99designs/gqlgen.svg)](https://pkg.go.dev/github.com/99designs/gqlgen) [![Read the Docs](https://badgen.net/badge/docs/available/green)](http://gqlgen.com/)
## What is gqlgen?
-[gqlgen](https://github.com/99designs/gqlgen) is a Go library for building GraphQL servers without any fuss.
+[gqlgen](https://github.com/99designs/gqlgen) is a Go library for building GraphQL servers without any fuss.
- **gqlgen is based on a Schema first approach** — You get to Define your API using the GraphQL [Schema Definition Language](http://graphql.org/learn/schema/).
- **gqlgen prioritizes Type safety** — You should never see `map[string]interface{}` here.
@@ -12,13 +13,30 @@
Still not convinced enough to use **gqlgen**? Compare **gqlgen** with other Go graphql [implementations](https://gqlgen.com/feature-comparison/)
-## Getting Started
-- To install gqlgen run the command `go get github.com/99designs/gqlgen` in your project directory.
-- You could initialize a new project using the recommended folder structure by running this command `go run github.com/99designs/gqlgen init`.
+## Quick start
+1. [Initialise a new go module](https://golang.org/doc/tutorial/create-module)
+
+ mkdir example
+ cd example
+ go mod init example
+
+2. Add `github.com/99designs/gqlgen` to your [project's tools.go](https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module)
+
+ printf '// +build tools\npackage tools\nimport _ "github.com/99designs/gqlgen"' | gofmt > tools.go
+ go mod tidy
+
+3. Initialise gqlgen config and generate models
+
+ go run github.com/99designs/gqlgen init
+
+4. Start the graphql server
+
+ go run server.go
-You could find a more comprehensive guide to help you get started [here](https://gqlgen.com/getting-started/).
-We also have a couple of real-world [examples](https://github.com/99designs/gqlgen/tree/master/example) that show how to GraphQL applications with **gqlgen** seamlessly,
-You can see these [examples](https://github.com/99designs/gqlgen/tree/master/example) here or visit [godoc](https://godoc.org/github.com/99designs/gqlgen).
+More help to get started:
+ - [Getting started tutorial](https://gqlgen.com/getting-started/) - a comprehensive guide to help you get started
+ - [Real-world examples](https://github.com/99designs/gqlgen/tree/master/example) show how to create GraphQL applications
+ - [Reference docs](https://pkg.go.dev/github.com/99designs/gqlgen) for the APIs
## Reporting Issues
diff --git a/TESTING.md b/TESTING.md
index ad7e63352ac..72ba06056c6 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -5,7 +5,7 @@ Testing generated code is a little tricky, heres how its currently set up.
### Testing responses from a server
-There is a server in `codegen/testserver` that is generated as part
+There is a server in `codegen/testserver` that is generated as part
of `go generate ./...`, and tests written against it.
There are also a bunch of tests in against the examples, feel free to take examples from there.
@@ -15,7 +15,7 @@ There are also a bunch of tests in against the examples, feel free to take examp
These tests are **really** slow, because they need to run the whole codegen step. Use them very sparingly. If you can, find a way to unit test it instead.
-Take a look at `codegen/input_test.go` for an example.
+Take a look at `codegen/testserver/input_test.go` for an example.
### Testing introspection
diff --git a/api/generate.go b/api/generate.go
index 3a19c017de9..6a85cd941ac 100644
--- a/api/generate.go
+++ b/api/generate.go
@@ -1,6 +1,7 @@
package api
import (
+ "fmt"
"syscall"
"github.com/99designs/gqlgen/codegen"
@@ -9,7 +10,6 @@ import (
"github.com/99designs/gqlgen/plugin/federation"
"github.com/99designs/gqlgen/plugin/modelgen"
"github.com/99designs/gqlgen/plugin/resolvergen"
- "github.com/pkg/errors"
)
func Generate(cfg *config.Config, option ...Option) error {
@@ -40,7 +40,7 @@ func Generate(cfg *config.Config, option ...Option) error {
}
if err := cfg.LoadSchema(); err != nil {
- return errors.Wrap(err, "failed to load schema")
+ return fmt.Errorf("failed to load schema: %w", err)
}
for _, p := range plugins {
@@ -53,47 +53,53 @@ func Generate(cfg *config.Config, option ...Option) error {
// LoadSchema again now we have everything
if err := cfg.LoadSchema(); err != nil {
- return errors.Wrap(err, "failed to load schema")
+ return fmt.Errorf("failed to load schema: %w", err)
}
if err := cfg.Init(); err != nil {
- return errors.Wrap(err, "generating core failed")
+ return fmt.Errorf("generating core failed: %w", err)
}
for _, p := range plugins {
if mut, ok := p.(plugin.ConfigMutator); ok {
err := mut.MutateConfig(cfg)
if err != nil {
- return errors.Wrap(err, p.Name())
+ return fmt.Errorf("%s: %w", p.Name(), err)
}
}
}
// Merge again now that the generated models have been injected into the typemap
data, err := codegen.BuildData(cfg)
if err != nil {
- return errors.Wrap(err, "merging type systems failed")
+ return fmt.Errorf("merging type systems failed: %w", err)
}
if err = codegen.GenerateCode(data); err != nil {
- return errors.Wrap(err, "generating core failed")
+ return fmt.Errorf("generating core failed: %w", err)
+ }
+
+ if !cfg.SkipModTidy {
+ if err = cfg.Packages.ModTidy(); err != nil {
+ return fmt.Errorf("tidy failed: %w", err)
+ }
}
for _, p := range plugins {
if mut, ok := p.(plugin.CodeGenerator); ok {
err := mut.GenerateCode(data)
if err != nil {
- return errors.Wrap(err, p.Name())
+ return fmt.Errorf("%s: %w", p.Name(), err)
}
}
}
if err = codegen.GenerateCode(data); err != nil {
- return errors.Wrap(err, "generating core failed")
+ return fmt.Errorf("generating core failed: %w", err)
}
if !cfg.SkipValidation {
if err := validate(cfg); err != nil {
- return errors.Wrap(err, "validation failed")
+ return fmt.Errorf("validation failed: %w", err)
}
}
diff --git a/api/option.go b/api/option.go
index f7ba6774bd0..ab41dfa2051 100644
--- a/api/option.go
+++ b/api/option.go
@@ -18,3 +18,23 @@ func AddPlugin(p plugin.Plugin) Option {
*plugins = append(*plugins, p)
}
}
+
+// ReplacePlugin replaces any existing plugin with a matching plugin name
+func ReplacePlugin(p plugin.Plugin) Option {
+ return func(cfg *config.Config, plugins *[]plugin.Plugin) {
+ if plugins != nil {
+ found := false
+ ps := *plugins
+ for i, o := range ps {
+ if p.Name() == o.Name() {
+ ps[i] = p
+ found = true
+ }
+ }
+ if !found {
+ ps = append(ps, p)
+ }
+ *plugins = ps
+ }
+ }
+}
diff --git a/api/option_test.go b/api/option_test.go
new file mode 100644
index 00000000000..749e29dd408
--- /dev/null
+++ b/api/option_test.go
@@ -0,0 +1,58 @@
+package api
+
+import (
+ "testing"
+
+ "github.com/99designs/gqlgen/codegen/config"
+ "github.com/99designs/gqlgen/plugin"
+ "github.com/99designs/gqlgen/plugin/federation"
+ "github.com/99designs/gqlgen/plugin/modelgen"
+ "github.com/99designs/gqlgen/plugin/resolvergen"
+ "github.com/stretchr/testify/require"
+)
+
+type testPlugin struct {
+}
+
+// Name returns the plugin name
+func (t *testPlugin) Name() string {
+ return "modelgen"
+}
+
+// MutateConfig mutates the configuration
+func (t *testPlugin) MutateConfig(_ *config.Config) error {
+ return nil
+}
+
+func TestReplacePlugin(t *testing.T) {
+
+ t.Run("replace plugin if exists", func(t *testing.T) {
+ pg := []plugin.Plugin{
+ federation.New(),
+ modelgen.New(),
+ resolvergen.New(),
+ }
+
+ expectedPlugin := &testPlugin{}
+ ReplacePlugin(expectedPlugin)(config.DefaultConfig(), &pg)
+
+ require.EqualValues(t, federation.New(), pg[0])
+ require.EqualValues(t, expectedPlugin, pg[1])
+ require.EqualValues(t, resolvergen.New(), pg[2])
+ })
+
+ t.Run("add plugin if doesn't exist", func(t *testing.T) {
+ pg := []plugin.Plugin{
+ federation.New(),
+ resolvergen.New(),
+ }
+
+ expectedPlugin := &testPlugin{}
+ ReplacePlugin(expectedPlugin)(config.DefaultConfig(), &pg)
+
+ require.EqualValues(t, federation.New(), pg[0])
+ require.EqualValues(t, resolvergen.New(), pg[1])
+ require.EqualValues(t, expectedPlugin, pg[2])
+ })
+
+}
diff --git a/client/client.go b/client/client.go
index 64367931e9f..e29c5fe5b3d 100644
--- a/client/client.go
+++ b/client/client.go
@@ -9,6 +9,7 @@ import (
"io/ioutil"
"net/http"
"net/http/httptest"
+ "regexp"
"github.com/mitchellh/mapstructure"
)
@@ -30,6 +31,7 @@ type (
Query string `json:"query"`
Variables map[string]interface{} `json:"variables,omitempty"`
OperationName string `json:"operationName,omitempty"`
+ Extensions map[string]interface{} `json:"extensions,omitempty"`
HTTP *http.Request `json:"-"`
}
@@ -82,7 +84,7 @@ func (p *Client) Post(query string, response interface{}, options ...Option) err
func (p *Client) RawPost(query string, options ...Option) (*Response, error) {
r, err := p.newRequest(query, options...)
if err != nil {
- return nil, fmt.Errorf("build: %s", err.Error())
+ return nil, fmt.Errorf("build: %w", err)
}
w := httptest.NewRecorder()
@@ -97,7 +99,7 @@ func (p *Client) RawPost(query string, options ...Option) (*Response, error) {
respDataRaw := &Response{}
err = json.Unmarshal(w.Body.Bytes(), &respDataRaw)
if err != nil {
- return nil, fmt.Errorf("decode: %s", err.Error())
+ return nil, fmt.Errorf("decode: %w", err)
}
return respDataRaw, nil
@@ -119,15 +121,18 @@ func (p *Client) newRequest(query string, options ...Option) (*http.Request, err
option(bd)
}
- switch bd.HTTP.Header.Get("Content-Type") {
- case "application/json":
+ contentType := bd.HTTP.Header.Get("Content-Type")
+ switch {
+ case regexp.MustCompile(`multipart/form-data; ?boundary=.*`).MatchString(contentType):
+ break
+ case "application/json" == contentType:
requestBody, err := json.Marshal(bd)
if err != nil {
- return nil, fmt.Errorf("encode: %s", err.Error())
+ return nil, fmt.Errorf("encode: %w", err)
}
bd.HTTP.Body = ioutil.NopCloser(bytes.NewBuffer(requestBody))
default:
- panic("unsupported encoding" + bd.HTTP.Header.Get("Content-Type"))
+ panic("unsupported encoding " + bd.HTTP.Header.Get("Content-Type"))
}
return bd.HTTP, nil
@@ -141,7 +146,7 @@ func unpack(data interface{}, into interface{}) error {
ZeroFields: true,
})
if err != nil {
- return fmt.Errorf("mapstructure: %s", err.Error())
+ return fmt.Errorf("mapstructure: %w", err)
}
return d.Decode(data)
diff --git a/client/client_test.go b/client/client_test.go
index 64a75a30c6a..176c48d12ae 100644
--- a/client/client_test.go
+++ b/client/client_test.go
@@ -1,9 +1,12 @@
package client_test
import (
+ "bytes"
"encoding/json"
"io/ioutil"
+ "mime/multipart"
"net/http"
+ "net/textproto"
"testing"
"github.com/99designs/gqlgen/client"
@@ -39,6 +42,44 @@ func TestClient(t *testing.T) {
require.Equal(t, "bob", resp.Name)
}
+func TestClientMultipartFormData(t *testing.T) {
+ h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ bodyBytes, err := ioutil.ReadAll(r.Body)
+ require.NoError(t, err)
+ require.Contains(t, string(bodyBytes), `Content-Disposition: form-data; name="operations"`)
+ require.Contains(t, string(bodyBytes), `{"query":"mutation ($input: Input!) {}","variables":{"file":{}}`)
+ require.Contains(t, string(bodyBytes), `Content-Disposition: form-data; name="map"`)
+ require.Contains(t, string(bodyBytes), `{"0":["variables.file"]}`)
+ require.Contains(t, string(bodyBytes), `Content-Disposition: form-data; name="0"; filename="example.txt"`)
+ require.Contains(t, string(bodyBytes), `Content-Type: text/plain`)
+ require.Contains(t, string(bodyBytes), `Hello World`)
+
+ w.Write([]byte(`{}`))
+ })
+
+ c := client.New(h)
+
+ var resp struct{}
+ c.MustPost("{ id }", &resp,
+ func(bd *client.Request) {
+ bodyBuf := &bytes.Buffer{}
+ bodyWriter := multipart.NewWriter(bodyBuf)
+ bodyWriter.WriteField("operations", `{"query":"mutation ($input: Input!) {}","variables":{"file":{}}`)
+ bodyWriter.WriteField("map", `{"0":["variables.file"]}`)
+
+ h := make(textproto.MIMEHeader)
+ h.Set("Content-Disposition", `form-data; name="0"; filename="example.txt"`)
+ h.Set("Content-Type", "text/plain")
+ ff, _ := bodyWriter.CreatePart(h)
+ ff.Write([]byte("Hello World"))
+ bodyWriter.Close()
+
+ bd.HTTP.Body = ioutil.NopCloser(bodyBuf)
+ bd.HTTP.Header.Set("Content-Type", bodyWriter.FormDataContentType())
+ },
+ )
+}
+
func TestAddHeader(t *testing.T) {
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, "ASDF", r.Header.Get("Test-Key"))
@@ -101,3 +142,30 @@ func TestAddCookie(t *testing.T) {
client.AddCookie(&http.Cookie{Name: "foo", Value: "value"}),
)
}
+
+func TestAddExtensions(t *testing.T) {
+ h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ b, err := ioutil.ReadAll(r.Body)
+ if err != nil {
+ panic(err)
+ }
+ require.Equal(t, `{"query":"user(id:1){name}","extensions":{"persistedQuery":{"sha256Hash":"ceec2897e2da519612279e63f24658c3e91194cbb2974744fa9007a7e1e9f9e7","version":1}}}`, string(b))
+ err = json.NewEncoder(w).Encode(map[string]interface{}{
+ "data": map[string]interface{}{
+ "Name": "Bob",
+ },
+ })
+ if err != nil {
+ panic(err)
+ }
+ })
+
+ c := client.New(h)
+
+ var resp struct {
+ Name string
+ }
+ c.MustPost("user(id:1){name}", &resp,
+ client.Extensions(map[string]interface{}{"persistedQuery": map[string]interface{}{"version": 1, "sha256Hash": "ceec2897e2da519612279e63f24658c3e91194cbb2974744fa9007a7e1e9f9e7"}}),
+ )
+}
diff --git a/client/options.go b/client/options.go
index e600f382852..bf4280ac711 100644
--- a/client/options.go
+++ b/client/options.go
@@ -20,6 +20,13 @@ func Operation(name string) Option {
}
}
+// Extensions sets the extensions to be sent with the outgoing request
+func Extensions(extensions map[string]interface{}) Option {
+ return func(bd *Request) {
+ bd.Extensions = extensions
+ }
+}
+
// Path sets the url that this request will be made against, useful if you are mounting your entire router
// and need to specify the url to the graphql endpoint.
func Path(url string) Option {
diff --git a/client/websocket.go b/client/websocket.go
index 35c74dddcd3..996ec7848c8 100644
--- a/client/websocket.go
+++ b/client/websocket.go
@@ -53,37 +53,37 @@ func (p *Client) WebsocketOnce(query string, resp interface{}, options ...Option
func (p *Client) WebsocketWithPayload(query string, initPayload map[string]interface{}, options ...Option) *Subscription {
r, err := p.newRequest(query, options...)
if err != nil {
- return errorSubscription(fmt.Errorf("request: %s", err.Error()))
+ return errorSubscription(fmt.Errorf("request: %w", err))
}
requestBody, err := ioutil.ReadAll(r.Body)
if err != nil {
- return errorSubscription(fmt.Errorf("parse body: %s", err.Error()))
+ return errorSubscription(fmt.Errorf("parse body: %w", err))
}
srv := httptest.NewServer(p.h)
- host := strings.Replace(srv.URL, "http://", "ws://", -1)
+ host := strings.ReplaceAll(srv.URL, "http://", "ws://")
c, _, err := websocket.DefaultDialer.Dial(host+r.URL.Path, r.Header)
if err != nil {
- return errorSubscription(fmt.Errorf("dial: %s", err.Error()))
+ return errorSubscription(fmt.Errorf("dial: %w", err))
}
initMessage := operationMessage{Type: connectionInitMsg}
if initPayload != nil {
initMessage.Payload, err = json.Marshal(initPayload)
if err != nil {
- return errorSubscription(fmt.Errorf("parse payload: %s", err.Error()))
+ return errorSubscription(fmt.Errorf("parse payload: %w", err))
}
}
if err = c.WriteJSON(initMessage); err != nil {
- return errorSubscription(fmt.Errorf("init: %s", err.Error()))
+ return errorSubscription(fmt.Errorf("init: %w", err))
}
var ack operationMessage
if err = c.ReadJSON(&ack); err != nil {
- return errorSubscription(fmt.Errorf("ack: %s", err.Error()))
+ return errorSubscription(fmt.Errorf("ack: %w", err))
}
if ack.Type != connectionAckMsg {
@@ -92,7 +92,7 @@ func (p *Client) WebsocketWithPayload(query string, initPayload map[string]inter
var ka operationMessage
if err = c.ReadJSON(&ka); err != nil {
- return errorSubscription(fmt.Errorf("ack: %s", err.Error()))
+ return errorSubscription(fmt.Errorf("ack: %w", err))
}
if ka.Type != connectionKaMsg {
@@ -100,7 +100,7 @@ func (p *Client) WebsocketWithPayload(query string, initPayload map[string]inter
}
if err = c.WriteJSON(operationMessage{Type: startMsg, ID: "1", Payload: requestBody}); err != nil {
- return errorSubscription(fmt.Errorf("start: %s", err.Error()))
+ return errorSubscription(fmt.Errorf("start: %w", err))
}
return &Subscription{
@@ -125,7 +125,7 @@ func (p *Client) WebsocketWithPayload(query string, initPayload map[string]inter
var respDataRaw Response
err = json.Unmarshal(op.Payload, &respDataRaw)
if err != nil {
- return fmt.Errorf("decode: %s", err.Error())
+ return fmt.Errorf("decode: %w", err)
}
// we want to unpack even if there is an error, so we can see partial responses
diff --git a/client/withfilesoption.go b/client/withfilesoption.go
new file mode 100644
index 00000000000..eff0d1c25f3
--- /dev/null
+++ b/client/withfilesoption.go
@@ -0,0 +1,133 @@
+package client
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io/ioutil"
+ "mime/multipart"
+ "net/http"
+ "net/textproto"
+ "os"
+ "strings"
+)
+
+type fileFormDataMap struct {
+ mapKey string
+ file *os.File
+}
+
+func findFiles(parentMapKey string, variables map[string]interface{}) []*fileFormDataMap {
+ files := []*fileFormDataMap{}
+ for key, value := range variables {
+ if v, ok := value.(map[string]interface{}); ok {
+ files = append(files, findFiles(parentMapKey+"."+key, v)...)
+ } else if v, ok := value.([]map[string]interface{}); ok {
+ for i, arr := range v {
+ files = append(files, findFiles(fmt.Sprintf(`%s.%s.%d`, parentMapKey, key, i), arr)...)
+ }
+ } else if v, ok := value.([]*os.File); ok {
+ for i, file := range v {
+ files = append(files, &fileFormDataMap{
+ mapKey: fmt.Sprintf(`%s.%s.%d`, parentMapKey, key, i),
+ file: file,
+ })
+ }
+ } else if v, ok := value.(*os.File); ok {
+ files = append(files, &fileFormDataMap{
+ mapKey: parentMapKey + "." + key,
+ file: v,
+ })
+ }
+ }
+
+ return files
+}
+
+// WithFiles encodes the outgoing request body as multipart form data for file variables
+func WithFiles() Option {
+ return func(bd *Request) {
+ bodyBuf := &bytes.Buffer{}
+ bodyWriter := multipart.NewWriter(bodyBuf)
+
+ //-b7955bd2e1d17b67ac157b9e9ddb6238888caefc6f3541920a1debad284d
+ // Content-Disposition: form-data; name="operations"
+ //
+ // {"query":"mutation ($input: Input!) {}","variables":{"input":{"file":{}}}
+ requestBody, _ := json.Marshal(bd)
+ bodyWriter.WriteField("operations", string(requestBody))
+
+ // --b7955bd2e1d17b67ac157b9e9ddb6238888caefc6f3541920a1debad284d
+ // Content-Disposition: form-data; name="map"
+ //
+ // `{ "0":["variables.input.file"] }`
+ // or
+ // `{ "0":["variables.input.files.0"], "1":["variables.input.files.1"] }`
+ // or
+ // `{ "0": ["variables.input.0.file"], "1": ["variables.input.1.file"] }`
+ // or
+ // `{ "0": ["variables.req.0.file", "variables.req.1.file"] }`
+ mapData := ""
+ filesData := findFiles("variables", bd.Variables)
+ filesGroup := [][]*fileFormDataMap{}
+ for _, fd := range filesData {
+ foundDuplicate := false
+ for j, fg := range filesGroup {
+ f1, _ := fd.file.Stat()
+ f2, _ := fg[0].file.Stat()
+ if os.SameFile(f1, f2) {
+ foundDuplicate = true
+ filesGroup[j] = append(filesGroup[j], fd)
+ }
+ }
+
+ if !foundDuplicate {
+ filesGroup = append(filesGroup, []*fileFormDataMap{fd})
+ }
+ }
+ if len(filesGroup) > 0 {
+ mapDataFiles := []string{}
+
+ for i, fileData := range filesGroup {
+ mapDataFiles = append(
+ mapDataFiles,
+ fmt.Sprintf(`"%d":[%s]`, i, strings.Join(collect(fileData, wrapMapKeyInQuotes), ",")),
+ )
+ }
+
+ mapData = `{` + strings.Join(mapDataFiles, ",") + `}`
+ }
+ bodyWriter.WriteField("map", mapData)
+
+ // --b7955bd2e1d17b67ac157b9e9ddb6238888caefc6f3541920a1debad284d
+ // Content-Disposition: form-data; name="0"; filename="tempFile"
+ // Content-Type: text/plain; charset=utf-8
+ // or
+ // Content-Type: application/octet-stream
+ //
+ for i, fileData := range filesGroup {
+ h := make(textproto.MIMEHeader)
+ h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="%d"; filename="%s"`, i, fileData[0].file.Name()))
+ b, _ := ioutil.ReadFile(fileData[0].file.Name())
+ h.Set("Content-Type", http.DetectContentType(b))
+ ff, _ := bodyWriter.CreatePart(h)
+ ff.Write(b)
+ }
+ bodyWriter.Close()
+
+ bd.HTTP.Body = ioutil.NopCloser(bodyBuf)
+ bd.HTTP.Header.Set("Content-Type", bodyWriter.FormDataContentType())
+ }
+}
+
+func collect(strArr []*fileFormDataMap, f func(s *fileFormDataMap) string) []string {
+ result := make([]string, len(strArr))
+ for i, str := range strArr {
+ result[i] = f(str)
+ }
+ return result
+}
+
+func wrapMapKeyInQuotes(s *fileFormDataMap) string {
+ return fmt.Sprintf("\"%s\"", s.mapKey)
+}
diff --git a/client/withfilesoption_test.go b/client/withfilesoption_test.go
new file mode 100644
index 00000000000..48b9e09d0c4
--- /dev/null
+++ b/client/withfilesoption_test.go
@@ -0,0 +1,237 @@
+package client_test
+
+import (
+ "io"
+ "io/ioutil"
+ "mime"
+ "mime/multipart"
+ "net/http"
+ "os"
+ "regexp"
+ "strings"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/stretchr/testify/require"
+)
+
+func TestWithFiles(t *testing.T) {
+ tempFile1, _ := ioutil.TempFile(os.TempDir(), "tempFile1")
+ tempFile2, _ := ioutil.TempFile(os.TempDir(), "tempFile2")
+ tempFile3, _ := ioutil.TempFile(os.TempDir(), "tempFile3")
+ defer os.Remove(tempFile1.Name())
+ defer os.Remove(tempFile2.Name())
+ defer os.Remove(tempFile3.Name())
+ tempFile1.WriteString(`The quick brown fox jumps over the lazy dog`)
+ tempFile2.WriteString(`hello world`)
+ tempFile3.WriteString(`La-Li-Lu-Le-Lo`)
+
+ t.Run("with one file", func(t *testing.T) {
+ h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ mediaType, params, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
+ require.NoError(t, err)
+ require.True(t, strings.HasPrefix(mediaType, "multipart/"))
+
+ mr := multipart.NewReader(r.Body, params["boundary"])
+ for {
+ p, err := mr.NextPart()
+ if err == io.EOF {
+ break
+ }
+ require.NoError(t, err)
+
+ slurp, err := ioutil.ReadAll(p)
+ require.NoError(t, err)
+
+ contentDisposition := p.Header.Get("Content-Disposition")
+
+ if contentDisposition == `form-data; name="operations"` {
+ require.EqualValues(t, `{"query":"{ id }","variables":{"file":{}}}`, slurp)
+ }
+ if contentDisposition == `form-data; name="map"` {
+ require.EqualValues(t, `{"0":["variables.file"]}`, slurp)
+ }
+ if regexp.MustCompile(`form-data; name="0"; filename=.*`).MatchString(contentDisposition) {
+ require.Equal(t, `text/plain; charset=utf-8`, p.Header.Get("Content-Type"))
+ require.EqualValues(t, `The quick brown fox jumps over the lazy dog`, slurp)
+ }
+ }
+ w.Write([]byte(`{}`))
+ })
+
+ c := client.New(h)
+
+ var resp struct{}
+ c.MustPost("{ id }", &resp,
+ client.Var("file", tempFile1),
+ client.WithFiles(),
+ )
+ })
+
+ t.Run("with multiple files", func(t *testing.T) {
+ h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ mediaType, params, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
+ require.NoError(t, err)
+ require.True(t, strings.HasPrefix(mediaType, "multipart/"))
+
+ mr := multipart.NewReader(r.Body, params["boundary"])
+ for {
+ p, err := mr.NextPart()
+ if err == io.EOF {
+ break
+ }
+ require.NoError(t, err)
+
+ slurp, err := ioutil.ReadAll(p)
+ require.NoError(t, err)
+
+ contentDisposition := p.Header.Get("Content-Disposition")
+
+ if contentDisposition == `form-data; name="operations"` {
+ require.EqualValues(t, `{"query":"{ id }","variables":{"input":{"files":[{},{}]}}}`, slurp)
+ }
+ if contentDisposition == `form-data; name="map"` {
+ // returns `{"0":["variables.input.files.0"],"1":["variables.input.files.1"]}`
+ // but the order of file inputs is unpredictable between different OS systems
+ require.Contains(t, string(slurp), `{"0":`)
+ require.Contains(t, string(slurp), `["variables.input.files.0"]`)
+ require.Contains(t, string(slurp), `,"1":`)
+ require.Contains(t, string(slurp), `["variables.input.files.1"]`)
+ require.Contains(t, string(slurp), `}`)
+ }
+ if regexp.MustCompile(`form-data; name="[0,1]"; filename=.*`).MatchString(contentDisposition) {
+ require.Equal(t, `text/plain; charset=utf-8`, p.Header.Get("Content-Type"))
+ require.Contains(t, []string{
+ `The quick brown fox jumps over the lazy dog`,
+ `hello world`,
+ }, string(slurp))
+ }
+ }
+ w.Write([]byte(`{}`))
+ })
+
+ c := client.New(h)
+
+ var resp struct{}
+ c.MustPost("{ id }", &resp,
+ client.Var("input", map[string]interface{}{
+ "files": []*os.File{tempFile1, tempFile2},
+ }),
+ client.WithFiles(),
+ )
+ })
+
+ t.Run("with multiple files across multiple variables", func(t *testing.T) {
+ h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ mediaType, params, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
+ require.NoError(t, err)
+ require.True(t, strings.HasPrefix(mediaType, "multipart/"))
+
+ mr := multipart.NewReader(r.Body, params["boundary"])
+ for {
+ p, err := mr.NextPart()
+ if err == io.EOF {
+ break
+ }
+ require.NoError(t, err)
+
+ slurp, err := ioutil.ReadAll(p)
+ require.NoError(t, err)
+
+ contentDisposition := p.Header.Get("Content-Disposition")
+
+ if contentDisposition == `form-data; name="operations"` {
+ require.EqualValues(t, `{"query":"{ id }","variables":{"req":{"files":[{},{}],"foo":{"bar":{}}}}}`, slurp)
+ }
+ if contentDisposition == `form-data; name="map"` {
+ // returns `{"0":["variables.req.files.0"],"1":["variables.req.files.1"],"2":["variables.req.foo.bar"]}`
+ // but the order of file inputs is unpredictable between different OS systems
+ require.Contains(t, string(slurp), `{"0":`)
+ require.Contains(t, string(slurp), `["variables.req.files.0"]`)
+ require.Contains(t, string(slurp), `,"1":`)
+ require.Contains(t, string(slurp), `["variables.req.files.1"]`)
+ require.Contains(t, string(slurp), `,"2":`)
+ require.Contains(t, string(slurp), `["variables.req.foo.bar"]`)
+ require.Contains(t, string(slurp), `}`)
+ }
+ if regexp.MustCompile(`form-data; name="[0,1,2]"; filename=.*`).MatchString(contentDisposition) {
+ require.Equal(t, `text/plain; charset=utf-8`, p.Header.Get("Content-Type"))
+ require.Contains(t, []string{
+ `The quick brown fox jumps over the lazy dog`,
+ `La-Li-Lu-Le-Lo`,
+ `hello world`,
+ }, string(slurp))
+ }
+ }
+ w.Write([]byte(`{}`))
+ })
+
+ c := client.New(h)
+
+ var resp struct{}
+ c.MustPost("{ id }", &resp,
+ client.Var("req", map[string]interface{}{
+ "files": []*os.File{tempFile1, tempFile2},
+ "foo": map[string]interface{}{
+ "bar": tempFile3,
+ },
+ }),
+ client.WithFiles(),
+ )
+ })
+
+ t.Run("with multiple files and file reuse", func(t *testing.T) {
+ h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ mediaType, params, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
+ require.NoError(t, err)
+ require.True(t, strings.HasPrefix(mediaType, "multipart/"))
+
+ mr := multipart.NewReader(r.Body, params["boundary"])
+ for {
+ p, err := mr.NextPart()
+ if err == io.EOF {
+ break
+ }
+ require.NoError(t, err)
+
+ slurp, err := ioutil.ReadAll(p)
+ require.NoError(t, err)
+
+ contentDisposition := p.Header.Get("Content-Disposition")
+
+ if contentDisposition == `form-data; name="operations"` {
+ require.EqualValues(t, `{"query":"{ id }","variables":{"files":[{},{},{}]}}`, slurp)
+ }
+ if contentDisposition == `form-data; name="map"` {
+ require.EqualValues(t, `{"0":["variables.files.0","variables.files.2"],"1":["variables.files.1"]}`, slurp)
+ // returns `{"0":["variables.files.0","variables.files.2"],"1":["variables.files.1"]}`
+ // but the order of file inputs is unpredictable between different OS systems
+ require.Contains(t, string(slurp), `{"0":`)
+ require.Contains(t, string(slurp), `["variables.files.0"`)
+ require.Contains(t, string(slurp), `,"1":`)
+ require.Contains(t, string(slurp), `"variables.files.1"]`)
+ require.Contains(t, string(slurp), `"variables.files.2"]`)
+ require.NotContains(t, string(slurp), `,"2":`)
+ require.Contains(t, string(slurp), `}`)
+ }
+ if regexp.MustCompile(`form-data; name="[0,1]"; filename=.*`).MatchString(contentDisposition) {
+ require.Equal(t, `text/plain; charset=utf-8`, p.Header.Get("Content-Type"))
+ require.Contains(t, []string{
+ `The quick brown fox jumps over the lazy dog`,
+ `hello world`,
+ }, string(slurp))
+ }
+ require.False(t, regexp.MustCompile(`form-data; name="2"; filename=.*`).MatchString(contentDisposition))
+ }
+ w.Write([]byte(`{}`))
+ })
+
+ c := client.New(h)
+
+ var resp struct{}
+ c.MustPost("{ id }", &resp,
+ client.Var("files", []*os.File{tempFile1, tempFile2, tempFile1}),
+ client.WithFiles(),
+ )
+ })
+}
diff --git a/cmd/gen.go b/cmd/gen.go
index b875bb43d02..f973cc22c0f 100644
--- a/cmd/gen.go
+++ b/cmd/gen.go
@@ -1,11 +1,11 @@
package cmd
import (
- "os"
+ "errors"
+ "io/fs"
"github.com/99designs/gqlgen/api"
"github.com/99designs/gqlgen/codegen/config"
- "github.com/pkg/errors"
"github.com/urfave/cli/v2"
)
@@ -26,7 +26,7 @@ var genCmd = &cli.Command{
}
} else {
cfg, err = config.LoadConfigFromDefaultLocations()
- if os.IsNotExist(errors.Cause(err)) {
+ if errors.Is(err, fs.ErrNotExist) {
cfg, err = config.LoadDefaultConfig()
}
diff --git a/cmd/init.go b/cmd/init.go
index ad95a5cec50..1a528be4d85 100644
--- a/cmd/init.go
+++ b/cmd/init.go
@@ -2,8 +2,10 @@ package cmd
import (
"bytes"
+ "errors"
"fmt"
"html/template"
+ "io/fs"
"io/ioutil"
"os"
"path/filepath"
@@ -109,90 +111,88 @@ var initCmd = &cli.Command{
Usage: "create a new gqlgen project",
Flags: []cli.Flag{
&cli.BoolFlag{Name: "verbose, v", Usage: "show logs"},
- &cli.StringFlag{Name: "config, c", Usage: "the config filename"},
+ &cli.StringFlag{Name: "config, c", Usage: "the config filename", Value: "gqlgen.yml"},
&cli.StringFlag{Name: "server", Usage: "where to write the server stub to", Value: "server.go"},
&cli.StringFlag{Name: "schema", Usage: "where to write the schema stub to", Value: "graph/schema.graphqls"},
},
Action: func(ctx *cli.Context) error {
configFilename := ctx.String("config")
serverFilename := ctx.String("server")
+ schemaFilename := ctx.String("schema")
pkgName := code.ImportPathForDir(".")
if pkgName == "" {
return fmt.Errorf("unable to determine import path for current directory, you probably need to run go mod init first")
}
- if err := initSchema(ctx.String("schema")); err != nil {
- return err
- }
- if !configExists(configFilename) {
- if err := initConfig(configFilename, pkgName); err != nil {
- return err
+ // check schema and config don't already exist
+ for _, filename := range []string{configFilename, schemaFilename, serverFilename} {
+ if fileExists(filename) {
+ return fmt.Errorf("%s already exists", filename)
}
}
+ _, err := config.LoadConfigFromDefaultLocations()
+ if err == nil {
+ return fmt.Errorf("gqlgen.yml already exists in a parent directory\n")
+ }
- GenerateGraphServer(serverFilename)
- return nil
- },
-}
+ // create config
+ fmt.Println("Creating", configFilename)
+ if err := initFile(configFilename, executeConfigTemplate(pkgName)); err != nil {
+ return err
+ }
-func GenerateGraphServer(serverFilename string) {
- cfg, err := config.LoadConfigFromDefaultLocations()
- if err != nil {
- fmt.Fprintln(os.Stderr, err.Error())
- }
+ // create schema
+ fmt.Println("Creating", schemaFilename)
+ if err := initFile(schemaFilename, schemaDefault); err != nil {
+ return err
+ }
- if err := api.Generate(cfg, api.AddPlugin(servergen.New(serverFilename))); err != nil {
- fmt.Fprintln(os.Stderr, err.Error())
- }
+ // create the package directory with a temporary file so that go recognises it as a package
+ // and autobinding doesn't error out
+ tmpPackageNameFile := "graph/model/_tmp_gqlgen_init.go"
+ if err := initFile(tmpPackageNameFile, "package model"); err != nil {
+ return err
+ }
+ defer os.Remove(tmpPackageNameFile)
- fmt.Fprintf(os.Stdout, "Exec \"go run ./%s\" to start GraphQL server\n", serverFilename)
-}
+ var cfg *config.Config
+ if cfg, err = config.LoadConfig(configFilename); err != nil {
+ panic(err)
+ }
-func configExists(configFilename string) bool {
- var cfg *config.Config
+ fmt.Println("Creating", serverFilename)
+ fmt.Println("Generating...")
+ if err := api.Generate(cfg, api.AddPlugin(servergen.New(serverFilename))); err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ }
- if configFilename != "" {
- cfg, _ = config.LoadConfig(configFilename)
- } else {
- cfg, _ = config.LoadConfigFromDefaultLocations()
- }
- return cfg != nil
+ fmt.Printf("\nExec \"go run ./%s\" to start GraphQL server\n", serverFilename)
+ return nil
+ },
}
-func initConfig(configFilename string, pkgName string) error {
- if configFilename == "" {
- configFilename = "gqlgen.yml"
- }
-
- if err := os.MkdirAll(filepath.Dir(configFilename), 0755); err != nil {
- return fmt.Errorf("unable to create config dir: " + err.Error())
- }
-
+func executeConfigTemplate(pkgName string) string {
var buf bytes.Buffer
if err := configTemplate.Execute(&buf, pkgName); err != nil {
panic(err)
}
- if err := ioutil.WriteFile(configFilename, buf.Bytes(), 0644); err != nil {
- return fmt.Errorf("unable to write cfg file: " + err.Error())
- }
+ return buf.String()
+}
- return nil
+func fileExists(filename string) bool {
+ _, err := os.Stat(filename)
+ return !errors.Is(err, fs.ErrNotExist)
}
-func initSchema(schemaFilename string) error {
- _, err := os.Stat(schemaFilename)
- if !os.IsNotExist(err) {
- return nil
+func initFile(filename, contents string) error {
+ if err := os.MkdirAll(filepath.Dir(filename), 0755); err != nil {
+ return fmt.Errorf("unable to create directory for file '%s': %w\n", filename, err)
}
-
- if err := os.MkdirAll(filepath.Dir(schemaFilename), 0755); err != nil {
- return fmt.Errorf("unable to create schema dir: " + err.Error())
+ if err := ioutil.WriteFile(filename, []byte(contents), 0644); err != nil {
+ return fmt.Errorf("unable to write file '%s': %w\n", filename, err)
}
- if err = ioutil.WriteFile(schemaFilename, []byte(schemaDefault), 0644); err != nil {
- return fmt.Errorf("unable to write schema file: " + err.Error())
- }
return nil
}
diff --git a/cmd/root.go b/cmd/root.go
index 2776aa2842f..ce96c1b86d2 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -39,7 +39,7 @@ func Execute() {
}
if err := app.Run(os.Args); err != nil {
- fmt.Fprint(os.Stderr, err.Error())
+ fmt.Fprint(os.Stderr, err.Error()+"\n")
os.Exit(1)
}
}
diff --git a/codegen/args.go b/codegen/args.go
index 20a26e97542..9a9c8fdbee8 100644
--- a/codegen/args.go
+++ b/codegen/args.go
@@ -7,7 +7,6 @@ import (
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/codegen/templates"
- "github.com/pkg/errors"
"github.com/vektah/gqlparser/v2/ast"
)
@@ -26,7 +25,7 @@ type FieldArgument struct {
Value interface{} // value set in Data
}
-//ImplDirectives get not Builtin and location ARGUMENT_DEFINITION directive
+// ImplDirectives get not Builtin and location ARGUMENT_DEFINITION directive
func (f *FieldArgument) ImplDirectives() []*Directive {
d := make([]*Directive, 0)
for i := range f.Directives {
@@ -67,7 +66,7 @@ func (b *builder) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgu
if arg.DefaultValue != nil {
newArg.Default, err = arg.DefaultValue.Value(nil)
if err != nil {
- return nil, errors.Errorf("default value is not valid: %s", err.Error())
+ return nil, fmt.Errorf("default value is not valid: %w", err)
}
}
@@ -111,7 +110,7 @@ func (a *Data) Args() map[string][]*FieldArgument {
}
}
- for _, d := range a.Directives {
+ for _, d := range a.Directives() {
if len(d.Args) > 0 {
ret[d.ArgsFunc()] = d.Args
}
diff --git a/codegen/config/binder.go b/codegen/config/binder.go
index 2be7b7bdd6b..0974e44cf91 100644
--- a/codegen/config/binder.go
+++ b/codegen/config/binder.go
@@ -1,13 +1,13 @@
package config
import (
+ "errors"
"fmt"
"go/token"
"go/types"
"github.com/99designs/gqlgen/codegen/templates"
"github.com/99designs/gqlgen/internal/code"
- "github.com/pkg/errors"
"github.com/vektah/gqlparser/v2/ast"
)
@@ -117,7 +117,11 @@ func (b *Binder) FindObject(pkgName string, typeName string) (types.Object, erro
pkg := b.pkgs.LoadWithTypes(pkgName)
if pkg == nil {
- return nil, errors.Errorf("required package was not loaded: %s", fullName)
+ err := b.pkgs.Errors()
+ if err != nil {
+ return nil, fmt.Errorf("package could not be loaded: %s: %w", fullName, err)
+ }
+ return nil, fmt.Errorf("required package was not loaded: %s", fullName)
}
// function based marshalers take precedence
@@ -144,22 +148,14 @@ func (b *Binder) FindObject(pkgName string, typeName string) (types.Object, erro
}
}
- return nil, errors.Errorf("unable to find type %s\n", fullName)
+ return nil, fmt.Errorf("unable to find type %s\n", fullName)
}
func (b *Binder) PointerTo(ref *TypeReference) *TypeReference {
- newRef := &TypeReference{
- GO: types.NewPointer(ref.GO),
- GQL: ref.GQL,
- CastType: ref.CastType,
- Definition: ref.Definition,
- Unmarshaler: ref.Unmarshaler,
- Marshaler: ref.Marshaler,
- IsMarshaler: ref.IsMarshaler,
- }
-
- b.References = append(b.References, newRef)
- return newRef
+ newRef := *ref
+ newRef.GO = types.NewPointer(ref.GO)
+ b.References = append(b.References, &newRef)
+ return &newRef
}
// TypeReference is used by args and field types. The Definition can refer to both input and output types.
@@ -172,33 +168,21 @@ type TypeReference struct {
Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function
Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function
IsMarshaler bool // Does the type implement graphql.Marshaler and graphql.Unmarshaler
+ IsContext bool // Is the Marshaler/Unmarshaller the context version; applies to either the method or interface variety.
}
func (ref *TypeReference) Elem() *TypeReference {
if p, isPtr := ref.GO.(*types.Pointer); isPtr {
- return &TypeReference{
- GO: p.Elem(),
- Target: ref.Target,
- GQL: ref.GQL,
- CastType: ref.CastType,
- Definition: ref.Definition,
- Unmarshaler: ref.Unmarshaler,
- Marshaler: ref.Marshaler,
- IsMarshaler: ref.IsMarshaler,
- }
+ newRef := *ref
+ newRef.GO = p.Elem()
+ return &newRef
}
if ref.IsSlice() {
- return &TypeReference{
- GO: ref.GO.(*types.Slice).Elem(),
- Target: ref.Target,
- GQL: ref.GQL.Elem,
- CastType: ref.CastType,
- Definition: ref.Definition,
- Unmarshaler: ref.Unmarshaler,
- Marshaler: ref.Marshaler,
- IsMarshaler: ref.IsMarshaler,
- }
+ newRef := *ref
+ newRef.GO = ref.GO.(*types.Slice).Elem()
+ newRef.GQL = ref.GQL.Elem
+ return &newRef
}
return nil
}
@@ -208,6 +192,16 @@ func (t *TypeReference) IsPtr() bool {
return isPtr
}
+// fix for https://github.com/golang/go/issues/31103 may make it possible to remove this (may still be useful)
+//
+func (t *TypeReference) IsPtrToPtr() bool {
+ if p, isPtr := t.GO.(*types.Pointer); isPtr {
+ _, isPtr := p.Elem().(*types.Pointer)
+ return isPtr
+ }
+ return false
+}
+
func (t *TypeReference) IsNilable() bool {
return IsNilable(t.GO)
}
@@ -217,6 +211,14 @@ func (t *TypeReference) IsSlice() bool {
return t.GQL.Elem != nil && isSlice
}
+func (t *TypeReference) IsPtrToSlice() bool {
+ if t.IsPtr() {
+ _, isPointerToSlice := t.GO.(*types.Pointer).Elem().(*types.Slice)
+ return isPointerToSlice
+ }
+ return false
+}
+
func (t *TypeReference) IsNamed() bool {
_, isSlice := t.GO.(*types.Named)
return isSlice
@@ -351,8 +353,13 @@ func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret
if fun, isFunc := obj.(*types.Func); isFunc {
ref.GO = fun.Type().(*types.Signature).Params().At(0).Type()
+ ref.IsContext = fun.Type().(*types.Signature).Results().At(0).Type().String() == "github.com/99designs/gqlgen/graphql.ContextMarshaler"
ref.Marshaler = fun
ref.Unmarshaler = types.NewFunc(0, fun.Pkg(), "Unmarshal"+typeName, nil)
+ } else if hasMethod(obj.Type(), "MarshalGQLContext") && hasMethod(obj.Type(), "UnmarshalGQLContext") {
+ ref.GO = obj.Type()
+ ref.IsContext = true
+ ref.IsMarshaler = true
} else if hasMethod(obj.Type(), "MarshalGQL") && hasMethod(obj.Type(), "UnmarshalGQL") {
ref.GO = obj.Type()
ref.IsMarshaler = true
diff --git a/codegen/config/binder_test.go b/codegen/config/binder_test.go
index 67e9ed011ba..55227563d82 100644
--- a/codegen/config/binder_test.go
+++ b/codegen/config/binder_test.go
@@ -28,7 +28,7 @@ func TestSlicePointerBinding(t *testing.T) {
panic(err)
}
- require.Equal(t, ta.GO.String(), "[]*github.com/99designs/gqlgen/example/chat.Message")
+ require.Equal(t, ta.GO.String(), "[]*github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.Message")
})
t.Run("with OmitSliceElementPointers", func(t *testing.T) {
@@ -41,14 +41,14 @@ func TestSlicePointerBinding(t *testing.T) {
panic(err)
}
- require.Equal(t, ta.GO.String(), "[]github.com/99designs/gqlgen/example/chat.Message")
+ require.Equal(t, ta.GO.String(), "[]github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.Message")
})
}
func createBinder(cfg Config) (*Binder, *ast.Schema) {
cfg.Models = TypeMap{
"Message": TypeMapEntry{
- Model: []string{"github.com/99designs/gqlgen/example/chat.Message"},
+ Model: []string{"github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.Message"},
},
}
cfg.Packages = &code.Packages{}
diff --git a/codegen/config/config.go b/codegen/config/config.go
index ba939fcf59a..b030ab6cbc5 100644
--- a/codegen/config/config.go
+++ b/codegen/config/config.go
@@ -10,7 +10,6 @@ import (
"strings"
"github.com/99designs/gqlgen/internal/code"
- "github.com/pkg/errors"
"github.com/vektah/gqlparser/v2"
"github.com/vektah/gqlparser/v2/ast"
"gopkg.in/yaml.v2"
@@ -18,7 +17,7 @@ import (
type Config struct {
SchemaFilename StringList `yaml:"schema,omitempty"`
- Exec PackageConfig `yaml:"exec"`
+ Exec ExecConfig `yaml:"exec"`
Model PackageConfig `yaml:"model,omitempty"`
Federation PackageConfig `yaml:"federation,omitempty"`
Resolver ResolverConfig `yaml:"resolver,omitempty"`
@@ -28,11 +27,12 @@ type Config struct {
Directives map[string]DirectiveConfig `yaml:"directives,omitempty"`
OmitSliceElementPointers bool `yaml:"omit_slice_element_pointers,omitempty"`
SkipValidation bool `yaml:"skip_validation,omitempty"`
+ SkipModTidy bool `yaml:"skip_mod_tidy,omitempty"`
Sources []*ast.Source `yaml:"-"`
Packages *code.Packages `yaml:"-"`
Schema *ast.Schema `yaml:"-"`
- // Deprecated use Federation instead. Will be removed next release
+ // Deprecated: use Federation instead. Will be removed next release
Federated bool `yaml:"federated,omitempty"`
}
@@ -43,7 +43,7 @@ func DefaultConfig() *Config {
return &Config{
SchemaFilename: StringList{"schema.graphql"},
Model: PackageConfig{Filename: "models_gen.go"},
- Exec: PackageConfig{Filename: "generated.go"},
+ Exec: ExecConfig{Filename: "generated.go"},
Directives: map[string]DirectiveConfig{},
Models: TypeMap{},
}
@@ -59,7 +59,7 @@ func LoadDefaultConfig() (*Config, error) {
var schemaRaw []byte
schemaRaw, err = ioutil.ReadFile(filename)
if err != nil {
- return nil, errors.Wrap(err, "unable to open schema")
+ return nil, fmt.Errorf("unable to open schema: %w", err)
}
config.Sources = append(config.Sources, &ast.Source{Name: filename, Input: string(schemaRaw)})
@@ -78,7 +78,7 @@ func LoadConfigFromDefaultLocations() (*Config, error) {
err = os.Chdir(filepath.Dir(cfgFile))
if err != nil {
- return nil, errors.Wrap(err, "unable to enter config dir")
+ return nil, fmt.Errorf("unable to enter config dir: %w", err)
}
return LoadConfig(cfgFile)
}
@@ -96,13 +96,23 @@ func LoadConfig(filename string) (*Config, error) {
b, err := ioutil.ReadFile(filename)
if err != nil {
- return nil, errors.Wrap(err, "unable to read config")
+ return nil, fmt.Errorf("unable to read config: %w", err)
}
if err := yaml.UnmarshalStrict(b, config); err != nil {
- return nil, errors.Wrap(err, "unable to parse config")
+ return nil, fmt.Errorf("unable to parse config: %w", err)
}
+ if err := CompleteConfig(config); err != nil {
+ return nil, err
+ }
+
+ return config, nil
+}
+
+// CompleteConfig fills in the schema and other values to a config loaded from
+// YAML.
+func CompleteConfig(config *Config) error {
defaultDirectives := map[string]DirectiveConfig{
"skip": {SkipRuntime: true},
"include": {SkipRuntime: true},
@@ -140,12 +150,13 @@ func LoadConfig(filename string) (*Config, error) {
return nil
}); err != nil {
- return nil, errors.Wrapf(err, "failed to walk schema at root %s", pathParts[0])
+ return fmt.Errorf("failed to walk schema at root %s: %w", pathParts[0], err)
}
} else {
+ var err error
matches, err = filepath.Glob(f)
if err != nil {
- return nil, errors.Wrapf(err, "failed to glob schema filename %s", f)
+ return fmt.Errorf("failed to glob schema filename %s: %w", f, err)
}
}
@@ -163,13 +174,12 @@ func LoadConfig(filename string) (*Config, error) {
var schemaRaw []byte
schemaRaw, err = ioutil.ReadFile(filename)
if err != nil {
- return nil, errors.Wrap(err, "unable to open schema")
+ return fmt.Errorf("unable to open schema: %w", err)
}
config.Sources = append(config.Sources, &ast.Source{Name: filename, Input: string(schemaRaw)})
}
-
- return config, nil
+ return nil
}
func (c *Config) Init() error {
@@ -194,15 +204,8 @@ func (c *Config) Init() error {
}
c.injectBuiltins()
-
// prefetch all packages in one big packages.Load call
- pkgs := []string{
- "github.com/99designs/gqlgen/graphql",
- "github.com/99designs/gqlgen/graphql/introspection",
- }
- pkgs = append(pkgs, c.Models.ReferencedPackages()...)
- pkgs = append(pkgs, c.AutoBind...)
- c.Packages.LoadAll(pkgs...)
+ c.Packages.LoadAll(c.packageList()...)
// check everything is valid on the way out
err = c.check()
@@ -213,6 +216,20 @@ func (c *Config) Init() error {
return nil
}
+func (c *Config) packageList() []string {
+ pkgs := []string{
+ "github.com/99designs/gqlgen/graphql",
+ "github.com/99designs/gqlgen/graphql/introspection",
+ }
+ pkgs = append(pkgs, c.Models.ReferencedPackages()...)
+ pkgs = append(pkgs, c.AutoBind...)
+ return pkgs
+}
+
+func (c *Config) ReloadAllPackages() {
+ c.Packages.ReloadAll(c.packageList()...)
+}
+
func (c *Config) injectTypesFromSchema() error {
c.Directives["goModel"] = DirectiveConfig{
SkipRuntime: true,
@@ -222,6 +239,10 @@ func (c *Config) injectTypesFromSchema() error {
SkipRuntime: true,
}
+ c.Directives["extraTag"] = DirectiveConfig{
+ SkipRuntime: true,
+ }
+
for _, schemaType := range c.Schema.Types {
if schemaType == c.Schema.Query || schemaType == c.Schema.Mutation || schemaType == c.Schema.Subscription {
continue
@@ -244,9 +265,15 @@ func (c *Config) injectTypesFromSchema() error {
if schemaType.Kind == ast.Object || schemaType.Kind == ast.InputObject {
for _, field := range schemaType.Fields {
+ typeMapField := TypeMapField{
+ ExtraTag: c.Models[schemaType.Name].Fields[field.Name].ExtraTag,
+ FieldName: c.Models[schemaType.Name].Fields[field.Name].FieldName,
+ Resolver: c.Models[schemaType.Name].Fields[field.Name].Resolver,
+ }
+ directive := false
if fd := field.Directives.ForName("goField"); fd != nil {
- forceResolver := c.Models[schemaType.Name].Fields[field.Name].Resolver
- fieldName := c.Models[schemaType.Name].Fields[field.Name].FieldName
+ forceResolver := typeMapField.Resolver
+ fieldName := typeMapField.FieldName
if ra := fd.Arguments.ForName("forceResolver"); ra != nil {
if fr, err := ra.Value.Value(nil); err == nil {
@@ -260,17 +287,28 @@ func (c *Config) injectTypesFromSchema() error {
}
}
+ typeMapField.FieldName = fieldName
+ typeMapField.Resolver = forceResolver
+ directive = true
+ }
+
+ if ex := field.Directives.ForName("extraTag"); ex != nil {
+ args := []string{}
+ for _, arg := range ex.Arguments {
+ args = append(args, arg.Name+`:"`+arg.Value.Raw+`"`)
+ }
+ typeMapField.ExtraTag = strings.Join(args, " ")
+ directive = true
+ }
+
+ if directive {
if c.Models[schemaType.Name].Fields == nil {
c.Models[schemaType.Name] = TypeMapEntry{
Model: c.Models[schemaType.Name].Model,
Fields: map[string]TypeMapField{},
}
}
-
- c.Models[schemaType.Name].Fields[field.Name] = TypeMapField{
- FieldName: fieldName,
- Resolver: forceResolver,
- }
+ c.Models[schemaType.Name].Fields[field.Name] = typeMapField
}
}
}
@@ -287,6 +325,7 @@ type TypeMapEntry struct {
type TypeMapField struct {
Resolver bool `yaml:"resolver"`
FieldName string `yaml:"fieldName"`
+ ExtraTag string `yaml:"extraTag"`
GeneratedMethod string `yaml:"-"`
}
@@ -333,10 +372,10 @@ func (c *Config) check() error {
fileList := map[string][]FilenamePackage{}
if err := c.Models.Check(); err != nil {
- return errors.Wrap(err, "config.models")
+ return fmt.Errorf("config.models: %w", err)
}
if err := c.Exec.Check(); err != nil {
- return errors.Wrap(err, "config.exec")
+ return fmt.Errorf("config.exec: %w", err)
}
fileList[c.Exec.ImportPath()] = append(fileList[c.Exec.ImportPath()], FilenamePackage{
Filename: c.Exec.Filename,
@@ -346,7 +385,7 @@ func (c *Config) check() error {
if c.Model.IsDefined() {
if err := c.Model.Check(); err != nil {
- return errors.Wrap(err, "config.model")
+ return fmt.Errorf("config.model: %w", err)
}
fileList[c.Model.ImportPath()] = append(fileList[c.Model.ImportPath()], FilenamePackage{
Filename: c.Model.Filename,
@@ -356,7 +395,7 @@ func (c *Config) check() error {
}
if c.Resolver.IsDefined() {
if err := c.Resolver.Check(); err != nil {
- return errors.Wrap(err, "config.resolver")
+ return fmt.Errorf("config.resolver: %w", err)
}
fileList[c.Resolver.ImportPath()] = append(fileList[c.Resolver.ImportPath()], FilenamePackage{
Filename: c.Resolver.Filename,
@@ -366,7 +405,7 @@ func (c *Config) check() error {
}
if c.Federation.IsDefined() {
if err := c.Federation.Check(); err != nil {
- return errors.Wrap(err, "config.federation")
+ return fmt.Errorf("config.federation: %w", err)
}
fileList[c.Federation.ImportPath()] = append(fileList[c.Federation.ImportPath()], FilenamePackage{
Filename: c.Federation.Filename,
@@ -470,7 +509,7 @@ func inStrSlice(haystack []string, needle string) bool {
func findCfg() (string, error) {
dir, err := os.Getwd()
if err != nil {
- return "", errors.Wrap(err, "unable to get working dir to findCfg")
+ return "", fmt.Errorf("unable to get working dir to findCfg: %w", err)
}
cfg := findCfgInDir(dir)
@@ -510,7 +549,7 @@ func (c *Config) autobind() error {
}
for i, p := range ps {
- if p == nil {
+ if p == nil || p.Module == nil {
return fmt.Errorf("unable to load %s - make sure you're using an import path to a package that exists", c.AutoBind[i])
}
if t := p.Types.Scope().Lookup(t.Name); t != nil {
@@ -554,7 +593,7 @@ func (c *Config) injectBuiltins() {
"__EnumValue": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.EnumValue"}},
"__InputValue": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.InputValue"}},
"__Schema": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.Schema"}},
- "Float": {Model: StringList{"github.com/99designs/gqlgen/graphql.Float"}},
+ "Float": {Model: StringList{"github.com/99designs/gqlgen/graphql.FloatContext"}},
"String": {Model: StringList{"github.com/99designs/gqlgen/graphql.String"}},
"Boolean": {Model: StringList{"github.com/99designs/gqlgen/graphql.Boolean"}},
"Int": {Model: StringList{
diff --git a/codegen/config/config_test.go b/codegen/config/config_test.go
index b16e90c11a5..baa836c3ba3 100644
--- a/codegen/config/config_test.go
+++ b/codegen/config/config_test.go
@@ -1,12 +1,13 @@
package config
import (
+ "errors"
+ "io/fs"
"os"
"path/filepath"
"runtime"
"testing"
- "github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2"
@@ -82,7 +83,7 @@ func TestLoadConfigFromDefaultLocation(t *testing.T) {
require.NoError(t, err)
cfg, err = LoadConfigFromDefaultLocations()
- require.True(t, os.IsNotExist(err))
+ require.True(t, errors.Is(err, fs.ErrNotExist))
})
}
@@ -105,7 +106,7 @@ func TestLoadDefaultConfig(t *testing.T) {
require.NoError(t, err)
cfg, err = LoadDefaultConfig()
- require.True(t, os.IsNotExist(errors.Cause(err)))
+ require.True(t, errors.Is(err, fs.ErrNotExist))
})
}
@@ -131,41 +132,45 @@ func TestReferencedPackages(t *testing.T) {
}
func TestConfigCheck(t *testing.T) {
- t.Run("invalid config format due to conflicting package names", func(t *testing.T) {
- config := Config{
- Exec: PackageConfig{Filename: "generated/exec.go", Package: "graphql"},
- Model: PackageConfig{Filename: "generated/models.go"},
- }
-
- require.EqualError(t, config.check(), "exec and model define the same import path (github.com/99designs/gqlgen/codegen/config/generated) with different package names (graphql vs generated)")
- })
-
- t.Run("federation must be in exec package", func(t *testing.T) {
- config := Config{
- Exec: PackageConfig{Filename: "generated/exec.go"},
- Federation: PackageConfig{Filename: "anotherpkg/federation.go"},
- }
-
- require.EqualError(t, config.check(), "federation and exec must be in the same package")
- })
-
- t.Run("federation must have same package name as exec", func(t *testing.T) {
- config := Config{
- Exec: PackageConfig{Filename: "generated/exec.go"},
- Federation: PackageConfig{Filename: "generated/federation.go", Package: "federation"},
- }
-
- require.EqualError(t, config.check(), "exec and federation define the same import path (github.com/99designs/gqlgen/codegen/config/generated) with different package names (generated vs federation)")
- })
-
- t.Run("deprecated federated flag raises an error", func(t *testing.T) {
- config := Config{
- Exec: PackageConfig{Filename: "generated/exec.go"},
- Federated: true,
- }
-
- require.EqualError(t, config.check(), "federated has been removed, instead use\nfederation:\n filename: path/to/federated.go")
- })
+ for _, execLayout := range []ExecLayout{ExecLayoutSingleFile, ExecLayoutFollowSchema} {
+ t.Run(string(execLayout), func(t *testing.T) {
+ t.Run("invalid config format due to conflicting package names", func(t *testing.T) {
+ config := Config{
+ Exec: ExecConfig{Layout: execLayout, Filename: "generated/exec.go", DirName: "generated", Package: "graphql"},
+ Model: PackageConfig{Filename: "generated/models.go"},
+ }
+
+ require.EqualError(t, config.check(), "exec and model define the same import path (github.com/99designs/gqlgen/codegen/config/generated) with different package names (graphql vs generated)")
+ })
+
+ t.Run("federation must be in exec package", func(t *testing.T) {
+ config := Config{
+ Exec: ExecConfig{Layout: execLayout, Filename: "generated/exec.go", DirName: "generated"},
+ Federation: PackageConfig{Filename: "anotherpkg/federation.go"},
+ }
+
+ require.EqualError(t, config.check(), "federation and exec must be in the same package")
+ })
+
+ t.Run("federation must have same package name as exec", func(t *testing.T) {
+ config := Config{
+ Exec: ExecConfig{Layout: execLayout, Filename: "generated/exec.go", DirName: "generated"},
+ Federation: PackageConfig{Filename: "generated/federation.go", Package: "federation"},
+ }
+
+ require.EqualError(t, config.check(), "exec and federation define the same import path (github.com/99designs/gqlgen/codegen/config/generated) with different package names (generated vs federation)")
+ })
+
+ t.Run("deprecated federated flag raises an error", func(t *testing.T) {
+ config := Config{
+ Exec: ExecConfig{Layout: execLayout, Filename: "generated/exec.go", DirName: "generated"},
+ Federated: true,
+ }
+
+ require.EqualError(t, config.check(), "federated has been removed, instead use\nfederation:\n filename: path/to/federated.go")
+ })
+ })
+ }
}
func TestAutobinding(t *testing.T) {
@@ -173,8 +178,8 @@ func TestAutobinding(t *testing.T) {
cfg := Config{
Models: TypeMap{},
AutoBind: []string{
- "github.com/99designs/gqlgen/example/chat",
- "github.com/99designs/gqlgen/example/scalars/model",
+ "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat",
+ "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/scalars/model",
},
Packages: &code.Packages{},
}
@@ -186,8 +191,8 @@ func TestAutobinding(t *testing.T) {
require.NoError(t, cfg.autobind())
- require.Equal(t, "github.com/99designs/gqlgen/example/scalars/model.Banned", cfg.Models["Banned"].Model[0])
- require.Equal(t, "github.com/99designs/gqlgen/example/chat.Message", cfg.Models["Message"].Model[0])
+ require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/scalars/model.Banned", cfg.Models["Banned"].Model[0])
+ require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.Message", cfg.Models["Message"].Model[0])
})
t.Run("with file path", func(t *testing.T) {
diff --git a/codegen/config/exec.go b/codegen/config/exec.go
new file mode 100644
index 00000000000..fe1dccd21da
--- /dev/null
+++ b/codegen/config/exec.go
@@ -0,0 +1,97 @@
+package config
+
+import (
+ "fmt"
+ "go/types"
+ "path/filepath"
+ "strings"
+
+ "github.com/99designs/gqlgen/internal/code"
+)
+
+type ExecConfig struct {
+ Package string `yaml:"package,omitempty"`
+ Layout ExecLayout `yaml:"layout,omitempty"` // Default: single-file
+
+ // Only for single-file layout:
+ Filename string `yaml:"filename,omitempty"`
+
+ // Only for follow-schema layout:
+ FilenameTemplate string `yaml:"filename_template,omitempty"` // String template with {name} as placeholder for base name.
+ DirName string `yaml:"dir"`
+}
+
+type ExecLayout string
+
+var (
+ // Write all generated code to a single file.
+ ExecLayoutSingleFile ExecLayout = "single-file"
+ // Write generated code to a directory, generating one Go source file for each GraphQL schema file.
+ ExecLayoutFollowSchema ExecLayout = "follow-schema"
+)
+
+func (r *ExecConfig) Check() error {
+ if r.Layout == "" {
+ r.Layout = ExecLayoutSingleFile
+ }
+
+ switch r.Layout {
+ case ExecLayoutSingleFile:
+ if r.Filename == "" {
+ return fmt.Errorf("filename must be specified when using single-file layout")
+ }
+ if !strings.HasSuffix(r.Filename, ".go") {
+ return fmt.Errorf("filename should be path to a go source file when using single-file layout")
+ }
+ r.Filename = abs(r.Filename)
+ case ExecLayoutFollowSchema:
+ if r.DirName == "" {
+ return fmt.Errorf("dir must be specified when using follow-schema layout")
+ }
+ r.DirName = abs(r.DirName)
+ default:
+ return fmt.Errorf("invalid layout %s", r.Layout)
+ }
+
+ if strings.ContainsAny(r.Package, "./\\") {
+ return fmt.Errorf("package should be the output package name only, do not include the output filename")
+ }
+
+ if r.Package == "" && r.Dir() != "" {
+ r.Package = code.NameForDir(r.Dir())
+ }
+
+ return nil
+}
+
+func (r *ExecConfig) ImportPath() string {
+ if r.Dir() == "" {
+ return ""
+ }
+ return code.ImportPathForDir(r.Dir())
+}
+
+func (r *ExecConfig) Dir() string {
+ switch r.Layout {
+ case ExecLayoutSingleFile:
+ if r.Filename == "" {
+ return ""
+ }
+ return filepath.Dir(r.Filename)
+ case ExecLayoutFollowSchema:
+ return abs(r.DirName)
+ default:
+ panic("invalid layout " + r.Layout)
+ }
+}
+
+func (r *ExecConfig) Pkg() *types.Package {
+ if r.Dir() == "" {
+ return nil
+ }
+ return types.NewPackage(r.ImportPath(), r.Package)
+}
+
+func (r *ExecConfig) IsDefined() bool {
+ return r.Filename != "" || r.DirName != ""
+}
diff --git a/codegen/config/testdata/autobinding/chat/message.go b/codegen/config/testdata/autobinding/chat/message.go
new file mode 100644
index 00000000000..b35be48c938
--- /dev/null
+++ b/codegen/config/testdata/autobinding/chat/message.go
@@ -0,0 +1,12 @@
+package chat
+
+import (
+ "time"
+)
+
+type Message struct {
+ ID string `json:"id"`
+ Text string `json:"text"`
+ CreatedBy string `json:"createdBy"`
+ CreatedAt time.Time `json:"createdAt"`
+}
diff --git a/codegen/config/testdata/autobinding/scalars/model/model.go b/codegen/config/testdata/autobinding/scalars/model/model.go
new file mode 100644
index 00000000000..944a48b6720
--- /dev/null
+++ b/codegen/config/testdata/autobinding/scalars/model/model.go
@@ -0,0 +1,30 @@
+package model
+
+import (
+ "fmt"
+ "io"
+ "strings"
+)
+
+type Banned bool
+
+func (b Banned) MarshalGQL(w io.Writer) {
+ if b {
+ w.Write([]byte("true"))
+ } else {
+ w.Write([]byte("false"))
+ }
+}
+
+func (b *Banned) UnmarshalGQL(v interface{}) error {
+ switch v := v.(type) {
+ case string:
+ *b = strings.ToLower(v) == "true"
+ return nil
+ case bool:
+ *b = Banned(v)
+ return nil
+ default:
+ return fmt.Errorf("%T is not a bool", v)
+ }
+}
diff --git a/codegen/data.go b/codegen/data.go
index bedbef9d441..690718de3a9 100644
--- a/codegen/data.go
+++ b/codegen/data.go
@@ -4,7 +4,6 @@ import (
"fmt"
"sort"
- "github.com/pkg/errors"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen/config"
@@ -13,9 +12,15 @@ import (
// Data is a unified model of the code to be generated. Plugins may modify this structure to do things like implement
// resolvers or directives automatically (eg grpc, validation)
type Data struct {
- Config *config.Config
- Schema *ast.Schema
- Directives DirectiveList
+ Config *config.Config
+ Schema *ast.Schema
+ // If a schema is broken up into multiple Data instance, each representing part of the schema,
+ // AllDirectives should contain the directives for the entire schema. Directives() can
+ // then be used to get the directives that were defined in this Data instance's sources.
+ // If a single Data instance is used for the entire schema, AllDirectives and Directives()
+ // will be identical.
+ // AllDirectives should rarely be used directly.
+ AllDirectives DirectiveList
Objects Objects
Inputs Objects
Interfaces map[string]*Interface
@@ -34,6 +39,20 @@ type builder struct {
Directives map[string]*Directive
}
+// Get only the directives which are defined in the config's sources.
+func (d *Data) Directives() DirectiveList {
+ res := DirectiveList{}
+ for k, directive := range d.AllDirectives {
+ for _, s := range d.Config.Sources {
+ if directive.Position.Src.Name == s.Name {
+ res[k] = directive
+ break
+ }
+ }
+ }
+ return res
+}
+
func BuildData(cfg *config.Config) (*Data, error) {
b := builder{
Config: cfg,
@@ -56,10 +75,10 @@ func BuildData(cfg *config.Config) (*Data, error) {
}
s := Data{
- Config: cfg,
- Directives: dataDirectives,
- Schema: b.Schema,
- Interfaces: map[string]*Interface{},
+ Config: cfg,
+ AllDirectives: dataDirectives,
+ Schema: b.Schema,
+ Interfaces: map[string]*Interface{},
}
for _, schemaType := range b.Schema.Types {
@@ -67,14 +86,14 @@ func BuildData(cfg *config.Config) (*Data, error) {
case ast.Object:
obj, err := b.buildObject(schemaType)
if err != nil {
- return nil, errors.Wrap(err, "unable to build object definition")
+ return nil, fmt.Errorf("unable to build object definition: %w", err)
}
s.Objects = append(s.Objects, obj)
case ast.InputObject:
input, err := b.buildObject(schemaType)
if err != nil {
- return nil, errors.Wrap(err, "unable to build input definition")
+ return nil, fmt.Errorf("unable to build input definition: %w", err)
}
s.Inputs = append(s.Inputs, input)
@@ -82,7 +101,7 @@ func BuildData(cfg *config.Config) (*Data, error) {
case ast.Union, ast.Interface:
s.Interfaces[schemaType.Name], err = b.buildInterface(schemaType)
if err != nil {
- return nil, errors.Wrap(err, "unable to bind to interface")
+ return nil, fmt.Errorf("unable to bind to interface: %w", err)
}
}
}
diff --git a/codegen/data_test.go b/codegen/data_test.go
new file mode 100644
index 00000000000..a1ac4d3df9f
--- /dev/null
+++ b/codegen/data_test.go
@@ -0,0 +1,68 @@
+package codegen
+
+import (
+ "testing"
+
+ "github.com/99designs/gqlgen/codegen/config"
+ "github.com/vektah/gqlparser/v2/ast"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestData_Directives(t *testing.T) {
+ d := Data{
+ Config: &config.Config{
+ Sources: []*ast.Source{
+ {
+ Name: "schema.graphql",
+ },
+ },
+ },
+ AllDirectives: DirectiveList{
+ "includeDirective": {
+ DirectiveDefinition: &ast.DirectiveDefinition{
+ Name: "includeDirective",
+ Position: &ast.Position{
+ Src: &ast.Source{
+ Name: "schema.graphql",
+ },
+ },
+ },
+ Name: "includeDirective",
+ Args: nil,
+ Builtin: false,
+ },
+ "excludeDirective": {
+ DirectiveDefinition: &ast.DirectiveDefinition{
+ Name: "excludeDirective",
+ Position: &ast.Position{
+ Src: &ast.Source{
+ Name: "anothersource.graphql",
+ },
+ },
+ },
+ Name: "excludeDirective",
+ Args: nil,
+ Builtin: false,
+ },
+ },
+ }
+
+ expected := DirectiveList{
+ "includeDirective": {
+ DirectiveDefinition: &ast.DirectiveDefinition{
+ Name: "includeDirective",
+ Position: &ast.Position{
+ Src: &ast.Source{
+ Name: "schema.graphql",
+ },
+ },
+ },
+ Name: "includeDirective",
+ Args: nil,
+ Builtin: false,
+ },
+ }
+
+ assert.Equal(t, expected, d.Directives())
+}
diff --git a/codegen/directive.go b/codegen/directive.go
index 5d4c038ffa7..973061129a2 100644
--- a/codegen/directive.go
+++ b/codegen/directive.go
@@ -6,13 +6,12 @@ import (
"strings"
"github.com/99designs/gqlgen/codegen/templates"
- "github.com/pkg/errors"
"github.com/vektah/gqlparser/v2/ast"
)
type DirectiveList map[string]*Directive
-//LocationDirectives filter directives by location
+// LocationDirectives filter directives by location
func (dl DirectiveList) LocationDirectives(location string) DirectiveList {
return locationDirectives(dl, ast.DirectiveLocation(location))
}
@@ -24,7 +23,7 @@ type Directive struct {
Builtin bool
}
-//IsLocation check location directive
+// IsLocation check location directive
func (d *Directive) IsLocation(location ...ast.DirectiveLocation) bool {
for _, l := range d.Locations {
for _, a := range location {
@@ -52,7 +51,7 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) {
for name, dir := range b.Schema.Directives {
if _, ok := directives[name]; ok {
- return nil, errors.Errorf("directive with name %s already exists", name)
+ return nil, fmt.Errorf("directive with name %s already exists", name)
}
var args []*FieldArgument
@@ -72,7 +71,7 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) {
var err error
newArg.Default, err = arg.DefaultValue.Value(nil)
if err != nil {
- return nil, errors.Errorf("default value for directive argument %s(%s) is not valid: %s", dir.Name, arg.Name, err.Error())
+ return nil, fmt.Errorf("default value for directive argument %s(%s) is not valid: %w", dir.Name, arg.Name, err)
}
}
args = append(args, newArg)
diff --git a/codegen/field.go b/codegen/field.go
index 5983119f757..245632aac02 100644
--- a/codegen/field.go
+++ b/codegen/field.go
@@ -10,7 +10,6 @@ import (
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/codegen/templates"
- "github.com/pkg/errors"
"github.com/vektah/gqlparser/v2/ast"
)
@@ -25,6 +24,7 @@ type Field struct {
Args []*FieldArgument // A list of arguments to be passed to this field
MethodHasContext bool // If this is bound to a go method, does the method also take a context
NoErr bool // If this is bound to a go method, does that method have an error as the second argument
+ VOkFunc bool // If this is bound to a go method, is it of shape (interface{}, bool)
Object *Object // A link back to the parent object
Default interface{} // The default value
Stream bool // does this field return a channel?
@@ -50,7 +50,7 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e
var err error
f.Default, err = field.DefaultValue.Value(nil)
if err != nil {
- return nil, errors.Errorf("default value %s is not valid: %s", field.Name, err.Error())
+ return nil, fmt.Errorf("default value %s is not valid: %w", field.Name, err)
}
}
@@ -88,6 +88,11 @@ func (b *builder) bindField(obj *Object, f *Field) (errret error) {
if err != nil {
errret = err
}
+ for _, dir := range obj.Directives {
+ if dir.IsLocation(ast.LocationInputObject) {
+ dirs = append(dirs, dir)
+ }
+ }
f.Directives = append(dirs, f.Directives...)
}
}()
@@ -110,6 +115,7 @@ func (b *builder) bindField(obj *Object, f *Field) (errret error) {
f.GoReceiverName = "ec"
f.GoFieldName = "__resolve_entities"
f.MethodHasContext = true
+ f.NoErr = true
return nil
case f.Name == "_service":
f.GoFieldType = GoFieldMethod
@@ -152,6 +158,8 @@ func (b *builder) bindField(obj *Object, f *Field) (errret error) {
sig := target.Type().(*types.Signature)
if sig.Results().Len() == 1 {
f.NoErr = true
+ } else if s := sig.Results(); s.Len() == 2 && s.At(1).Type().String() == "bool" {
+ f.VOkFunc = true
} else if sig.Results().Len() != 2 {
return fmt.Errorf("method has wrong number of args")
}
@@ -168,7 +176,7 @@ func (b *builder) bindField(obj *Object, f *Field) (errret error) {
}
if err = b.bindArgs(f, params); err != nil {
- return errors.Wrapf(err, "%s:%d", pos.Filename, pos.Line)
+ return fmt.Errorf("%s:%d: %w", pos.Filename, pos.Line, err)
}
result := sig.Results().At(0)
@@ -237,7 +245,7 @@ func (b *builder) findBindTarget(t types.Type, name string) (types.Object, error
return foundField, nil
case foundField != nil && foundMethod != nil:
// Error
- return nil, errors.Errorf("found more than one way to bind for %s", name)
+ return nil, fmt.Errorf("found more than one way to bind for %s", name)
}
// Search embeds
@@ -262,7 +270,7 @@ func (b *builder) findBindStructTagTarget(in types.Type, name string) (types.Obj
tags := reflect.StructTag(t.Tag(i))
if val, ok := tags.Lookup(b.Config.StructTag); ok && equalFieldName(val, name) {
if found != nil {
- return nil, errors.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", b.Config.StructTag, val)
+ return nil, fmt.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", b.Config.StructTag, val)
}
found = field
@@ -300,7 +308,7 @@ func (b *builder) findBindMethoderTarget(methodFunc func(i int) *types.Func, met
}
if found != nil {
- return nil, errors.Errorf("found more than one matching method to bind for %s", name)
+ return nil, fmt.Errorf("found more than one matching method to bind for %s", name)
}
found = method
@@ -322,7 +330,7 @@ func (b *builder) findBindFieldTarget(in types.Type, name string) (types.Object,
}
if found != nil {
- return nil, errors.Errorf("found more than one matching field to bind for %s", name)
+ return nil, fmt.Errorf("found more than one matching field to bind for %s", name)
}
found = field
@@ -366,7 +374,7 @@ func (b *builder) findBindStructEmbedsTarget(strukt *types.Struct, name string)
}
if f != nil && found != nil {
- return nil, errors.Errorf("found more than one way to bind for %s", name)
+ return nil, fmt.Errorf("found more than one way to bind for %s", name)
}
if f != nil {
@@ -388,7 +396,7 @@ func (b *builder) findBindInterfaceEmbedsTarget(iface *types.Interface, name str
}
if f != nil && found != nil {
- return nil, errors.Errorf("found more than one way to bind for %s", name)
+ return nil, fmt.Errorf("found more than one way to bind for %s", name)
}
if f != nil {
@@ -417,7 +425,8 @@ func (f *Field) ImplDirectives() []*Directive {
loc = ast.LocationInputFieldDefinition
}
for i := range f.Directives {
- if !f.Directives[i].Builtin && f.Directives[i].IsLocation(loc, ast.LocationObject) {
+ if !f.Directives[i].Builtin &&
+ (f.Directives[i].IsLocation(loc, ast.LocationObject) || f.Directives[i].IsLocation(loc, ast.LocationInputObject)) {
d = append(d, f.Directives[i])
}
}
@@ -453,9 +462,9 @@ func (f *Field) GoNameUnexported() string {
func (f *Field) ShortInvocation() string {
if f.Object.Kind == ast.InputObject {
- return fmt.Sprintf("%s().%s(ctx, &it, data)", f.Object.Definition.Name, f.GoFieldName)
+ return fmt.Sprintf("%s().%s(ctx, &it, data)", strings.Title(f.Object.Definition.Name), f.GoFieldName)
}
- return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.Name, f.GoFieldName, f.CallArgs())
+ return fmt.Sprintf("%s().%s(%s)", strings.Title(f.Object.Definition.Name), f.GoFieldName, f.CallArgs())
}
func (f *Field) ArgsFunc() string {
diff --git a/codegen/field.gotpl b/codegen/field.gotpl
index 66f715981a6..0c6becaea6a 100644
--- a/codegen/field.gotpl
+++ b/codegen/field.gotpl
@@ -29,7 +29,7 @@ func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Contex
}
fc.Args = args
{{- end }}
- {{- if $.Directives.LocationDirectives "FIELD" }}
+ {{- if $.AllDirectives.LocationDirectives "FIELD" }}
resTmp := ec._fieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {
{{ template "field" $field }}
})
@@ -112,7 +112,13 @@ func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Contex
return nil, fmt.Errorf("unexpected type %T for field %s", v, {{ .Name | quote}})
}
{{- else if .IsMethod -}}
- {{- if .NoErr -}}
+ {{- if .VOkFunc -}}
+ v, ok := {{.GoReceiverName}}.{{.GoFieldName}}({{ .CallArgs }})
+ if !ok {
+ return nil, nil
+ }
+ return v, nil
+ {{- else if .NoErr -}}
return {{.GoReceiverName}}.{{.GoFieldName}}({{ .CallArgs }}), nil
{{- else -}}
return {{.GoReceiverName}}.{{.GoFieldName}}({{ .CallArgs }})
diff --git a/codegen/generate.go b/codegen/generate.go
index f1ed2ca27be..84c130a2e8f 100644
--- a/codegen/generate.go
+++ b/codegen/generate.go
@@ -1,10 +1,35 @@
package codegen
import (
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "path/filepath"
+ "runtime"
+ "strings"
+
+ "github.com/vektah/gqlparser/v2/ast"
+
+ "github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/codegen/templates"
)
func GenerateCode(data *Data) error {
+ if !data.Config.Exec.IsDefined() {
+ return fmt.Errorf("missing exec config")
+ }
+
+ switch data.Config.Exec.Layout {
+ case config.ExecLayoutSingleFile:
+ return generateSingleFile(data)
+ case config.ExecLayoutFollowSchema:
+ return generatePerSchema(data)
+ }
+
+ return fmt.Errorf("unrecognized exec layout %s", data.Config.Exec.Layout)
+}
+
+func generateSingleFile(data *Data) error {
return templates.Render(templates.Options{
PackageName: data.Config.Exec.Package,
Filename: data.Config.Exec.Filename,
@@ -14,3 +39,176 @@ func GenerateCode(data *Data) error {
Packages: data.Config.Packages,
})
}
+
+func generatePerSchema(data *Data) error {
+ err := generateRootFile(data)
+ if err != nil {
+ return err
+ }
+
+ builds := map[string]*Data{}
+
+ err = addObjects(data, &builds)
+ if err != nil {
+ return err
+ }
+
+ err = addInputs(data, &builds)
+ if err != nil {
+ return err
+ }
+
+ err = addInterfaces(data, &builds)
+ if err != nil {
+ return err
+ }
+
+ err = addReferencedTypes(data, &builds)
+ if err != nil {
+ return err
+ }
+
+ for filename, build := range builds {
+ if filename == "" {
+ continue
+ }
+
+ dir := data.Config.Exec.DirName
+ path := filepath.Join(dir, filename)
+
+ err = templates.Render(templates.Options{
+ PackageName: data.Config.Exec.Package,
+ Filename: path,
+ Data: build,
+ RegionTags: true,
+ GeneratedHeader: true,
+ Packages: data.Config.Packages,
+ })
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+func filename(p *ast.Position, config *config.Config) string {
+ name := "common!"
+ if p != nil && p.Src != nil {
+ gqlname := filepath.Base(p.Src.Name)
+ ext := filepath.Ext(p.Src.Name)
+ name = strings.TrimSuffix(gqlname, ext)
+ }
+
+ filenameTempl := config.Exec.FilenameTemplate
+ if filenameTempl == "" {
+ filenameTempl = "{name}.generated.go"
+ }
+
+ return strings.ReplaceAll(filenameTempl, "{name}", name)
+}
+
+func addBuild(filename string, p *ast.Position, data *Data, builds *map[string]*Data) {
+ buildConfig := *data.Config
+ if p != nil {
+ buildConfig.Sources = []*ast.Source{p.Src}
+ }
+
+ (*builds)[filename] = &Data{
+ Config: &buildConfig,
+ QueryRoot: data.QueryRoot,
+ MutationRoot: data.MutationRoot,
+ SubscriptionRoot: data.SubscriptionRoot,
+ AllDirectives: data.AllDirectives,
+ }
+}
+
+// Root file contains top-level definitions that should not be duplicated across the generated
+// files for each schema file.
+func generateRootFile(data *Data) error {
+ dir := data.Config.Exec.DirName
+ path := filepath.Join(dir, "root!.generated.go")
+
+ _, thisFile, _, _ := runtime.Caller(0)
+ rootDir := filepath.Dir(thisFile)
+ templatePath := filepath.Join(rootDir, "root_.gotpl")
+ templateBytes, err := ioutil.ReadFile(templatePath)
+ if err != nil {
+ return err
+ }
+ template := string(templateBytes)
+
+ return templates.Render(templates.Options{
+ PackageName: data.Config.Exec.Package,
+ Template: template,
+ Filename: path,
+ Data: data,
+ RegionTags: false,
+ GeneratedHeader: true,
+ Packages: data.Config.Packages,
+ })
+}
+
+func addObjects(data *Data, builds *map[string]*Data) error {
+ for _, o := range data.Objects {
+ filename := filename(o.Position, data.Config)
+ if (*builds)[filename] == nil {
+ addBuild(filename, o.Position, data, builds)
+ }
+
+ (*builds)[filename].Objects = append((*builds)[filename].Objects, o)
+ }
+ return nil
+}
+
+func addInputs(data *Data, builds *map[string]*Data) error {
+ for _, in := range data.Inputs {
+ filename := filename(in.Position, data.Config)
+ if (*builds)[filename] == nil {
+ addBuild(filename, in.Position, data, builds)
+ }
+
+ (*builds)[filename].Inputs = append((*builds)[filename].Inputs, in)
+ }
+ return nil
+}
+
+func addInterfaces(data *Data, builds *map[string]*Data) error {
+ for k, inf := range data.Interfaces {
+ filename := filename(inf.Position, data.Config)
+ if (*builds)[filename] == nil {
+ addBuild(filename, inf.Position, data, builds)
+ }
+ build := (*builds)[filename]
+
+ if build.Interfaces == nil {
+ build.Interfaces = map[string]*Interface{}
+ }
+ if build.Interfaces[k] != nil {
+ return errors.New("conflicting interface keys")
+ }
+
+ build.Interfaces[k] = inf
+ }
+ return nil
+}
+
+func addReferencedTypes(data *Data, builds *map[string]*Data) error {
+ for k, rt := range data.ReferencedTypes {
+ filename := filename(rt.Definition.Position, data.Config)
+ if (*builds)[filename] == nil {
+ addBuild(filename, rt.Definition.Position, data, builds)
+ }
+ build := (*builds)[filename]
+
+ if build.ReferencedTypes == nil {
+ build.ReferencedTypes = map[string]*config.TypeReference{}
+ }
+ if build.ReferencedTypes[k] != nil {
+ return errors.New("conflicting referenced type keys")
+ }
+
+ build.ReferencedTypes[k] = rt
+ }
+ return nil
+}
diff --git a/codegen/generated!.gotpl b/codegen/generated!.gotpl
index cd2c88cf6c9..bf59daccef9 100644
--- a/codegen/generated!.gotpl
+++ b/codegen/generated!.gotpl
@@ -14,58 +14,60 @@
{{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }}
-// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.
-func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
- return &executableSchema{
- resolvers: cfg.Resolvers,
- directives: cfg.Directives,
- complexity: cfg.Complexity,
+{{ if eq .Config.Exec.Layout "single-file" }}
+ // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.
+ func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
+ return &executableSchema{
+ resolvers: cfg.Resolvers,
+ directives: cfg.Directives,
+ complexity: cfg.Complexity,
+ }
}
-}
-type Config struct {
- Resolvers ResolverRoot
- Directives DirectiveRoot
- Complexity ComplexityRoot
-}
+ type Config struct {
+ Resolvers ResolverRoot
+ Directives DirectiveRoot
+ Complexity ComplexityRoot
+ }
-type ResolverRoot interface {
-{{- range $object := .Objects -}}
- {{ if $object.HasResolvers -}}
- {{$object.Name}}() {{$object.Name}}Resolver
- {{ end }}
-{{- end }}
-{{- range $object := .Inputs -}}
+ type ResolverRoot interface {
+ {{- range $object := .Objects -}}
+ {{ if $object.HasResolvers -}}
+ {{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver
+ {{ end }}
+ {{- end }}
+ {{- range $object := .Inputs -}}
{{ if $object.HasResolvers -}}
- {{$object.Name}}() {{$object.Name}}Resolver
+ {{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver
{{ end }}
{{- end }}
}
-type DirectiveRoot struct {
-{{ range $directive := .Directives }}
- {{- $directive.Declaration }}
-{{ end }}
-}
+ type DirectiveRoot struct {
+ {{ range $directive := .Directives }}
+ {{- $directive.Declaration }}
+ {{ end }}
+ }
-type ComplexityRoot struct {
-{{ range $object := .Objects }}
- {{ if not $object.IsReserved -}}
- {{ $object.Name|go }} struct {
- {{ range $_, $fields := $object.UniqueFields }}
- {{- $field := index $fields 0 -}}
- {{ if not $field.IsReserved -}}
- {{ $field.GoFieldName }} {{ $field.ComplexitySignature }}
- {{ end }}
+ type ComplexityRoot struct {
+ {{ range $object := .Objects }}
+ {{ if not $object.IsReserved -}}
+ {{ ucFirst $object.Name }} struct {
+ {{ range $_, $fields := $object.UniqueFields }}
+ {{- $field := index $fields 0 -}}
+ {{ if not $field.IsReserved -}}
+ {{ $field.GoFieldName }} {{ $field.ComplexitySignature }}
+ {{ end }}
+ {{- end }}
+ }
{{- end }}
- }
- {{- end }}
+ {{ end }}
+ }
{{ end }}
-}
{{ range $object := .Objects -}}
{{ if $object.HasResolvers }}
- type {{$object.Name}}Resolver interface {
+ type {{ucFirst $object.Name}}Resolver interface {
{{ range $field := $object.Fields -}}
{{- if $field.IsResolver }}
{{- $field.GoFieldName}}{{ $field.ShortResolverDeclaration }}
@@ -87,145 +89,147 @@ type ComplexityRoot struct {
{{- end }}
{{- end }}
-type executableSchema struct {
- resolvers ResolverRoot
- directives DirectiveRoot
- complexity ComplexityRoot
-}
+{{ if eq .Config.Exec.Layout "single-file" }}
+ type executableSchema struct {
+ resolvers ResolverRoot
+ directives DirectiveRoot
+ complexity ComplexityRoot
+ }
-func (e *executableSchema) Schema() *ast.Schema {
- return parsedSchema
-}
+ func (e *executableSchema) Schema() *ast.Schema {
+ return parsedSchema
+ }
-func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {
- ec := executionContext{nil, e}
- _ = ec
- switch typeName + "." + field {
- {{ range $object := .Objects }}
- {{ if not $object.IsReserved }}
- {{ range $_, $fields := $object.UniqueFields }}
- {{- $len := len $fields }}
- {{- range $i, $field := $fields }}
- {{- $last := eq (add $i 1) $len }}
- {{- if not $field.IsReserved }}
- {{- if eq $i 0 }}case {{ end }}"{{$object.Name}}.{{$field.Name}}"{{ if not $last }},{{ else }}:
- if e.complexity.{{$object.Name|go}}.{{$field.GoFieldName}} == nil {
- break
- }
- {{ if $field.Args }}
- args, err := ec.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)
- if err != nil {
- return 0, false
+ func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {
+ ec := executionContext{nil, e}
+ _ = ec
+ switch typeName + "." + field {
+ {{ range $object := .Objects }}
+ {{ if not $object.IsReserved }}
+ {{ range $_, $fields := $object.UniqueFields }}
+ {{- $len := len $fields }}
+ {{- range $i, $field := $fields }}
+ {{- $last := eq (add $i 1) $len }}
+ {{- if not $field.IsReserved }}
+ {{- if eq $i 0 }}case {{ end }}"{{$object.Name}}.{{$field.Name}}"{{ if not $last }},{{ else }}:
+ if e.complexity.{{ucFirst $object.Name}}.{{$field.GoFieldName}} == nil {
+ break
}
+ {{ if $field.Args }}
+ args, err := ec.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)
+ if err != nil {
+ return 0, false
+ }
+ {{ end }}
+ return e.complexity.{{ucFirst $object.Name}}.{{$field.GoFieldName}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{ end }}), true
{{ end }}
- return e.complexity.{{$object.Name|go}}.{{$field.GoFieldName}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{ end }}), true
- {{ end }}
+ {{- end }}
{{- end }}
- {{- end }}
+ {{ end }}
{{ end }}
{{ end }}
- {{ end }}
+ }
+ return 0, false
}
- return 0, false
-}
-func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
- rc := graphql.GetOperationContext(ctx)
- ec := executionContext{rc, e}
- first := true
-
- switch rc.Operation.Operation {
- {{- if .QueryRoot }} case ast.Query:
- return func(ctx context.Context) *graphql.Response {
- if !first { return nil }
- first = false
- {{ if .Directives.LocationDirectives "QUERY" -}}
- data := ec._queryMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){
- return ec._{{.QueryRoot.Name}}(ctx, rc.Operation.SelectionSet), nil
- })
- {{- else -}}
- data := ec._{{.QueryRoot.Name}}(ctx, rc.Operation.SelectionSet)
- {{- end }}
- var buf bytes.Buffer
- data.MarshalGQL(&buf)
+ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
+ rc := graphql.GetOperationContext(ctx)
+ ec := executionContext{rc, e}
+ first := true
+
+ switch rc.Operation.Operation {
+ {{- if .QueryRoot }} case ast.Query:
+ return func(ctx context.Context) *graphql.Response {
+ if !first { return nil }
+ first = false
+ {{ if .Directives.LocationDirectives "QUERY" -}}
+ data := ec._queryMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){
+ return ec._{{.QueryRoot.Name}}(ctx, rc.Operation.SelectionSet), nil
+ })
+ {{- else -}}
+ data := ec._{{.QueryRoot.Name}}(ctx, rc.Operation.SelectionSet)
+ {{- end }}
+ var buf bytes.Buffer
+ data.MarshalGQL(&buf)
- return &graphql.Response{
- Data: buf.Bytes(),
+ return &graphql.Response{
+ Data: buf.Bytes(),
+ }
}
- }
- {{ end }}
+ {{ end }}
+
+ {{- if .MutationRoot }} case ast.Mutation:
+ return func(ctx context.Context) *graphql.Response {
+ if !first { return nil }
+ first = false
+ {{ if .Directives.LocationDirectives "MUTATION" -}}
+ data := ec._mutationMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){
+ return ec._{{.MutationRoot.Name}}(ctx, rc.Operation.SelectionSet), nil
+ })
+ {{- else -}}
+ data := ec._{{.MutationRoot.Name}}(ctx, rc.Operation.SelectionSet)
+ {{- end }}
+ var buf bytes.Buffer
+ data.MarshalGQL(&buf)
- {{- if .MutationRoot }} case ast.Mutation:
- return func(ctx context.Context) *graphql.Response {
- if !first { return nil }
- first = false
- {{ if .Directives.LocationDirectives "MUTATION" -}}
- data := ec._mutationMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){
- return ec._{{.MutationRoot.Name}}(ctx, rc.Operation.SelectionSet), nil
+ return &graphql.Response{
+ Data: buf.Bytes(),
+ }
+ }
+ {{ end }}
+
+ {{- if .SubscriptionRoot }} case ast.Subscription:
+ {{ if .Directives.LocationDirectives "SUBSCRIPTION" -}}
+ next := ec._subscriptionMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){
+ return ec._{{.SubscriptionRoot.Name}}(ctx, rc.Operation.SelectionSet),nil
})
{{- else -}}
- data := ec._{{.MutationRoot.Name}}(ctx, rc.Operation.SelectionSet)
+ next := ec._{{.SubscriptionRoot.Name}}(ctx, rc.Operation.SelectionSet)
{{- end }}
- var buf bytes.Buffer
- data.MarshalGQL(&buf)
- return &graphql.Response{
- Data: buf.Bytes(),
+ var buf bytes.Buffer
+ return func(ctx context.Context) *graphql.Response {
+ buf.Reset()
+ data := next()
+
+ if data == nil {
+ return nil
+ }
+ data.MarshalGQL(&buf)
+
+ return &graphql.Response{
+ Data: buf.Bytes(),
+ }
}
+ {{ end }}
+ default:
+ return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation"))
}
- {{ end }}
-
- {{- if .SubscriptionRoot }} case ast.Subscription:
- {{ if .Directives.LocationDirectives "SUBSCRIPTION" -}}
- next := ec._subscriptionMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){
- return ec._{{.SubscriptionRoot.Name}}(ctx, rc.Operation.SelectionSet),nil
- })
- {{- else -}}
- next := ec._{{.SubscriptionRoot.Name}}(ctx, rc.Operation.SelectionSet)
- {{- end }}
-
- var buf bytes.Buffer
- return func(ctx context.Context) *graphql.Response {
- buf.Reset()
- data := next()
+ }
- if data == nil {
- return nil
- }
- data.MarshalGQL(&buf)
+ type executionContext struct {
+ *graphql.OperationContext
+ *executableSchema
+ }
- return &graphql.Response{
- Data: buf.Bytes(),
- }
+ func (ec *executionContext) introspectSchema() (*introspection.Schema, error) {
+ if ec.DisableIntrospection {
+ return nil, errors.New("introspection disabled")
}
- {{ end }}
- default:
- return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation"))
+ return introspection.WrapSchema(parsedSchema), nil
}
-}
-
-type executionContext struct {
- *graphql.OperationContext
- *executableSchema
-}
-func (ec *executionContext) introspectSchema() (*introspection.Schema, error) {
- if ec.DisableIntrospection {
- return nil, errors.New("introspection disabled")
+ func (ec *executionContext) introspectType(name string) (*introspection.Type, error) {
+ if ec.DisableIntrospection {
+ return nil, errors.New("introspection disabled")
+ }
+ return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil
}
- return introspection.WrapSchema(parsedSchema), nil
-}
-func (ec *executionContext) introspectType(name string) (*introspection.Type, error) {
- if ec.DisableIntrospection {
- return nil, errors.New("introspection disabled")
+ var sources = []*ast.Source{
+ {{- range $source := .Config.Sources }}
+ {Name: {{$source.Name|quote}}, Input: {{$source.Input|rawQuote}}, BuiltIn: {{$source.BuiltIn}}},
+ {{- end }}
}
- return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil
-}
-
-var sources = []*ast.Source{
-{{- range $source := .Config.Sources }}
- {Name: {{$source.Name|quote}}, Input: {{$source.Input|rawQuote}}, BuiltIn: {{$source.BuiltIn}}},
-{{- end }}
-}
-var parsedSchema = gqlparser.MustLoadSchema(sources...)
+ var parsedSchema = gqlparser.MustLoadSchema(sources...)
+{{ end }}
diff --git a/codegen/input.gotpl b/codegen/input.gotpl
index 37c20f8ecc9..5694bcd613c 100644
--- a/codegen/input.gotpl
+++ b/codegen/input.gotpl
@@ -2,9 +2,12 @@
{{- if not .HasUnmarshal }}
func (ec *executionContext) unmarshalInput{{ .Name }}(ctx context.Context, obj interface{}) ({{.Type | ref}}, error) {
var it {{.Type | ref}}
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
{{ range $field := .Fields}}
- {{- if $field.Default}}
+ {{- if notNil "Default" $field }}
if _, present := asMap[{{$field.Name|quote}}] ; !present {
asMap[{{$field.Name|quote}}] = {{ $field.Default | dump }}
}
diff --git a/codegen/interface.go b/codegen/interface.go
index a55ce1e6bf9..cdc4d4d32ed 100644
--- a/codegen/interface.go
+++ b/codegen/interface.go
@@ -4,7 +4,6 @@ import (
"fmt"
"go/types"
- "github.com/pkg/errors"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen/config"
@@ -49,7 +48,7 @@ func (b *builder) buildInterface(typ *ast.Definition) (*Interface, error) {
implementorType, err := findGoNamedType(obj)
if err != nil {
- return nil, errors.Wrapf(err, "can not find backing go type %s", obj.String())
+ return nil, fmt.Errorf("can not find backing go type %s: %w", obj.String(), err)
} else if implementorType == nil {
return nil, fmt.Errorf("can not find backing go type %s", obj.String())
}
diff --git a/codegen/object.go b/codegen/object.go
index 7b91c900497..6cf922d47c4 100644
--- a/codegen/object.go
+++ b/codegen/object.go
@@ -1,13 +1,13 @@
package codegen
import (
+ "fmt"
"go/types"
"strconv"
"strings"
"unicode"
"github.com/99designs/gqlgen/codegen/config"
- "github.com/pkg/errors"
"github.com/vektah/gqlparser/v2/ast"
)
@@ -36,7 +36,7 @@ type Object struct {
func (b *builder) buildObject(typ *ast.Definition) (*Object, error) {
dirs, err := b.getDirectives(typ.Directives)
if err != nil {
- return nil, errors.Wrap(err, typ.Name)
+ return nil, fmt.Errorf("%s: %w", typ.Name, err)
}
obj := &Object{
@@ -46,7 +46,7 @@ func (b *builder) buildObject(typ *ast.Definition) (*Object, error) {
Stream: typ == b.Schema.Subscription,
Directives: dirs,
ResolverInterface: types.NewNamed(
- types.NewTypeName(0, b.Config.Exec.Pkg(), typ.Name+"Resolver", nil),
+ types.NewTypeName(0, b.Config.Exec.Pkg(), strings.Title(typ.Name)+"Resolver", nil),
nil,
nil,
),
diff --git a/codegen/object.gotpl b/codegen/object.gotpl
index 33775a0b4c3..8cb9d28ced7 100644
--- a/codegen/object.gotpl
+++ b/codegen/object.gotpl
@@ -25,56 +25,84 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec
{{- else }}
func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet{{ if not $object.Root }},obj {{$object.Reference | ref }}{{ end }}) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, {{$object.Name|lcFirst}}Implementors)
- {{if $object.Root}}
- ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
- Object: {{$object.Name|quote}},
- })
- {{end}}
-
+ {{- if $object.Root }}
+ ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
+ Object: {{$object.Name|quote}},
+ })
+ {{end}}
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
- switch field.Name {
- case "__typename":
- out.Values[i] = graphql.MarshalString({{$object.Name|quote}})
- {{- range $field := $object.Fields }}
- case "{{$field.Name}}":
- {{- if $field.IsConcurrent }}
- field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
- defer func() {
- if r := recover(); r != nil {
- ec.Error(ctx, ec.Recover(ctx, r))
- }
- }()
- res = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}})
- {{- if $field.TypeReference.GQL.NonNull }}
- if res == graphql.Null {
- {{- if $object.IsConcurrent }}
- atomic.AddUint32(&invalids, 1)
- {{- else }}
- invalids++
- {{- end }}
- }
- {{- end }}
- return res
- })
- {{- else }}
- out.Values[i] = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}})
- {{- if $field.TypeReference.GQL.NonNull }}
- if out.Values[i] == graphql.Null {
- {{- if $object.IsConcurrent }}
- atomic.AddUint32(&invalids, 1)
- {{- else }}
- invalids++
- {{- end }}
- }
- {{- end }}
- {{- end }}
- {{- end }}
- default:
- panic("unknown field " + strconv.Quote(field.Name))
- }
+ {{- if $object.Root }}
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+ {{end}}
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString({{$object.Name|quote}})
+ {{- range $field := $object.Fields }}
+ case "{{$field.Name}}":
+ {{- if $field.IsConcurrent }}
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}})
+ {{- if $field.TypeReference.GQL.NonNull }}
+ if res == graphql.Null {
+ {{- if $object.IsConcurrent }}
+ atomic.AddUint32(&invalids, 1)
+ {{- else }}
+ invalids++
+ {{- end }}
+ }
+ {{- end }}
+ return res
+ }
+
+ {{if $object.Root}}
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+ {{end}}
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ {{- if $object.Root -}}
+ return rrm(innerCtx)
+ {{- else -}}
+ return innerFunc(ctx)
+ {{end}}
+ })
+ {{- else }}
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}})
+ }
+ {{if $object.Root}}
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+ {{else}}
+ out.Values[i] = innerFunc(ctx)
+ {{end}}
+
+ {{- if $field.TypeReference.GQL.NonNull }}
+ if out.Values[i] == graphql.Null {
+ {{- if $object.IsConcurrent }}
+ atomic.AddUint32(&invalids, 1)
+ {{- else }}
+ invalids++
+ {{- end }}
+ }
+ {{- end }}
+ {{- end }}
+ {{- end }}
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
}
out.Dispatch()
if invalids > 0 { return graphql.Null }
diff --git a/codegen/root_.gotpl b/codegen/root_.gotpl
new file mode 100644
index 00000000000..13d77961837
--- /dev/null
+++ b/codegen/root_.gotpl
@@ -0,0 +1,201 @@
+{{ reserveImport "context" }}
+{{ reserveImport "fmt" }}
+{{ reserveImport "io" }}
+{{ reserveImport "strconv" }}
+{{ reserveImport "time" }}
+{{ reserveImport "sync" }}
+{{ reserveImport "sync/atomic" }}
+{{ reserveImport "errors" }}
+{{ reserveImport "bytes" }}
+
+{{ reserveImport "github.com/vektah/gqlparser/v2" "gqlparser" }}
+{{ reserveImport "github.com/vektah/gqlparser/v2/ast" }}
+{{ reserveImport "github.com/99designs/gqlgen/graphql" }}
+{{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }}
+
+// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.
+func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
+ return &executableSchema{
+ resolvers: cfg.Resolvers,
+ directives: cfg.Directives,
+ complexity: cfg.Complexity,
+ }
+}
+
+type Config struct {
+ Resolvers ResolverRoot
+ Directives DirectiveRoot
+ Complexity ComplexityRoot
+}
+
+type ResolverRoot interface {
+{{- range $object := .Objects -}}
+ {{ if $object.HasResolvers -}}
+ {{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver
+ {{ end }}
+{{- end }}
+}
+
+type DirectiveRoot struct {
+{{ range $directive := .Directives }}
+ {{- $directive.Declaration }}
+{{ end }}
+}
+
+type ComplexityRoot struct {
+{{ range $object := .Objects }}
+ {{ if not $object.IsReserved -}}
+ {{ ucFirst $object.Name }} struct {
+ {{ range $_, $fields := $object.UniqueFields }}
+ {{- $field := index $fields 0 -}}
+ {{ if not $field.IsReserved -}}
+ {{ $field.GoFieldName }} {{ $field.ComplexitySignature }}
+ {{ end }}
+ {{- end }}
+ }
+ {{- end }}
+{{ end }}
+}
+
+type executableSchema struct {
+ resolvers ResolverRoot
+ directives DirectiveRoot
+ complexity ComplexityRoot
+}
+
+func (e *executableSchema) Schema() *ast.Schema {
+ return parsedSchema
+}
+
+func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {
+ ec := executionContext{nil, e}
+ _ = ec
+ switch typeName + "." + field {
+ {{ range $object := .Objects }}
+ {{ if not $object.IsReserved }}
+ {{ range $_, $fields := $object.UniqueFields }}
+ {{- $len := len $fields }}
+ {{- range $i, $field := $fields }}
+ {{- $last := eq (add $i 1) $len }}
+ {{- if not $field.IsReserved }}
+ {{- if eq $i 0 }}case {{ end }}"{{$object.Name}}.{{$field.Name}}"{{ if not $last }},{{ else }}:
+ if e.complexity.{{ucFirst $object.Name }}.{{$field.GoFieldName}} == nil {
+ break
+ }
+ {{ if $field.Args }}
+ args, err := ec.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)
+ if err != nil {
+ return 0, false
+ }
+ {{ end }}
+ return e.complexity.{{ucFirst $object.Name}}.{{$field.GoFieldName}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{ end }}), true
+ {{ end }}
+ {{- end }}
+ {{- end }}
+ {{ end }}
+ {{ end }}
+ {{ end }}
+ }
+ return 0, false
+}
+
+func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
+ rc := graphql.GetOperationContext(ctx)
+ ec := executionContext{rc, e}
+ first := true
+
+ switch rc.Operation.Operation {
+ {{- if .QueryRoot }} case ast.Query:
+ return func(ctx context.Context) *graphql.Response {
+ if !first { return nil }
+ first = false
+ {{ if .Directives.LocationDirectives "QUERY" -}}
+ data := ec._queryMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){
+ return ec._{{.QueryRoot.Name}}(ctx, rc.Operation.SelectionSet), nil
+ })
+ {{- else -}}
+ data := ec._{{.QueryRoot.Name}}(ctx, rc.Operation.SelectionSet)
+ {{- end }}
+ var buf bytes.Buffer
+ data.MarshalGQL(&buf)
+
+ return &graphql.Response{
+ Data: buf.Bytes(),
+ }
+ }
+ {{ end }}
+
+ {{- if .MutationRoot }} case ast.Mutation:
+ return func(ctx context.Context) *graphql.Response {
+ if !first { return nil }
+ first = false
+ {{ if .Directives.LocationDirectives "MUTATION" -}}
+ data := ec._mutationMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){
+ return ec._{{.MutationRoot.Name}}(ctx, rc.Operation.SelectionSet), nil
+ })
+ {{- else -}}
+ data := ec._{{.MutationRoot.Name}}(ctx, rc.Operation.SelectionSet)
+ {{- end }}
+ var buf bytes.Buffer
+ data.MarshalGQL(&buf)
+
+ return &graphql.Response{
+ Data: buf.Bytes(),
+ }
+ }
+ {{ end }}
+
+ {{- if .SubscriptionRoot }} case ast.Subscription:
+ {{ if .Directives.LocationDirectives "SUBSCRIPTION" -}}
+ next := ec._subscriptionMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){
+ return ec._{{.SubscriptionRoot.Name}}(ctx, rc.Operation.SelectionSet),nil
+ })
+ {{- else -}}
+ next := ec._{{.SubscriptionRoot.Name}}(ctx, rc.Operation.SelectionSet)
+ {{- end }}
+
+ var buf bytes.Buffer
+ return func(ctx context.Context) *graphql.Response {
+ buf.Reset()
+ data := next()
+
+ if data == nil {
+ return nil
+ }
+ data.MarshalGQL(&buf)
+
+ return &graphql.Response{
+ Data: buf.Bytes(),
+ }
+ }
+ {{ end }}
+ default:
+ return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation"))
+ }
+}
+
+type executionContext struct {
+ *graphql.OperationContext
+ *executableSchema
+}
+
+func (ec *executionContext) introspectSchema() (*introspection.Schema, error) {
+ if ec.DisableIntrospection {
+ return nil, errors.New("introspection disabled")
+ }
+ return introspection.WrapSchema(parsedSchema), nil
+}
+
+func (ec *executionContext) introspectType(name string) (*introspection.Type, error) {
+ if ec.DisableIntrospection {
+ return nil, errors.New("introspection disabled")
+ }
+ return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil
+}
+
+var sources = []*ast.Source{
+{{- range $source := .Config.Sources }}
+ {Name: {{$source.Name|quote}}, Input: {{$source.Input|rawQuote}}, BuiltIn: {{$source.BuiltIn}}},
+{{- end }}
+}
+var parsedSchema = gqlparser.MustLoadSchema(sources...)
diff --git a/codegen/templates/import.go b/codegen/templates/import.go
index 17bd96ab2eb..00a82ea5ef1 100644
--- a/codegen/templates/import.go
+++ b/codegen/templates/import.go
@@ -105,7 +105,7 @@ func (s *Imports) Lookup(path string) string {
for s.findByAlias(alias) != nil {
alias = imp.Name + strconv.Itoa(i)
i++
- if i > 10 {
+ if i > 1000 {
panic(fmt.Errorf("too many collisions, last attempt was %s", alias))
}
}
diff --git a/codegen/templates/import_test.go b/codegen/templates/import_test.go
index 2e8dd5a89aa..a91d2a8ccd3 100644
--- a/codegen/templates/import_test.go
+++ b/codegen/templates/import_test.go
@@ -1,6 +1,7 @@
package templates
import (
+ "fmt"
"go/types"
"os"
"testing"
@@ -45,6 +46,19 @@ func TestImports(t *testing.T) {
})
})
+ t.Run("duplicates above 10 are decollisioned", func(t *testing.T) {
+ a := Imports{destDir: wd, packages: &code.Packages{}}
+ for i := 0; i < 100; i++ {
+ cBar := fmt.Sprintf("github.com/99designs/gqlgen/codegen/templates/testdata/%d/bar", i)
+ if i > 0 {
+ require.Equal(t, fmt.Sprintf("bar%d", i), a.Lookup(cBar))
+ } else {
+ require.Equal(t, "bar", a.Lookup(cBar))
+
+ }
+ }
+ })
+
t.Run("package name defined in code will be used", func(t *testing.T) {
a := Imports{destDir: wd, packages: &code.Packages{}}
diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go
index 79b0c5c7d46..2358452af27 100644
--- a/codegen/templates/templates.go
+++ b/codegen/templates/templates.go
@@ -18,7 +18,6 @@ import (
"github.com/99designs/gqlgen/internal/code"
"github.com/99designs/gqlgen/internal/imports"
- "github.com/pkg/errors"
)
// CurrentImports keeps track of all the import declarations that are needed during the execution of a plugin.
@@ -79,7 +78,7 @@ func Render(cfg Options) error {
var err error
t, err = t.New("template.gotpl").Parse(cfg.Template)
if err != nil {
- return errors.Wrap(err, "error with provided template")
+ return fmt.Errorf("error with provided template: %w", err)
}
roots = append(roots, "template.gotpl")
} else {
@@ -92,6 +91,10 @@ func Render(cfg Options) error {
if !strings.HasSuffix(info.Name(), ".gotpl") {
return nil
}
+ // omit any templates with "_" at the end of their name, which are meant for specific contexts only
+ if strings.HasSuffix(info.Name(), "_.gotpl") {
+ return nil
+ }
b, err := ioutil.ReadFile(path)
if err != nil {
return err
@@ -99,7 +102,7 @@ func Render(cfg Options) error {
t, err = t.New(name).Parse(string(b))
if err != nil {
- return errors.Wrap(err, cfg.Filename)
+ return fmt.Errorf("%s: %w", cfg.Filename, err)
}
roots = append(roots, name)
@@ -107,7 +110,7 @@ func Render(cfg Options) error {
return nil
})
if err != nil {
- return errors.Wrap(err, "locating templates")
+ return fmt.Errorf("locating templates: %w", err)
}
}
@@ -129,7 +132,7 @@ func Render(cfg Options) error {
}
err := t.Lookup(root).Execute(&buf, cfg.Data)
if err != nil {
- return errors.Wrap(err, root)
+ return fmt.Errorf("%s: %w", root, err)
}
if cfg.RegionTags {
buf.WriteString("\n// endregion " + center(70, "*", " "+root+" ") + "\n")
@@ -456,12 +459,15 @@ var commonInitialisms = map[string]bool{
"HTML": true,
"HTTP": true,
"HTTPS": true,
+ "ICMP": true,
"ID": true,
"IP": true,
"JSON": true,
+ "KVK": true,
"LHS": true,
"PGP": true,
"QPS": true,
+ "QR": true,
"RAM": true,
"RHS": true,
"RPC": true,
@@ -469,16 +475,17 @@ var commonInitialisms = map[string]bool{
"SMTP": true,
"SQL": true,
"SSH": true,
+ "SVG": true,
"TCP": true,
"TLS": true,
"TTL": true,
"UDP": true,
"UI": true,
"UID": true,
- "UUID": true,
"URI": true,
"URL": true,
"UTF8": true,
+ "UUID": true,
"VM": true,
"XML": true,
"XMPP": true,
@@ -487,7 +494,7 @@ var commonInitialisms = map[string]bool{
}
func rawQuote(s string) string {
- return "`" + strings.Replace(s, "`", "`+\"`\"+`", -1) + "`"
+ return "`" + strings.ReplaceAll(s, "`", "`+\"`\"+`") + "`"
}
func notNil(field string, data interface{}) bool {
@@ -549,7 +556,7 @@ func Dump(val interface{}) string {
}
func prefixLines(prefix, s string) string {
- return prefix + strings.Replace(s, "\n", "\n"+prefix, -1)
+ return prefix + strings.ReplaceAll(s, "\n", "\n"+prefix)
}
func resolveName(name string, skip int) string {
@@ -584,7 +591,7 @@ func render(filename string, tpldata interface{}) (*bytes.Buffer, error) {
func write(filename string, b []byte, packages *code.Packages) error {
err := os.MkdirAll(filepath.Dir(filename), 0755)
if err != nil {
- return errors.Wrap(err, "failed to create directory")
+ return fmt.Errorf("failed to create directory: %w", err)
}
formatted, err := imports.Prune(filename, b, packages)
@@ -595,7 +602,7 @@ func write(filename string, b []byte, packages *code.Packages) error {
err = ioutil.WriteFile(filename, formatted, 0644)
if err != nil {
- return errors.Wrapf(err, "failed to write %s", filename)
+ return fmt.Errorf("failed to write %s: %w", filename, err)
}
return nil
diff --git a/codegen/testserver/empty.go b/codegen/testserver/empty.go
new file mode 100644
index 00000000000..e46955dab29
--- /dev/null
+++ b/codegen/testserver/empty.go
@@ -0,0 +1,3 @@
+package testserver
+
+// Empty file to silence go build error complaining that codegen/testserver/ has no non-test Go source files.
diff --git a/codegen/testserver/followschema/builtinscalar.generated.go b/codegen/testserver/followschema/builtinscalar.generated.go
new file mode 100644
index 00000000000..6b58040853b
--- /dev/null
+++ b/codegen/testserver/followschema/builtinscalar.generated.go
@@ -0,0 +1,106 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _Map_id(ctx context.Context, field graphql.CollectedField, obj *Map) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Map",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var mapImplementors = []string{"Map"}
+
+func (ec *executionContext) _Map(ctx context.Context, sel ast.SelectionSet, obj *Map) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, mapImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Map")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Map_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/builtinscalar.graphql b/codegen/testserver/followschema/builtinscalar.graphql
similarity index 100%
rename from codegen/testserver/builtinscalar.graphql
rename to codegen/testserver/followschema/builtinscalar.graphql
diff --git a/codegen/testserver/followschema/bytes.go b/codegen/testserver/followschema/bytes.go
new file mode 100644
index 00000000000..10395285ae0
--- /dev/null
+++ b/codegen/testserver/followschema/bytes.go
@@ -0,0 +1,27 @@
+package followschema
+
+import (
+ "fmt"
+ "io"
+
+ "github.com/99designs/gqlgen/graphql"
+)
+
+func MarshalBytes(b []byte) graphql.Marshaler {
+ return graphql.WriterFunc(func(w io.Writer) {
+ _, _ = fmt.Fprintf(w, "%q", string(b))
+ })
+}
+
+func UnmarshalBytes(v interface{}) ([]byte, error) {
+ switch v := v.(type) {
+ case string:
+ return []byte(v), nil
+ case *string:
+ return []byte(*v), nil
+ case []byte:
+ return v, nil
+ default:
+ return nil, fmt.Errorf("%T is not []byte", v)
+ }
+}
diff --git a/codegen/testserver/followschema/complexity.generated.go b/codegen/testserver/followschema/complexity.generated.go
new file mode 100644
index 00000000000..f39c2ebeb17
--- /dev/null
+++ b/codegen/testserver/followschema/complexity.generated.go
@@ -0,0 +1,296 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+ "sync/atomic"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+type OverlappingFieldsResolver interface {
+ OldFoo(ctx context.Context, obj *OverlappingFields) (int, error)
+}
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "OverlappingFields",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Foo, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "OverlappingFields",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Foo, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "OverlappingFields",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.OverlappingFields().OldFoo(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "OverlappingFields",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.NewFoo, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "OverlappingFields",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.NewFoo, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var overlappingFieldsImplementors = []string{"OverlappingFields"}
+
+func (ec *executionContext) _OverlappingFields(ctx context.Context, sel ast.SelectionSet, obj *OverlappingFields) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, overlappingFieldsImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("OverlappingFields")
+ case "oneFoo":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._OverlappingFields_oneFoo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ case "twoFoo":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._OverlappingFields_twoFoo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ case "oldFoo":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._OverlappingFields_oldFoo(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "newFoo":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._OverlappingFields_newFoo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ case "new_foo":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._OverlappingFields_new_foo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOverlappingFields(ctx context.Context, sel ast.SelectionSet, v *OverlappingFields) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._OverlappingFields(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/complexity.graphql b/codegen/testserver/followschema/complexity.graphql
similarity index 100%
rename from codegen/testserver/complexity.graphql
rename to codegen/testserver/followschema/complexity.graphql
diff --git a/codegen/testserver/followschema/complexity_test.go b/codegen/testserver/followschema/complexity_test.go
new file mode 100644
index 00000000000..6a91e0f0005
--- /dev/null
+++ b/codegen/testserver/followschema/complexity_test.go
@@ -0,0 +1,119 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/99designs/gqlgen/graphql/handler/extension"
+ "github.com/stretchr/testify/require"
+)
+
+func TestComplexityCollisions(t *testing.T) {
+ resolvers := &Stub{}
+
+ srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))
+
+ c := client.New(srv)
+
+ resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) {
+ return &OverlappingFields{
+ Foo: 2,
+ NewFoo: 3,
+ }, nil
+ }
+
+ resolvers.OverlappingFieldsResolver.OldFoo = func(ctx context.Context, obj *OverlappingFields) (i int, e error) {
+ return obj.Foo, nil
+ }
+
+ var resp struct {
+ Overlapping struct {
+ OneFoo int `json:"oneFoo"`
+ TwoFoo int `json:"twoFoo"`
+ OldFoo int `json:"oldFoo"`
+ NewFoo int `json:"newFoo"`
+ New_foo int `json:"new_foo"`
+ }
+ }
+ c.MustPost(`query { overlapping { oneFoo, twoFoo, oldFoo, newFoo, new_foo } }`, &resp)
+ require.Equal(t, 2, resp.Overlapping.OneFoo)
+ require.Equal(t, 2, resp.Overlapping.TwoFoo)
+ require.Equal(t, 2, resp.Overlapping.OldFoo)
+ require.Equal(t, 3, resp.Overlapping.NewFoo)
+ require.Equal(t, 3, resp.Overlapping.New_foo)
+}
+
+func TestComplexityFuncs(t *testing.T) {
+ resolvers := &Stub{}
+ cfg := Config{Resolvers: resolvers}
+ cfg.Complexity.OverlappingFields.Foo = func(childComplexity int) int { return 1000 }
+ cfg.Complexity.OverlappingFields.NewFoo = func(childComplexity int) int { return 5 }
+
+ srv := handler.NewDefaultServer(NewExecutableSchema(cfg))
+ srv.Use(extension.FixedComplexityLimit(10))
+ c := client.New(srv)
+
+ resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) {
+ return &OverlappingFields{
+ Foo: 2,
+ NewFoo: 3,
+ }, nil
+ }
+
+ t.Run("with high complexity limit will not run", func(t *testing.T) {
+ ran := false
+ resolvers.OverlappingFieldsResolver.OldFoo = func(ctx context.Context, obj *OverlappingFields) (i int, e error) {
+ ran = true
+ return obj.Foo, nil
+ }
+
+ var resp struct {
+ Overlapping interface{}
+ }
+ err := c.Post(`query { overlapping { oneFoo, twoFoo, oldFoo, newFoo, new_foo } }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"operation has complexity 2012, which exceeds the limit of 10","extensions":{"code":"COMPLEXITY_LIMIT_EXCEEDED"}}]`)
+ require.False(t, ran)
+ })
+
+ t.Run("with low complexity will run", func(t *testing.T) {
+ ran := false
+ resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) {
+ ran = true
+ return &OverlappingFields{
+ Foo: 2,
+ NewFoo: 3,
+ }, nil
+ }
+
+ var resp struct {
+ Overlapping interface{}
+ }
+ c.MustPost(`query { overlapping { newFoo } }`, &resp)
+
+ require.True(t, ran)
+ })
+
+ t.Run("with multiple low complexity will not run", func(t *testing.T) {
+ ran := false
+ resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) {
+ ran = true
+ return &OverlappingFields{
+ Foo: 2,
+ NewFoo: 3,
+ }, nil
+ }
+
+ var resp interface{}
+ err := c.Post(`query {
+ a: overlapping { newFoo },
+ b: overlapping { newFoo },
+ c: overlapping { newFoo },
+ }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"operation has complexity 18, which exceeds the limit of 10","extensions":{"code":"COMPLEXITY_LIMIT_EXCEEDED"}}]`)
+ require.False(t, ran)
+ })
+}
diff --git a/codegen/testserver/followschema/defaults.generated.go b/codegen/testserver/followschema/defaults.generated.go
new file mode 100644
index 00000000000..a62937e031b
--- /dev/null
+++ b/codegen/testserver/followschema/defaults.generated.go
@@ -0,0 +1,421 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+type MutationResolver interface {
+ DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error)
+ UpdateSomething(ctx context.Context, input SpecialInput) (string, error)
+ UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error)
+}
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+func (ec *executionContext) field_Mutation_defaultInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 DefaultInput
+ if tmp, ok := rawArgs["input"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
+ arg0, err = ec.unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultInput(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["input"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Mutation_updatePtrToPtr_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 UpdatePtrToPtrOuter
+ if tmp, ok := rawArgs["input"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
+ arg0, err = ec.unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrOuter(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["input"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Mutation_updateSomething_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 SpecialInput
+ if tmp, ok := rawArgs["input"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
+ arg0, err = ec.unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSpecialInput(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["input"] = arg0
+ return args, nil
+}
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "DefaultParametersMirror",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.FalsyBoolean, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*bool)
+ fc.Result = res
+ return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "DefaultParametersMirror",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.TruthyBoolean, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*bool)
+ fc.Result = res
+ return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Mutation",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Mutation_defaultInput_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Mutation().DefaultInput(rctx, args["input"].(DefaultInput))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*DefaultParametersMirror)
+ fc.Result = res
+ return ec.marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Mutation",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Mutation_updateSomething_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Mutation().UpdateSomething(rctx, args["input"].(SpecialInput))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Mutation",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Mutation_updatePtrToPtr_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Mutation().UpdatePtrToPtr(rctx, args["input"].(UpdatePtrToPtrOuter))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*PtrToPtrOuter)
+ fc.Result = res
+ return ec.marshalNPtrToPtrOuter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrOuter(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+func (ec *executionContext) unmarshalInputDefaultInput(ctx context.Context, obj interface{}) (DefaultInput, error) {
+ var it DefaultInput
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ if _, present := asMap["falsyBoolean"]; !present {
+ asMap["falsyBoolean"] = false
+ }
+ if _, present := asMap["truthyBoolean"]; !present {
+ asMap["truthyBoolean"] = true
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "falsyBoolean":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("falsyBoolean"))
+ it.FalsyBoolean, err = ec.unmarshalOBoolean2ᚖbool(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "truthyBoolean":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("truthyBoolean"))
+ it.TruthyBoolean, err = ec.unmarshalOBoolean2ᚖbool(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var defaultParametersMirrorImplementors = []string{"DefaultParametersMirror"}
+
+func (ec *executionContext) _DefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, obj *DefaultParametersMirror) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, defaultParametersMirrorImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("DefaultParametersMirror")
+ case "falsyBoolean":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._DefaultParametersMirror_falsyBoolean(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "truthyBoolean":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._DefaultParametersMirror_truthyBoolean(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var mutationImplementors = []string{"Mutation"}
+
+func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors)
+ ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
+ Object: "Mutation",
+ })
+
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Mutation")
+ case "defaultInput":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_defaultInput(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "updateSomething":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_updateSomething(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "updatePtrToPtr":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_updatePtrToPtr(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultInput(ctx context.Context, v interface{}) (DefaultInput, error) {
+ res, err := ec.unmarshalInputDefaultInput(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNDefaultParametersMirror2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v DefaultParametersMirror) graphql.Marshaler {
+ return ec._DefaultParametersMirror(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v *DefaultParametersMirror) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._DefaultParametersMirror(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/followschema/defaults.graphql b/codegen/testserver/followschema/defaults.graphql
new file mode 100644
index 00000000000..1c9a9ebf03d
--- /dev/null
+++ b/codegen/testserver/followschema/defaults.graphql
@@ -0,0 +1,20 @@
+extend type Query {
+ defaultParameters(
+ falsyBoolean: Boolean = false
+ truthyBoolean: Boolean = true
+ ): DefaultParametersMirror!
+}
+
+extend type Mutation {
+ defaultInput(input: DefaultInput!): DefaultParametersMirror!
+}
+
+input DefaultInput {
+ falsyBoolean: Boolean = false
+ truthyBoolean: Boolean = true
+}
+
+type DefaultParametersMirror {
+ falsyBoolean: Boolean
+ truthyBoolean: Boolean
+}
diff --git a/codegen/testserver/followschema/defaults_test.go b/codegen/testserver/followschema/defaults_test.go
new file mode 100644
index 00000000000..e5708a72e33
--- /dev/null
+++ b/codegen/testserver/followschema/defaults_test.go
@@ -0,0 +1,68 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func assertDefaults(t *testing.T, ret *DefaultParametersMirror) {
+ require.NotNil(t, ret)
+ require.NotNil(t, ret.FalsyBoolean)
+ require.Equal(t, *ret.FalsyBoolean, false)
+ require.NotNil(t, ret.TruthyBoolean)
+ require.Equal(t, *ret.TruthyBoolean, true)
+}
+
+func TestDefaults(t *testing.T) {
+ resolvers := &Stub{}
+ srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))
+ c := client.New(srv)
+
+ t.Run("default field parameters", func(t *testing.T) {
+ resolvers.QueryResolver.DefaultParameters = func(
+ ctx context.Context,
+ falsyBoolean, truthyBoolean *bool,
+ ) (*DefaultParametersMirror, error) {
+ return &DefaultParametersMirror{
+ FalsyBoolean: falsyBoolean,
+ TruthyBoolean: truthyBoolean,
+ }, nil
+ }
+
+ var resp struct{ DefaultParameters *DefaultParametersMirror }
+ err := c.Post(`query {
+ defaultParameters {
+ falsyBoolean
+ truthyBoolean
+ }
+ }`, &resp)
+ require.NoError(t, err)
+ assertDefaults(t, resp.DefaultParameters)
+ })
+
+ t.Run("default input fields", func(t *testing.T) {
+ resolvers.MutationResolver.DefaultInput = func(
+ ctx context.Context,
+ input DefaultInput,
+ ) (*DefaultParametersMirror, error) {
+ return &DefaultParametersMirror{
+ FalsyBoolean: input.FalsyBoolean,
+ TruthyBoolean: input.TruthyBoolean,
+ }, nil
+ }
+
+ var resp struct{ DefaultInput *DefaultParametersMirror }
+ err := c.Post(`mutation {
+ defaultInput(input: {}) {
+ falsyBoolean
+ truthyBoolean
+ }
+ }`, &resp)
+ require.NoError(t, err)
+ assertDefaults(t, resp.DefaultInput)
+ })
+}
diff --git a/codegen/testserver/followschema/directive.generated.go b/codegen/testserver/followschema/directive.generated.go
new file mode 100644
index 00000000000..70aecc97e4c
--- /dev/null
+++ b/codegen/testserver/followschema/directive.generated.go
@@ -0,0 +1,707 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+func (ec *executionContext) dir_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 int
+ if tmp, ok := rawArgs["min"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("min"))
+ arg0, err = ec.unmarshalNInt2int(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["min"] = arg0
+ var arg1 *int
+ if tmp, ok := rawArgs["max"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("max"))
+ arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["max"] = arg1
+ var arg2 *string
+ if tmp, ok := rawArgs["message"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("message"))
+ arg2, err = ec.unmarshalOString2ᚖstring(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["message"] = arg2
+ return args, nil
+}
+
+func (ec *executionContext) dir_logged_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["id"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
+ arg0, err = ec.unmarshalNUUID2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["id"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) dir_order1_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["location"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("location"))
+ arg0, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["location"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) dir_order2_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["location"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("location"))
+ arg0, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["location"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 *int
+ if tmp, ok := rawArgs["min"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("min"))
+ arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["min"] = arg0
+ var arg1 *int
+ if tmp, ok := rawArgs["max"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("max"))
+ arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["max"] = arg1
+ return args, nil
+}
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) interface{} {
+ fc := graphql.GetFieldContext(ctx)
+ for _, d := range fc.Field.Directives {
+ switch d.Name {
+ case "logged":
+ rawArgs := d.ArgumentMap(ec.Variables)
+ args, err := ec.dir_logged_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return nil
+ }
+ n := next
+ next = func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Logged == nil {
+ return nil, errors.New("directive logged is not implemented")
+ }
+ return ec.directives.Logged(ctx, obj, n, args["id"].(string))
+ }
+ }
+ }
+ res, err := ec.ResolverMiddleware(ctx, next)
+ if err != nil {
+ ec.Error(ctx, err)
+ return nil
+ }
+ return res
+}
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _ObjectDirectives_text(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ObjectDirectives",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Text, nil
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ min, err := ec.unmarshalNInt2int(ctx, 0)
+ if err != nil {
+ return nil, err
+ }
+ max, err := ec.unmarshalOInt2ᚖint(ctx, 7)
+ if err != nil {
+ return nil, err
+ }
+ message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Length == nil {
+ return nil, errors.New("directive length is not implemented")
+ }
+ return ec.directives.Length(ctx, obj, directive0, min, max, message)
+ }
+
+ tmp, err := directive1(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(string); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ObjectDirectives_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ObjectDirectives",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.NullableText, nil
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.ToNull == nil {
+ return nil, errors.New("directive toNull is not implemented")
+ }
+ return ec.directives.ToNull(ctx, obj, directive0)
+ }
+
+ tmp, err := directive1(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(*string); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ObjectDirectives_order(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ObjectDirectives",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Order, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]string)
+ fc.Result = res
+ return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ObjectDirectivesWithCustomGoModel_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectivesWithCustomGoModel) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ObjectDirectivesWithCustomGoModel",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.NullableText, nil
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.ToNull == nil {
+ return nil, errors.New("directive toNull is not implemented")
+ }
+ return ec.directives.ToNull(ctx, obj, directive0)
+ }
+
+ tmp, err := directive1(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(string); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+func (ec *executionContext) unmarshalInputInnerDirectives(ctx context.Context, obj interface{}) (InnerDirectives, error) {
+ var it InnerDirectives
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "message":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("message"))
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, v) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ min, err := ec.unmarshalNInt2int(ctx, 1)
+ if err != nil {
+ return nil, err
+ }
+ message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Length == nil {
+ return nil, errors.New("directive length is not implemented")
+ }
+ return ec.directives.Length(ctx, obj, directive0, min, nil, message)
+ }
+
+ tmp, err := directive1(ctx)
+ if err != nil {
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(string); ok {
+ it.Message = data
+ } else {
+ err := fmt.Errorf(`unexpected type %T from directive, should be string`, tmp)
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ }
+ }
+
+ return it, nil
+}
+
+func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, obj interface{}) (InputDirectives, error) {
+ var it InputDirectives
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "text":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text"))
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, v) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive3 == nil {
+ return nil, errors.New("directive directive3 is not implemented")
+ }
+ return ec.directives.Directive3(ctx, obj, directive0)
+ }
+ directive2 := func(ctx context.Context) (interface{}, error) {
+ min, err := ec.unmarshalNInt2int(ctx, 0)
+ if err != nil {
+ return nil, err
+ }
+ max, err := ec.unmarshalOInt2ᚖint(ctx, 7)
+ if err != nil {
+ return nil, err
+ }
+ message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Length == nil {
+ return nil, errors.New("directive length is not implemented")
+ }
+ return ec.directives.Length(ctx, obj, directive1, min, max, message)
+ }
+
+ tmp, err := directive2(ctx)
+ if err != nil {
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(string); ok {
+ it.Text = data
+ } else {
+ err := fmt.Errorf(`unexpected type %T from directive, should be string`, tmp)
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ case "nullableText":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nullableText"))
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive3 == nil {
+ return nil, errors.New("directive directive3 is not implemented")
+ }
+ return ec.directives.Directive3(ctx, obj, directive0)
+ }
+ directive2 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.ToNull == nil {
+ return nil, errors.New("directive toNull is not implemented")
+ }
+ return ec.directives.ToNull(ctx, obj, directive1)
+ }
+
+ tmp, err := directive2(ctx)
+ if err != nil {
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*string); ok {
+ it.NullableText = data
+ } else if tmp == nil {
+ it.NullableText = nil
+ } else {
+ err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp)
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ case "inner":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner"))
+ directive0 := func(ctx context.Context) (interface{}, error) {
+ return ec.unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerDirectives(ctx, v)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive3 == nil {
+ return nil, errors.New("directive directive3 is not implemented")
+ }
+ return ec.directives.Directive3(ctx, obj, directive0)
+ }
+
+ tmp, err := directive1(ctx)
+ if err != nil {
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*InnerDirectives); ok {
+ it.Inner = data
+ } else if tmp == nil {
+ it.Inner = nil
+ } else {
+ err := fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver/followschema.InnerDirectives`, tmp)
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ case "innerNullable":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("innerNullable"))
+ directive0 := func(ctx context.Context) (interface{}, error) {
+ return ec.unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerDirectives(ctx, v)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive3 == nil {
+ return nil, errors.New("directive directive3 is not implemented")
+ }
+ return ec.directives.Directive3(ctx, obj, directive0)
+ }
+
+ tmp, err := directive1(ctx)
+ if err != nil {
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*InnerDirectives); ok {
+ it.InnerNullable = data
+ } else if tmp == nil {
+ it.InnerNullable = nil
+ } else {
+ err := fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver/followschema.InnerDirectives`, tmp)
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ case "thirdParty":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("thirdParty"))
+ directive0 := func(ctx context.Context) (interface{}, error) {
+ return ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐThirdParty(ctx, v)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive3 == nil {
+ return nil, errors.New("directive directive3 is not implemented")
+ }
+ return ec.directives.Directive3(ctx, obj, directive0)
+ }
+ directive2 := func(ctx context.Context) (interface{}, error) {
+ min, err := ec.unmarshalNInt2int(ctx, 0)
+ if err != nil {
+ return nil, err
+ }
+ max, err := ec.unmarshalOInt2ᚖint(ctx, 7)
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Length == nil {
+ return nil, errors.New("directive length is not implemented")
+ }
+ return ec.directives.Length(ctx, obj, directive1, min, max, nil)
+ }
+
+ tmp, err := directive2(ctx)
+ if err != nil {
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*ThirdParty); ok {
+ it.ThirdParty = data
+ } else if tmp == nil {
+ it.ThirdParty = nil
+ } else {
+ err := fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver/followschema.ThirdParty`, tmp)
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ }
+ }
+
+ return it, nil
+}
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var objectDirectivesImplementors = []string{"ObjectDirectives"}
+
+func (ec *executionContext) _ObjectDirectives(ctx context.Context, sel ast.SelectionSet, obj *ObjectDirectives) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, objectDirectivesImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("ObjectDirectives")
+ case "text":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ObjectDirectives_text(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "nullableText":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ObjectDirectives_nullableText(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "order":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ObjectDirectives_order(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var objectDirectivesWithCustomGoModelImplementors = []string{"ObjectDirectivesWithCustomGoModel"}
+
+func (ec *executionContext) _ObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, obj *ObjectDirectivesWithCustomGoModel) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, objectDirectivesWithCustomGoModelImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("ObjectDirectivesWithCustomGoModel")
+ case "nullableText":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ObjectDirectivesWithCustomGoModel_nullableText(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) {
+ res, err := ec.unmarshalInputInnerDirectives(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputDirectives(ctx context.Context, v interface{}) (InputDirectives, error) {
+ res, err := ec.unmarshalInputInputDirectives(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalInputInnerDirectives(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputDirectives(ctx context.Context, v interface{}) (*InputDirectives, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalInputInputDirectives(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐObjectDirectives(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectives) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._ObjectDirectives(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectivesWithCustomGoModel) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._ObjectDirectivesWithCustomGoModel(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/directive.graphql b/codegen/testserver/followschema/directive.graphql
similarity index 88%
rename from codegen/testserver/directive.graphql
rename to codegen/testserver/followschema/directive.graphql
index 4005cfd8907..8cf2470986e 100644
--- a/codegen/testserver/directive.graphql
+++ b/codegen/testserver/followschema/directive.graphql
@@ -5,8 +5,9 @@ directive @logged(id: UUID!) on FIELD
directive @toNull on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION
directive @directive1 on FIELD_DEFINITION
directive @directive2 on FIELD_DEFINITION
+directive @directive3 on INPUT_OBJECT
directive @unimplemented on FIELD_DEFINITION
-directive @order1(location: String!) on FIELD_DEFINITION | OBJECT
+directive @order1(location: String!) repeatable on FIELD_DEFINITION | OBJECT
directive @order2(location: String!) on OBJECT
extend type Query {
@@ -30,7 +31,7 @@ extend type Subscription {
directiveUnimplemented: String @unimplemented
}
-input InputDirectives {
+input InputDirectives @directive3 {
text: String! @length(min: 0, max: 7, message: "not valid")
nullableText: String @toNull
inner: InnerDirectives!
@@ -42,7 +43,7 @@ input InnerDirectives {
message: String! @length(min: 1, message: "not valid")
}
-type ObjectDirectives @order1(location: "ObjectDirectives_object_1") @order2(location: "ObjectDirectives_object_2") {
+type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2") @order2(location: "order2_1") {
text: String! @length(min: 0, max: 7, message: "not valid")
nullableText: String @toNull
order: [String!]!
diff --git a/codegen/testserver/followschema/directive_test.go b/codegen/testserver/followschema/directive_test.go
new file mode 100644
index 00000000000..e995b2721cd
--- /dev/null
+++ b/codegen/testserver/followschema/directive_test.go
@@ -0,0 +1,465 @@
+package followschema
+
+import (
+ "context"
+ "fmt"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+type ckey string
+
+func TestDirectives(t *testing.T) {
+ resolvers := &Stub{}
+ ok := "Ok"
+ resolvers.QueryResolver.DirectiveArg = func(ctx context.Context, arg string) (i *string, e error) {
+ return &ok, nil
+ }
+
+ resolvers.QueryResolver.DirectiveInput = func(ctx context.Context, arg InputDirectives) (i *string, e error) {
+ return &ok, nil
+ }
+
+ resolvers.QueryResolver.DirectiveInputNullable = func(ctx context.Context, arg *InputDirectives) (i *string, e error) {
+ return &ok, nil
+ }
+
+ resolvers.QueryResolver.DirectiveNullableArg = func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) {
+ return &ok, nil
+ }
+
+ resolvers.QueryResolver.DirectiveInputType = func(ctx context.Context, arg InnerInput) (i *string, e error) {
+ return &ok, nil
+ }
+
+ resolvers.QueryResolver.DirectiveObject = func(ctx context.Context) (*ObjectDirectives, error) {
+ return &ObjectDirectives{
+ Text: ok,
+ NullableText: &ok,
+ }, nil
+ }
+
+ resolvers.QueryResolver.DirectiveObjectWithCustomGoModel = func(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) {
+ return &ObjectDirectivesWithCustomGoModel{
+ NullableText: ok,
+ }, nil
+ }
+
+ resolvers.QueryResolver.DirectiveField = func(ctx context.Context) (*string, error) {
+ if s, ok := ctx.Value(ckey("request_id")).(*string); ok {
+ return s, nil
+ }
+
+ return nil, nil
+ }
+
+ resolvers.QueryResolver.DirectiveDouble = func(ctx context.Context) (*string, error) {
+ return &ok, nil
+ }
+
+ resolvers.QueryResolver.DirectiveUnimplemented = func(ctx context.Context) (*string, error) {
+ return &ok, nil
+ }
+
+ okchan := func() (<-chan *string, error) {
+ res := make(chan *string, 1)
+ res <- &ok
+ close(res)
+ return res, nil
+ }
+
+ resolvers.SubscriptionResolver.DirectiveArg = func(ctx context.Context, arg string) (strings <-chan *string, e error) {
+ return okchan()
+ }
+
+ resolvers.SubscriptionResolver.DirectiveNullableArg = func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (strings <-chan *string, e error) {
+ return okchan()
+ }
+
+ resolvers.SubscriptionResolver.DirectiveDouble = func(ctx context.Context) (strings <-chan *string, e error) {
+ return okchan()
+ }
+
+ resolvers.SubscriptionResolver.DirectiveUnimplemented = func(ctx context.Context) (<-chan *string, error) {
+ return okchan()
+ }
+ srv := handler.NewDefaultServer(NewExecutableSchema(Config{
+ Resolvers: resolvers,
+ Directives: DirectiveRoot{
+ Length: func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message *string) (interface{}, error) {
+ e := func(msg string) error {
+ if message == nil {
+ return fmt.Errorf(msg)
+ }
+ return fmt.Errorf(*message)
+ }
+ res, err := next(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ s := res.(string)
+ if len(s) < min {
+ return nil, e("too short")
+ }
+ if max != nil && len(s) > *max {
+ return nil, e("too long")
+ }
+ return res, nil
+ },
+ Range: func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int) (interface{}, error) {
+ res, err := next(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ switch res := res.(type) {
+ case int:
+ if min != nil && res < *min {
+ return nil, fmt.Errorf("too small")
+ }
+ if max != nil && res > *max {
+ return nil, fmt.Errorf("too large")
+ }
+ return next(ctx)
+
+ case int64:
+ if min != nil && int(res) < *min {
+ return nil, fmt.Errorf("too small")
+ }
+ if max != nil && int(res) > *max {
+ return nil, fmt.Errorf("too large")
+ }
+ return next(ctx)
+
+ case *int:
+ if min != nil && *res < *min {
+ return nil, fmt.Errorf("too small")
+ }
+ if max != nil && *res > *max {
+ return nil, fmt.Errorf("too large")
+ }
+ return next(ctx)
+ }
+ return nil, fmt.Errorf("unsupported type %T", res)
+ },
+ Custom: func(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) {
+ return next(ctx)
+ },
+ Logged: func(ctx context.Context, obj interface{}, next graphql.Resolver, id string) (interface{}, error) {
+ return next(context.WithValue(ctx, ckey("request_id"), &id))
+ },
+ ToNull: func(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) {
+ return nil, nil
+ },
+ Directive1: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
+ return next(ctx)
+ },
+ Directive2: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
+ return next(ctx)
+ },
+ Directive3: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
+ return next(ctx)
+ },
+ Order1: func(ctx context.Context, obj interface{}, next graphql.Resolver, location string) (res interface{}, err error) {
+ order := []string{location}
+ res, err = next(ctx)
+ od := res.(*ObjectDirectives)
+ od.Order = append(order, od.Order...)
+ return od, err
+ },
+ Order2: func(ctx context.Context, obj interface{}, next graphql.Resolver, location string) (res interface{}, err error) {
+ order := []string{location}
+ res, err = next(ctx)
+ od := res.(*ObjectDirectives)
+ od.Order = append(order, od.Order...)
+ return od, err
+ },
+ Unimplemented: nil,
+ },
+ }))
+
+ srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
+ path, _ := ctx.Value(ckey("path")).([]int)
+ return next(context.WithValue(ctx, ckey("path"), append(path, 1)))
+ })
+
+ srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
+ path, _ := ctx.Value(ckey("path")).([]int)
+ return next(context.WithValue(ctx, ckey("path"), append(path, 2)))
+ })
+
+ c := client.New(srv)
+
+ t.Run("arg directives", func(t *testing.T) {
+ t.Run("when function errors on directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveArg *string
+ }
+
+ err := c.Post(`query { directiveArg(arg: "") }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"invalid length","path":["directiveArg","arg"]}]`)
+ require.Nil(t, resp.DirectiveArg)
+ })
+ t.Run("when function errors on nullable arg directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveNullableArg *string
+ }
+
+ err := c.Post(`query { directiveNullableArg(arg: -100) }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"too small","path":["directiveNullableArg","arg"]}]`)
+ require.Nil(t, resp.DirectiveNullableArg)
+ })
+ t.Run("when function success on nullable arg directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveNullableArg *string
+ }
+
+ err := c.Post(`query { directiveNullableArg }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, "Ok", *resp.DirectiveNullableArg)
+ })
+ t.Run("when function success on valid nullable arg directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveNullableArg *string
+ }
+
+ err := c.Post(`query { directiveNullableArg(arg: 1) }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, "Ok", *resp.DirectiveNullableArg)
+ })
+ t.Run("when function success", func(t *testing.T) {
+ var resp struct {
+ DirectiveArg *string
+ }
+
+ err := c.Post(`query { directiveArg(arg: "test") }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, "Ok", *resp.DirectiveArg)
+ })
+ })
+ t.Run("field definition directives", func(t *testing.T) {
+ resolvers.QueryResolver.DirectiveFieldDef = func(ctx context.Context, ret string) (i string, e error) {
+ return ret, nil
+ }
+
+ t.Run("too short", func(t *testing.T) {
+ var resp struct {
+ DirectiveFieldDef string
+ }
+
+ err := c.Post(`query { directiveFieldDef(ret: "") }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"not valid","path":["directiveFieldDef"]}]`)
+ })
+
+ t.Run("has 2 directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveDouble string
+ }
+
+ c.MustPost(`query { directiveDouble }`, &resp)
+
+ require.Equal(t, "Ok", resp.DirectiveDouble)
+ })
+
+ t.Run("directive is not implemented", func(t *testing.T) {
+ var resp struct {
+ DirectiveUnimplemented string
+ }
+
+ err := c.Post(`query { directiveUnimplemented }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"directive unimplemented is not implemented","path":["directiveUnimplemented"]}]`)
+ })
+
+ t.Run("ok", func(t *testing.T) {
+ var resp struct {
+ DirectiveFieldDef string
+ }
+
+ c.MustPost(`query { directiveFieldDef(ret: "aaa") }`, &resp)
+
+ require.Equal(t, "aaa", resp.DirectiveFieldDef)
+ })
+ })
+ t.Run("field directives", func(t *testing.T) {
+ t.Run("add field directive", func(t *testing.T) {
+ var resp struct {
+ DirectiveField string
+ }
+
+ c.MustPost(`query { directiveField@logged(id:"testes_id") }`, &resp)
+
+ require.Equal(t, resp.DirectiveField, `testes_id`)
+ })
+ t.Run("without field directive", func(t *testing.T) {
+ var resp struct {
+ DirectiveField *string
+ }
+
+ c.MustPost(`query { directiveField }`, &resp)
+
+ require.Nil(t, resp.DirectiveField)
+ })
+ })
+ t.Run("input field directives", func(t *testing.T) {
+ t.Run("when function errors on directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveInputNullable *string
+ }
+
+ err := c.Post(`query { directiveInputNullable(arg: {text:"invalid text",inner:{message:"123"}}) }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"not valid","path":["directiveInputNullable","arg","text"]}]`)
+ require.Nil(t, resp.DirectiveInputNullable)
+ })
+ t.Run("when function errors on inner directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveInputNullable *string
+ }
+
+ err := c.Post(`query { directiveInputNullable(arg: {text:"2",inner:{message:""}}) }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"not valid","path":["directiveInputNullable","arg","inner","message"]}]`)
+ require.Nil(t, resp.DirectiveInputNullable)
+ })
+ t.Run("when function errors on nullable inner directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveInputNullable *string
+ }
+
+ err := c.Post(`query { directiveInputNullable(arg: {text:"success",inner:{message:"1"},innerNullable:{message:""}}) }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"not valid","path":["directiveInputNullable","arg","innerNullable","message"]}]`)
+ require.Nil(t, resp.DirectiveInputNullable)
+ })
+ t.Run("when function success", func(t *testing.T) {
+ var resp struct {
+ DirectiveInputNullable *string
+ }
+
+ err := c.Post(`query { directiveInputNullable(arg: {text:"23",inner:{message:"1"}}) }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, "Ok", *resp.DirectiveInputNullable)
+ })
+ t.Run("when function inner nullable success", func(t *testing.T) {
+ var resp struct {
+ DirectiveInputNullable *string
+ }
+
+ err := c.Post(`query { directiveInputNullable(arg: {text:"23",nullableText:"23",inner:{message:"1"},innerNullable:{message:"success"}}) }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, "Ok", *resp.DirectiveInputNullable)
+ })
+ t.Run("when arg has directive", func(t *testing.T) {
+ var resp struct {
+ DirectiveInputType *string
+ }
+
+ err := c.Post(`query { directiveInputType(arg: {id: 1}) }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, "Ok", *resp.DirectiveInputType)
+ })
+ })
+ t.Run("object field directives", func(t *testing.T) {
+ t.Run("when function success", func(t *testing.T) {
+ var resp struct {
+ DirectiveObject *struct {
+ Text string
+ NullableText *string
+ Order []string
+ }
+ }
+
+ err := c.Post(`query { directiveObject{ text nullableText order} }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, "Ok", resp.DirectiveObject.Text)
+ require.True(t, resp.DirectiveObject.NullableText == nil)
+ require.Equal(t, "Query_field", resp.DirectiveObject.Order[0])
+ require.Equal(t, "order2_1", resp.DirectiveObject.Order[1])
+ require.Equal(t, "order1_2", resp.DirectiveObject.Order[2])
+ require.Equal(t, "order1_1", resp.DirectiveObject.Order[3])
+ })
+ t.Run("when directive returns nil & custom go field is not nilable", func(t *testing.T) {
+ var resp struct {
+ DirectiveObjectWithCustomGoModel *struct {
+ NullableText *string
+ }
+ }
+
+ err := c.Post(`query { directiveObjectWithCustomGoModel{ nullableText } }`, &resp)
+
+ require.Nil(t, err)
+ require.True(t, resp.DirectiveObjectWithCustomGoModel.NullableText == nil)
+ })
+ })
+
+ t.Run("Subscription directives", func(t *testing.T) {
+ t.Run("arg directives", func(t *testing.T) {
+ t.Run("when function errors on directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveArg *string
+ }
+
+ err := c.WebsocketOnce(`subscription { directiveArg(arg: "") }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"invalid length","path":["directiveArg","arg"]}]`)
+ require.Nil(t, resp.DirectiveArg)
+ })
+ t.Run("when function errors on nullable arg directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveNullableArg *string
+ }
+
+ err := c.WebsocketOnce(`subscription { directiveNullableArg(arg: -100) }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"too small","path":["directiveNullableArg","arg"]}]`)
+ require.Nil(t, resp.DirectiveNullableArg)
+ })
+ t.Run("when function success on nullable arg directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveNullableArg *string
+ }
+
+ err := c.WebsocketOnce(`subscription { directiveNullableArg }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, "Ok", *resp.DirectiveNullableArg)
+ })
+ t.Run("when function success on valid nullable arg directives", func(t *testing.T) {
+ var resp struct {
+ DirectiveNullableArg *string
+ }
+
+ err := c.WebsocketOnce(`subscription { directiveNullableArg(arg: 1) }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, "Ok", *resp.DirectiveNullableArg)
+ })
+ t.Run("when function success", func(t *testing.T) {
+ var resp struct {
+ DirectiveArg *string
+ }
+
+ err := c.WebsocketOnce(`subscription { directiveArg(arg: "test") }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, "Ok", *resp.DirectiveArg)
+ })
+ })
+ })
+}
diff --git a/codegen/testserver/followschema/embedded.generated.go b/codegen/testserver/followschema/embedded.generated.go
new file mode 100644
index 00000000000..0263b49735f
--- /dev/null
+++ b/codegen/testserver/followschema/embedded.generated.go
@@ -0,0 +1,253 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase1) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "EmbeddedCase1",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ExportedEmbeddedPointerExportedMethod(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase2) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "EmbeddedCase2",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.UnexportedEmbeddedPointerExportedMethod(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase3) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "EmbeddedCase3",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.UnexportedEmbeddedInterfaceExportedMethod(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var embeddedCase1Implementors = []string{"EmbeddedCase1"}
+
+func (ec *executionContext) _EmbeddedCase1(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase1) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase1Implementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("EmbeddedCase1")
+ case "exportedEmbeddedPointerExportedMethod":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var embeddedCase2Implementors = []string{"EmbeddedCase2"}
+
+func (ec *executionContext) _EmbeddedCase2(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase2) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase2Implementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("EmbeddedCase2")
+ case "unexportedEmbeddedPointerExportedMethod":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var embeddedCase3Implementors = []string{"EmbeddedCase3"}
+
+func (ec *executionContext) _EmbeddedCase3(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase3) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase3Implementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("EmbeddedCase3")
+ case "unexportedEmbeddedInterfaceExportedMethod":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase1(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase1) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._EmbeddedCase1(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase2(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase2) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._EmbeddedCase2(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase3(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase3) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._EmbeddedCase3(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/followschema/embedded.go b/codegen/testserver/followschema/embedded.go
new file mode 100644
index 00000000000..f22f83b592d
--- /dev/null
+++ b/codegen/testserver/followschema/embedded.go
@@ -0,0 +1,43 @@
+package followschema
+
+// EmbeddedCase1 model
+type EmbeddedCase1 struct {
+ Empty
+ *ExportedEmbeddedPointerAfterInterface
+}
+
+// Empty interface
+type Empty interface{}
+
+// ExportedEmbeddedPointerAfterInterface model
+type ExportedEmbeddedPointerAfterInterface struct{}
+
+// ExportedEmbeddedPointerExportedMethod method
+func (*ExportedEmbeddedPointerAfterInterface) ExportedEmbeddedPointerExportedMethod() string {
+ return "ExportedEmbeddedPointerExportedMethodResponse"
+}
+
+// EmbeddedCase2 model
+type EmbeddedCase2 struct {
+ *unexportedEmbeddedPointer
+}
+
+type unexportedEmbeddedPointer struct{}
+
+// UnexportedEmbeddedPointerExportedMethod method
+func (*unexportedEmbeddedPointer) UnexportedEmbeddedPointerExportedMethod() string {
+ return "UnexportedEmbeddedPointerExportedMethodResponse"
+}
+
+// EmbeddedCase3 model
+type EmbeddedCase3 struct {
+ unexportedEmbeddedInterface
+}
+
+type unexportedEmbeddedInterface interface {
+ nestedInterface
+}
+
+type nestedInterface interface {
+ UnexportedEmbeddedInterfaceExportedMethod() string
+}
diff --git a/codegen/testserver/followschema/embedded.graphql b/codegen/testserver/followschema/embedded.graphql
new file mode 100644
index 00000000000..e707a236031
--- /dev/null
+++ b/codegen/testserver/followschema/embedded.graphql
@@ -0,0 +1,17 @@
+extend type Query {
+ embeddedCase1: EmbeddedCase1
+ embeddedCase2: EmbeddedCase2
+ embeddedCase3: EmbeddedCase3
+}
+
+type EmbeddedCase1 @goModel(model:"followschema.EmbeddedCase1") {
+ exportedEmbeddedPointerExportedMethod: String!
+}
+
+type EmbeddedCase2 @goModel(model:"followschema.EmbeddedCase2") {
+ unexportedEmbeddedPointerExportedMethod: String!
+}
+
+type EmbeddedCase3 @goModel(model:"followschema.EmbeddedCase3") {
+ unexportedEmbeddedInterfaceExportedMethod: String!
+}
diff --git a/codegen/testserver/followschema/embedded_test.go b/codegen/testserver/followschema/embedded_test.go
new file mode 100644
index 00000000000..b5e1575bac3
--- /dev/null
+++ b/codegen/testserver/followschema/embedded_test.go
@@ -0,0 +1,66 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+type fakeUnexportedEmbeddedInterface struct{}
+
+func (*fakeUnexportedEmbeddedInterface) UnexportedEmbeddedInterfaceExportedMethod() string {
+ return "UnexportedEmbeddedInterfaceExportedMethod"
+}
+
+func TestEmbedded(t *testing.T) {
+ resolver := &Stub{}
+ resolver.QueryResolver.EmbeddedCase1 = func(ctx context.Context) (*EmbeddedCase1, error) {
+ return &EmbeddedCase1{}, nil
+ }
+ resolver.QueryResolver.EmbeddedCase2 = func(ctx context.Context) (*EmbeddedCase2, error) {
+ return &EmbeddedCase2{&unexportedEmbeddedPointer{}}, nil
+ }
+ resolver.QueryResolver.EmbeddedCase3 = func(ctx context.Context) (*EmbeddedCase3, error) {
+ return &EmbeddedCase3{&fakeUnexportedEmbeddedInterface{}}, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(
+ NewExecutableSchema(Config{Resolvers: resolver}),
+ ))
+
+ t.Run("embedded case 1", func(t *testing.T) {
+ var resp struct {
+ EmbeddedCase1 struct {
+ ExportedEmbeddedPointerExportedMethod string
+ }
+ }
+ err := c.Post(`query { embeddedCase1 { exportedEmbeddedPointerExportedMethod } }`, &resp)
+ require.NoError(t, err)
+ require.Equal(t, resp.EmbeddedCase1.ExportedEmbeddedPointerExportedMethod, "ExportedEmbeddedPointerExportedMethodResponse")
+ })
+
+ t.Run("embedded case 2", func(t *testing.T) {
+ var resp struct {
+ EmbeddedCase2 struct {
+ UnexportedEmbeddedPointerExportedMethod string
+ }
+ }
+ err := c.Post(`query { embeddedCase2 { unexportedEmbeddedPointerExportedMethod } }`, &resp)
+ require.NoError(t, err)
+ require.Equal(t, resp.EmbeddedCase2.UnexportedEmbeddedPointerExportedMethod, "UnexportedEmbeddedPointerExportedMethodResponse")
+ })
+
+ t.Run("embedded case 3", func(t *testing.T) {
+ var resp struct {
+ EmbeddedCase3 struct {
+ UnexportedEmbeddedInterfaceExportedMethod string
+ }
+ }
+ err := c.Post(`query { embeddedCase3 { unexportedEmbeddedInterfaceExportedMethod } }`, &resp)
+ require.NoError(t, err)
+ require.Equal(t, resp.EmbeddedCase3.UnexportedEmbeddedInterfaceExportedMethod, "UnexportedEmbeddedInterfaceExportedMethod")
+ })
+}
diff --git a/codegen/testserver/followschema/enum.generated.go b/codegen/testserver/followschema/enum.generated.go
new file mode 100644
index 00000000000..59752873f91
--- /dev/null
+++ b/codegen/testserver/followschema/enum.generated.go
@@ -0,0 +1,83 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+func (ec *executionContext) unmarshalInputInputWithEnumValue(ctx context.Context, obj interface{}) (InputWithEnumValue, error) {
+ var it InputWithEnumValue
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "enum":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enum"))
+ it.Enum, err = ec.unmarshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEnumTest(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEnumTest(ctx context.Context, v interface{}) (EnumTest, error) {
+ var res EnumTest
+ err := res.UnmarshalGQL(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEnumTest(ctx context.Context, sel ast.SelectionSet, v EnumTest) graphql.Marshaler {
+ return v
+}
+
+func (ec *executionContext) unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputWithEnumValue(ctx context.Context, v interface{}) (*InputWithEnumValue, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalInputInputWithEnumValue(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/enum.graphql b/codegen/testserver/followschema/enum.graphql
similarity index 100%
rename from codegen/testserver/enum.graphql
rename to codegen/testserver/followschema/enum.graphql
diff --git a/codegen/testserver/followschema/enums_test.go b/codegen/testserver/followschema/enums_test.go
new file mode 100644
index 00000000000..4f4f1c76d8f
--- /dev/null
+++ b/codegen/testserver/followschema/enums_test.go
@@ -0,0 +1,52 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestEnumsResolver(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.EnumInInput = func(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) {
+ return input.Enum, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ t.Run("input with valid enum value", func(t *testing.T) {
+ var resp struct {
+ EnumInInput EnumTest
+ }
+ c.MustPost(`query {
+ enumInInput(input: {enum: OK})
+ }
+ `, &resp)
+ require.Equal(t, resp.EnumInInput, EnumTestOk)
+ })
+
+ t.Run("input with invalid enum value", func(t *testing.T) {
+ var resp struct {
+ EnumInInput EnumTest
+ }
+ err := c.Post(`query {
+ enumInInput(input: {enum: INVALID})
+ }
+ `, &resp)
+ require.EqualError(t, err, `http 422: {"errors":[{"message":"Expected type EnumTest!, found INVALID.","locations":[{"line":2,"column":30}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`)
+ })
+
+ t.Run("input with invalid enum value via vars", func(t *testing.T) {
+ var resp struct {
+ EnumInInput EnumTest
+ }
+ err := c.Post(`query ($input: InputWithEnumValue) {
+ enumInInput(input: $input)
+ }
+ `, &resp, client.Var("input", map[string]interface{}{"enum": "INVALID"}))
+ require.EqualError(t, err, `http 422: {"errors":[{"message":"INVALID is not a valid EnumTest","path":["variable","input","enum"],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`)
+ })
+}
diff --git a/codegen/testserver/followschema/generated_test.go b/codegen/testserver/followschema/generated_test.go
new file mode 100644
index 00000000000..9d10cde2c35
--- /dev/null
+++ b/codegen/testserver/followschema/generated_test.go
@@ -0,0 +1,80 @@
+//go:generate rm -f resolver.go
+//go:generate go run ../../../testdata/gqlgen.go -config gqlgen.yml -stub stub.go
+
+package followschema
+
+import (
+ "context"
+ "reflect"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestForcedResolverFieldIsPointer(t *testing.T) {
+ field, ok := reflect.TypeOf((*ForcedResolverResolver)(nil)).Elem().MethodByName("Field")
+ require.True(t, ok)
+ require.Equal(t, "*followschema.Circle", field.Type.Out(0).String())
+}
+
+func TestEnums(t *testing.T) {
+ t.Run("list of enums", func(t *testing.T) {
+ require.Equal(t, StatusOk, AllStatus[0])
+ require.Equal(t, StatusError, AllStatus[1])
+ })
+
+ t.Run("invalid enum values", func(t *testing.T) {
+ require.Equal(t, StatusOk, AllStatus[0])
+ require.Equal(t, StatusError, AllStatus[1])
+ })
+}
+
+func TestUnionFragments(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.ShapeUnion = func(ctx context.Context) (ShapeUnion, error) {
+ return &Circle{Radius: 32}, nil
+ }
+
+ srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))
+ c := client.New(srv)
+
+ t.Run("inline fragment on union", func(t *testing.T) {
+ var resp struct {
+ ShapeUnion struct {
+ Radius float64
+ }
+ }
+ c.MustPost(`query {
+ shapeUnion {
+ ... on Circle {
+ radius
+ }
+ }
+ }
+ `, &resp)
+ require.NotEmpty(t, resp.ShapeUnion.Radius)
+ })
+
+ t.Run("named fragment", func(t *testing.T) {
+ var resp struct {
+ ShapeUnion struct {
+ Radius float64
+ }
+ }
+ c.MustPost(`query {
+ shapeUnion {
+ ...C
+ }
+ }
+
+ fragment C on ShapeUnion {
+ ... on Circle {
+ radius
+ }
+ }
+ `, &resp)
+ require.NotEmpty(t, resp.ShapeUnion.Radius)
+ })
+}
diff --git a/codegen/testserver/followschema/gqlgen.yml b/codegen/testserver/followschema/gqlgen.yml
new file mode 100644
index 00000000000..5119a2f5038
--- /dev/null
+++ b/codegen/testserver/followschema/gqlgen.yml
@@ -0,0 +1,26 @@
+schema:
+ - "*.graphql"
+skip_validation: true
+exec:
+ layout: follow-schema
+ dir: .
+ package: followschema
+model:
+ filename: models-gen.go
+ package: followschema
+resolver:
+ filename: resolver.go
+ package: followschema
+ type: Resolver
+
+autobind:
+ - "github.com/99designs/gqlgen/codegen/testserver"
+ - "github.com/99designs/gqlgen/codegen/testserver/followschema"
+ - "github.com/99designs/gqlgen/codegen/testserver/followschema/introspection"
+ - "github.com/99designs/gqlgen/codegen/testserver/followschema/invalid-packagename"
+
+models:
+ Email:
+ model: "github.com/99designs/gqlgen/codegen/testserver/followschema.Email"
+ StringFromContextFunction:
+ model: "github.com/99designs/gqlgen/codegen/testserver/followschema.StringFromContextFunction"
diff --git a/codegen/testserver/followschema/input_test.go b/codegen/testserver/followschema/input_test.go
new file mode 100644
index 00000000000..b4417a010af
--- /dev/null
+++ b/codegen/testserver/followschema/input_test.go
@@ -0,0 +1,69 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestInput(t *testing.T) {
+ resolvers := &Stub{}
+ srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))
+ c := client.New(srv)
+
+ t.Run("when function errors on directives", func(t *testing.T) {
+ resolvers.QueryResolver.InputSlice = func(ctx context.Context, arg []string) (b bool, e error) {
+ return true, nil
+ }
+
+ var resp struct {
+ DirectiveArg *string
+ }
+
+ err := c.Post(`query { inputSlice(arg: ["ok", 1, 2, "ok"]) }`, &resp)
+
+ require.EqualError(t, err, `http 422: {"errors":[{"message":"Expected type String!, found 1.","locations":[{"line":1,"column":32}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}},{"message":"Expected type String!, found 2.","locations":[{"line":1,"column":35}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`)
+ require.Nil(t, resp.DirectiveArg)
+ })
+
+ t.Run("when input slice nullable", func(t *testing.T) {
+ resolvers.QueryResolver.InputNullableSlice = func(ctx context.Context, arg []string) (b bool, e error) {
+ return arg == nil, nil
+ }
+
+ var resp struct {
+ InputNullableSlice bool
+ }
+ var err error
+ err = c.Post(`query { inputNullableSlice(arg: null) }`, &resp)
+ require.NoError(t, err)
+ require.True(t, resp.InputNullableSlice)
+
+ err = c.Post(`query { inputNullableSlice(arg: []) }`, &resp)
+ require.NoError(t, err)
+ require.False(t, resp.InputNullableSlice)
+ })
+
+ t.Run("coerce single value to slice", func(t *testing.T) {
+ check := func(ctx context.Context, arg []string) (b bool, e error) {
+ return len(arg) == 1 && arg[0] == "coerced", nil
+ }
+ resolvers.QueryResolver.InputSlice = check
+ resolvers.QueryResolver.InputNullableSlice = check
+
+ var resp struct {
+ Coerced bool
+ }
+ var err error
+ err = c.Post(`query { coerced: inputSlice(arg: "coerced") }`, &resp)
+ require.NoError(t, err)
+ require.True(t, resp.Coerced)
+
+ err = c.Post(`query { coerced: inputNullableSlice(arg: "coerced") }`, &resp)
+ require.NoError(t, err)
+ require.True(t, resp.Coerced)
+ })
+}
diff --git a/codegen/testserver/followschema/interfaces.generated.go b/codegen/testserver/followschema/interfaces.generated.go
new file mode 100644
index 00000000000..c5e71e7b506
--- /dev/null
+++ b/codegen/testserver/followschema/interfaces.generated.go
@@ -0,0 +1,1241 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "fmt"
+ "strconv"
+ "sync"
+ "sync/atomic"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+type BackedByInterfaceResolver interface {
+ ID(ctx context.Context, obj BackedByInterface) (string, error)
+}
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _BackedByInterface_id(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "BackedByInterface",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.BackedByInterface().ID(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _BackedByInterface_thisShouldBind(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "BackedByInterface",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ThisShouldBind(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _BackedByInterface_thisShouldBindWithError(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "BackedByInterface",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ThisShouldBindWithError()
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Cat_species(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Cat",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Species, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Cat_catBreed(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Cat",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.CatBreed, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Circle",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Radius, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(float64)
+ fc.Result = res
+ return ec.marshalOFloat2float64(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Circle",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Area(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(float64)
+ fc.Result = res
+ return ec.marshalOFloat2float64(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Circle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Circle",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Coordinates, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(Coordinates)
+ fc.Result = res
+ return ec.marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ConcreteNodeA_id(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ConcreteNodeA",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ConcreteNodeA_child(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ConcreteNodeA",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Child()
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(Node)
+ fc.Result = res
+ return ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ConcreteNodeA_name(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ConcreteNodeA",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Name, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ConcreteNodeInterface_id(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ConcreteNodeInterface",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ConcreteNodeInterface_child(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ConcreteNodeInterface",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Child()
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(Node)
+ fc.Result = res
+ return ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Coordinates_x(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Coordinates",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.X, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(float64)
+ fc.Result = res
+ return ec.marshalNFloat2float64(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Coordinates_y(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Coordinates",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Y, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(float64)
+ fc.Result = res
+ return ec.marshalNFloat2float64(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Dog",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Species, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Dog",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.DogBreed, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Rectangle",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Length, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(float64)
+ fc.Result = res
+ return ec.marshalOFloat2float64(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Rectangle",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Width, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(float64)
+ fc.Result = res
+ return ec.marshalOFloat2float64(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Rectangle",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Area(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(float64)
+ fc.Result = res
+ return ec.marshalOFloat2float64(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Rectangle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Rectangle",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Coordinates, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(Coordinates)
+ fc.Result = res
+ return ec.marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, obj Animal) graphql.Marshaler {
+ switch obj := (obj).(type) {
+ case nil:
+ return graphql.Null
+ case Dog:
+ return ec._Dog(ctx, sel, &obj)
+ case *Dog:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._Dog(ctx, sel, obj)
+ case Cat:
+ return ec._Cat(ctx, sel, &obj)
+ case *Cat:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._Cat(ctx, sel, obj)
+ default:
+ panic(fmt.Errorf("unexpected type %T", obj))
+ }
+}
+
+func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj Node) graphql.Marshaler {
+ switch obj := (obj).(type) {
+ case nil:
+ return graphql.Null
+ case *ConcreteNodeA:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._ConcreteNodeA(ctx, sel, obj)
+ case ConcreteNodeInterface:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._ConcreteNodeInterface(ctx, sel, obj)
+ default:
+ panic(fmt.Errorf("unexpected type %T", obj))
+ }
+}
+
+func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, obj Shape) graphql.Marshaler {
+ switch obj := (obj).(type) {
+ case nil:
+ return graphql.Null
+ case *Circle:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._Circle(ctx, sel, obj)
+ case *Rectangle:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._Rectangle(ctx, sel, obj)
+ default:
+ panic(fmt.Errorf("unexpected type %T", obj))
+ }
+}
+
+func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSet, obj ShapeUnion) graphql.Marshaler {
+ switch obj := (obj).(type) {
+ case nil:
+ return graphql.Null
+ case *Circle:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._Circle(ctx, sel, obj)
+ case *Rectangle:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._Rectangle(ctx, sel, obj)
+ default:
+ panic(fmt.Errorf("unexpected type %T", obj))
+ }
+}
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var backedByInterfaceImplementors = []string{"BackedByInterface"}
+
+func (ec *executionContext) _BackedByInterface(ctx context.Context, sel ast.SelectionSet, obj BackedByInterface) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, backedByInterfaceImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("BackedByInterface")
+ case "id":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._BackedByInterface_id(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "thisShouldBind":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._BackedByInterface_thisShouldBind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ case "thisShouldBindWithError":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._BackedByInterface_thisShouldBindWithError(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var catImplementors = []string{"Cat", "Animal"}
+
+func (ec *executionContext) _Cat(ctx context.Context, sel ast.SelectionSet, obj *Cat) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, catImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Cat")
+ case "species":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Cat_species(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "catBreed":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Cat_catBreed(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var circleImplementors = []string{"Circle", "Shape", "ShapeUnion"}
+
+func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, circleImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Circle")
+ case "radius":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Circle_radius(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "area":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Circle_area(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "coordinates":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Circle_coordinates(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var concreteNodeAImplementors = []string{"ConcreteNodeA", "Node"}
+
+func (ec *executionContext) _ConcreteNodeA(ctx context.Context, sel ast.SelectionSet, obj *ConcreteNodeA) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeAImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("ConcreteNodeA")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ConcreteNodeA_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "child":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ConcreteNodeA_child(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "name":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ConcreteNodeA_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var concreteNodeInterfaceImplementors = []string{"ConcreteNodeInterface", "Node"}
+
+func (ec *executionContext) _ConcreteNodeInterface(ctx context.Context, sel ast.SelectionSet, obj ConcreteNodeInterface) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeInterfaceImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("ConcreteNodeInterface")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ConcreteNodeInterface_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "child":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ConcreteNodeInterface_child(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var coordinatesImplementors = []string{"Coordinates"}
+
+func (ec *executionContext) _Coordinates(ctx context.Context, sel ast.SelectionSet, obj *Coordinates) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, coordinatesImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Coordinates")
+ case "x":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Coordinates_x(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "y":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Coordinates_y(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var dogImplementors = []string{"Dog", "Animal"}
+
+func (ec *executionContext) _Dog(ctx context.Context, sel ast.SelectionSet, obj *Dog) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, dogImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Dog")
+ case "species":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Dog_species(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "dogBreed":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Dog_dogBreed(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var rectangleImplementors = []string{"Rectangle", "Shape", "ShapeUnion"}
+
+func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, rectangleImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Rectangle")
+ case "length":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Rectangle_length(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "width":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Rectangle_width(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "area":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Rectangle_area(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "coordinates":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Rectangle_coordinates(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx context.Context, sel ast.SelectionSet, v Node) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._Node(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShapeUnion(ctx context.Context, sel ast.SelectionSet, v ShapeUnion) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._ShapeUnion(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAnimal(ctx context.Context, sel ast.SelectionSet, v Animal) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._Animal(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐBackedByInterface(ctx context.Context, sel ast.SelectionSet, v BackedByInterface) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._BackedByInterface(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._Circle(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx context.Context, sel ast.SelectionSet, v Coordinates) graphql.Marshaler {
+ return ec._Coordinates(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._Shape(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ return ret
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/followschema/interfaces.go b/codegen/testserver/followschema/interfaces.go
new file mode 100644
index 00000000000..7f06298b714
--- /dev/null
+++ b/codegen/testserver/followschema/interfaces.go
@@ -0,0 +1,87 @@
+package followschema
+
+import "math"
+
+type Shape interface {
+ Area() float64
+ isShape()
+}
+
+type ShapeUnion interface {
+ Area() float64
+ isShapeUnion()
+}
+
+type Circle struct {
+ Radius float64
+ Coordinates
+}
+
+func (c *Circle) Area() float64 {
+ return c.Radius * math.Pi * math.Pi
+}
+
+func (c *Circle) isShapeUnion() {}
+func (c *Circle) isShape() {}
+
+type Rectangle struct {
+ Length, Width float64
+ Coordinates
+}
+
+func (r *Rectangle) Area() float64 {
+ return r.Length * r.Width
+}
+func (r *Rectangle) isShapeUnion() {}
+func (r *Rectangle) isShape() {}
+
+type Node interface {
+ Child() (Node, error)
+}
+
+type ConcreteNodeA struct {
+ ID string
+ Name string
+ child Node
+}
+
+func (n *ConcreteNodeA) Child() (Node, error) {
+ return n.child, nil
+}
+
+// Implements the Node interface with another interface
+type ConcreteNodeInterface interface {
+ Node
+ ID() string
+}
+
+type ConcreteNodeInterfaceImplementor struct{}
+
+func (c ConcreteNodeInterfaceImplementor) ID() string {
+ return "CNII"
+}
+
+func (c ConcreteNodeInterfaceImplementor) Child() (Node, error) {
+ return &ConcreteNodeA{
+ ID: "Child",
+ Name: "child",
+ }, nil
+}
+
+type BackedByInterface interface {
+ ThisShouldBind() string
+ ThisShouldBindWithError() (string, error)
+}
+
+type BackedByInterfaceImpl struct {
+ Value string
+ Error error
+}
+
+func (b *BackedByInterfaceImpl) ThisShouldBind() string {
+ return b.Value
+}
+
+func (b *BackedByInterfaceImpl) ThisShouldBindWithError() (string, error) {
+ return b.Value, b.Error
+}
diff --git a/codegen/testserver/followschema/interfaces.graphql b/codegen/testserver/followschema/interfaces.graphql
new file mode 100644
index 00000000000..af5c17170c3
--- /dev/null
+++ b/codegen/testserver/followschema/interfaces.graphql
@@ -0,0 +1,70 @@
+extend type Query {
+ shapes: [Shape]
+ noShape: Shape @makeNil
+ node: Node!
+ noShapeTypedNil: Shape @makeTypedNil
+ animal: Animal @makeTypedNil
+ notAnInterface: BackedByInterface
+}
+
+interface Animal {
+ species: String!
+}
+
+type BackedByInterface {
+ id: String!
+ thisShouldBind: String!
+ thisShouldBindWithError: String!
+}
+
+type Dog implements Animal {
+ species: String!
+ dogBreed: String!
+}
+
+type Cat implements Animal {
+ species: String!
+ catBreed: String!
+}
+
+type Coordinates {
+ x: Float!
+ y: Float!
+}
+interface Shape {
+ area: Float
+ coordinates: Coordinates
+}
+
+type Circle implements Shape {
+ radius: Float
+ area: Float
+ coordinates: Coordinates
+}
+type Rectangle implements Shape {
+ length: Float
+ width: Float
+ area: Float
+ coordinates: Coordinates
+}
+union ShapeUnion @goModel(model: "followschema.ShapeUnion") = Circle | Rectangle
+
+directive @makeNil on FIELD_DEFINITION
+directive @makeTypedNil on FIELD_DEFINITION
+
+interface Node {
+ id: ID!
+ child: Node!
+}
+
+type ConcreteNodeA implements Node {
+ id: ID!
+ child: Node!
+ name: String!
+}
+
+" Implements the Node interface with another interface "
+type ConcreteNodeInterface implements Node {
+ id: ID!
+ child: Node!
+}
diff --git a/codegen/testserver/followschema/interfaces_test.go b/codegen/testserver/followschema/interfaces_test.go
new file mode 100644
index 00000000000..d67c7da59f4
--- /dev/null
+++ b/codegen/testserver/followschema/interfaces_test.go
@@ -0,0 +1,256 @@
+package followschema
+
+import (
+ "context"
+ "fmt"
+ "reflect"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestInterfaces(t *testing.T) {
+ t.Run("slices of interfaces are not pointers", func(t *testing.T) {
+ field, ok := reflect.TypeOf((*QueryResolver)(nil)).Elem().MethodByName("Shapes")
+ require.True(t, ok)
+ require.Equal(t, "[]followschema.Shape", field.Type.Out(0).String())
+ })
+
+ t.Run("models returning interfaces", func(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.Node = func(ctx context.Context) (node Node, err error) {
+ return &ConcreteNodeA{
+ ID: "1234",
+ Name: "asdf",
+ child: &ConcreteNodeA{
+ ID: "5678",
+ Name: "hjkl",
+ child: nil,
+ },
+ }, nil
+ }
+
+ srv := handler.NewDefaultServer(
+ NewExecutableSchema(Config{
+ Resolvers: resolvers,
+ }),
+ )
+
+ c := client.New(srv)
+
+ var resp struct {
+ Node struct {
+ ID string
+ Child struct {
+ ID string
+ }
+ }
+ }
+ c.MustPost(`{ node { id, child { id } } }`, &resp)
+ require.Equal(t, "1234", resp.Node.ID)
+ require.Equal(t, "5678", resp.Node.Child.ID)
+ })
+
+ t.Run("interfaces can be nil", func(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.NoShape = func(ctx context.Context) (shapes Shape, e error) {
+ return nil, nil
+ }
+
+ srv := handler.NewDefaultServer(
+ NewExecutableSchema(Config{
+ Resolvers: resolvers,
+ Directives: DirectiveRoot{
+ MakeNil: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
+ return nil, nil
+ },
+ },
+ }),
+ )
+
+ c := client.New(srv)
+
+ var resp interface{}
+ c.MustPost(`{ noShape { area } }`, &resp)
+ })
+
+ t.Run("interfaces can be typed nil", func(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.NoShapeTypedNil = func(ctx context.Context) (shapes Shape, e error) {
+ panic("should not be called")
+ }
+
+ srv := handler.NewDefaultServer(
+ NewExecutableSchema(Config{
+ Resolvers: resolvers,
+ Directives: DirectiveRoot{
+ MakeTypedNil: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
+ var circle *Circle
+ return circle, nil
+ },
+ },
+ }),
+ )
+
+ c := client.New(srv)
+
+ var resp interface{}
+ c.MustPost(`{ noShapeTypedNil { area } }`, &resp)
+ })
+
+ t.Run("interfaces can be nil (test with code-generated resolver)", func(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.Animal = func(ctx context.Context) (animal Animal, e error) {
+ panic("should not be called")
+ }
+
+ srv := handler.NewDefaultServer(
+ NewExecutableSchema(Config{
+ Resolvers: resolvers,
+ Directives: DirectiveRoot{
+ MakeTypedNil: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
+ var dog *Dog // return a typed nil, not just nil
+ return dog, nil
+ },
+ },
+ }),
+ )
+
+ c := client.New(srv)
+
+ var resp interface{}
+ c.MustPost(`{ animal { species } }`, &resp)
+ })
+
+ t.Run("can bind to interfaces even when the graphql is not", func(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.BackedByInterfaceResolver.ID = func(ctx context.Context, obj BackedByInterface) (s string, err error) {
+ return "ID:" + obj.ThisShouldBind(), nil
+ }
+ resolvers.QueryResolver.NotAnInterface = func(ctx context.Context) (byInterface BackedByInterface, err error) {
+ return &BackedByInterfaceImpl{
+ Value: "A",
+ Error: nil,
+ }, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ var resp struct {
+ NotAnInterface struct {
+ ID string
+ ThisShouldBind string
+ ThisShouldBindWithError string
+ }
+ }
+ c.MustPost(`{ notAnInterface { id, thisShouldBind, thisShouldBindWithError } }`, &resp)
+ require.Equal(t, "ID:A", resp.NotAnInterface.ID)
+ require.Equal(t, "A", resp.NotAnInterface.ThisShouldBind)
+ require.Equal(t, "A", resp.NotAnInterface.ThisShouldBindWithError)
+ })
+
+ t.Run("can return errors from interface funcs", func(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.BackedByInterfaceResolver.ID = func(ctx context.Context, obj BackedByInterface) (s string, err error) {
+ return "ID:" + obj.ThisShouldBind(), nil
+ }
+ resolvers.QueryResolver.NotAnInterface = func(ctx context.Context) (byInterface BackedByInterface, err error) {
+ return &BackedByInterfaceImpl{
+ Value: "A",
+ Error: fmt.Errorf("boom"),
+ }, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ var resp struct {
+ NotAnInterface struct {
+ ID string
+ ThisShouldBind string
+ ThisShouldBindWithError string
+ }
+ }
+ err := c.Post(`{ notAnInterface { id, thisShouldBind, thisShouldBindWithError } }`, &resp)
+ require.EqualError(t, err, `[{"message":"boom","path":["notAnInterface","thisShouldBindWithError"]}]`)
+ })
+
+ t.Run("interfaces can implement other interfaces", func(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.Node = func(ctx context.Context) (node Node, err error) {
+ return ConcreteNodeInterfaceImplementor{}, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ var resp struct {
+ Node struct {
+ ID string
+ Child struct {
+ ID string
+ }
+ }
+ }
+ c.MustPost(`{ node { id, child { id } } }`, &resp)
+ require.Equal(t, "CNII", resp.Node.ID)
+ require.Equal(t, "Child", resp.Node.Child.ID)
+ })
+
+ t.Run("interface implementors should return merged base fields", func(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.Shapes = func(ctx context.Context) (shapes []Shape, err error) {
+ return []Shape{
+ &Rectangle{
+ Coordinates: Coordinates{
+ X: -1,
+ Y: -1,
+ },
+ },
+ &Circle{
+ Coordinates: Coordinates{
+ X: 1,
+ Y: 1,
+ },
+ },
+ }, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+ var resp struct {
+ Shapes []struct {
+ Coordinates struct {
+ X float64
+ Y float64
+ }
+ }
+ }
+
+ c.MustPost(`
+ {
+ shapes {
+ coordinates {
+ x
+ }
+ ... on Rectangle {
+ coordinates {
+ x
+ }
+ }
+ ... on Circle {
+ coordinates {
+ y
+ }
+ }
+ }
+ }
+ `, &resp)
+
+ require.Equal(t, 2, len(resp.Shapes))
+ require.Equal(t, float64(-1), resp.Shapes[0].Coordinates.X)
+ require.Equal(t, float64(0), resp.Shapes[0].Coordinates.Y)
+ require.Equal(t, float64(1), resp.Shapes[1].Coordinates.X)
+ require.Equal(t, float64(1), resp.Shapes[1].Coordinates.Y)
+ })
+}
diff --git a/codegen/testserver/introspection/it.go b/codegen/testserver/followschema/introspection/it.go
similarity index 100%
rename from codegen/testserver/introspection/it.go
rename to codegen/testserver/followschema/introspection/it.go
diff --git a/codegen/testserver/followschema/introspection_test.go b/codegen/testserver/followschema/introspection_test.go
new file mode 100644
index 00000000000..ef2bfafb53b
--- /dev/null
+++ b/codegen/testserver/followschema/introspection_test.go
@@ -0,0 +1,79 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/99designs/gqlgen/graphql/handler/transport"
+ "github.com/99designs/gqlgen/graphql/introspection"
+ "github.com/stretchr/testify/require"
+)
+
+func TestIntrospection(t *testing.T) {
+ t.Run("disabled when creating your own server", func(t *testing.T) {
+ resolvers := &Stub{}
+
+ srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers}))
+ srv.AddTransport(transport.POST{})
+ c := client.New(srv)
+
+ var resp interface{}
+ err := c.Post(introspection.Query, &resp)
+ require.EqualError(t, err, "[{\"message\":\"introspection disabled\",\"path\":[\"__schema\"]}]")
+ })
+
+ t.Run("enabled by default", func(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(
+ NewExecutableSchema(Config{Resolvers: resolvers}),
+ ))
+
+ var resp interface{}
+ err := c.Post(introspection.Query, &resp)
+ require.NoError(t, err)
+
+ t.Run("does not return empty deprecation strings", func(t *testing.T) {
+ q := `{
+ __type(name:"InnerObject") {
+ fields {
+ name
+ deprecationReason
+ }
+ }
+ }`
+
+ var resp struct {
+ Type struct {
+ Fields []struct {
+ Name string
+ DeprecationReason *string
+ }
+ } `json:"__type"`
+ }
+ err := c.Post(q, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, "id", resp.Type.Fields[0].Name)
+ require.Nil(t, resp.Type.Fields[0].DeprecationReason)
+ })
+ })
+
+ t.Run("disabled by middleware", func(t *testing.T) {
+ resolvers := &Stub{}
+
+ srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))
+ srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
+ graphql.GetOperationContext(ctx).DisableIntrospection = true
+ return next(ctx)
+ })
+ c := client.New(srv)
+
+ var resp interface{}
+ err := c.Post(introspection.Query, &resp)
+ require.EqualError(t, err, "[{\"message\":\"introspection disabled\",\"path\":[\"__schema\"]}]")
+ })
+}
diff --git a/codegen/testserver/invalid-packagename/invalid-identifier.go b/codegen/testserver/followschema/invalid-packagename/invalid-identifier.go
similarity index 100%
rename from codegen/testserver/invalid-packagename/invalid-identifier.go
rename to codegen/testserver/followschema/invalid-packagename/invalid-identifier.go
diff --git a/codegen/testserver/followschema/issue896.generated.go b/codegen/testserver/followschema/issue896.generated.go
new file mode 100644
index 00000000000..43591226e8f
--- /dev/null
+++ b/codegen/testserver/followschema/issue896.generated.go
@@ -0,0 +1,206 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+ "sync"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _CheckIssue896_id(ctx context.Context, field graphql.CollectedField, obj *CheckIssue896) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "CheckIssue896",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*int)
+ fc.Result = res
+ return ec.marshalOInt2ᚖint(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var checkIssue896Implementors = []string{"CheckIssue896"}
+
+func (ec *executionContext) _CheckIssue896(ctx context.Context, sel ast.SelectionSet, obj *CheckIssue896) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, checkIssue896Implementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("CheckIssue896")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._CheckIssue896_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._CheckIssue896(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v []*CheckIssue896) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalOCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ return ret
+}
+
+func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896ᚄ(ctx context.Context, sel ast.SelectionSet, v []*CheckIssue896) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalOCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._CheckIssue896(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/issue896.graphql b/codegen/testserver/followschema/issue896.graphql
similarity index 100%
rename from codegen/testserver/issue896.graphql
rename to codegen/testserver/followschema/issue896.graphql
diff --git a/codegen/testserver/followschema/loops.generated.go b/codegen/testserver/followschema/loops.generated.go
new file mode 100644
index 00000000000..b90f1fa7ef6
--- /dev/null
+++ b/codegen/testserver/followschema/loops.generated.go
@@ -0,0 +1,189 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _LoopA_b(ctx context.Context, field graphql.CollectedField, obj *LoopA) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "LoopA",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.B, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*LoopB)
+ fc.Result = res
+ return ec.marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopB(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.CollectedField, obj *LoopB) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "LoopB",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.A, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*LoopA)
+ fc.Result = res
+ return ec.marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopA(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var loopAImplementors = []string{"LoopA"}
+
+func (ec *executionContext) _LoopA(ctx context.Context, sel ast.SelectionSet, obj *LoopA) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, loopAImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("LoopA")
+ case "b":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._LoopA_b(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var loopBImplementors = []string{"LoopB"}
+
+func (ec *executionContext) _LoopB(ctx context.Context, sel ast.SelectionSet, obj *LoopB) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, loopBImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("LoopB")
+ case "a":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._LoopB_a(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopA(ctx context.Context, sel ast.SelectionSet, v *LoopA) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._LoopA(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopB(ctx context.Context, sel ast.SelectionSet, v *LoopB) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._LoopB(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/loops.graphql b/codegen/testserver/followschema/loops.graphql
similarity index 100%
rename from codegen/testserver/loops.graphql
rename to codegen/testserver/followschema/loops.graphql
diff --git a/codegen/testserver/followschema/maps.generated.go b/codegen/testserver/followschema/maps.generated.go
new file mode 100644
index 00000000000..d82085836b7
--- /dev/null
+++ b/codegen/testserver/followschema/maps.generated.go
@@ -0,0 +1,200 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "fmt"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "MapStringInterfaceType",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ switch v := obj["a"].(type) {
+ case *string:
+ return v, nil
+ case string:
+ return &v, nil
+ case nil:
+ return (*string)(nil), nil
+ default:
+ return nil, fmt.Errorf("unexpected type %T for field %s", v, "a")
+ }
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "MapStringInterfaceType",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ switch v := obj["b"].(type) {
+ case *int:
+ return v, nil
+ case int:
+ return &v, nil
+ case nil:
+ return (*int)(nil), nil
+ default:
+ return nil, fmt.Errorf("unexpected type %T for field %s", v, "b")
+ }
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*int)
+ fc.Result = res
+ return ec.marshalOInt2ᚖint(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+func (ec *executionContext) unmarshalInputNestedMapInput(ctx context.Context, obj interface{}) (NestedMapInput, error) {
+ var it NestedMapInput
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "map":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map"))
+ it.Map, err = ec.unmarshalOMapStringInterfaceInput2map(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var mapStringInterfaceTypeImplementors = []string{"MapStringInterfaceType"}
+
+func (ec *executionContext) _MapStringInterfaceType(ctx context.Context, sel ast.SelectionSet, obj map[string]interface{}) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, mapStringInterfaceTypeImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("MapStringInterfaceType")
+ case "a":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._MapStringInterfaceType_a(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "b":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._MapStringInterfaceType_b(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalOMapStringInterfaceInput2map(ctx context.Context, v interface{}) (map[string]interface{}, error) {
+ if v == nil {
+ return nil, nil
+ }
+ return v.(map[string]interface{}), nil
+}
+
+func (ec *executionContext) marshalOMapStringInterfaceType2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._MapStringInterfaceType(ctx, sel, v)
+}
+
+func (ec *executionContext) unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNestedMapInput(ctx context.Context, v interface{}) (*NestedMapInput, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalInputNestedMapInput(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/maps.graphql b/codegen/testserver/followschema/maps.graphql
similarity index 100%
rename from codegen/testserver/maps.graphql
rename to codegen/testserver/followschema/maps.graphql
diff --git a/codegen/testserver/followschema/maps_test.go b/codegen/testserver/followschema/maps_test.go
new file mode 100644
index 00000000000..fe9750450fb
--- /dev/null
+++ b/codegen/testserver/followschema/maps_test.go
@@ -0,0 +1,73 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestMaps(t *testing.T) {
+ resolver := &Stub{}
+ resolver.QueryResolver.MapStringInterface = func(ctx context.Context, in map[string]interface{}) (i map[string]interface{}, e error) {
+ return in, nil
+ }
+ resolver.QueryResolver.MapNestedStringInterface = func(ctx context.Context, in *NestedMapInput) (i map[string]interface{}, e error) {
+ if in == nil {
+ return nil, nil
+ }
+ return in.Map, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(
+ NewExecutableSchema(Config{Resolvers: resolver}),
+ ))
+ t.Run("unset", func(t *testing.T) {
+ var resp struct {
+ MapStringInterface map[string]interface{}
+ }
+ err := c.Post(`query { mapStringInterface { a, b } }`, &resp)
+ require.NoError(t, err)
+ require.Nil(t, resp.MapStringInterface)
+ })
+
+ t.Run("nil", func(t *testing.T) {
+ var resp struct {
+ MapStringInterface map[string]interface{}
+ }
+ err := c.Post(`query { mapStringInterface(in: null) { a, b } }`, &resp)
+ require.NoError(t, err)
+ require.Nil(t, resp.MapStringInterface)
+ })
+
+ t.Run("values", func(t *testing.T) {
+ var resp struct {
+ MapStringInterface map[string]interface{}
+ }
+ err := c.Post(`query { mapStringInterface(in: { a: "a", b: null }) { a, b } }`, &resp)
+ require.NoError(t, err)
+ require.Equal(t, "a", resp.MapStringInterface["a"])
+ require.Nil(t, resp.MapStringInterface["b"])
+ })
+
+ t.Run("nested", func(t *testing.T) {
+ var resp struct {
+ MapNestedStringInterface map[string]interface{}
+ }
+ err := c.Post(`query { mapNestedStringInterface(in: { map: { a: "a", b: null } }) { a, b } }`, &resp)
+ require.NoError(t, err)
+ require.Equal(t, "a", resp.MapNestedStringInterface["a"])
+ require.Nil(t, resp.MapNestedStringInterface["b"])
+ })
+
+ t.Run("nested nil", func(t *testing.T) {
+ var resp struct {
+ MapNestedStringInterface map[string]interface{}
+ }
+ err := c.Post(`query { mapNestedStringInterface(in: { map: null }) { a, b } }`, &resp)
+ require.NoError(t, err)
+ require.Nil(t, resp.MapNestedStringInterface)
+ })
+}
diff --git a/codegen/testserver/followschema/middleware_test.go b/codegen/testserver/followschema/middleware_test.go
new file mode 100644
index 00000000000..843ca806f88
--- /dev/null
+++ b/codegen/testserver/followschema/middleware_test.go
@@ -0,0 +1,110 @@
+package followschema
+
+import (
+ "context"
+ "sync"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/99designs/gqlgen/graphql/handler"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+func TestMiddleware(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.ErrorBubble = func(ctx context.Context) (i *Error, e error) {
+ return &Error{ID: "E1234"}, nil
+ }
+
+ resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) {
+ return &User{ID: 1}, nil
+ }
+
+ resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) (users []*User, e error) {
+ return []*User{{ID: 1}}, nil
+ }
+
+ resolvers.QueryResolver.ModelMethods = func(ctx context.Context) (methods *ModelMethods, e error) {
+ return &ModelMethods{}, nil
+ }
+
+ var mu sync.Mutex
+ areMethods := map[string]bool{}
+ areResolvers := map[string]bool{}
+ srv := handler.NewDefaultServer(
+ NewExecutableSchema(Config{Resolvers: resolvers}),
+ )
+ srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
+ path, _ := ctx.Value(ckey("path")).([]int)
+ return next(context.WithValue(ctx, ckey("path"), append(path, 1)))
+ })
+
+ srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
+ path, _ := ctx.Value(ckey("path")).([]int)
+ return next(context.WithValue(ctx, ckey("path"), append(path, 2)))
+ })
+
+ srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
+ fc := graphql.GetFieldContext(ctx)
+ mu.Lock()
+ areMethods[fc.Field.Name] = fc.IsMethod
+ areResolvers[fc.Field.Name] = fc.IsResolver
+ mu.Unlock()
+ return next(ctx)
+ })
+
+ c := client.New(srv)
+
+ var resp struct {
+ User struct {
+ ID int
+ Friends []struct {
+ ID int
+ }
+ }
+ ModelMethods struct {
+ NoContext bool
+ }
+ }
+
+ called := false
+ resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) ([]*User, error) {
+ assert.Equal(t, []int{1, 2, 1, 2}, ctx.Value(ckey("path")))
+ called = true
+ return []*User{}, nil
+ }
+
+ err := c.Post(`query {
+ user(id: 1) {
+ id,
+ friends {
+ id
+ }
+ }
+ modelMethods {
+ noContext
+ }
+ }`, &resp)
+
+ assert.Equal(t, map[string]bool{
+ "user": true,
+ "id": false,
+ "friends": true,
+ "modelMethods": true,
+ "noContext": true,
+ }, areMethods)
+ assert.Equal(t, map[string]bool{
+ "user": true,
+ "id": false,
+ "friends": true,
+ "modelMethods": true,
+ "noContext": false,
+ }, areResolvers)
+
+ require.NoError(t, err)
+ require.True(t, called)
+
+}
diff --git a/codegen/testserver/followschema/modelmethod_test.go b/codegen/testserver/followschema/modelmethod_test.go
new file mode 100644
index 00000000000..4cf1803729e
--- /dev/null
+++ b/codegen/testserver/followschema/modelmethod_test.go
@@ -0,0 +1,44 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestModelMethods(t *testing.T) {
+ resolver := &Stub{}
+ resolver.QueryResolver.ModelMethods = func(ctx context.Context) (methods *ModelMethods, e error) {
+ return &ModelMethods{}, nil
+ }
+ resolver.ModelMethodsResolver.ResolverField = func(ctx context.Context, obj *ModelMethods) (b bool, e error) {
+ return true, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(
+ NewExecutableSchema(Config{Resolvers: resolver}),
+ ))
+ t.Run("without context", func(t *testing.T) {
+ var resp struct {
+ ModelMethods struct {
+ NoContext bool
+ }
+ }
+ err := c.Post(`query { modelMethods{ noContext } }`, &resp)
+ require.NoError(t, err)
+ require.True(t, resp.ModelMethods.NoContext)
+ })
+ t.Run("with context", func(t *testing.T) {
+ var resp struct {
+ ModelMethods struct {
+ WithContext bool
+ }
+ }
+ err := c.Post(`query { modelMethods{ withContext } }`, &resp)
+ require.NoError(t, err)
+ require.True(t, resp.ModelMethods.WithContext)
+ })
+}
diff --git a/codegen/testserver/followschema/models-gen.go b/codegen/testserver/followschema/models-gen.go
new file mode 100644
index 00000000000..6ddd209366c
--- /dev/null
+++ b/codegen/testserver/followschema/models-gen.go
@@ -0,0 +1,304 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "fmt"
+ "io"
+ "strconv"
+ "time"
+)
+
+type Animal interface {
+ IsAnimal()
+}
+
+type ContentChild interface {
+ IsContentChild()
+}
+
+type TestUnion interface {
+ IsTestUnion()
+}
+
+type A struct {
+ ID string `json:"id"`
+}
+
+func (A) IsTestUnion() {}
+
+type AIt struct {
+ ID string `json:"id"`
+}
+
+type AbIt struct {
+ ID string `json:"id"`
+}
+
+type B struct {
+ ID string `json:"id"`
+}
+
+func (B) IsTestUnion() {}
+
+type Cat struct {
+ Species string `json:"species"`
+ CatBreed string `json:"catBreed"`
+}
+
+func (Cat) IsAnimal() {}
+
+type CheckIssue896 struct {
+ ID *int `json:"id"`
+}
+
+type ContentPost struct {
+ Foo *string `json:"foo"`
+}
+
+func (ContentPost) IsContentChild() {}
+
+type ContentUser struct {
+ Foo *string `json:"foo"`
+}
+
+func (ContentUser) IsContentChild() {}
+
+type Coordinates struct {
+ X float64 `json:"x"`
+ Y float64 `json:"y"`
+}
+
+type DefaultInput struct {
+ FalsyBoolean *bool `json:"falsyBoolean"`
+ TruthyBoolean *bool `json:"truthyBoolean"`
+}
+
+type DefaultParametersMirror struct {
+ FalsyBoolean *bool `json:"falsyBoolean"`
+ TruthyBoolean *bool `json:"truthyBoolean"`
+}
+
+type Dog struct {
+ Species string `json:"species"`
+ DogBreed string `json:"dogBreed"`
+}
+
+func (Dog) IsAnimal() {}
+
+type EmbeddedDefaultScalar struct {
+ Value *string `json:"value"`
+}
+
+type InnerDirectives struct {
+ Message string `json:"message"`
+}
+
+type InnerInput struct {
+ ID int `json:"id"`
+}
+
+type InnerObject struct {
+ ID int `json:"id"`
+}
+
+type InputDirectives struct {
+ Text string `json:"text"`
+ NullableText *string `json:"nullableText"`
+ Inner *InnerDirectives `json:"inner"`
+ InnerNullable *InnerDirectives `json:"innerNullable"`
+ ThirdParty *ThirdParty `json:"thirdParty"`
+}
+
+type InputWithEnumValue struct {
+ Enum EnumTest `json:"enum"`
+}
+
+type LoopA struct {
+ B *LoopB `json:"b"`
+}
+
+type LoopB struct {
+ A *LoopA `json:"a"`
+}
+
+// Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_
+// added to the TypeMap
+type Map struct {
+ ID string `json:"id"`
+}
+
+type NestedInput struct {
+ Field Email `json:"field"`
+}
+
+type NestedMapInput struct {
+ Map map[string]interface{} `json:"map"`
+}
+
+type ObjectDirectives struct {
+ Text string `json:"text"`
+ NullableText *string `json:"nullableText"`
+ Order []string `json:"order"`
+}
+
+type OuterInput struct {
+ Inner *InnerInput `json:"inner"`
+}
+
+type OuterObject struct {
+ Inner *InnerObject `json:"inner"`
+}
+
+type Slices struct {
+ Test1 []*string `json:"test1"`
+ Test2 []string `json:"test2"`
+ Test3 []*string `json:"test3"`
+ Test4 []string `json:"test4"`
+}
+
+type SpecialInput struct {
+ Nesting *NestedInput `json:"nesting"`
+}
+
+type User struct {
+ ID int `json:"id"`
+ Friends []*User `json:"friends"`
+ Created time.Time `json:"created"`
+ Updated *time.Time `json:"updated"`
+}
+
+type ValidInput struct {
+ Break string `json:"break"`
+ Default string `json:"default"`
+ Func string `json:"func"`
+ Interface string `json:"interface"`
+ Select string `json:"select"`
+ Case string `json:"case"`
+ Defer string `json:"defer"`
+ Go string `json:"go"`
+ Map string `json:"map"`
+ Struct string `json:"struct"`
+ Chan string `json:"chan"`
+ Else string `json:"else"`
+ Goto string `json:"goto"`
+ Package string `json:"package"`
+ Switch string `json:"switch"`
+ Const string `json:"const"`
+ Fallthrough string `json:"fallthrough"`
+ If string `json:"if"`
+ Range string `json:"range"`
+ Type string `json:"type"`
+ Continue string `json:"continue"`
+ For string `json:"for"`
+ Import string `json:"import"`
+ Return string `json:"return"`
+ Var string `json:"var"`
+ Underscore string `json:"_"`
+}
+
+// These things are all valid, but without care generate invalid go code
+type ValidType struct {
+ DifferentCase string `json:"differentCase"`
+ DifferentCaseOld string `json:"different_case"`
+ ValidInputKeywords bool `json:"validInputKeywords"`
+ ValidArgs bool `json:"validArgs"`
+}
+
+type XXIt struct {
+ ID string `json:"id"`
+}
+
+type XxIt struct {
+ ID string `json:"id"`
+}
+
+type AsdfIt struct {
+ ID string `json:"id"`
+}
+
+type IIt struct {
+ ID string `json:"id"`
+}
+
+type EnumTest string
+
+const (
+ EnumTestOk EnumTest = "OK"
+ EnumTestNg EnumTest = "NG"
+)
+
+var AllEnumTest = []EnumTest{
+ EnumTestOk,
+ EnumTestNg,
+}
+
+func (e EnumTest) IsValid() bool {
+ switch e {
+ case EnumTestOk, EnumTestNg:
+ return true
+ }
+ return false
+}
+
+func (e EnumTest) String() string {
+ return string(e)
+}
+
+func (e *EnumTest) UnmarshalGQL(v interface{}) error {
+ str, ok := v.(string)
+ if !ok {
+ return fmt.Errorf("enums must be strings")
+ }
+
+ *e = EnumTest(str)
+ if !e.IsValid() {
+ return fmt.Errorf("%s is not a valid EnumTest", str)
+ }
+ return nil
+}
+
+func (e EnumTest) MarshalGQL(w io.Writer) {
+ fmt.Fprint(w, strconv.Quote(e.String()))
+}
+
+type Status string
+
+const (
+ StatusOk Status = "OK"
+ StatusError Status = "ERROR"
+)
+
+var AllStatus = []Status{
+ StatusOk,
+ StatusError,
+}
+
+func (e Status) IsValid() bool {
+ switch e {
+ case StatusOk, StatusError:
+ return true
+ }
+ return false
+}
+
+func (e Status) String() string {
+ return string(e)
+}
+
+func (e *Status) UnmarshalGQL(v interface{}) error {
+ str, ok := v.(string)
+ if !ok {
+ return fmt.Errorf("enums must be strings")
+ }
+
+ *e = Status(str)
+ if !e.IsValid() {
+ return fmt.Errorf("%s is not a valid Status", str)
+ }
+ return nil
+}
+
+func (e Status) MarshalGQL(w io.Writer) {
+ fmt.Fprint(w, strconv.Quote(e.String()))
+}
diff --git a/codegen/testserver/followschema/models.go b/codegen/testserver/followschema/models.go
new file mode 100644
index 00000000000..66fa415d75c
--- /dev/null
+++ b/codegen/testserver/followschema/models.go
@@ -0,0 +1,106 @@
+package followschema
+
+import (
+ "context"
+ "fmt"
+ "io"
+)
+
+type ForcedResolver struct {
+ Field Circle
+}
+
+type ModelMethods struct {
+}
+
+func (m ModelMethods) NoContext() bool {
+ return true
+}
+
+func (m ModelMethods) WithContext(_ context.Context) bool {
+ return true
+}
+
+type Errors struct{}
+
+type Error struct {
+ ID string
+}
+
+func (Error) ErrorOnRequiredField() (string, error) {
+ return "", fmt.Errorf("boom")
+}
+
+func (Error) ErrorOnNonRequiredField() (string, error) {
+ return "", fmt.Errorf("boom")
+}
+
+func (Error) NilOnRequiredField() *string {
+ return nil
+}
+
+type EmbeddedPointerModel struct {
+ *EmbeddedPointer
+ ID string
+}
+
+type EmbeddedPointer struct {
+ Title string
+}
+
+type MarshalPanic string
+
+func (m *MarshalPanic) UnmarshalGQL(v interface{}) error {
+ panic("BOOM")
+}
+
+func (m MarshalPanic) MarshalGQL(w io.Writer) {
+ panic("BOOM")
+}
+
+type Panics struct {
+}
+
+func (p *Panics) FieldFuncMarshal(ctx context.Context, u []MarshalPanic) []MarshalPanic {
+ return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")}
+}
+
+type Autobind struct {
+ Int int
+ Int32 int32
+ Int64 int64
+
+ IdStr string
+ IdInt int
+}
+
+type OverlappingFields struct {
+ Foo int
+ NewFoo int
+}
+
+type ObjectDirectivesWithCustomGoModel struct {
+ NullableText string // not *string, but schema is `String @toNull` type.
+}
+
+type FallbackToStringEncoding string
+
+const (
+ FallbackToStringEncodingA FallbackToStringEncoding = "A"
+ FallbackToStringEncodingB FallbackToStringEncoding = "B"
+ FallbackToStringEncodingC FallbackToStringEncoding = "C"
+)
+
+type Primitive int
+
+func (p Primitive) Squared() int {
+ return int(p) * int(p)
+}
+
+type PrimitiveString string
+
+func (s PrimitiveString) Doubled() string {
+ return string(s) + string(s)
+}
+
+type Bytes []byte
diff --git a/codegen/testserver/followschema/mutation_with_custom_scalar.generated.go b/codegen/testserver/followschema/mutation_with_custom_scalar.generated.go
new file mode 100644
index 00000000000..c0d4d0bd93f
--- /dev/null
+++ b/codegen/testserver/followschema/mutation_with_custom_scalar.generated.go
@@ -0,0 +1,108 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+func (ec *executionContext) unmarshalInputNestedInput(ctx context.Context, obj interface{}) (NestedInput, error) {
+ var it NestedInput
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "field":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field"))
+ it.Field, err = ec.unmarshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmail(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+func (ec *executionContext) unmarshalInputSpecialInput(ctx context.Context, obj interface{}) (SpecialInput, error) {
+ var it SpecialInput
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "nesting":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nesting"))
+ it.Nesting, err = ec.unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNestedInput(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmail(ctx context.Context, v interface{}) (Email, error) {
+ var res Email
+ err := res.UnmarshalGQL(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmail(ctx context.Context, sel ast.SelectionSet, v Email) graphql.Marshaler {
+ return v
+}
+
+func (ec *executionContext) unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNestedInput(ctx context.Context, v interface{}) (*NestedInput, error) {
+ res, err := ec.unmarshalInputNestedInput(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSpecialInput(ctx context.Context, v interface{}) (SpecialInput, error) {
+ res, err := ec.unmarshalInputSpecialInput(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/followschema/mutation_with_custom_scalar.go b/codegen/testserver/followschema/mutation_with_custom_scalar.go
new file mode 100644
index 00000000000..6245a5fc9b1
--- /dev/null
+++ b/codegen/testserver/followschema/mutation_with_custom_scalar.go
@@ -0,0 +1,29 @@
+package followschema
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "regexp"
+)
+
+var re = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
+
+type Email string
+
+func (value *Email) UnmarshalGQL(v interface{}) error {
+ input, ok := v.(string)
+ if !ok {
+ return fmt.Errorf("email expects a string value")
+ }
+ if !re.MatchString(input) {
+ return fmt.Errorf("invalid email format")
+ }
+ *value = Email(input)
+ return nil
+}
+
+func (value Email) MarshalGQL(w io.Writer) {
+ output, _ := json.Marshal(string(value))
+ w.Write(output)
+}
diff --git a/codegen/testserver/mutation_with_custom_scalar.graphql b/codegen/testserver/followschema/mutation_with_custom_scalar.graphql
similarity index 100%
rename from codegen/testserver/mutation_with_custom_scalar.graphql
rename to codegen/testserver/followschema/mutation_with_custom_scalar.graphql
diff --git a/codegen/testserver/followschema/mutation_with_custom_scalar_test.go b/codegen/testserver/followschema/mutation_with_custom_scalar_test.go
new file mode 100644
index 00000000000..2f46c3ad4d0
--- /dev/null
+++ b/codegen/testserver/followschema/mutation_with_custom_scalar_test.go
@@ -0,0 +1,50 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestErrorInsideMutationArgument(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.MutationResolver.UpdateSomething = func(_ context.Context, input SpecialInput) (s string, err error) {
+ return "Hello world", nil
+ }
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ t.Run("mutation with correct input doesn't return error", func(t *testing.T) {
+ var resp map[string]interface{}
+ input := map[string]interface{}{
+ "nesting": map[string]interface{}{
+ "field": "email@example.com",
+ },
+ }
+ err := c.Post(
+ `mutation TestMutation($input: SpecialInput!) { updateSomething(input: $input) }`,
+ &resp,
+ client.Var("input", input),
+ )
+ require.Equal(t, resp["updateSomething"], "Hello world")
+ require.NoError(t, err)
+ })
+
+ t.Run("mutation with incorrect input returns full path", func(t *testing.T) {
+ var resp map[string]interface{}
+ input := map[string]interface{}{
+ "nesting": map[string]interface{}{
+ "field": "not-an-email",
+ },
+ }
+ err := c.Post(
+ `mutation TestMutation($input: SpecialInput!) { updateSomething(input: $input) }`,
+ &resp,
+ client.Var("input", input),
+ )
+ require.EqualError(t, err, `[{"message":"invalid email format","path":["updateSomething","input","nesting","field"]}]`)
+ })
+}
diff --git a/codegen/testserver/followschema/nulls.generated.go b/codegen/testserver/followschema/nulls.generated.go
new file mode 100644
index 00000000000..33cec45379c
--- /dev/null
+++ b/codegen/testserver/followschema/nulls.generated.go
@@ -0,0 +1,633 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+ "sync"
+ "sync/atomic"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+type ErrorsResolver interface {
+ A(ctx context.Context, obj *Errors) (*Error, error)
+ B(ctx context.Context, obj *Errors) (*Error, error)
+ C(ctx context.Context, obj *Errors) (*Error, error)
+ D(ctx context.Context, obj *Errors) (*Error, error)
+ E(ctx context.Context, obj *Errors) (*Error, error)
+}
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Error",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Error",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ErrorOnNonRequiredField()
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Error",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ErrorOnRequiredField()
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Error",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.NilOnRequiredField(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalNString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Errors_a(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Errors",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Errors().A(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*Error)
+ fc.Result = res
+ return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Errors_b(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Errors",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Errors().B(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*Error)
+ fc.Result = res
+ return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Errors_c(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Errors",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Errors().C(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*Error)
+ fc.Result = res
+ return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Errors_d(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Errors",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Errors().D(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*Error)
+ fc.Result = res
+ return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Errors_e(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Errors",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Errors().E(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*Error)
+ fc.Result = res
+ return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var errorImplementors = []string{"Error"}
+
+func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *Error) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, errorImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Error")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Error_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "errorOnNonRequiredField":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Error_errorOnNonRequiredField(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "errorOnRequiredField":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Error_errorOnRequiredField(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "nilOnRequiredField":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Error_nilOnRequiredField(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var errorsImplementors = []string{"Errors"}
+
+func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, obj *Errors) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, errorsImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Errors")
+ case "a":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Errors_a(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "b":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Errors_b(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "c":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Errors_c(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "d":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Errors_d(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "e":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Errors_e(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalNError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler {
+ return ec._Error(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._Error(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ return ret
+}
+
+func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrorᚄ(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._Error(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrors(ctx context.Context, sel ast.SelectionSet, v *Errors) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._Errors(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/nulls.graphql b/codegen/testserver/followschema/nulls.graphql
similarity index 84%
rename from codegen/testserver/nulls.graphql
rename to codegen/testserver/followschema/nulls.graphql
index d93f6b0cf62..a1fea680ce2 100644
--- a/codegen/testserver/nulls.graphql
+++ b/codegen/testserver/followschema/nulls.graphql
@@ -1,5 +1,7 @@
extend type Query {
errorBubble: Error
+ errorBubbleList: [Error!]
+ errorList: [Error]
errors: Errors
valid: String!
}
diff --git a/codegen/testserver/followschema/nulls_test.go b/codegen/testserver/followschema/nulls_test.go
new file mode 100644
index 00000000000..ef586e01c93
--- /dev/null
+++ b/codegen/testserver/followschema/nulls_test.go
@@ -0,0 +1,134 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestNullBubbling(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) {
+ return "Ok", nil
+ }
+ resolvers.QueryResolver.Errors = func(ctx context.Context) (errors *Errors, e error) {
+ return &Errors{}, nil
+ }
+ resolvers.QueryResolver.ErrorBubble = func(ctx context.Context) (i *Error, e error) {
+ return &Error{ID: "E1234"}, nil
+ }
+ resolvers.QueryResolver.ErrorBubbleList = func(ctx context.Context) (i []*Error, e error) {
+ return []*Error{nil}, nil
+ }
+ resolvers.QueryResolver.ErrorList = func(ctx context.Context) (i []*Error, e error) {
+ return []*Error{nil}, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ t.Run("when function errors on non required field", func(t *testing.T) {
+ var resp struct {
+ Valid string
+ ErrorBubble *struct {
+ Id string
+ ErrorOnNonRequiredField *string
+ }
+ }
+ err := c.Post(`query { valid, errorBubble { id, errorOnNonRequiredField } }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"boom","path":["errorBubble","errorOnNonRequiredField"]}]`)
+ require.Equal(t, "E1234", resp.ErrorBubble.Id)
+ require.Nil(t, resp.ErrorBubble.ErrorOnNonRequiredField)
+ require.Equal(t, "Ok", resp.Valid)
+ })
+
+ t.Run("when function errors", func(t *testing.T) {
+ var resp struct {
+ Valid string
+ ErrorBubble *struct {
+ NilOnRequiredField string
+ }
+ }
+ err := c.Post(`query { valid, errorBubble { id, errorOnRequiredField } }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"boom","path":["errorBubble","errorOnRequiredField"]}]`)
+ require.Nil(t, resp.ErrorBubble)
+ require.Equal(t, "Ok", resp.Valid)
+ })
+
+ t.Run("when user returns null on required field", func(t *testing.T) {
+ var resp struct {
+ Valid string
+ ErrorBubble *struct {
+ NilOnRequiredField string
+ }
+ }
+ err := c.Post(`query { valid, errorBubble { id, nilOnRequiredField } }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"must not be null","path":["errorBubble","nilOnRequiredField"]}]`)
+ require.Nil(t, resp.ErrorBubble)
+ require.Equal(t, "Ok", resp.Valid)
+ })
+
+ t.Run("when list element is null", func(t *testing.T) {
+ var resp struct {
+ Valid string
+ ErrorList []*struct{}
+ }
+ err := c.Post(`query { valid, errorList { id } }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, len(resp.ErrorList), 1)
+ require.Nil(t, resp.ErrorList[0])
+ require.Equal(t, "Ok", resp.Valid)
+ })
+
+ t.Run("when non-null list element is null", func(t *testing.T) {
+ var resp struct {
+ Valid string
+ ErrorBubbleList []*struct{}
+ }
+ err := c.Post(`query { valid, errorBubbleList { id } }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"must not be null","path":["errorBubbleList",0]}]`)
+ require.Nil(t, resp.ErrorBubbleList)
+ require.Equal(t, "Ok", resp.Valid)
+ })
+
+ t.Run("null args", func(t *testing.T) {
+ var resp struct {
+ NullableArg *string
+ }
+ resolvers.QueryResolver.NullableArg = func(ctx context.Context, arg *int) (i *string, e error) {
+ v := "Ok"
+ return &v, nil
+ }
+
+ err := c.Post(`query { nullableArg(arg: null) }`, &resp)
+ require.Nil(t, err)
+ require.Equal(t, "Ok", *resp.NullableArg)
+ })
+
+ t.Run("concurrent null detection", func(t *testing.T) {
+ var resp interface{}
+ resolvers.ErrorsResolver.A = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil }
+ resolvers.ErrorsResolver.B = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil }
+ resolvers.ErrorsResolver.C = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil }
+ resolvers.ErrorsResolver.D = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil }
+ resolvers.ErrorsResolver.E = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil }
+
+ err := c.Post(`{ errors {
+ a { id },
+ b { id },
+ c { id },
+ d { id },
+ e { id },
+ } }`, &resp)
+
+ require.Error(t, err)
+ require.Contains(t, err.Error(), "must not be null")
+ })
+}
diff --git a/codegen/testserver/otherpkg/model.go b/codegen/testserver/followschema/otherpkg/model.go
similarity index 100%
rename from codegen/testserver/otherpkg/model.go
rename to codegen/testserver/followschema/otherpkg/model.go
diff --git a/codegen/testserver/followschema/panics.generated.go b/codegen/testserver/followschema/panics.generated.go
new file mode 100644
index 00000000000..1aa80a17b03
--- /dev/null
+++ b/codegen/testserver/followschema/panics.generated.go
@@ -0,0 +1,324 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+ "sync/atomic"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+type PanicsResolver interface {
+ FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error)
+
+ ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error)
+}
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+func (ec *executionContext) field_Panics_argUnmarshal_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 []MarshalPanic
+ if tmp, ok := rawArgs["u"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("u"))
+ arg0, err = ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["u"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Panics_fieldFuncMarshal_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 []MarshalPanic
+ if tmp, ok := rawArgs["u"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("u"))
+ arg0, err = ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["u"] = arg0
+ return args, nil
+}
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Panics",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Panics().FieldScalarMarshal(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]MarshalPanic)
+ fc.Result = res
+ return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Panics",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Panics_fieldFuncMarshal_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.FieldFuncMarshal(ctx, args["u"].([]MarshalPanic)), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]MarshalPanic)
+ fc.Result = res
+ return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Panics",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Panics_argUnmarshal_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Panics().ArgUnmarshal(rctx, obj, args["u"].([]MarshalPanic))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var panicsImplementors = []string{"Panics"}
+
+func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, obj *Panics) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, panicsImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Panics")
+ case "fieldScalarMarshal":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Panics_fieldScalarMarshal(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "fieldFuncMarshal":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Panics_fieldFuncMarshal(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "argUnmarshal":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Panics_argUnmarshal(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx context.Context, v interface{}) (MarshalPanic, error) {
+ var res MarshalPanic
+ err := res.UnmarshalGQL(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx context.Context, sel ast.SelectionSet, v MarshalPanic) graphql.Marshaler {
+ return v
+}
+
+func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx context.Context, v interface{}) ([]MarshalPanic, error) {
+ var vSlice []interface{}
+ if v != nil {
+ if tmp1, ok := v.([]interface{}); ok {
+ vSlice = tmp1
+ } else {
+ vSlice = []interface{}{v}
+ }
+ }
+ var err error
+ res := make([]MarshalPanic, len(vSlice))
+ for i := range vSlice {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
+ res[i], err = ec.unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx, vSlice[i])
+ if err != nil {
+ return nil, err
+ }
+ }
+ return res, nil
+}
+
+func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx context.Context, sel ast.SelectionSet, v []MarshalPanic) graphql.Marshaler {
+ ret := make(graphql.Array, len(v))
+ for i := range v {
+ ret[i] = ec.marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx, sel, v[i])
+ }
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPanics(ctx context.Context, sel ast.SelectionSet, v *Panics) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._Panics(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/panics.graphql b/codegen/testserver/followschema/panics.graphql
similarity index 100%
rename from codegen/testserver/panics.graphql
rename to codegen/testserver/followschema/panics.graphql
diff --git a/codegen/testserver/followschema/panics_test.go b/codegen/testserver/followschema/panics_test.go
new file mode 100644
index 00000000000..4433aad01a3
--- /dev/null
+++ b/codegen/testserver/followschema/panics_test.go
@@ -0,0 +1,69 @@
+package followschema
+
+import (
+ "context"
+ "fmt"
+ "testing"
+
+ "github.com/99designs/gqlgen/graphql"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+ "github.com/vektah/gqlparser/v2/gqlerror"
+)
+
+func TestPanics(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.Panics = func(ctx context.Context) (panics *Panics, e error) {
+ return &Panics{}, nil
+ }
+ resolvers.PanicsResolver.ArgUnmarshal = func(ctx context.Context, obj *Panics, u []MarshalPanic) (b bool, e error) {
+ return true, nil
+ }
+ resolvers.PanicsResolver.FieldScalarMarshal = func(ctx context.Context, obj *Panics) (marshalPanic []MarshalPanic, e error) {
+ return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")}, nil
+ }
+
+ srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))
+ srv.SetRecoverFunc(func(ctx context.Context, err interface{}) (userMessage error) {
+ return fmt.Errorf("panic: %v", err)
+ })
+
+ srv.SetErrorPresenter(func(ctx context.Context, err error) *gqlerror.Error {
+ return &gqlerror.Error{
+ Message: "presented: " + err.Error(),
+ Path: graphql.GetPath(ctx),
+ }
+ })
+
+ c := client.New(srv)
+
+ t.Run("panics in marshallers will not kill server", func(t *testing.T) {
+ var resp interface{}
+ err := c.Post(`query { panics { fieldScalarMarshal } }`, &resp)
+
+ require.EqualError(t, err, "http 422: {\"errors\":[{\"message\":\"presented: panic: BOOM\"}],\"data\":null}")
+ })
+
+ t.Run("panics in unmarshalers will not kill server", func(t *testing.T) {
+ var resp interface{}
+ err := c.Post(`query { panics { argUnmarshal(u: ["aa", "bb"]) } }`, &resp)
+
+ require.EqualError(t, err, "[{\"message\":\"presented: input: panics.argUnmarshal panic: BOOM\",\"path\":[\"panics\",\"argUnmarshal\"]}]")
+ })
+
+ t.Run("panics in funcs unmarshal return errors", func(t *testing.T) {
+ var resp interface{}
+ err := c.Post(`query { panics { fieldFuncMarshal(u: ["aa", "bb"]) } }`, &resp)
+
+ require.EqualError(t, err, "[{\"message\":\"presented: input: panics.fieldFuncMarshal panic: BOOM\",\"path\":[\"panics\",\"fieldFuncMarshal\"]}]")
+ })
+
+ t.Run("panics in funcs marshal return errors", func(t *testing.T) {
+ var resp interface{}
+ err := c.Post(`query { panics { fieldFuncMarshal(u: []) } }`, &resp)
+
+ require.EqualError(t, err, "http 422: {\"errors\":[{\"message\":\"presented: panic: BOOM\"}],\"data\":null}")
+ })
+}
diff --git a/codegen/testserver/followschema/prelude.generated.go b/codegen/testserver/followschema/prelude.generated.go
new file mode 100644
index 00000000000..39c1364a7c4
--- /dev/null
+++ b/codegen/testserver/followschema/prelude.generated.go
@@ -0,0 +1,2333 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+ "sync"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/99designs/gqlgen/graphql/introspection"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 bool
+ if tmp, ok := rawArgs["includeDeprecated"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated"))
+ arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["includeDeprecated"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 bool
+ if tmp, ok := rawArgs["includeDeprecated"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated"))
+ arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["includeDeprecated"] = arg0
+ return args, nil
+}
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Name, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Description, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Locations, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]string)
+ fc.Result = res
+ return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Args, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]introspection.InputValue)
+ fc.Result = res
+ return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__EnumValue",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Name, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__EnumValue",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Description, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__EnumValue",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsDeprecated(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__EnumValue",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.DeprecationReason(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Field",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Name, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Field",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Description, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Field",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Args, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]introspection.InputValue)
+ fc.Result = res
+ return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Field",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Type, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*introspection.Type)
+ fc.Result = res
+ return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Field",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsDeprecated(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Field",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.DeprecationReason(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__InputValue",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Name, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__InputValue",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Description, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__InputValue",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Type, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*introspection.Type)
+ fc.Result = res
+ return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__InputValue",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.DefaultValue, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Schema",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Types(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]introspection.Type)
+ fc.Result = res
+ return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Schema",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.QueryType(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*introspection.Type)
+ fc.Result = res
+ return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Schema",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.MutationType(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*introspection.Type)
+ fc.Result = res
+ return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Schema",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.SubscriptionType(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*introspection.Type)
+ fc.Result = res
+ return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Schema",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Directives(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]introspection.Directive)
+ fc.Result = res
+ return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Type",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Kind(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalN__TypeKind2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Type",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Name(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Type",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Description(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Type",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field___Type_fields_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Fields(args["includeDeprecated"].(bool)), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]introspection.Field)
+ fc.Result = res
+ return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Type",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Interfaces(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]introspection.Type)
+ fc.Result = res
+ return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Type",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.PossibleTypes(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]introspection.Type)
+ fc.Result = res
+ return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Type",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field___Type_enumValues_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.EnumValues(args["includeDeprecated"].(bool)), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]introspection.EnumValue)
+ fc.Result = res
+ return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Type",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.InputFields(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]introspection.InputValue)
+ fc.Result = res
+ return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Type",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.OfType(), nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*introspection.Type)
+ fc.Result = res
+ return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var __DirectiveImplementors = []string{"__Directive"}
+
+func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("__Directive")
+ case "name":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "description":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "locations":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "args":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var __EnumValueImplementors = []string{"__EnumValue"}
+
+func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("__EnumValue")
+ case "name":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "description":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "isDeprecated":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "deprecationReason":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var __FieldImplementors = []string{"__Field"}
+
+func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("__Field")
+ case "name":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "description":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "args":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "type":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isDeprecated":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "deprecationReason":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var __InputValueImplementors = []string{"__InputValue"}
+
+func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("__InputValue")
+ case "name":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "description":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "type":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "defaultValue":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var __SchemaImplementors = []string{"__Schema"}
+
+func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("__Schema")
+ case "types":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "queryType":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "mutationType":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "subscriptionType":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "directives":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var __TypeImplementors = []string{"__Type"}
+
+func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("__Type")
+ case "kind":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "name":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "description":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "fields":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "interfaces":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "possibleTypes":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "enumValues":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "inputFields":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "ofType":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) {
+ res, err := graphql.UnmarshalBoolean(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
+ res := graphql.MarshalBoolean(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v interface{}) (float64, error) {
+ res, err := graphql.UnmarshalFloatContext(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler {
+ res := graphql.MarshalFloatContext(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return graphql.WrapContextMarshaler(ctx, res)
+}
+
+func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) {
+ res, err := graphql.UnmarshalIntID(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler {
+ res := graphql.MarshalIntID(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) {
+ res, err := graphql.UnmarshalID(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
+ res := graphql.MarshalID(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) {
+ res, err := graphql.UnmarshalInt(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler {
+ res := graphql.MarshalInt(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) unmarshalNInt2int32(ctx context.Context, v interface{}) (int32, error) {
+ res, err := graphql.UnmarshalInt32(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.SelectionSet, v int32) graphql.Marshaler {
+ res := graphql.MarshalInt32(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) unmarshalNInt2int64(ctx context.Context, v interface{}) (int64, error) {
+ res, err := graphql.UnmarshalInt64(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler {
+ res := graphql.MarshalInt64(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) {
+ res, err := graphql.UnmarshalString(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
+ res := graphql.MarshalString(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) {
+ var vSlice []interface{}
+ if v != nil {
+ if tmp1, ok := v.([]interface{}); ok {
+ vSlice = tmp1
+ } else {
+ vSlice = []interface{}{v}
+ }
+ }
+ var err error
+ res := make([]string, len(vSlice))
+ for i := range vSlice {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
+ res[i], err = ec.unmarshalNString2string(ctx, vSlice[i])
+ if err != nil {
+ return nil, err
+ }
+ }
+ return res, nil
+}
+
+func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler {
+ ret := make(graphql.Array, len(v))
+ for i := range v {
+ ret[i] = ec.marshalNString2string(ctx, sel, v[i])
+ }
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) unmarshalNString2ᚕᚖstring(ctx context.Context, v interface{}) ([]*string, error) {
+ var vSlice []interface{}
+ if v != nil {
+ if tmp1, ok := v.([]interface{}); ok {
+ vSlice = tmp1
+ } else {
+ vSlice = []interface{}{v}
+ }
+ }
+ var err error
+ res := make([]*string, len(vSlice))
+ for i := range vSlice {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
+ res[i], err = ec.unmarshalOString2ᚖstring(ctx, vSlice[i])
+ if err != nil {
+ return nil, err
+ }
+ }
+ return res, nil
+}
+
+func (ec *executionContext) marshalNString2ᚕᚖstring(ctx context.Context, sel ast.SelectionSet, v []*string) graphql.Marshaler {
+ ret := make(graphql.Array, len(v))
+ for i := range v {
+ ret[i] = ec.marshalOString2ᚖstring(ctx, sel, v[i])
+ }
+
+ return ret
+}
+
+func (ec *executionContext) unmarshalNString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
+ res, err := graphql.UnmarshalString(v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := graphql.MarshalString(*v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
+ return ec.___Directive(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) {
+ res, err := graphql.UnmarshalString(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
+ res := graphql.MarshalString(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) {
+ var vSlice []interface{}
+ if v != nil {
+ if tmp1, ok := v.([]interface{}); ok {
+ vSlice = tmp1
+ } else {
+ vSlice = []interface{}{v}
+ }
+ }
+ var err error
+ res := make([]string, len(vSlice))
+ for i := range vSlice {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
+ res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i])
+ if err != nil {
+ return nil, err
+ }
+ }
+ return res, nil
+}
+
+func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler {
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
+ return ec.___EnumValue(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
+ return ec.___Field(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
+ return ec.___InputValue(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
+ return ec.___Type(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec.___Type(ctx, sel, v)
+}
+
+func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) {
+ res, err := graphql.UnmarshalString(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
+ res := graphql.MarshalString(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) {
+ res, err := graphql.UnmarshalBoolean(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
+ res := graphql.MarshalBoolean(v)
+ return res
+}
+
+func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := graphql.UnmarshalBoolean(v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ res := graphql.MarshalBoolean(*v)
+ return res
+}
+
+func (ec *executionContext) unmarshalOFloat2float64(ctx context.Context, v interface{}) (float64, error) {
+ res, err := graphql.UnmarshalFloatContext(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler {
+ res := graphql.MarshalFloatContext(v)
+ return graphql.WrapContextMarshaler(ctx, res)
+}
+
+func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := graphql.UnmarshalInt(v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ res := graphql.MarshalInt(*v)
+ return res
+}
+
+func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) {
+ res, err := graphql.UnmarshalString(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
+ res := graphql.MarshalString(v)
+ return res
+}
+
+func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) {
+ if v == nil {
+ return nil, nil
+ }
+ var vSlice []interface{}
+ if v != nil {
+ if tmp1, ok := v.([]interface{}); ok {
+ vSlice = tmp1
+ } else {
+ vSlice = []interface{}{v}
+ }
+ }
+ var err error
+ res := make([]string, len(vSlice))
+ for i := range vSlice {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
+ res[i], err = ec.unmarshalNString2string(ctx, vSlice[i])
+ if err != nil {
+ return nil, err
+ }
+ }
+ return res, nil
+}
+
+func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ for i := range v {
+ ret[i] = ec.marshalNString2string(ctx, sel, v[i])
+ }
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) unmarshalOString2ᚕᚖstring(ctx context.Context, v interface{}) ([]*string, error) {
+ if v == nil {
+ return nil, nil
+ }
+ var vSlice []interface{}
+ if v != nil {
+ if tmp1, ok := v.([]interface{}); ok {
+ vSlice = tmp1
+ } else {
+ vSlice = []interface{}{v}
+ }
+ }
+ var err error
+ res := make([]*string, len(vSlice))
+ for i := range vSlice {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
+ res[i], err = ec.unmarshalOString2ᚖstring(ctx, vSlice[i])
+ if err != nil {
+ return nil, err
+ }
+ }
+ return res, nil
+}
+
+func (ec *executionContext) marshalOString2ᚕᚖstring(ctx context.Context, sel ast.SelectionSet, v []*string) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ for i := range v {
+ ret[i] = ec.marshalOString2ᚖstring(ctx, sel, v[i])
+ }
+
+ return ret
+}
+
+func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := graphql.UnmarshalString(v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ res := graphql.MarshalString(*v)
+ return res
+}
+
+func (ec *executionContext) unmarshalOString2ᚖᚕstringᚄ(ctx context.Context, v interface{}) (*[]string, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOString2ᚖᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v *[]string) graphql.Marshaler {
+ return ec.marshalOString2ᚕstringᚄ(ctx, sel, *v)
+}
+
+func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.___Schema(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.___Type(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/followschema/primitive_objects.generated.go b/codegen/testserver/followschema/primitive_objects.generated.go
new file mode 100644
index 00000000000..715910f0d2e
--- /dev/null
+++ b/codegen/testserver/followschema/primitive_objects.generated.go
@@ -0,0 +1,432 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+ "sync"
+ "sync/atomic"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+type PrimitiveResolver interface {
+ Value(ctx context.Context, obj *Primitive) (int, error)
+}
+type PrimitiveStringResolver interface {
+ Value(ctx context.Context, obj *PrimitiveString) (string, error)
+
+ Len(ctx context.Context, obj *PrimitiveString) (int, error)
+}
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _Primitive_value(ctx context.Context, field graphql.CollectedField, obj *Primitive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Primitive",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Primitive().Value(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Primitive_squared(ctx context.Context, field graphql.CollectedField, obj *Primitive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Primitive",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Squared(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _PrimitiveString_value(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PrimitiveString",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.PrimitiveString().Value(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _PrimitiveString_doubled(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PrimitiveString",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Doubled(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _PrimitiveString_len(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PrimitiveString",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.PrimitiveString().Len(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var primitiveImplementors = []string{"Primitive"}
+
+func (ec *executionContext) _Primitive(ctx context.Context, sel ast.SelectionSet, obj *Primitive) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, primitiveImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Primitive")
+ case "value":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Primitive_value(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "squared":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Primitive_squared(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var primitiveStringImplementors = []string{"PrimitiveString"}
+
+func (ec *executionContext) _PrimitiveString(ctx context.Context, sel ast.SelectionSet, obj *PrimitiveString) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, primitiveStringImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("PrimitiveString")
+ case "value":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._PrimitiveString_value(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "doubled":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PrimitiveString_doubled(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ case "len":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._PrimitiveString_len(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalNPrimitive2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitive(ctx context.Context, sel ast.SelectionSet, v Primitive) graphql.Marshaler {
+ return ec._Primitive(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveᚄ(ctx context.Context, sel ast.SelectionSet, v []Primitive) graphql.Marshaler {
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalNPrimitive2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitive(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalNPrimitiveString2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveString(ctx context.Context, sel ast.SelectionSet, v PrimitiveString) graphql.Marshaler {
+ return ec._PrimitiveString(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveStringᚄ(ctx context.Context, sel ast.SelectionSet, v []PrimitiveString) graphql.Marshaler {
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalNPrimitiveString2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveString(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/primitive_objects.graphql b/codegen/testserver/followschema/primitive_objects.graphql
similarity index 100%
rename from codegen/testserver/primitive_objects.graphql
rename to codegen/testserver/followschema/primitive_objects.graphql
diff --git a/codegen/testserver/followschema/primitive_objects_test.go b/codegen/testserver/followschema/primitive_objects_test.go
new file mode 100644
index 00000000000..87de88bb452
--- /dev/null
+++ b/codegen/testserver/followschema/primitive_objects_test.go
@@ -0,0 +1,73 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPrimitiveObjects(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.PrimitiveObject = func(ctx context.Context) (out []Primitive, e error) {
+ return []Primitive{2, 4}, nil
+ }
+
+ resolvers.PrimitiveResolver.Value = func(ctx context.Context, obj *Primitive) (i int, e error) {
+ return int(*obj), nil
+ }
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ t.Run("can fetch value", func(t *testing.T) {
+ var resp struct {
+ PrimitiveObject []struct {
+ Value int
+ Squared int
+ }
+ }
+ c.MustPost(`query { primitiveObject { value, squared } }`, &resp)
+
+ assert.Equal(t, 2, resp.PrimitiveObject[0].Value)
+ assert.Equal(t, 4, resp.PrimitiveObject[0].Squared)
+ assert.Equal(t, 4, resp.PrimitiveObject[1].Value)
+ assert.Equal(t, 16, resp.PrimitiveObject[1].Squared)
+ })
+}
+
+func TestPrimitiveStringObjects(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.PrimitiveStringObject = func(ctx context.Context) (out []PrimitiveString, e error) {
+ return []PrimitiveString{"hello", "world"}, nil
+ }
+
+ resolvers.PrimitiveStringResolver.Value = func(ctx context.Context, obj *PrimitiveString) (i string, e error) {
+ return string(*obj), nil
+ }
+
+ resolvers.PrimitiveStringResolver.Len = func(ctx context.Context, obj *PrimitiveString) (i int, e error) {
+ return len(string(*obj)), nil
+ }
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ t.Run("can fetch value", func(t *testing.T) {
+ var resp struct {
+ PrimitiveStringObject []struct {
+ Value string
+ Doubled string
+ Len int
+ }
+ }
+ c.MustPost(`query { primitiveStringObject { value, doubled, len } }`, &resp)
+
+ assert.Equal(t, "hello", resp.PrimitiveStringObject[0].Value)
+ assert.Equal(t, "hellohello", resp.PrimitiveStringObject[0].Doubled)
+ assert.Equal(t, 5, resp.PrimitiveStringObject[0].Len)
+ assert.Equal(t, "world", resp.PrimitiveStringObject[1].Value)
+ assert.Equal(t, "worldworld", resp.PrimitiveStringObject[1].Doubled)
+ assert.Equal(t, 5, resp.PrimitiveStringObject[1].Len)
+ })
+}
diff --git a/codegen/testserver/followschema/ptr_to_ptr_input.generated.go b/codegen/testserver/followschema/ptr_to_ptr_input.generated.go
new file mode 100644
index 00000000000..0b51b80a79f
--- /dev/null
+++ b/codegen/testserver/followschema/ptr_to_ptr_input.generated.go
@@ -0,0 +1,513 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _PtrToPtrInner_key(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrInner) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PtrToPtrInner",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Key, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _PtrToPtrInner_value(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrInner) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PtrToPtrInner",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Value, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _PtrToPtrOuter_name(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PtrToPtrOuter",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Name, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _PtrToPtrOuter_inner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PtrToPtrOuter",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Inner, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*PtrToPtrInner)
+ fc.Result = res
+ return ec.marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _PtrToPtrOuter_stupidInner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PtrToPtrOuter",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.StupidInner, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*******PtrToPtrInner)
+ fc.Result = res
+ return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+func (ec *executionContext) unmarshalInputUpdatePtrToPtrInner(ctx context.Context, obj interface{}) (UpdatePtrToPtrInner, error) {
+ var it UpdatePtrToPtrInner
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "key":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key"))
+ it.Key, err = ec.unmarshalOString2ᚖstring(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "value":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value"))
+ it.Value, err = ec.unmarshalOString2ᚖstring(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+func (ec *executionContext) unmarshalInputUpdatePtrToPtrOuter(ctx context.Context, obj interface{}) (UpdatePtrToPtrOuter, error) {
+ var it UpdatePtrToPtrOuter
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "name":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name"))
+ it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "inner":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner"))
+ it.Inner, err = ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "stupidInner":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stupidInner"))
+ it.StupidInner, err = ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var ptrToPtrInnerImplementors = []string{"PtrToPtrInner"}
+
+func (ec *executionContext) _PtrToPtrInner(ctx context.Context, sel ast.SelectionSet, obj *PtrToPtrInner) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, ptrToPtrInnerImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("PtrToPtrInner")
+ case "key":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToPtrInner_key(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "value":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToPtrInner_value(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var ptrToPtrOuterImplementors = []string{"PtrToPtrOuter"}
+
+func (ec *executionContext) _PtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, obj *PtrToPtrOuter) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, ptrToPtrOuterImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("PtrToPtrOuter")
+ case "name":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToPtrOuter_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "inner":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToPtrOuter_inner(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "stupidInner":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToPtrOuter_stupidInner(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalNPtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, v PtrToPtrOuter) graphql.Marshaler {
+ return ec._PtrToPtrOuter(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNPtrToPtrOuter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, v *PtrToPtrOuter) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._PtrToPtrOuter(ctx, sel, v)
+}
+
+func (ec *executionContext) unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrOuter(ctx context.Context, v interface{}) (UpdatePtrToPtrOuter, error) {
+ res, err := ec.unmarshalInputUpdatePtrToPtrOuter(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._PtrToPtrInner(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v **PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ***PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ****PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *****PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ******PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *******PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (*UpdatePtrToPtrInner, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalInputUpdatePtrToPtrInner(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (**UpdatePtrToPtrInner, error) {
+ var pres *UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (***UpdatePtrToPtrInner, error) {
+ var pres **UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (****UpdatePtrToPtrInner, error) {
+ var pres ***UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (*****UpdatePtrToPtrInner, error) {
+ var pres ****UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (******UpdatePtrToPtrInner, error) {
+ var pres *****UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (*******UpdatePtrToPtrInner, error) {
+ var pres ******UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (********UpdatePtrToPtrInner, error) {
+ var pres *******UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/followschema/ptr_to_ptr_input.go b/codegen/testserver/followschema/ptr_to_ptr_input.go
new file mode 100644
index 00000000000..c4c082b75ec
--- /dev/null
+++ b/codegen/testserver/followschema/ptr_to_ptr_input.go
@@ -0,0 +1,23 @@
+package followschema
+
+type PtrToPtrOuter struct {
+ Name string
+ Inner *PtrToPtrInner
+ StupidInner *******PtrToPtrInner
+}
+
+type PtrToPtrInner struct {
+ Key string
+ Value string
+}
+
+type UpdatePtrToPtrOuter struct {
+ Name *string
+ Inner **UpdatePtrToPtrInner
+ StupidInner ********UpdatePtrToPtrInner
+}
+
+type UpdatePtrToPtrInner struct {
+ Key *string
+ Value *string
+}
diff --git a/codegen/testserver/followschema/ptr_to_ptr_input.graphql b/codegen/testserver/followschema/ptr_to_ptr_input.graphql
new file mode 100644
index 00000000000..c34b5c56fc5
--- /dev/null
+++ b/codegen/testserver/followschema/ptr_to_ptr_input.graphql
@@ -0,0 +1,25 @@
+type PtrToPtrOuter {
+ name: String!
+ inner: PtrToPtrInner
+ stupidInner: PtrToPtrInner
+}
+
+type PtrToPtrInner {
+ key: String!
+ value: String!
+}
+
+input UpdatePtrToPtrOuter {
+ name: String
+ inner: UpdatePtrToPtrInner
+ stupidInner: UpdatePtrToPtrInner
+}
+
+input UpdatePtrToPtrInner {
+ key: String
+ value: String
+}
+
+extend type Mutation {
+ updatePtrToPtr(input: UpdatePtrToPtrOuter!): PtrToPtrOuter!
+}
diff --git a/codegen/testserver/followschema/ptr_to_ptr_input_test.go b/codegen/testserver/followschema/ptr_to_ptr_input_test.go
new file mode 100644
index 00000000000..bb644e492b4
--- /dev/null
+++ b/codegen/testserver/followschema/ptr_to_ptr_input_test.go
@@ -0,0 +1,174 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+type UpdatePtrToPtrResults struct {
+ UpdatedPtrToPtr PtrToPtrOuter `json:"updatePtrToPtr"`
+}
+
+func TestPtrToPtr(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.MutationResolver.UpdatePtrToPtr = func(ctx context.Context, in UpdatePtrToPtrOuter) (ret *PtrToPtrOuter, err error) {
+ ret = &PtrToPtrOuter{
+ Name: "oldName",
+ Inner: &PtrToPtrInner{
+ Key: "oldKey",
+ Value: "oldValue",
+ },
+ StupidInner: nest7(&PtrToPtrInner{
+ Key: "oldStupidKey",
+ Value: "oldStupidValue",
+ }),
+ }
+
+ if in.Name != nil {
+ ret.Name = *in.Name
+ }
+
+ if in.Inner != nil {
+ inner := *in.Inner
+ if inner == nil {
+ ret.Inner = nil
+ } else {
+ if in.Inner == nil {
+ ret.Inner = &PtrToPtrInner{}
+ }
+ if inner.Key != nil {
+ ret.Inner.Key = *inner.Key
+ }
+ if inner.Value != nil {
+ ret.Inner.Value = *inner.Value
+ }
+ }
+ }
+
+ if in.StupidInner != nil {
+ si := *in.StupidInner
+ if si == nil {
+ ret.StupidInner = nil
+ } else {
+ deepIn := ******si
+ deepOut := ******ret.StupidInner
+ if deepIn.Key != nil {
+ deepOut.Key = *deepIn.Key
+ }
+ if deepIn.Value != nil {
+ deepOut.Value = *deepIn.Value
+ }
+ }
+ }
+ return
+ }
+
+ t.Run("pointer to pointer input missing", func(t *testing.T) {
+ var resp UpdatePtrToPtrResults
+
+ err := c.Post(`mutation { updatePtrToPtr(input: { name: "newName" }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, resp.UpdatedPtrToPtr.Name, "newName")
+ require.NotNil(t, resp.UpdatedPtrToPtr.Inner)
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Key, "oldKey")
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Value, "oldValue")
+ require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner)
+ require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner)
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Key, "oldStupidKey")
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Value, "oldStupidValue")
+ })
+
+ t.Run("pointer to pointer input non-null", func(t *testing.T) {
+ var resp UpdatePtrToPtrResults
+
+ err := c.Post(`mutation {
+ updatePtrToPtr(input: {
+ inner: {
+ key: "newKey"
+ value: "newValue"
+ }
+ })
+ { name, inner { key, value }, stupidInner { key, value }}
+ }`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, resp.UpdatedPtrToPtr.Name, "oldName")
+ require.NotNil(t, resp.UpdatedPtrToPtr.Inner)
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Key, "newKey")
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Value, "newValue")
+ require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner)
+ require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner)
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Key, "oldStupidKey")
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Value, "oldStupidValue")
+ })
+
+ t.Run("pointer to pointer input null", func(t *testing.T) {
+ var resp UpdatePtrToPtrResults
+
+ err := c.Post(`mutation { updatePtrToPtr(input: { inner: null }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, resp.UpdatedPtrToPtr.Name, "oldName")
+ require.Nil(t, resp.UpdatedPtrToPtr.Inner)
+ require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner)
+ require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner)
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Key, "oldStupidKey")
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Value, "oldStupidValue")
+ })
+
+ t.Run("many pointers input non-null", func(t *testing.T) {
+ var resp UpdatePtrToPtrResults
+
+ err := c.Post(`mutation {
+ updatePtrToPtr(input: {
+ stupidInner: {
+ key: "newKey"
+ value: "newValue"
+ }
+ })
+ { name, inner { key, value }, stupidInner { key, value }}
+ }`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, resp.UpdatedPtrToPtr.Name, "oldName")
+ require.NotNil(t, resp.UpdatedPtrToPtr.Inner)
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Key, "oldKey")
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Value, "oldValue")
+ require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner)
+ require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner)
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Key, "newKey")
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Value, "newValue")
+ })
+
+ t.Run("many pointers input null", func(t *testing.T) {
+ var resp UpdatePtrToPtrResults
+
+ err := c.Post(`mutation { updatePtrToPtr(input: { stupidInner: null }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, resp.UpdatedPtrToPtr.Name, "oldName")
+ require.NotNil(t, resp.UpdatedPtrToPtr.Inner)
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Key, "oldKey")
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Value, "oldValue")
+ require.Nil(t, resp.UpdatedPtrToPtr.StupidInner)
+ })
+}
+
+func nest7(in *PtrToPtrInner) *******PtrToPtrInner {
+ si2 := &in
+ si3 := &si2
+ si4 := &si3
+ si5 := &si4
+ si6 := &si5
+ si7 := &si6
+
+ return si7
+}
diff --git a/codegen/testserver/followschema/ptr_to_slice.generated.go b/codegen/testserver/followschema/ptr_to_slice.generated.go
new file mode 100644
index 00000000000..0ead7386453
--- /dev/null
+++ b/codegen/testserver/followschema/ptr_to_slice.generated.go
@@ -0,0 +1,114 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _PtrToSliceContainer_ptrToSlice(ctx context.Context, field graphql.CollectedField, obj *PtrToSliceContainer) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PtrToSliceContainer",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.PtrToSlice, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*[]string)
+ fc.Result = res
+ return ec.marshalOString2ᚖᚕstringᚄ(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var ptrToSliceContainerImplementors = []string{"PtrToSliceContainer"}
+
+func (ec *executionContext) _PtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, obj *PtrToSliceContainer) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, ptrToSliceContainerImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("PtrToSliceContainer")
+ case "ptrToSlice":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToSliceContainer_ptrToSlice(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalNPtrToSliceContainer2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, v PtrToSliceContainer) graphql.Marshaler {
+ return ec._PtrToSliceContainer(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNPtrToSliceContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, v *PtrToSliceContainer) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._PtrToSliceContainer(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/followschema/ptr_to_slice.go b/codegen/testserver/followschema/ptr_to_slice.go
new file mode 100644
index 00000000000..8cdd22d7c8a
--- /dev/null
+++ b/codegen/testserver/followschema/ptr_to_slice.go
@@ -0,0 +1,5 @@
+package followschema
+
+type PtrToSliceContainer struct {
+ PtrToSlice *[]string
+}
diff --git a/codegen/testserver/followschema/ptr_to_slice.graphql b/codegen/testserver/followschema/ptr_to_slice.graphql
new file mode 100644
index 00000000000..b773d83d428
--- /dev/null
+++ b/codegen/testserver/followschema/ptr_to_slice.graphql
@@ -0,0 +1,7 @@
+type PtrToSliceContainer {
+ ptrToSlice: [String!]
+}
+
+extend type Query {
+ ptrToSliceContainer: PtrToSliceContainer!
+}
diff --git a/codegen/testserver/followschema/ptr_to_slice_test.go b/codegen/testserver/followschema/ptr_to_slice_test.go
new file mode 100644
index 00000000000..ba7fbb3eed9
--- /dev/null
+++ b/codegen/testserver/followschema/ptr_to_slice_test.go
@@ -0,0 +1,37 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestPtrToSlice(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.QueryResolver.PtrToSliceContainer = func(ctx context.Context) (wrappedStruct *PtrToSliceContainer, e error) {
+ ptrToSliceContainer := PtrToSliceContainer{
+ PtrToSlice: &[]string{"hello"},
+ }
+ return &ptrToSliceContainer, nil
+ }
+
+ t.Run("pointer to slice", func(t *testing.T) {
+ var resp struct {
+ PtrToSliceContainer struct {
+ PtrToSlice []string
+ }
+ }
+
+ err := c.Post(`query { ptrToSliceContainer { ptrToSlice }}`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, []string{"hello"}, resp.PtrToSliceContainer.PtrToSlice)
+
+ })
+}
diff --git a/codegen/testserver/followschema/recursive.go b/codegen/testserver/followschema/recursive.go
new file mode 100644
index 00000000000..b5c096ff757
--- /dev/null
+++ b/codegen/testserver/followschema/recursive.go
@@ -0,0 +1,5 @@
+package followschema
+
+type RecursiveInputSlice struct {
+ Self []RecursiveInputSlice
+}
diff --git a/codegen/testserver/followschema/resolver.go b/codegen/testserver/followschema/resolver.go
new file mode 100644
index 00000000000..5e46f854016
--- /dev/null
+++ b/codegen/testserver/followschema/resolver.go
@@ -0,0 +1,438 @@
+package followschema
+
+// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.
+
+import (
+ "context"
+
+ introspection1 "github.com/99designs/gqlgen/codegen/testserver/followschema/introspection"
+ invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/followschema/invalid-packagename"
+ "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg"
+)
+
+type Resolver struct{}
+
+func (r *backedByInterfaceResolver) ID(ctx context.Context, obj BackedByInterface) (string, error) {
+ panic("not implemented")
+}
+
+func (r *errorsResolver) A(ctx context.Context, obj *Errors) (*Error, error) {
+ panic("not implemented")
+}
+
+func (r *errorsResolver) B(ctx context.Context, obj *Errors) (*Error, error) {
+ panic("not implemented")
+}
+
+func (r *errorsResolver) C(ctx context.Context, obj *Errors) (*Error, error) {
+ panic("not implemented")
+}
+
+func (r *errorsResolver) D(ctx context.Context, obj *Errors) (*Error, error) {
+ panic("not implemented")
+}
+
+func (r *errorsResolver) E(ctx context.Context, obj *Errors) (*Error, error) {
+ panic("not implemented")
+}
+
+func (r *forcedResolverResolver) Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) {
+ panic("not implemented")
+}
+
+func (r *modelMethodsResolver) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) {
+ panic("not implemented")
+}
+
+func (r *mutationResolver) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) {
+ panic("not implemented")
+}
+
+func (r *mutationResolver) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) {
+ panic("not implemented")
+}
+
+func (r *mutationResolver) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) {
+ panic("not implemented")
+}
+
+func (r *overlappingFieldsResolver) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) {
+ panic("not implemented")
+}
+
+func (r *panicsResolver) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) {
+ panic("not implemented")
+}
+
+func (r *panicsResolver) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) {
+ panic("not implemented")
+}
+
+func (r *primitiveResolver) Value(ctx context.Context, obj *Primitive) (int, error) {
+ panic("not implemented")
+}
+
+func (r *primitiveStringResolver) Value(ctx context.Context, obj *PrimitiveString) (string, error) {
+ panic("not implemented")
+}
+
+func (r *primitiveStringResolver) Len(ctx context.Context, obj *PrimitiveString) (int, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Collision(ctx context.Context) (*introspection1.It, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) MapInput(ctx context.Context, input map[string]interface{}) (*bool, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) ModelMethods(ctx context.Context) (*ModelMethods, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) User(ctx context.Context, id int) (*User, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) NullableArg(ctx context.Context, arg *int) (*string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) InputNullableSlice(ctx context.Context, arg []string) (bool, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Overlapping(ctx context.Context) (*OverlappingFields, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DirectiveFieldDef(ctx context.Context, ret string) (string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DirectiveField(ctx context.Context) (*string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DirectiveDouble(ctx context.Context) (*string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DirectiveUnimplemented(ctx context.Context) (*string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Shapes(ctx context.Context) ([]Shape, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) NoShape(ctx context.Context) (Shape, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Node(ctx context.Context) (Node, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) NoShapeTypedNil(ctx context.Context) (Shape, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Animal(ctx context.Context) (Animal, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) NotAnInterface(ctx context.Context) (BackedByInterface, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Issue896a(ctx context.Context) ([]*CheckIssue896, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) ErrorBubble(ctx context.Context) (*Error, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) ErrorBubbleList(ctx context.Context) ([]*Error, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) ErrorList(ctx context.Context) ([]*Error, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Errors(ctx context.Context) (*Errors, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Valid(ctx context.Context) (string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) PrimitiveObject(ctx context.Context) ([]Primitive, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Infinity(ctx context.Context) (float64, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) StringFromContextFunction(ctx context.Context) (string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Slices(ctx context.Context) (*Slices, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) ScalarSlice(ctx context.Context) ([]byte, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) WrappedStruct(ctx context.Context) (*WrappedStruct, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) WrappedMap(ctx context.Context) (WrappedMap, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) WrappedSlice(ctx context.Context) (WrappedSlice, error) {
+ panic("not implemented")
+}
+
+func (r *subscriptionResolver) Updated(ctx context.Context) (<-chan string, error) {
+ panic("not implemented")
+}
+
+func (r *subscriptionResolver) InitPayload(ctx context.Context) (<-chan string, error) {
+ panic("not implemented")
+}
+
+func (r *subscriptionResolver) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) {
+ panic("not implemented")
+}
+
+func (r *subscriptionResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) {
+ panic("not implemented")
+}
+
+func (r *subscriptionResolver) DirectiveDouble(ctx context.Context) (<-chan *string, error) {
+ panic("not implemented")
+}
+
+func (r *subscriptionResolver) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) {
+ panic("not implemented")
+}
+
+func (r *subscriptionResolver) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) {
+ panic("not implemented")
+}
+
+func (r *userResolver) Friends(ctx context.Context, obj *User) ([]*User, error) {
+ panic("not implemented")
+}
+
+func (r *wrappedMapResolver) Get(ctx context.Context, obj WrappedMap, key string) (string, error) {
+ panic("not implemented")
+}
+
+func (r *wrappedSliceResolver) Get(ctx context.Context, obj WrappedSlice, idx int) (string, error) {
+ panic("not implemented")
+}
+
+// BackedByInterface returns BackedByInterfaceResolver implementation.
+func (r *Resolver) BackedByInterface() BackedByInterfaceResolver {
+ return &backedByInterfaceResolver{r}
+}
+
+// Errors returns ErrorsResolver implementation.
+func (r *Resolver) Errors() ErrorsResolver { return &errorsResolver{r} }
+
+// ForcedResolver returns ForcedResolverResolver implementation.
+func (r *Resolver) ForcedResolver() ForcedResolverResolver { return &forcedResolverResolver{r} }
+
+// ModelMethods returns ModelMethodsResolver implementation.
+func (r *Resolver) ModelMethods() ModelMethodsResolver { return &modelMethodsResolver{r} }
+
+// Mutation returns MutationResolver implementation.
+func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} }
+
+// OverlappingFields returns OverlappingFieldsResolver implementation.
+func (r *Resolver) OverlappingFields() OverlappingFieldsResolver {
+ return &overlappingFieldsResolver{r}
+}
+
+// Panics returns PanicsResolver implementation.
+func (r *Resolver) Panics() PanicsResolver { return &panicsResolver{r} }
+
+// Primitive returns PrimitiveResolver implementation.
+func (r *Resolver) Primitive() PrimitiveResolver { return &primitiveResolver{r} }
+
+// PrimitiveString returns PrimitiveStringResolver implementation.
+func (r *Resolver) PrimitiveString() PrimitiveStringResolver { return &primitiveStringResolver{r} }
+
+// Query returns QueryResolver implementation.
+func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }
+
+// Subscription returns SubscriptionResolver implementation.
+func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} }
+
+// User returns UserResolver implementation.
+func (r *Resolver) User() UserResolver { return &userResolver{r} }
+
+// WrappedMap returns WrappedMapResolver implementation.
+func (r *Resolver) WrappedMap() WrappedMapResolver { return &wrappedMapResolver{r} }
+
+// WrappedSlice returns WrappedSliceResolver implementation.
+func (r *Resolver) WrappedSlice() WrappedSliceResolver { return &wrappedSliceResolver{r} }
+
+type backedByInterfaceResolver struct{ *Resolver }
+type errorsResolver struct{ *Resolver }
+type forcedResolverResolver struct{ *Resolver }
+type modelMethodsResolver struct{ *Resolver }
+type mutationResolver struct{ *Resolver }
+type overlappingFieldsResolver struct{ *Resolver }
+type panicsResolver struct{ *Resolver }
+type primitiveResolver struct{ *Resolver }
+type primitiveStringResolver struct{ *Resolver }
+type queryResolver struct{ *Resolver }
+type subscriptionResolver struct{ *Resolver }
+type userResolver struct{ *Resolver }
+type wrappedMapResolver struct{ *Resolver }
+type wrappedSliceResolver struct{ *Resolver }
diff --git a/codegen/testserver/followschema/response_extension_test.go b/codegen/testserver/followschema/response_extension_test.go
new file mode 100644
index 00000000000..4ee1b5749f8
--- /dev/null
+++ b/codegen/testserver/followschema/response_extension_test.go
@@ -0,0 +1,33 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestResponseExtension(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) {
+ return "Ok", nil
+ }
+
+ srv := handler.NewDefaultServer(
+ NewExecutableSchema(Config{Resolvers: resolvers}),
+ )
+
+ srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response {
+ graphql.RegisterExtension(ctx, "example", "value")
+
+ return next(ctx)
+ })
+
+ c := client.New(srv)
+
+ raw, _ := c.RawPost(`query { valid }`)
+ require.Equal(t, raw.Extensions["example"], "value")
+}
diff --git a/codegen/testserver/followschema/root!.generated.go b/codegen/testserver/followschema/root!.generated.go
new file mode 100644
index 00000000000..a79ff80a1b0
--- /dev/null
+++ b/codegen/testserver/followschema/root!.generated.go
@@ -0,0 +1,2551 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "bytes"
+ "context"
+ "errors"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/99designs/gqlgen/graphql/introspection"
+ gqlparser "github.com/vektah/gqlparser/v2"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.
+func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
+ return &executableSchema{
+ resolvers: cfg.Resolvers,
+ directives: cfg.Directives,
+ complexity: cfg.Complexity,
+ }
+}
+
+type Config struct {
+ Resolvers ResolverRoot
+ Directives DirectiveRoot
+ Complexity ComplexityRoot
+}
+
+type ResolverRoot interface {
+ BackedByInterface() BackedByInterfaceResolver
+ Errors() ErrorsResolver
+ ForcedResolver() ForcedResolverResolver
+ ModelMethods() ModelMethodsResolver
+ Mutation() MutationResolver
+ OverlappingFields() OverlappingFieldsResolver
+ Panics() PanicsResolver
+ Primitive() PrimitiveResolver
+ PrimitiveString() PrimitiveStringResolver
+ Query() QueryResolver
+ Subscription() SubscriptionResolver
+ User() UserResolver
+ WrappedMap() WrappedMapResolver
+ WrappedSlice() WrappedSliceResolver
+}
+
+type DirectiveRoot struct {
+ Custom func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
+ Directive1 func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
+ Directive2 func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
+ Directive3 func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
+ Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message *string) (res interface{}, err error)
+ Logged func(ctx context.Context, obj interface{}, next graphql.Resolver, id string) (res interface{}, err error)
+ MakeNil func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
+ MakeTypedNil func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
+ Order1 func(ctx context.Context, obj interface{}, next graphql.Resolver, location string) (res interface{}, err error)
+ Order2 func(ctx context.Context, obj interface{}, next graphql.Resolver, location string) (res interface{}, err error)
+ Range func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int) (res interface{}, err error)
+ ToNull func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
+ Unimplemented func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
+}
+
+type ComplexityRoot struct {
+ A struct {
+ ID func(childComplexity int) int
+ }
+
+ AIt struct {
+ ID func(childComplexity int) int
+ }
+
+ AbIt struct {
+ ID func(childComplexity int) int
+ }
+
+ Autobind struct {
+ IdInt func(childComplexity int) int
+ IdStr func(childComplexity int) int
+ Int func(childComplexity int) int
+ Int32 func(childComplexity int) int
+ Int64 func(childComplexity int) int
+ }
+
+ B struct {
+ ID func(childComplexity int) int
+ }
+
+ BackedByInterface struct {
+ ID func(childComplexity int) int
+ ThisShouldBind func(childComplexity int) int
+ ThisShouldBindWithError func(childComplexity int) int
+ }
+
+ Cat struct {
+ CatBreed func(childComplexity int) int
+ Species func(childComplexity int) int
+ }
+
+ CheckIssue896 struct {
+ ID func(childComplexity int) int
+ }
+
+ Circle struct {
+ Area func(childComplexity int) int
+ Coordinates func(childComplexity int) int
+ Radius func(childComplexity int) int
+ }
+
+ ConcreteNodeA struct {
+ Child func(childComplexity int) int
+ ID func(childComplexity int) int
+ Name func(childComplexity int) int
+ }
+
+ ConcreteNodeInterface struct {
+ Child func(childComplexity int) int
+ ID func(childComplexity int) int
+ }
+
+ Content_Post struct {
+ Foo func(childComplexity int) int
+ }
+
+ Content_User struct {
+ Foo func(childComplexity int) int
+ }
+
+ Coordinates struct {
+ X func(childComplexity int) int
+ Y func(childComplexity int) int
+ }
+
+ DefaultParametersMirror struct {
+ FalsyBoolean func(childComplexity int) int
+ TruthyBoolean func(childComplexity int) int
+ }
+
+ Dog struct {
+ DogBreed func(childComplexity int) int
+ Species func(childComplexity int) int
+ }
+
+ EmbeddedCase1 struct {
+ ExportedEmbeddedPointerExportedMethod func(childComplexity int) int
+ }
+
+ EmbeddedCase2 struct {
+ UnexportedEmbeddedPointerExportedMethod func(childComplexity int) int
+ }
+
+ EmbeddedCase3 struct {
+ UnexportedEmbeddedInterfaceExportedMethod func(childComplexity int) int
+ }
+
+ EmbeddedDefaultScalar struct {
+ Value func(childComplexity int) int
+ }
+
+ EmbeddedPointer struct {
+ ID func(childComplexity int) int
+ Title func(childComplexity int) int
+ }
+
+ Error struct {
+ ErrorOnNonRequiredField func(childComplexity int) int
+ ErrorOnRequiredField func(childComplexity int) int
+ ID func(childComplexity int) int
+ NilOnRequiredField func(childComplexity int) int
+ }
+
+ Errors struct {
+ A func(childComplexity int) int
+ B func(childComplexity int) int
+ C func(childComplexity int) int
+ D func(childComplexity int) int
+ E func(childComplexity int) int
+ }
+
+ ForcedResolver struct {
+ Field func(childComplexity int) int
+ }
+
+ InnerObject struct {
+ ID func(childComplexity int) int
+ }
+
+ InvalidIdentifier struct {
+ ID func(childComplexity int) int
+ }
+
+ It struct {
+ ID func(childComplexity int) int
+ }
+
+ LoopA struct {
+ B func(childComplexity int) int
+ }
+
+ LoopB struct {
+ A func(childComplexity int) int
+ }
+
+ Map struct {
+ ID func(childComplexity int) int
+ }
+
+ MapStringInterfaceType struct {
+ A func(childComplexity int) int
+ B func(childComplexity int) int
+ }
+
+ ModelMethods struct {
+ NoContext func(childComplexity int) int
+ ResolverField func(childComplexity int) int
+ WithContext func(childComplexity int) int
+ }
+
+ Mutation struct {
+ DefaultInput func(childComplexity int, input DefaultInput) int
+ UpdatePtrToPtr func(childComplexity int, input UpdatePtrToPtrOuter) int
+ UpdateSomething func(childComplexity int, input SpecialInput) int
+ }
+
+ ObjectDirectives struct {
+ NullableText func(childComplexity int) int
+ Order func(childComplexity int) int
+ Text func(childComplexity int) int
+ }
+
+ ObjectDirectivesWithCustomGoModel struct {
+ NullableText func(childComplexity int) int
+ }
+
+ OuterObject struct {
+ Inner func(childComplexity int) int
+ }
+
+ OverlappingFields struct {
+ Foo func(childComplexity int) int
+ NewFoo func(childComplexity int) int
+ OldFoo func(childComplexity int) int
+ }
+
+ Panics struct {
+ ArgUnmarshal func(childComplexity int, u []MarshalPanic) int
+ FieldFuncMarshal func(childComplexity int, u []MarshalPanic) int
+ FieldScalarMarshal func(childComplexity int) int
+ }
+
+ Primitive struct {
+ Squared func(childComplexity int) int
+ Value func(childComplexity int) int
+ }
+
+ PrimitiveString struct {
+ Doubled func(childComplexity int) int
+ Len func(childComplexity int) int
+ Value func(childComplexity int) int
+ }
+
+ PtrToPtrInner struct {
+ Key func(childComplexity int) int
+ Value func(childComplexity int) int
+ }
+
+ PtrToPtrOuter struct {
+ Inner func(childComplexity int) int
+ Name func(childComplexity int) int
+ StupidInner func(childComplexity int) int
+ }
+
+ PtrToSliceContainer struct {
+ PtrToSlice func(childComplexity int) int
+ }
+
+ Query struct {
+ Animal func(childComplexity int) int
+ Autobind func(childComplexity int) int
+ Collision func(childComplexity int) int
+ DefaultParameters func(childComplexity int, falsyBoolean *bool, truthyBoolean *bool) int
+ DefaultScalar func(childComplexity int, arg string) int
+ DeprecatedField func(childComplexity int) int
+ DirectiveArg func(childComplexity int, arg string) int
+ DirectiveDouble func(childComplexity int) int
+ DirectiveField func(childComplexity int) int
+ DirectiveFieldDef func(childComplexity int, ret string) int
+ DirectiveInput func(childComplexity int, arg InputDirectives) int
+ DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int
+ DirectiveInputType func(childComplexity int, arg InnerInput) int
+ DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int, arg3 *string) int
+ DirectiveObject func(childComplexity int) int
+ DirectiveObjectWithCustomGoModel func(childComplexity int) int
+ DirectiveUnimplemented func(childComplexity int) int
+ EmbeddedCase1 func(childComplexity int) int
+ EmbeddedCase2 func(childComplexity int) int
+ EmbeddedCase3 func(childComplexity int) int
+ EnumInInput func(childComplexity int, input *InputWithEnumValue) int
+ ErrorBubble func(childComplexity int) int
+ ErrorBubbleList func(childComplexity int) int
+ ErrorList func(childComplexity int) int
+ Errors func(childComplexity int) int
+ Fallback func(childComplexity int, arg FallbackToStringEncoding) int
+ Infinity func(childComplexity int) int
+ InputNullableSlice func(childComplexity int, arg []string) int
+ InputSlice func(childComplexity int, arg []string) int
+ InvalidIdentifier func(childComplexity int) int
+ Issue896a func(childComplexity int) int
+ MapInput func(childComplexity int, input map[string]interface{}) int
+ MapNestedStringInterface func(childComplexity int, in *NestedMapInput) int
+ MapStringInterface func(childComplexity int, in map[string]interface{}) int
+ ModelMethods func(childComplexity int) int
+ NestedInputs func(childComplexity int, input [][]*OuterInput) int
+ NestedOutputs func(childComplexity int) int
+ NoShape func(childComplexity int) int
+ NoShapeTypedNil func(childComplexity int) int
+ Node func(childComplexity int) int
+ NotAnInterface func(childComplexity int) int
+ NullableArg func(childComplexity int, arg *int) int
+ OptionalUnion func(childComplexity int) int
+ Overlapping func(childComplexity int) int
+ Panics func(childComplexity int) int
+ PrimitiveObject func(childComplexity int) int
+ PrimitiveStringObject func(childComplexity int) int
+ PtrToSliceContainer func(childComplexity int) int
+ Recursive func(childComplexity int, input *RecursiveInputSlice) int
+ ScalarSlice func(childComplexity int) int
+ ShapeUnion func(childComplexity int) int
+ Shapes func(childComplexity int) int
+ Slices func(childComplexity int) int
+ StringFromContextFunction func(childComplexity int) int
+ StringFromContextInterface func(childComplexity int) int
+ User func(childComplexity int, id int) int
+ VOkCaseNil func(childComplexity int) int
+ VOkCaseValue func(childComplexity int) int
+ Valid func(childComplexity int) int
+ ValidType func(childComplexity int) int
+ WrappedMap func(childComplexity int) int
+ WrappedScalar func(childComplexity int) int
+ WrappedSlice func(childComplexity int) int
+ WrappedStruct func(childComplexity int) int
+ }
+
+ Rectangle struct {
+ Area func(childComplexity int) int
+ Coordinates func(childComplexity int) int
+ Length func(childComplexity int) int
+ Width func(childComplexity int) int
+ }
+
+ Slices struct {
+ Test1 func(childComplexity int) int
+ Test2 func(childComplexity int) int
+ Test3 func(childComplexity int) int
+ Test4 func(childComplexity int) int
+ }
+
+ Subscription struct {
+ DirectiveArg func(childComplexity int, arg string) int
+ DirectiveDouble func(childComplexity int) int
+ DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int, arg3 *string) int
+ DirectiveUnimplemented func(childComplexity int) int
+ InitPayload func(childComplexity int) int
+ Issue896b func(childComplexity int) int
+ Updated func(childComplexity int) int
+ }
+
+ User struct {
+ Created func(childComplexity int) int
+ Friends func(childComplexity int) int
+ ID func(childComplexity int) int
+ Updated func(childComplexity int) int
+ }
+
+ VOkCaseNil struct {
+ Value func(childComplexity int) int
+ }
+
+ VOkCaseValue struct {
+ Value func(childComplexity int) int
+ }
+
+ ValidType struct {
+ DifferentCase func(childComplexity int) int
+ DifferentCaseOld func(childComplexity int) int
+ ValidArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _ string) int
+ ValidInputKeywords func(childComplexity int, input *ValidInput) int
+ }
+
+ WrappedMap struct {
+ Get func(childComplexity int, key string) int
+ }
+
+ WrappedSlice struct {
+ Get func(childComplexity int, idx int) int
+ }
+
+ WrappedStruct struct {
+ Desc func(childComplexity int) int
+ Name func(childComplexity int) int
+ }
+
+ XXIt struct {
+ ID func(childComplexity int) int
+ }
+
+ XxIt struct {
+ ID func(childComplexity int) int
+ }
+
+ AsdfIt struct {
+ ID func(childComplexity int) int
+ }
+
+ IIt struct {
+ ID func(childComplexity int) int
+ }
+}
+
+type executableSchema struct {
+ resolvers ResolverRoot
+ directives DirectiveRoot
+ complexity ComplexityRoot
+}
+
+func (e *executableSchema) Schema() *ast.Schema {
+ return parsedSchema
+}
+
+func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {
+ ec := executionContext{nil, e}
+ _ = ec
+ switch typeName + "." + field {
+
+ case "A.id":
+ if e.complexity.A.ID == nil {
+ break
+ }
+
+ return e.complexity.A.ID(childComplexity), true
+
+ case "AIt.id":
+ if e.complexity.AIt.ID == nil {
+ break
+ }
+
+ return e.complexity.AIt.ID(childComplexity), true
+
+ case "AbIt.id":
+ if e.complexity.AbIt.ID == nil {
+ break
+ }
+
+ return e.complexity.AbIt.ID(childComplexity), true
+
+ case "Autobind.idInt":
+ if e.complexity.Autobind.IdInt == nil {
+ break
+ }
+
+ return e.complexity.Autobind.IdInt(childComplexity), true
+
+ case "Autobind.idStr":
+ if e.complexity.Autobind.IdStr == nil {
+ break
+ }
+
+ return e.complexity.Autobind.IdStr(childComplexity), true
+
+ case "Autobind.int":
+ if e.complexity.Autobind.Int == nil {
+ break
+ }
+
+ return e.complexity.Autobind.Int(childComplexity), true
+
+ case "Autobind.int32":
+ if e.complexity.Autobind.Int32 == nil {
+ break
+ }
+
+ return e.complexity.Autobind.Int32(childComplexity), true
+
+ case "Autobind.int64":
+ if e.complexity.Autobind.Int64 == nil {
+ break
+ }
+
+ return e.complexity.Autobind.Int64(childComplexity), true
+
+ case "B.id":
+ if e.complexity.B.ID == nil {
+ break
+ }
+
+ return e.complexity.B.ID(childComplexity), true
+
+ case "BackedByInterface.id":
+ if e.complexity.BackedByInterface.ID == nil {
+ break
+ }
+
+ return e.complexity.BackedByInterface.ID(childComplexity), true
+
+ case "BackedByInterface.thisShouldBind":
+ if e.complexity.BackedByInterface.ThisShouldBind == nil {
+ break
+ }
+
+ return e.complexity.BackedByInterface.ThisShouldBind(childComplexity), true
+
+ case "BackedByInterface.thisShouldBindWithError":
+ if e.complexity.BackedByInterface.ThisShouldBindWithError == nil {
+ break
+ }
+
+ return e.complexity.BackedByInterface.ThisShouldBindWithError(childComplexity), true
+
+ case "Cat.catBreed":
+ if e.complexity.Cat.CatBreed == nil {
+ break
+ }
+
+ return e.complexity.Cat.CatBreed(childComplexity), true
+
+ case "Cat.species":
+ if e.complexity.Cat.Species == nil {
+ break
+ }
+
+ return e.complexity.Cat.Species(childComplexity), true
+
+ case "CheckIssue896.id":
+ if e.complexity.CheckIssue896.ID == nil {
+ break
+ }
+
+ return e.complexity.CheckIssue896.ID(childComplexity), true
+
+ case "Circle.area":
+ if e.complexity.Circle.Area == nil {
+ break
+ }
+
+ return e.complexity.Circle.Area(childComplexity), true
+
+ case "Circle.coordinates":
+ if e.complexity.Circle.Coordinates == nil {
+ break
+ }
+
+ return e.complexity.Circle.Coordinates(childComplexity), true
+
+ case "Circle.radius":
+ if e.complexity.Circle.Radius == nil {
+ break
+ }
+
+ return e.complexity.Circle.Radius(childComplexity), true
+
+ case "ConcreteNodeA.child":
+ if e.complexity.ConcreteNodeA.Child == nil {
+ break
+ }
+
+ return e.complexity.ConcreteNodeA.Child(childComplexity), true
+
+ case "ConcreteNodeA.id":
+ if e.complexity.ConcreteNodeA.ID == nil {
+ break
+ }
+
+ return e.complexity.ConcreteNodeA.ID(childComplexity), true
+
+ case "ConcreteNodeA.name":
+ if e.complexity.ConcreteNodeA.Name == nil {
+ break
+ }
+
+ return e.complexity.ConcreteNodeA.Name(childComplexity), true
+
+ case "ConcreteNodeInterface.child":
+ if e.complexity.ConcreteNodeInterface.Child == nil {
+ break
+ }
+
+ return e.complexity.ConcreteNodeInterface.Child(childComplexity), true
+
+ case "ConcreteNodeInterface.id":
+ if e.complexity.ConcreteNodeInterface.ID == nil {
+ break
+ }
+
+ return e.complexity.ConcreteNodeInterface.ID(childComplexity), true
+
+ case "Content_Post.foo":
+ if e.complexity.Content_Post.Foo == nil {
+ break
+ }
+
+ return e.complexity.Content_Post.Foo(childComplexity), true
+
+ case "Content_User.foo":
+ if e.complexity.Content_User.Foo == nil {
+ break
+ }
+
+ return e.complexity.Content_User.Foo(childComplexity), true
+
+ case "Coordinates.x":
+ if e.complexity.Coordinates.X == nil {
+ break
+ }
+
+ return e.complexity.Coordinates.X(childComplexity), true
+
+ case "Coordinates.y":
+ if e.complexity.Coordinates.Y == nil {
+ break
+ }
+
+ return e.complexity.Coordinates.Y(childComplexity), true
+
+ case "DefaultParametersMirror.falsyBoolean":
+ if e.complexity.DefaultParametersMirror.FalsyBoolean == nil {
+ break
+ }
+
+ return e.complexity.DefaultParametersMirror.FalsyBoolean(childComplexity), true
+
+ case "DefaultParametersMirror.truthyBoolean":
+ if e.complexity.DefaultParametersMirror.TruthyBoolean == nil {
+ break
+ }
+
+ return e.complexity.DefaultParametersMirror.TruthyBoolean(childComplexity), true
+
+ case "Dog.dogBreed":
+ if e.complexity.Dog.DogBreed == nil {
+ break
+ }
+
+ return e.complexity.Dog.DogBreed(childComplexity), true
+
+ case "Dog.species":
+ if e.complexity.Dog.Species == nil {
+ break
+ }
+
+ return e.complexity.Dog.Species(childComplexity), true
+
+ case "EmbeddedCase1.exportedEmbeddedPointerExportedMethod":
+ if e.complexity.EmbeddedCase1.ExportedEmbeddedPointerExportedMethod == nil {
+ break
+ }
+
+ return e.complexity.EmbeddedCase1.ExportedEmbeddedPointerExportedMethod(childComplexity), true
+
+ case "EmbeddedCase2.unexportedEmbeddedPointerExportedMethod":
+ if e.complexity.EmbeddedCase2.UnexportedEmbeddedPointerExportedMethod == nil {
+ break
+ }
+
+ return e.complexity.EmbeddedCase2.UnexportedEmbeddedPointerExportedMethod(childComplexity), true
+
+ case "EmbeddedCase3.unexportedEmbeddedInterfaceExportedMethod":
+ if e.complexity.EmbeddedCase3.UnexportedEmbeddedInterfaceExportedMethod == nil {
+ break
+ }
+
+ return e.complexity.EmbeddedCase3.UnexportedEmbeddedInterfaceExportedMethod(childComplexity), true
+
+ case "EmbeddedDefaultScalar.value":
+ if e.complexity.EmbeddedDefaultScalar.Value == nil {
+ break
+ }
+
+ return e.complexity.EmbeddedDefaultScalar.Value(childComplexity), true
+
+ case "EmbeddedPointer.ID":
+ if e.complexity.EmbeddedPointer.ID == nil {
+ break
+ }
+
+ return e.complexity.EmbeddedPointer.ID(childComplexity), true
+
+ case "EmbeddedPointer.Title":
+ if e.complexity.EmbeddedPointer.Title == nil {
+ break
+ }
+
+ return e.complexity.EmbeddedPointer.Title(childComplexity), true
+
+ case "Error.errorOnNonRequiredField":
+ if e.complexity.Error.ErrorOnNonRequiredField == nil {
+ break
+ }
+
+ return e.complexity.Error.ErrorOnNonRequiredField(childComplexity), true
+
+ case "Error.errorOnRequiredField":
+ if e.complexity.Error.ErrorOnRequiredField == nil {
+ break
+ }
+
+ return e.complexity.Error.ErrorOnRequiredField(childComplexity), true
+
+ case "Error.id":
+ if e.complexity.Error.ID == nil {
+ break
+ }
+
+ return e.complexity.Error.ID(childComplexity), true
+
+ case "Error.nilOnRequiredField":
+ if e.complexity.Error.NilOnRequiredField == nil {
+ break
+ }
+
+ return e.complexity.Error.NilOnRequiredField(childComplexity), true
+
+ case "Errors.a":
+ if e.complexity.Errors.A == nil {
+ break
+ }
+
+ return e.complexity.Errors.A(childComplexity), true
+
+ case "Errors.b":
+ if e.complexity.Errors.B == nil {
+ break
+ }
+
+ return e.complexity.Errors.B(childComplexity), true
+
+ case "Errors.c":
+ if e.complexity.Errors.C == nil {
+ break
+ }
+
+ return e.complexity.Errors.C(childComplexity), true
+
+ case "Errors.d":
+ if e.complexity.Errors.D == nil {
+ break
+ }
+
+ return e.complexity.Errors.D(childComplexity), true
+
+ case "Errors.e":
+ if e.complexity.Errors.E == nil {
+ break
+ }
+
+ return e.complexity.Errors.E(childComplexity), true
+
+ case "ForcedResolver.field":
+ if e.complexity.ForcedResolver.Field == nil {
+ break
+ }
+
+ return e.complexity.ForcedResolver.Field(childComplexity), true
+
+ case "InnerObject.id":
+ if e.complexity.InnerObject.ID == nil {
+ break
+ }
+
+ return e.complexity.InnerObject.ID(childComplexity), true
+
+ case "InvalidIdentifier.id":
+ if e.complexity.InvalidIdentifier.ID == nil {
+ break
+ }
+
+ return e.complexity.InvalidIdentifier.ID(childComplexity), true
+
+ case "It.id":
+ if e.complexity.It.ID == nil {
+ break
+ }
+
+ return e.complexity.It.ID(childComplexity), true
+
+ case "LoopA.b":
+ if e.complexity.LoopA.B == nil {
+ break
+ }
+
+ return e.complexity.LoopA.B(childComplexity), true
+
+ case "LoopB.a":
+ if e.complexity.LoopB.A == nil {
+ break
+ }
+
+ return e.complexity.LoopB.A(childComplexity), true
+
+ case "Map.id":
+ if e.complexity.Map.ID == nil {
+ break
+ }
+
+ return e.complexity.Map.ID(childComplexity), true
+
+ case "MapStringInterfaceType.a":
+ if e.complexity.MapStringInterfaceType.A == nil {
+ break
+ }
+
+ return e.complexity.MapStringInterfaceType.A(childComplexity), true
+
+ case "MapStringInterfaceType.b":
+ if e.complexity.MapStringInterfaceType.B == nil {
+ break
+ }
+
+ return e.complexity.MapStringInterfaceType.B(childComplexity), true
+
+ case "ModelMethods.noContext":
+ if e.complexity.ModelMethods.NoContext == nil {
+ break
+ }
+
+ return e.complexity.ModelMethods.NoContext(childComplexity), true
+
+ case "ModelMethods.resolverField":
+ if e.complexity.ModelMethods.ResolverField == nil {
+ break
+ }
+
+ return e.complexity.ModelMethods.ResolverField(childComplexity), true
+
+ case "ModelMethods.withContext":
+ if e.complexity.ModelMethods.WithContext == nil {
+ break
+ }
+
+ return e.complexity.ModelMethods.WithContext(childComplexity), true
+
+ case "Mutation.defaultInput":
+ if e.complexity.Mutation.DefaultInput == nil {
+ break
+ }
+
+ args, err := ec.field_Mutation_defaultInput_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Mutation.DefaultInput(childComplexity, args["input"].(DefaultInput)), true
+
+ case "Mutation.updatePtrToPtr":
+ if e.complexity.Mutation.UpdatePtrToPtr == nil {
+ break
+ }
+
+ args, err := ec.field_Mutation_updatePtrToPtr_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Mutation.UpdatePtrToPtr(childComplexity, args["input"].(UpdatePtrToPtrOuter)), true
+
+ case "Mutation.updateSomething":
+ if e.complexity.Mutation.UpdateSomething == nil {
+ break
+ }
+
+ args, err := ec.field_Mutation_updateSomething_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Mutation.UpdateSomething(childComplexity, args["input"].(SpecialInput)), true
+
+ case "ObjectDirectives.nullableText":
+ if e.complexity.ObjectDirectives.NullableText == nil {
+ break
+ }
+
+ return e.complexity.ObjectDirectives.NullableText(childComplexity), true
+
+ case "ObjectDirectives.order":
+ if e.complexity.ObjectDirectives.Order == nil {
+ break
+ }
+
+ return e.complexity.ObjectDirectives.Order(childComplexity), true
+
+ case "ObjectDirectives.text":
+ if e.complexity.ObjectDirectives.Text == nil {
+ break
+ }
+
+ return e.complexity.ObjectDirectives.Text(childComplexity), true
+
+ case "ObjectDirectivesWithCustomGoModel.nullableText":
+ if e.complexity.ObjectDirectivesWithCustomGoModel.NullableText == nil {
+ break
+ }
+
+ return e.complexity.ObjectDirectivesWithCustomGoModel.NullableText(childComplexity), true
+
+ case "OuterObject.inner":
+ if e.complexity.OuterObject.Inner == nil {
+ break
+ }
+
+ return e.complexity.OuterObject.Inner(childComplexity), true
+
+ case "OverlappingFields.oneFoo", "OverlappingFields.twoFoo":
+ if e.complexity.OverlappingFields.Foo == nil {
+ break
+ }
+
+ return e.complexity.OverlappingFields.Foo(childComplexity), true
+
+ case "OverlappingFields.newFoo", "OverlappingFields.new_foo":
+ if e.complexity.OverlappingFields.NewFoo == nil {
+ break
+ }
+
+ return e.complexity.OverlappingFields.NewFoo(childComplexity), true
+
+ case "OverlappingFields.oldFoo":
+ if e.complexity.OverlappingFields.OldFoo == nil {
+ break
+ }
+
+ return e.complexity.OverlappingFields.OldFoo(childComplexity), true
+
+ case "Panics.argUnmarshal":
+ if e.complexity.Panics.ArgUnmarshal == nil {
+ break
+ }
+
+ args, err := ec.field_Panics_argUnmarshal_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Panics.ArgUnmarshal(childComplexity, args["u"].([]MarshalPanic)), true
+
+ case "Panics.fieldFuncMarshal":
+ if e.complexity.Panics.FieldFuncMarshal == nil {
+ break
+ }
+
+ args, err := ec.field_Panics_fieldFuncMarshal_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Panics.FieldFuncMarshal(childComplexity, args["u"].([]MarshalPanic)), true
+
+ case "Panics.fieldScalarMarshal":
+ if e.complexity.Panics.FieldScalarMarshal == nil {
+ break
+ }
+
+ return e.complexity.Panics.FieldScalarMarshal(childComplexity), true
+
+ case "Primitive.squared":
+ if e.complexity.Primitive.Squared == nil {
+ break
+ }
+
+ return e.complexity.Primitive.Squared(childComplexity), true
+
+ case "Primitive.value":
+ if e.complexity.Primitive.Value == nil {
+ break
+ }
+
+ return e.complexity.Primitive.Value(childComplexity), true
+
+ case "PrimitiveString.doubled":
+ if e.complexity.PrimitiveString.Doubled == nil {
+ break
+ }
+
+ return e.complexity.PrimitiveString.Doubled(childComplexity), true
+
+ case "PrimitiveString.len":
+ if e.complexity.PrimitiveString.Len == nil {
+ break
+ }
+
+ return e.complexity.PrimitiveString.Len(childComplexity), true
+
+ case "PrimitiveString.value":
+ if e.complexity.PrimitiveString.Value == nil {
+ break
+ }
+
+ return e.complexity.PrimitiveString.Value(childComplexity), true
+
+ case "PtrToPtrInner.key":
+ if e.complexity.PtrToPtrInner.Key == nil {
+ break
+ }
+
+ return e.complexity.PtrToPtrInner.Key(childComplexity), true
+
+ case "PtrToPtrInner.value":
+ if e.complexity.PtrToPtrInner.Value == nil {
+ break
+ }
+
+ return e.complexity.PtrToPtrInner.Value(childComplexity), true
+
+ case "PtrToPtrOuter.inner":
+ if e.complexity.PtrToPtrOuter.Inner == nil {
+ break
+ }
+
+ return e.complexity.PtrToPtrOuter.Inner(childComplexity), true
+
+ case "PtrToPtrOuter.name":
+ if e.complexity.PtrToPtrOuter.Name == nil {
+ break
+ }
+
+ return e.complexity.PtrToPtrOuter.Name(childComplexity), true
+
+ case "PtrToPtrOuter.stupidInner":
+ if e.complexity.PtrToPtrOuter.StupidInner == nil {
+ break
+ }
+
+ return e.complexity.PtrToPtrOuter.StupidInner(childComplexity), true
+
+ case "PtrToSliceContainer.ptrToSlice":
+ if e.complexity.PtrToSliceContainer.PtrToSlice == nil {
+ break
+ }
+
+ return e.complexity.PtrToSliceContainer.PtrToSlice(childComplexity), true
+
+ case "Query.animal":
+ if e.complexity.Query.Animal == nil {
+ break
+ }
+
+ return e.complexity.Query.Animal(childComplexity), true
+
+ case "Query.autobind":
+ if e.complexity.Query.Autobind == nil {
+ break
+ }
+
+ return e.complexity.Query.Autobind(childComplexity), true
+
+ case "Query.collision":
+ if e.complexity.Query.Collision == nil {
+ break
+ }
+
+ return e.complexity.Query.Collision(childComplexity), true
+
+ case "Query.defaultParameters":
+ if e.complexity.Query.DefaultParameters == nil {
+ break
+ }
+
+ args, err := ec.field_Query_defaultParameters_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.DefaultParameters(childComplexity, args["falsyBoolean"].(*bool), args["truthyBoolean"].(*bool)), true
+
+ case "Query.defaultScalar":
+ if e.complexity.Query.DefaultScalar == nil {
+ break
+ }
+
+ args, err := ec.field_Query_defaultScalar_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.DefaultScalar(childComplexity, args["arg"].(string)), true
+
+ case "Query.deprecatedField":
+ if e.complexity.Query.DeprecatedField == nil {
+ break
+ }
+
+ return e.complexity.Query.DeprecatedField(childComplexity), true
+
+ case "Query.directiveArg":
+ if e.complexity.Query.DirectiveArg == nil {
+ break
+ }
+
+ args, err := ec.field_Query_directiveArg_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true
+
+ case "Query.directiveDouble":
+ if e.complexity.Query.DirectiveDouble == nil {
+ break
+ }
+
+ return e.complexity.Query.DirectiveDouble(childComplexity), true
+
+ case "Query.directiveField":
+ if e.complexity.Query.DirectiveField == nil {
+ break
+ }
+
+ return e.complexity.Query.DirectiveField(childComplexity), true
+
+ case "Query.directiveFieldDef":
+ if e.complexity.Query.DirectiveFieldDef == nil {
+ break
+ }
+
+ args, err := ec.field_Query_directiveFieldDef_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.DirectiveFieldDef(childComplexity, args["ret"].(string)), true
+
+ case "Query.directiveInput":
+ if e.complexity.Query.DirectiveInput == nil {
+ break
+ }
+
+ args, err := ec.field_Query_directiveInput_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true
+
+ case "Query.directiveInputNullable":
+ if e.complexity.Query.DirectiveInputNullable == nil {
+ break
+ }
+
+ args, err := ec.field_Query_directiveInputNullable_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true
+
+ case "Query.directiveInputType":
+ if e.complexity.Query.DirectiveInputType == nil {
+ break
+ }
+
+ args, err := ec.field_Query_directiveInputType_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.DirectiveInputType(childComplexity, args["arg"].(InnerInput)), true
+
+ case "Query.directiveNullableArg":
+ if e.complexity.Query.DirectiveNullableArg == nil {
+ break
+ }
+
+ args, err := ec.field_Query_directiveNullableArg_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int), args["arg3"].(*string)), true
+
+ case "Query.directiveObject":
+ if e.complexity.Query.DirectiveObject == nil {
+ break
+ }
+
+ return e.complexity.Query.DirectiveObject(childComplexity), true
+
+ case "Query.directiveObjectWithCustomGoModel":
+ if e.complexity.Query.DirectiveObjectWithCustomGoModel == nil {
+ break
+ }
+
+ return e.complexity.Query.DirectiveObjectWithCustomGoModel(childComplexity), true
+
+ case "Query.directiveUnimplemented":
+ if e.complexity.Query.DirectiveUnimplemented == nil {
+ break
+ }
+
+ return e.complexity.Query.DirectiveUnimplemented(childComplexity), true
+
+ case "Query.embeddedCase1":
+ if e.complexity.Query.EmbeddedCase1 == nil {
+ break
+ }
+
+ return e.complexity.Query.EmbeddedCase1(childComplexity), true
+
+ case "Query.embeddedCase2":
+ if e.complexity.Query.EmbeddedCase2 == nil {
+ break
+ }
+
+ return e.complexity.Query.EmbeddedCase2(childComplexity), true
+
+ case "Query.embeddedCase3":
+ if e.complexity.Query.EmbeddedCase3 == nil {
+ break
+ }
+
+ return e.complexity.Query.EmbeddedCase3(childComplexity), true
+
+ case "Query.enumInInput":
+ if e.complexity.Query.EnumInInput == nil {
+ break
+ }
+
+ args, err := ec.field_Query_enumInInput_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.EnumInInput(childComplexity, args["input"].(*InputWithEnumValue)), true
+
+ case "Query.errorBubble":
+ if e.complexity.Query.ErrorBubble == nil {
+ break
+ }
+
+ return e.complexity.Query.ErrorBubble(childComplexity), true
+
+ case "Query.errorBubbleList":
+ if e.complexity.Query.ErrorBubbleList == nil {
+ break
+ }
+
+ return e.complexity.Query.ErrorBubbleList(childComplexity), true
+
+ case "Query.errorList":
+ if e.complexity.Query.ErrorList == nil {
+ break
+ }
+
+ return e.complexity.Query.ErrorList(childComplexity), true
+
+ case "Query.errors":
+ if e.complexity.Query.Errors == nil {
+ break
+ }
+
+ return e.complexity.Query.Errors(childComplexity), true
+
+ case "Query.fallback":
+ if e.complexity.Query.Fallback == nil {
+ break
+ }
+
+ args, err := ec.field_Query_fallback_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.Fallback(childComplexity, args["arg"].(FallbackToStringEncoding)), true
+
+ case "Query.infinity":
+ if e.complexity.Query.Infinity == nil {
+ break
+ }
+
+ return e.complexity.Query.Infinity(childComplexity), true
+
+ case "Query.inputNullableSlice":
+ if e.complexity.Query.InputNullableSlice == nil {
+ break
+ }
+
+ args, err := ec.field_Query_inputNullableSlice_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.InputNullableSlice(childComplexity, args["arg"].([]string)), true
+
+ case "Query.inputSlice":
+ if e.complexity.Query.InputSlice == nil {
+ break
+ }
+
+ args, err := ec.field_Query_inputSlice_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.InputSlice(childComplexity, args["arg"].([]string)), true
+
+ case "Query.invalidIdentifier":
+ if e.complexity.Query.InvalidIdentifier == nil {
+ break
+ }
+
+ return e.complexity.Query.InvalidIdentifier(childComplexity), true
+
+ case "Query.issue896a":
+ if e.complexity.Query.Issue896a == nil {
+ break
+ }
+
+ return e.complexity.Query.Issue896a(childComplexity), true
+
+ case "Query.mapInput":
+ if e.complexity.Query.MapInput == nil {
+ break
+ }
+
+ args, err := ec.field_Query_mapInput_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.MapInput(childComplexity, args["input"].(map[string]interface{})), true
+
+ case "Query.mapNestedStringInterface":
+ if e.complexity.Query.MapNestedStringInterface == nil {
+ break
+ }
+
+ args, err := ec.field_Query_mapNestedStringInterface_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.MapNestedStringInterface(childComplexity, args["in"].(*NestedMapInput)), true
+
+ case "Query.mapStringInterface":
+ if e.complexity.Query.MapStringInterface == nil {
+ break
+ }
+
+ args, err := ec.field_Query_mapStringInterface_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.MapStringInterface(childComplexity, args["in"].(map[string]interface{})), true
+
+ case "Query.modelMethods":
+ if e.complexity.Query.ModelMethods == nil {
+ break
+ }
+
+ return e.complexity.Query.ModelMethods(childComplexity), true
+
+ case "Query.nestedInputs":
+ if e.complexity.Query.NestedInputs == nil {
+ break
+ }
+
+ args, err := ec.field_Query_nestedInputs_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.NestedInputs(childComplexity, args["input"].([][]*OuterInput)), true
+
+ case "Query.nestedOutputs":
+ if e.complexity.Query.NestedOutputs == nil {
+ break
+ }
+
+ return e.complexity.Query.NestedOutputs(childComplexity), true
+
+ case "Query.noShape":
+ if e.complexity.Query.NoShape == nil {
+ break
+ }
+
+ return e.complexity.Query.NoShape(childComplexity), true
+
+ case "Query.noShapeTypedNil":
+ if e.complexity.Query.NoShapeTypedNil == nil {
+ break
+ }
+
+ return e.complexity.Query.NoShapeTypedNil(childComplexity), true
+
+ case "Query.node":
+ if e.complexity.Query.Node == nil {
+ break
+ }
+
+ return e.complexity.Query.Node(childComplexity), true
+
+ case "Query.notAnInterface":
+ if e.complexity.Query.NotAnInterface == nil {
+ break
+ }
+
+ return e.complexity.Query.NotAnInterface(childComplexity), true
+
+ case "Query.nullableArg":
+ if e.complexity.Query.NullableArg == nil {
+ break
+ }
+
+ args, err := ec.field_Query_nullableArg_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.NullableArg(childComplexity, args["arg"].(*int)), true
+
+ case "Query.optionalUnion":
+ if e.complexity.Query.OptionalUnion == nil {
+ break
+ }
+
+ return e.complexity.Query.OptionalUnion(childComplexity), true
+
+ case "Query.overlapping":
+ if e.complexity.Query.Overlapping == nil {
+ break
+ }
+
+ return e.complexity.Query.Overlapping(childComplexity), true
+
+ case "Query.panics":
+ if e.complexity.Query.Panics == nil {
+ break
+ }
+
+ return e.complexity.Query.Panics(childComplexity), true
+
+ case "Query.primitiveObject":
+ if e.complexity.Query.PrimitiveObject == nil {
+ break
+ }
+
+ return e.complexity.Query.PrimitiveObject(childComplexity), true
+
+ case "Query.primitiveStringObject":
+ if e.complexity.Query.PrimitiveStringObject == nil {
+ break
+ }
+
+ return e.complexity.Query.PrimitiveStringObject(childComplexity), true
+
+ case "Query.ptrToSliceContainer":
+ if e.complexity.Query.PtrToSliceContainer == nil {
+ break
+ }
+
+ return e.complexity.Query.PtrToSliceContainer(childComplexity), true
+
+ case "Query.recursive":
+ if e.complexity.Query.Recursive == nil {
+ break
+ }
+
+ args, err := ec.field_Query_recursive_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.Recursive(childComplexity, args["input"].(*RecursiveInputSlice)), true
+
+ case "Query.scalarSlice":
+ if e.complexity.Query.ScalarSlice == nil {
+ break
+ }
+
+ return e.complexity.Query.ScalarSlice(childComplexity), true
+
+ case "Query.shapeUnion":
+ if e.complexity.Query.ShapeUnion == nil {
+ break
+ }
+
+ return e.complexity.Query.ShapeUnion(childComplexity), true
+
+ case "Query.shapes":
+ if e.complexity.Query.Shapes == nil {
+ break
+ }
+
+ return e.complexity.Query.Shapes(childComplexity), true
+
+ case "Query.slices":
+ if e.complexity.Query.Slices == nil {
+ break
+ }
+
+ return e.complexity.Query.Slices(childComplexity), true
+
+ case "Query.stringFromContextFunction":
+ if e.complexity.Query.StringFromContextFunction == nil {
+ break
+ }
+
+ return e.complexity.Query.StringFromContextFunction(childComplexity), true
+
+ case "Query.stringFromContextInterface":
+ if e.complexity.Query.StringFromContextInterface == nil {
+ break
+ }
+
+ return e.complexity.Query.StringFromContextInterface(childComplexity), true
+
+ case "Query.user":
+ if e.complexity.Query.User == nil {
+ break
+ }
+
+ args, err := ec.field_Query_user_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.User(childComplexity, args["id"].(int)), true
+
+ case "Query.vOkCaseNil":
+ if e.complexity.Query.VOkCaseNil == nil {
+ break
+ }
+
+ return e.complexity.Query.VOkCaseNil(childComplexity), true
+
+ case "Query.vOkCaseValue":
+ if e.complexity.Query.VOkCaseValue == nil {
+ break
+ }
+
+ return e.complexity.Query.VOkCaseValue(childComplexity), true
+
+ case "Query.valid":
+ if e.complexity.Query.Valid == nil {
+ break
+ }
+
+ return e.complexity.Query.Valid(childComplexity), true
+
+ case "Query.validType":
+ if e.complexity.Query.ValidType == nil {
+ break
+ }
+
+ return e.complexity.Query.ValidType(childComplexity), true
+
+ case "Query.wrappedMap":
+ if e.complexity.Query.WrappedMap == nil {
+ break
+ }
+
+ return e.complexity.Query.WrappedMap(childComplexity), true
+
+ case "Query.wrappedScalar":
+ if e.complexity.Query.WrappedScalar == nil {
+ break
+ }
+
+ return e.complexity.Query.WrappedScalar(childComplexity), true
+
+ case "Query.wrappedSlice":
+ if e.complexity.Query.WrappedSlice == nil {
+ break
+ }
+
+ return e.complexity.Query.WrappedSlice(childComplexity), true
+
+ case "Query.wrappedStruct":
+ if e.complexity.Query.WrappedStruct == nil {
+ break
+ }
+
+ return e.complexity.Query.WrappedStruct(childComplexity), true
+
+ case "Rectangle.area":
+ if e.complexity.Rectangle.Area == nil {
+ break
+ }
+
+ return e.complexity.Rectangle.Area(childComplexity), true
+
+ case "Rectangle.coordinates":
+ if e.complexity.Rectangle.Coordinates == nil {
+ break
+ }
+
+ return e.complexity.Rectangle.Coordinates(childComplexity), true
+
+ case "Rectangle.length":
+ if e.complexity.Rectangle.Length == nil {
+ break
+ }
+
+ return e.complexity.Rectangle.Length(childComplexity), true
+
+ case "Rectangle.width":
+ if e.complexity.Rectangle.Width == nil {
+ break
+ }
+
+ return e.complexity.Rectangle.Width(childComplexity), true
+
+ case "Slices.test1":
+ if e.complexity.Slices.Test1 == nil {
+ break
+ }
+
+ return e.complexity.Slices.Test1(childComplexity), true
+
+ case "Slices.test2":
+ if e.complexity.Slices.Test2 == nil {
+ break
+ }
+
+ return e.complexity.Slices.Test2(childComplexity), true
+
+ case "Slices.test3":
+ if e.complexity.Slices.Test3 == nil {
+ break
+ }
+
+ return e.complexity.Slices.Test3(childComplexity), true
+
+ case "Slices.test4":
+ if e.complexity.Slices.Test4 == nil {
+ break
+ }
+
+ return e.complexity.Slices.Test4(childComplexity), true
+
+ case "Subscription.directiveArg":
+ if e.complexity.Subscription.DirectiveArg == nil {
+ break
+ }
+
+ args, err := ec.field_Subscription_directiveArg_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Subscription.DirectiveArg(childComplexity, args["arg"].(string)), true
+
+ case "Subscription.directiveDouble":
+ if e.complexity.Subscription.DirectiveDouble == nil {
+ break
+ }
+
+ return e.complexity.Subscription.DirectiveDouble(childComplexity), true
+
+ case "Subscription.directiveNullableArg":
+ if e.complexity.Subscription.DirectiveNullableArg == nil {
+ break
+ }
+
+ args, err := ec.field_Subscription_directiveNullableArg_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Subscription.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int), args["arg3"].(*string)), true
+
+ case "Subscription.directiveUnimplemented":
+ if e.complexity.Subscription.DirectiveUnimplemented == nil {
+ break
+ }
+
+ return e.complexity.Subscription.DirectiveUnimplemented(childComplexity), true
+
+ case "Subscription.initPayload":
+ if e.complexity.Subscription.InitPayload == nil {
+ break
+ }
+
+ return e.complexity.Subscription.InitPayload(childComplexity), true
+
+ case "Subscription.issue896b":
+ if e.complexity.Subscription.Issue896b == nil {
+ break
+ }
+
+ return e.complexity.Subscription.Issue896b(childComplexity), true
+
+ case "Subscription.updated":
+ if e.complexity.Subscription.Updated == nil {
+ break
+ }
+
+ return e.complexity.Subscription.Updated(childComplexity), true
+
+ case "User.created":
+ if e.complexity.User.Created == nil {
+ break
+ }
+
+ return e.complexity.User.Created(childComplexity), true
+
+ case "User.friends":
+ if e.complexity.User.Friends == nil {
+ break
+ }
+
+ return e.complexity.User.Friends(childComplexity), true
+
+ case "User.id":
+ if e.complexity.User.ID == nil {
+ break
+ }
+
+ return e.complexity.User.ID(childComplexity), true
+
+ case "User.updated":
+ if e.complexity.User.Updated == nil {
+ break
+ }
+
+ return e.complexity.User.Updated(childComplexity), true
+
+ case "VOkCaseNil.value":
+ if e.complexity.VOkCaseNil.Value == nil {
+ break
+ }
+
+ return e.complexity.VOkCaseNil.Value(childComplexity), true
+
+ case "VOkCaseValue.value":
+ if e.complexity.VOkCaseValue.Value == nil {
+ break
+ }
+
+ return e.complexity.VOkCaseValue.Value(childComplexity), true
+
+ case "ValidType.differentCase":
+ if e.complexity.ValidType.DifferentCase == nil {
+ break
+ }
+
+ return e.complexity.ValidType.DifferentCase(childComplexity), true
+
+ case "ValidType.different_case":
+ if e.complexity.ValidType.DifferentCaseOld == nil {
+ break
+ }
+
+ return e.complexity.ValidType.DifferentCaseOld(childComplexity), true
+
+ case "ValidType.validArgs":
+ if e.complexity.ValidType.ValidArgs == nil {
+ break
+ }
+
+ args, err := ec.field_ValidType_validArgs_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.ValidType.ValidArgs(childComplexity, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string), args["_"].(string)), true
+
+ case "ValidType.validInputKeywords":
+ if e.complexity.ValidType.ValidInputKeywords == nil {
+ break
+ }
+
+ args, err := ec.field_ValidType_validInputKeywords_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.ValidType.ValidInputKeywords(childComplexity, args["input"].(*ValidInput)), true
+
+ case "WrappedMap.get":
+ if e.complexity.WrappedMap.Get == nil {
+ break
+ }
+
+ args, err := ec.field_WrappedMap_get_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.WrappedMap.Get(childComplexity, args["key"].(string)), true
+
+ case "WrappedSlice.get":
+ if e.complexity.WrappedSlice.Get == nil {
+ break
+ }
+
+ args, err := ec.field_WrappedSlice_get_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.WrappedSlice.Get(childComplexity, args["idx"].(int)), true
+
+ case "WrappedStruct.desc":
+ if e.complexity.WrappedStruct.Desc == nil {
+ break
+ }
+
+ return e.complexity.WrappedStruct.Desc(childComplexity), true
+
+ case "WrappedStruct.name":
+ if e.complexity.WrappedStruct.Name == nil {
+ break
+ }
+
+ return e.complexity.WrappedStruct.Name(childComplexity), true
+
+ case "XXIt.id":
+ if e.complexity.XXIt.ID == nil {
+ break
+ }
+
+ return e.complexity.XXIt.ID(childComplexity), true
+
+ case "XxIt.id":
+ if e.complexity.XxIt.ID == nil {
+ break
+ }
+
+ return e.complexity.XxIt.ID(childComplexity), true
+
+ case "asdfIt.id":
+ if e.complexity.AsdfIt.ID == nil {
+ break
+ }
+
+ return e.complexity.AsdfIt.ID(childComplexity), true
+
+ case "iIt.id":
+ if e.complexity.IIt.ID == nil {
+ break
+ }
+
+ return e.complexity.IIt.ID(childComplexity), true
+
+ }
+ return 0, false
+}
+
+func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
+ rc := graphql.GetOperationContext(ctx)
+ ec := executionContext{rc, e}
+ first := true
+
+ switch rc.Operation.Operation {
+ case ast.Query:
+ return func(ctx context.Context) *graphql.Response {
+ if !first {
+ return nil
+ }
+ first = false
+ data := ec._Query(ctx, rc.Operation.SelectionSet)
+ var buf bytes.Buffer
+ data.MarshalGQL(&buf)
+
+ return &graphql.Response{
+ Data: buf.Bytes(),
+ }
+ }
+ case ast.Mutation:
+ return func(ctx context.Context) *graphql.Response {
+ if !first {
+ return nil
+ }
+ first = false
+ data := ec._Mutation(ctx, rc.Operation.SelectionSet)
+ var buf bytes.Buffer
+ data.MarshalGQL(&buf)
+
+ return &graphql.Response{
+ Data: buf.Bytes(),
+ }
+ }
+ case ast.Subscription:
+ next := ec._Subscription(ctx, rc.Operation.SelectionSet)
+
+ var buf bytes.Buffer
+ return func(ctx context.Context) *graphql.Response {
+ buf.Reset()
+ data := next()
+
+ if data == nil {
+ return nil
+ }
+ data.MarshalGQL(&buf)
+
+ return &graphql.Response{
+ Data: buf.Bytes(),
+ }
+ }
+
+ default:
+ return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation"))
+ }
+}
+
+type executionContext struct {
+ *graphql.OperationContext
+ *executableSchema
+}
+
+func (ec *executionContext) introspectSchema() (*introspection.Schema, error) {
+ if ec.DisableIntrospection {
+ return nil, errors.New("introspection disabled")
+ }
+ return introspection.WrapSchema(parsedSchema), nil
+}
+
+func (ec *executionContext) introspectType(name string) (*introspection.Type, error) {
+ if ec.DisableIntrospection {
+ return nil, errors.New("introspection disabled")
+ }
+ return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil
+}
+
+var sources = []*ast.Source{
+ {Name: "builtinscalar.graphql", Input: `
+"""
+Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_
+added to the TypeMap
+"""
+type Map {
+ id: ID!
+}
+`, BuiltIn: false},
+ {Name: "complexity.graphql", Input: `extend type Query {
+ overlapping: OverlappingFields
+}
+
+type OverlappingFields {
+ oneFoo: Int! @goField(name: "foo")
+ twoFoo: Int! @goField(name: "foo")
+ oldFoo: Int! @goField(name: "foo", forceResolver: true)
+ newFoo: Int!
+ new_foo: Int!
+}
+`, BuiltIn: false},
+ {Name: "defaults.graphql", Input: `extend type Query {
+ defaultParameters(
+ falsyBoolean: Boolean = false
+ truthyBoolean: Boolean = true
+ ): DefaultParametersMirror!
+}
+
+extend type Mutation {
+ defaultInput(input: DefaultInput!): DefaultParametersMirror!
+}
+
+input DefaultInput {
+ falsyBoolean: Boolean = false
+ truthyBoolean: Boolean = true
+}
+
+type DefaultParametersMirror {
+ falsyBoolean: Boolean
+ truthyBoolean: Boolean
+}
+`, BuiltIn: false},
+ {Name: "directive.graphql", Input: `directive @length(min: Int!, max: Int, message: String) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION
+directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION
+directive @custom on ARGUMENT_DEFINITION
+directive @logged(id: UUID!) on FIELD
+directive @toNull on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION
+directive @directive1 on FIELD_DEFINITION
+directive @directive2 on FIELD_DEFINITION
+directive @directive3 on INPUT_OBJECT
+directive @unimplemented on FIELD_DEFINITION
+directive @order1(location: String!) repeatable on FIELD_DEFINITION | OBJECT
+directive @order2(location: String!) on OBJECT
+
+extend type Query {
+ directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String
+ directiveNullableArg(arg: Int @range(min:0), arg2: Int @range, arg3: String @toNull): String
+ directiveInputNullable(arg: InputDirectives): String
+ directiveInput(arg: InputDirectives!): String
+ directiveInputType(arg: InnerInput! @custom): String
+ directiveObject: ObjectDirectives @order1(location: "Query_field")
+ directiveObjectWithCustomGoModel: ObjectDirectivesWithCustomGoModel
+ directiveFieldDef(ret: String!): String! @length(min: 1, message: "not valid")
+ directiveField: String
+ directiveDouble: String @directive1 @directive2
+ directiveUnimplemented: String @unimplemented
+}
+
+extend type Subscription {
+ directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String
+ directiveNullableArg(arg: Int @range(min:0), arg2: Int @range, arg3: String @toNull): String
+ directiveDouble: String @directive1 @directive2
+ directiveUnimplemented: String @unimplemented
+}
+
+input InputDirectives @directive3 {
+ text: String! @length(min: 0, max: 7, message: "not valid")
+ nullableText: String @toNull
+ inner: InnerDirectives!
+ innerNullable: InnerDirectives
+ thirdParty: ThirdParty @length(min: 0, max: 7)
+}
+
+input InnerDirectives {
+ message: String! @length(min: 1, message: "not valid")
+}
+
+type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2") @order2(location: "order2_1") {
+ text: String! @length(min: 0, max: 7, message: "not valid")
+ nullableText: String @toNull
+ order: [String!]!
+}
+
+type ObjectDirectivesWithCustomGoModel {
+ nullableText: String @toNull
+}
+`, BuiltIn: false},
+ {Name: "embedded.graphql", Input: `extend type Query {
+ embeddedCase1: EmbeddedCase1
+ embeddedCase2: EmbeddedCase2
+ embeddedCase3: EmbeddedCase3
+}
+
+type EmbeddedCase1 @goModel(model:"followschema.EmbeddedCase1") {
+ exportedEmbeddedPointerExportedMethod: String!
+}
+
+type EmbeddedCase2 @goModel(model:"followschema.EmbeddedCase2") {
+ unexportedEmbeddedPointerExportedMethod: String!
+}
+
+type EmbeddedCase3 @goModel(model:"followschema.EmbeddedCase3") {
+ unexportedEmbeddedInterfaceExportedMethod: String!
+}
+`, BuiltIn: false},
+ {Name: "enum.graphql", Input: `enum EnumTest {
+ OK
+ NG
+}
+
+input InputWithEnumValue {
+ enum: EnumTest!
+}
+
+extend type Query {
+ enumInInput(input: InputWithEnumValue): EnumTest!
+}
+`, BuiltIn: false},
+ {Name: "interfaces.graphql", Input: `extend type Query {
+ shapes: [Shape]
+ noShape: Shape @makeNil
+ node: Node!
+ noShapeTypedNil: Shape @makeTypedNil
+ animal: Animal @makeTypedNil
+ notAnInterface: BackedByInterface
+}
+
+interface Animal {
+ species: String!
+}
+
+type BackedByInterface {
+ id: String!
+ thisShouldBind: String!
+ thisShouldBindWithError: String!
+}
+
+type Dog implements Animal {
+ species: String!
+ dogBreed: String!
+}
+
+type Cat implements Animal {
+ species: String!
+ catBreed: String!
+}
+
+type Coordinates {
+ x: Float!
+ y: Float!
+}
+interface Shape {
+ area: Float
+ coordinates: Coordinates
+}
+
+type Circle implements Shape {
+ radius: Float
+ area: Float
+ coordinates: Coordinates
+}
+type Rectangle implements Shape {
+ length: Float
+ width: Float
+ area: Float
+ coordinates: Coordinates
+}
+union ShapeUnion @goModel(model: "followschema.ShapeUnion") = Circle | Rectangle
+
+directive @makeNil on FIELD_DEFINITION
+directive @makeTypedNil on FIELD_DEFINITION
+
+interface Node {
+ id: ID!
+ child: Node!
+}
+
+type ConcreteNodeA implements Node {
+ id: ID!
+ child: Node!
+ name: String!
+}
+
+" Implements the Node interface with another interface "
+type ConcreteNodeInterface implements Node {
+ id: ID!
+ child: Node!
+}
+`, BuiltIn: false},
+ {Name: "issue896.graphql", Input: `# This example should build stable output. If the file content starts
+# alternating nondeterministically between two outputs, then see
+# https://github.com/99designs/gqlgen/issues/896.
+
+extend schema {
+ query: Query
+ subscription: Subscription
+}
+
+type CheckIssue896 {id: Int}
+
+extend type Query {
+ issue896a: [CheckIssue896!] # Note the "!" or lack thereof.
+}
+
+extend type Subscription {
+ issue896b: [CheckIssue896] # Note the "!" or lack thereof.
+}
+`, BuiltIn: false},
+ {Name: "loops.graphql", Input: `type LoopA {
+ b: LoopB!
+}
+
+type LoopB {
+ a: LoopA!
+}
+`, BuiltIn: false},
+ {Name: "maps.graphql", Input: `extend type Query {
+ mapStringInterface(in: MapStringInterfaceInput): MapStringInterfaceType
+ mapNestedStringInterface(in: NestedMapInput): MapStringInterfaceType
+}
+
+type MapStringInterfaceType @goModel(model: "map[string]interface{}") {
+ a: String
+ b: Int
+}
+
+input MapStringInterfaceInput @goModel(model: "map[string]interface{}") {
+ a: String
+ b: Int
+}
+
+input NestedMapInput {
+ map: MapStringInterfaceInput
+}
+`, BuiltIn: false},
+ {Name: "mutation_with_custom_scalar.graphql", Input: `extend type Mutation {
+ updateSomething(input: SpecialInput!): String!
+}
+
+scalar Email
+
+input SpecialInput {
+ nesting: NestedInput!
+}
+
+input NestedInput {
+ field: Email!
+}
+`, BuiltIn: false},
+ {Name: "nulls.graphql", Input: `extend type Query {
+ errorBubble: Error
+ errorBubbleList: [Error!]
+ errorList: [Error]
+ errors: Errors
+ valid: String!
+}
+
+type Errors {
+ a: Error!
+ b: Error!
+ c: Error!
+ d: Error!
+ e: Error!
+}
+
+type Error {
+ id: ID!
+ errorOnNonRequiredField: String
+ errorOnRequiredField: String!
+ nilOnRequiredField: String!
+}
+`, BuiltIn: false},
+ {Name: "panics.graphql", Input: `extend type Query {
+ panics: Panics
+}
+
+type Panics {
+ fieldScalarMarshal: [MarshalPanic!]!
+ fieldFuncMarshal(u: [MarshalPanic!]!): [MarshalPanic!]!
+ argUnmarshal(u: [MarshalPanic!]!): Boolean!
+
+}
+
+scalar MarshalPanic
+`, BuiltIn: false},
+ {Name: "primitive_objects.graphql", Input: `extend type Query {
+ primitiveObject: [Primitive!]!
+ primitiveStringObject: [PrimitiveString!]!
+}
+
+type Primitive {
+ value: Int!
+ squared: Int!
+}
+
+type PrimitiveString {
+ value: String!
+ doubled: String!
+ len: Int!
+}
+`, BuiltIn: false},
+ {Name: "ptr_to_ptr_input.graphql", Input: `type PtrToPtrOuter {
+ name: String!
+ inner: PtrToPtrInner
+ stupidInner: PtrToPtrInner
+}
+
+type PtrToPtrInner {
+ key: String!
+ value: String!
+}
+
+input UpdatePtrToPtrOuter {
+ name: String
+ inner: UpdatePtrToPtrInner
+ stupidInner: UpdatePtrToPtrInner
+}
+
+input UpdatePtrToPtrInner {
+ key: String
+ value: String
+}
+
+extend type Mutation {
+ updatePtrToPtr(input: UpdatePtrToPtrOuter!): PtrToPtrOuter!
+}
+`, BuiltIn: false},
+ {Name: "ptr_to_slice.graphql", Input: `type PtrToSliceContainer {
+ ptrToSlice: [String!]
+}
+
+extend type Query {
+ ptrToSliceContainer: PtrToSliceContainer!
+}
+`, BuiltIn: false},
+ {Name: "scalar_context.graphql", Input: `extend type Query {
+ infinity: Float!
+ stringFromContextInterface: StringFromContextInterface!
+ stringFromContextFunction: StringFromContextFunction!
+}
+
+scalar StringFromContextInterface
+scalar StringFromContextFunction
+`, BuiltIn: false},
+ {Name: "scalar_default.graphql", Input: `extend type Query {
+ defaultScalar(arg: DefaultScalarImplementation! = "default"): DefaultScalarImplementation!
+}
+
+""" This doesnt have an implementation in the typemap, so it should act like a string """
+scalar DefaultScalarImplementation
+
+type EmbeddedDefaultScalar {
+ value: DefaultScalarImplementation
+}
+`, BuiltIn: false},
+ {Name: "schema.graphql", Input: `directive @goModel(
+ model: String
+ models: [String!]
+) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION
+directive @goField(
+ forceResolver: Boolean
+ name: String
+) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
+
+type Query {
+ invalidIdentifier: InvalidIdentifier
+ collision: It
+ mapInput(input: Changes): Boolean
+ recursive(input: RecursiveInputSlice): Boolean
+ nestedInputs(input: [[OuterInput]] = [[{ inner: { id: 1 } }]]): Boolean
+ nestedOutputs: [[OuterObject]]
+ modelMethods: ModelMethods
+ user(id: Int!): User!
+ nullableArg(arg: Int = 123): String
+ inputSlice(arg: [String!]!): Boolean!
+ inputNullableSlice(arg: [String!]): Boolean!
+ shapeUnion: ShapeUnion!
+ autobind: Autobind
+ deprecatedField: String! @deprecated(reason: "test deprecated directive")
+}
+
+type Subscription {
+ updated: String!
+ initPayload: String!
+}
+
+type User {
+ id: Int!
+ friends: [User!]! @goField(forceResolver: true)
+ created: Time!
+ updated: Time
+}
+
+type Autobind {
+ int: Int!
+ int32: Int!
+ int64: Int!
+
+ idStr: ID!
+ idInt: ID!
+}
+
+type ModelMethods {
+ resolverField: Boolean!
+ noContext: Boolean!
+ withContext: Boolean!
+}
+
+type InvalidIdentifier {
+ id: Int!
+}
+
+type It {
+ id: ID!
+}
+
+input Changes @goModel(model: "map[string]interface{}") {
+ a: Int
+ b: Int
+}
+
+input RecursiveInputSlice {
+ self: [RecursiveInputSlice!]
+}
+
+input InnerInput {
+ id: Int!
+}
+
+input OuterInput {
+ inner: InnerInput!
+}
+
+scalar ThirdParty @goModel(model:"followschema.ThirdParty")
+
+type OuterObject {
+ inner: InnerObject!
+}
+
+type InnerObject {
+ id: Int!
+}
+
+type ForcedResolver {
+ field: Circle @goField(forceResolver: true)
+}
+
+type EmbeddedPointer @goModel(model:"followschema.EmbeddedPointerModel") {
+ ID: String
+ Title: String
+}
+
+scalar UUID
+
+enum Status {
+ OK
+ ERROR
+}
+
+scalar Time
+`, BuiltIn: false},
+ {Name: "slices.graphql", Input: `extend type Query {
+ slices: Slices
+ scalarSlice: Bytes!
+}
+
+type Slices {
+ test1: [String]
+ test2: [String!]
+ test3: [String]!
+ test4: [String!]!
+}
+
+scalar Bytes
+`, BuiltIn: false},
+ {Name: "typefallback.graphql", Input: `extend type Query {
+ fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding!
+}
+
+enum FallbackToStringEncoding {
+ A
+ B
+ C
+}
+`, BuiltIn: false},
+ {Name: "useptr.graphql", Input: `type A {
+ id: ID!
+}
+
+type B {
+ id: ID!
+}
+
+union TestUnion = A | B
+
+extend type Query {
+ optionalUnion: TestUnion
+}
+`, BuiltIn: false},
+ {Name: "v-ok.graphql", Input: `extend type Query {
+ vOkCaseValue: VOkCaseValue
+ vOkCaseNil: VOkCaseNil
+}
+
+type VOkCaseValue @goModel(model:"followschema.VOkCaseValue") {
+ value: String
+}
+
+type VOkCaseNil @goModel(model:"followschema.VOkCaseNil") {
+ value: String
+}
+`, BuiltIn: false},
+ {Name: "validtypes.graphql", Input: `extend type Query {
+ validType: ValidType
+}
+
+""" These things are all valid, but without care generate invalid go code """
+type ValidType {
+ differentCase: String!
+ different_case: String! @goField(name:"DifferentCaseOld")
+ validInputKeywords(input: ValidInput): Boolean!
+ validArgs(
+ break: String!,
+ default: String!,
+ func: String!,
+ interface: String!,
+ select: String!,
+ case: String!,
+ defer: String!,
+ go: String!,
+ map: String!,
+ struct: String!,
+ chan: String!,
+ else: String!,
+ goto: String!,
+ package: String!,
+ switch: String!,
+ const: String!,
+ fallthrough: String!,
+ if: String!,
+ range: String!,
+ type: String!,
+ continue: String!,
+ for: String!,
+ import: String!,
+ return: String!,
+ var: String!,
+ _: String!,
+ ): Boolean!
+}
+
+input ValidInput {
+ break: String!
+ default: String!
+ func: String!
+ interface: String!
+ select: String!
+ case: String!
+ defer: String!
+ go: String!
+ map: String!
+ struct: String!
+ chan: String!
+ else: String!
+ goto: String!
+ package: String!
+ switch: String!
+ const: String!
+ fallthrough: String!
+ if: String!
+ range: String!
+ type: String!
+ continue: String!
+ for: String!
+ import: String!
+ return: String!
+ var: String!
+ _: String! @goField(name: "Underscore")
+}
+
+# see https://github.com/99designs/gqlgen/issues/694
+type Content_User {
+ foo: String
+}
+
+type Content_Post {
+ foo: String
+}
+
+union Content_Child = Content_User | Content_Post
+`, BuiltIn: false},
+ {Name: "weird_type_cases.graphql", Input: `# regression test for https://github.com/99designs/gqlgen/issues/583
+
+type asdfIt { id: ID! }
+type iIt { id: ID! }
+type AIt { id: ID! }
+type XXIt { id: ID! }
+type AbIt { id: ID! }
+type XxIt { id: ID! }
+`, BuiltIn: false},
+ {Name: "wrapped_type.graphql", Input: `# regression test for https://github.com/99designs/gqlgen/issues/721
+
+extend type Query {
+ wrappedStruct: WrappedStruct!
+ wrappedScalar: WrappedScalar!
+ wrappedMap: WrappedMap!
+ wrappedSlice: WrappedSlice!
+}
+
+type WrappedStruct { name: WrappedScalar!, desc: WrappedScalar }
+scalar WrappedScalar
+type WrappedMap { get(key: String!): String! }
+type WrappedSlice { get(idx: Int!): String! }
+`, BuiltIn: false},
+}
+var parsedSchema = gqlparser.MustLoadSchema(sources...)
diff --git a/codegen/testserver/followschema/scalar_context.generated.go b/codegen/testserver/followschema/scalar_context.generated.go
new file mode 100644
index 00000000000..c1607f021e6
--- /dev/null
+++ b/codegen/testserver/followschema/scalar_context.generated.go
@@ -0,0 +1,83 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalNStringFromContextFunction2string(ctx context.Context, v interface{}) (string, error) {
+ res, err := UnmarshalStringFromContextFunction(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNStringFromContextFunction2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
+ res := MarshalStringFromContextFunction(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return graphql.WrapContextMarshaler(ctx, res)
+}
+
+func (ec *executionContext) unmarshalNStringFromContextInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStringFromContextInterface(ctx context.Context, v interface{}) (StringFromContextInterface, error) {
+ var res StringFromContextInterface
+ err := res.UnmarshalGQLContext(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNStringFromContextInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStringFromContextInterface(ctx context.Context, sel ast.SelectionSet, v StringFromContextInterface) graphql.Marshaler {
+ return graphql.WrapContextMarshaler(ctx, v)
+}
+
+func (ec *executionContext) unmarshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStringFromContextInterface(ctx context.Context, v interface{}) (*StringFromContextInterface, error) {
+ var res = new(StringFromContextInterface)
+ err := res.UnmarshalGQLContext(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStringFromContextInterface(ctx context.Context, sel ast.SelectionSet, v *StringFromContextInterface) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return graphql.WrapContextMarshaler(ctx, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/followschema/scalar_context.go b/codegen/testserver/followschema/scalar_context.go
new file mode 100644
index 00000000000..7b8e7cca865
--- /dev/null
+++ b/codegen/testserver/followschema/scalar_context.go
@@ -0,0 +1,36 @@
+package followschema
+
+import (
+ "context"
+ "io"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+)
+
+type StringFromContextInterface struct {
+ OperationName string
+}
+
+var _ graphql.ContextMarshaler = StringFromContextInterface{}
+var _ graphql.ContextUnmarshaler = (*StringFromContextInterface)(nil)
+
+func (StringFromContextInterface) MarshalGQLContext(ctx context.Context, w io.Writer) error {
+ io.WriteString(w, strconv.Quote(graphql.GetFieldContext(ctx).Field.Name))
+ return nil
+}
+func (i *StringFromContextInterface) UnmarshalGQLContext(ctx context.Context, v interface{}) error {
+ i.OperationName = graphql.GetFieldContext(ctx).Field.Name
+ return nil
+}
+
+func MarshalStringFromContextFunction(v string) graphql.ContextMarshaler {
+ return graphql.ContextWriterFunc(func(ctx context.Context, w io.Writer) error {
+ io.WriteString(w, strconv.Quote(graphql.GetFieldContext(ctx).Field.Name))
+ return nil
+ })
+}
+
+func UnmarshalStringFromContextFunction(ctx context.Context, v interface{}) (string, error) {
+ return graphql.GetFieldContext(ctx).Field.Name, nil
+}
diff --git a/codegen/testserver/followschema/scalar_context.graphql b/codegen/testserver/followschema/scalar_context.graphql
new file mode 100644
index 00000000000..f49fa553139
--- /dev/null
+++ b/codegen/testserver/followschema/scalar_context.graphql
@@ -0,0 +1,8 @@
+extend type Query {
+ infinity: Float!
+ stringFromContextInterface: StringFromContextInterface!
+ stringFromContextFunction: StringFromContextFunction!
+}
+
+scalar StringFromContextInterface
+scalar StringFromContextFunction
diff --git a/codegen/testserver/followschema/scalar_context_test.go b/codegen/testserver/followschema/scalar_context_test.go
new file mode 100644
index 00000000000..b8427065c54
--- /dev/null
+++ b/codegen/testserver/followschema/scalar_context_test.go
@@ -0,0 +1,52 @@
+package followschema
+
+import (
+ "context"
+ "math"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestFloatInfAndNaN(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.QueryResolver.Infinity = func(ctx context.Context) (float64, error) {
+ return math.Inf(-1), nil
+ }
+
+ t.Run("errors on marshaller with context", func(t *testing.T) {
+ err := c.Post(`query { infinity }`, nil)
+ require.Error(t, err)
+ })
+
+}
+
+func TestContextPassedToMarshal(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.QueryResolver.StringFromContextInterface = func(ctx context.Context) (*StringFromContextInterface, error) {
+ return &StringFromContextInterface{}, nil
+ }
+ resolvers.QueryResolver.StringFromContextFunction = func(ctx context.Context) (string, error) {
+ return "", nil
+ }
+
+ var res struct {
+ StringFromContextInterface string
+ StringFromContextFunction string
+ }
+ err := c.Post(`query my_name {
+ stringFromContextInterface
+ stringFromContextFunction
+ }`, &res)
+ require.NoError(t, err)
+ require.Equal(t, "stringFromContextInterface", res.StringFromContextInterface)
+ require.Equal(t, "stringFromContextFunction", res.StringFromContextFunction)
+}
diff --git a/codegen/testserver/followschema/scalar_default.generated.go b/codegen/testserver/followschema/scalar_default.generated.go
new file mode 100644
index 00000000000..5ac087b7d54
--- /dev/null
+++ b/codegen/testserver/followschema/scalar_default.generated.go
@@ -0,0 +1,131 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _EmbeddedDefaultScalar_value(ctx context.Context, field graphql.CollectedField, obj *EmbeddedDefaultScalar) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "EmbeddedDefaultScalar",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Value, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalODefaultScalarImplementation2ᚖstring(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var embeddedDefaultScalarImplementors = []string{"EmbeddedDefaultScalar"}
+
+func (ec *executionContext) _EmbeddedDefaultScalar(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedDefaultScalar) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, embeddedDefaultScalarImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("EmbeddedDefaultScalar")
+ case "value":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedDefaultScalar_value(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalNDefaultScalarImplementation2string(ctx context.Context, v interface{}) (string, error) {
+ res, err := graphql.UnmarshalString(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNDefaultScalarImplementation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
+ res := graphql.MarshalString(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) unmarshalODefaultScalarImplementation2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := graphql.UnmarshalString(v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalODefaultScalarImplementation2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ res := graphql.MarshalString(*v)
+ return res
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/scalar_default.graphql b/codegen/testserver/followschema/scalar_default.graphql
similarity index 100%
rename from codegen/testserver/scalar_default.graphql
rename to codegen/testserver/followschema/scalar_default.graphql
diff --git a/codegen/testserver/followschema/scalar_default_test.go b/codegen/testserver/followschema/scalar_default_test.go
new file mode 100644
index 00000000000..f6fc05cb09e
--- /dev/null
+++ b/codegen/testserver/followschema/scalar_default_test.go
@@ -0,0 +1,32 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestDefaultScalarImplementation(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.QueryResolver.DefaultScalar = func(ctx context.Context, arg string) (i string, e error) {
+ return arg, nil
+ }
+
+ t.Run("with arg value", func(t *testing.T) {
+ var resp struct{ DefaultScalar string }
+ c.MustPost(`query { defaultScalar(arg: "fff") }`, &resp)
+ require.Equal(t, "fff", resp.DefaultScalar)
+ })
+
+ t.Run("with default value", func(t *testing.T) {
+ var resp struct{ DefaultScalar string }
+ c.MustPost(`query { defaultScalar }`, &resp)
+ require.Equal(t, "default", resp.DefaultScalar)
+ })
+}
diff --git a/codegen/testserver/followschema/schema.generated.go b/codegen/testserver/followschema/schema.generated.go
new file mode 100644
index 00000000000..5d8d9b6ce02
--- /dev/null
+++ b/codegen/testserver/followschema/schema.generated.go
@@ -0,0 +1,6188 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "io"
+ "strconv"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ introspection1 "github.com/99designs/gqlgen/codegen/testserver/followschema/introspection"
+ invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/followschema/invalid-packagename"
+ "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg"
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/99designs/gqlgen/graphql/introspection"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+type ForcedResolverResolver interface {
+ Field(ctx context.Context, obj *ForcedResolver) (*Circle, error)
+}
+type ModelMethodsResolver interface {
+ ResolverField(ctx context.Context, obj *ModelMethods) (bool, error)
+}
+type QueryResolver interface {
+ InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error)
+ Collision(ctx context.Context) (*introspection1.It, error)
+ MapInput(ctx context.Context, input map[string]interface{}) (*bool, error)
+ Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error)
+ NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error)
+ NestedOutputs(ctx context.Context) ([][]*OuterObject, error)
+ ModelMethods(ctx context.Context) (*ModelMethods, error)
+ User(ctx context.Context, id int) (*User, error)
+ NullableArg(ctx context.Context, arg *int) (*string, error)
+ InputSlice(ctx context.Context, arg []string) (bool, error)
+ InputNullableSlice(ctx context.Context, arg []string) (bool, error)
+ ShapeUnion(ctx context.Context) (ShapeUnion, error)
+ Autobind(ctx context.Context) (*Autobind, error)
+ DeprecatedField(ctx context.Context) (string, error)
+ Overlapping(ctx context.Context) (*OverlappingFields, error)
+ DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error)
+ DirectiveArg(ctx context.Context, arg string) (*string, error)
+ DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error)
+ DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error)
+ DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error)
+ DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error)
+ DirectiveObject(ctx context.Context) (*ObjectDirectives, error)
+ DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error)
+ DirectiveFieldDef(ctx context.Context, ret string) (string, error)
+ DirectiveField(ctx context.Context) (*string, error)
+ DirectiveDouble(ctx context.Context) (*string, error)
+ DirectiveUnimplemented(ctx context.Context) (*string, error)
+ EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error)
+ EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error)
+ EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error)
+ EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error)
+ Shapes(ctx context.Context) ([]Shape, error)
+ NoShape(ctx context.Context) (Shape, error)
+ Node(ctx context.Context) (Node, error)
+ NoShapeTypedNil(ctx context.Context) (Shape, error)
+ Animal(ctx context.Context) (Animal, error)
+ NotAnInterface(ctx context.Context) (BackedByInterface, error)
+ Issue896a(ctx context.Context) ([]*CheckIssue896, error)
+ MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error)
+ MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error)
+ ErrorBubble(ctx context.Context) (*Error, error)
+ ErrorBubbleList(ctx context.Context) ([]*Error, error)
+ ErrorList(ctx context.Context) ([]*Error, error)
+ Errors(ctx context.Context) (*Errors, error)
+ Valid(ctx context.Context) (string, error)
+ Panics(ctx context.Context) (*Panics, error)
+ PrimitiveObject(ctx context.Context) ([]Primitive, error)
+ PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error)
+ PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error)
+ Infinity(ctx context.Context) (float64, error)
+ StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error)
+ StringFromContextFunction(ctx context.Context) (string, error)
+ DefaultScalar(ctx context.Context, arg string) (string, error)
+ Slices(ctx context.Context) (*Slices, error)
+ ScalarSlice(ctx context.Context) ([]byte, error)
+ Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error)
+ OptionalUnion(ctx context.Context) (TestUnion, error)
+ VOkCaseValue(ctx context.Context) (*VOkCaseValue, error)
+ VOkCaseNil(ctx context.Context) (*VOkCaseNil, error)
+ ValidType(ctx context.Context) (*ValidType, error)
+ WrappedStruct(ctx context.Context) (*WrappedStruct, error)
+ WrappedScalar(ctx context.Context) (otherpkg.Scalar, error)
+ WrappedMap(ctx context.Context) (WrappedMap, error)
+ WrappedSlice(ctx context.Context) (WrappedSlice, error)
+}
+type SubscriptionResolver interface {
+ Updated(ctx context.Context) (<-chan string, error)
+ InitPayload(ctx context.Context) (<-chan string, error)
+ DirectiveArg(ctx context.Context, arg string) (<-chan *string, error)
+ DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error)
+ DirectiveDouble(ctx context.Context) (<-chan *string, error)
+ DirectiveUnimplemented(ctx context.Context) (<-chan *string, error)
+ Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error)
+}
+type UserResolver interface {
+ Friends(ctx context.Context, obj *User) ([]*User, error)
+}
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["name"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name"))
+ arg0, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["name"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_defaultParameters_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 *bool
+ if tmp, ok := rawArgs["falsyBoolean"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("falsyBoolean"))
+ arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["falsyBoolean"] = arg0
+ var arg1 *bool
+ if tmp, ok := rawArgs["truthyBoolean"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("truthyBoolean"))
+ arg1, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["truthyBoolean"] = arg1
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_defaultScalar_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ arg0, err = ec.unmarshalNDefaultScalarImplementation2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["arg"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, tmp) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ min, err := ec.unmarshalNInt2int(ctx, 1)
+ if err != nil {
+ return nil, err
+ }
+ max, err := ec.unmarshalOInt2ᚖint(ctx, 255)
+ if err != nil {
+ return nil, err
+ }
+ message, err := ec.unmarshalOString2ᚖstring(ctx, "invalid length")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Length == nil {
+ return nil, errors.New("directive length is not implemented")
+ }
+ return ec.directives.Length(ctx, rawArgs, directive0, min, max, message)
+ }
+
+ tmp, err = directive1(ctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(string); ok {
+ arg0 = data
+ } else {
+ return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp))
+ }
+ }
+ args["arg"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_directiveFieldDef_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["ret"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ret"))
+ arg0, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["ret"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 *InputDirectives
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ arg0, err = ec.unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputDirectives(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["arg"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_directiveInputType_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 InnerInput
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ directive0 := func(ctx context.Context) (interface{}, error) {
+ return ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerInput(ctx, tmp)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Custom == nil {
+ return nil, errors.New("directive custom is not implemented")
+ }
+ return ec.directives.Custom(ctx, rawArgs, directive0)
+ }
+
+ tmp, err = directive1(ctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(InnerInput); ok {
+ arg0 = data
+ } else {
+ return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver/followschema.InnerInput`, tmp))
+ }
+ }
+ args["arg"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_directiveInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 InputDirectives
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ arg0, err = ec.unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputDirectives(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["arg"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_directiveNullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 *int
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOInt2ᚖint(ctx, tmp) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ min, err := ec.unmarshalOInt2ᚖint(ctx, 0)
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Range == nil {
+ return nil, errors.New("directive range is not implemented")
+ }
+ return ec.directives.Range(ctx, rawArgs, directive0, min, nil)
+ }
+
+ tmp, err = directive1(ctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*int); ok {
+ arg0 = data
+ } else if tmp == nil {
+ arg0 = nil
+ } else {
+ return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp))
+ }
+ }
+ args["arg"] = arg0
+ var arg1 *int
+ if tmp, ok := rawArgs["arg2"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg2"))
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOInt2ᚖint(ctx, tmp) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ min, err := ec.unmarshalOInt2ᚖint(ctx, 0)
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Range == nil {
+ return nil, errors.New("directive range is not implemented")
+ }
+ return ec.directives.Range(ctx, rawArgs, directive0, min, nil)
+ }
+
+ tmp, err = directive1(ctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*int); ok {
+ arg1 = data
+ } else if tmp == nil {
+ arg1 = nil
+ } else {
+ return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp))
+ }
+ }
+ args["arg2"] = arg1
+ var arg2 *string
+ if tmp, ok := rawArgs["arg3"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg3"))
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, tmp) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.ToNull == nil {
+ return nil, errors.New("directive toNull is not implemented")
+ }
+ return ec.directives.ToNull(ctx, rawArgs, directive0)
+ }
+
+ tmp, err = directive1(ctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*string); ok {
+ arg2 = data
+ } else if tmp == nil {
+ arg2 = nil
+ } else {
+ return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp))
+ }
+ }
+ args["arg3"] = arg2
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_enumInInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 *InputWithEnumValue
+ if tmp, ok := rawArgs["input"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
+ arg0, err = ec.unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputWithEnumValue(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["input"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_fallback_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 FallbackToStringEncoding
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ arg0, err = ec.unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFallbackToStringEncoding(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["arg"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_inputNullableSlice_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 []string
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ arg0, err = ec.unmarshalOString2ᚕstringᚄ(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["arg"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_inputSlice_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 []string
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ arg0, err = ec.unmarshalNString2ᚕstringᚄ(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["arg"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 map[string]interface{}
+ if tmp, ok := rawArgs["input"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
+ arg0, err = ec.unmarshalOChanges2map(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["input"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_mapNestedStringInterface_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 *NestedMapInput
+ if tmp, ok := rawArgs["in"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("in"))
+ arg0, err = ec.unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNestedMapInput(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["in"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_mapStringInterface_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 map[string]interface{}
+ if tmp, ok := rawArgs["in"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("in"))
+ arg0, err = ec.unmarshalOMapStringInterfaceInput2map(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["in"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 [][]*OuterInput
+ if tmp, ok := rawArgs["input"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
+ arg0, err = ec.unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["input"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 *int
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["arg"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 *RecursiveInputSlice
+ if tmp, ok := rawArgs["input"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
+ arg0, err = ec.unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSlice(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["input"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 int
+ if tmp, ok := rawArgs["id"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
+ arg0, err = ec.unmarshalNInt2int(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["id"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Subscription_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, tmp) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ min, err := ec.unmarshalNInt2int(ctx, 1)
+ if err != nil {
+ return nil, err
+ }
+ max, err := ec.unmarshalOInt2ᚖint(ctx, 255)
+ if err != nil {
+ return nil, err
+ }
+ message, err := ec.unmarshalOString2ᚖstring(ctx, "invalid length")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Length == nil {
+ return nil, errors.New("directive length is not implemented")
+ }
+ return ec.directives.Length(ctx, rawArgs, directive0, min, max, message)
+ }
+
+ tmp, err = directive1(ctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(string); ok {
+ arg0 = data
+ } else {
+ return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp))
+ }
+ }
+ args["arg"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Subscription_directiveNullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 *int
+ if tmp, ok := rawArgs["arg"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOInt2ᚖint(ctx, tmp) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ min, err := ec.unmarshalOInt2ᚖint(ctx, 0)
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Range == nil {
+ return nil, errors.New("directive range is not implemented")
+ }
+ return ec.directives.Range(ctx, rawArgs, directive0, min, nil)
+ }
+
+ tmp, err = directive1(ctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*int); ok {
+ arg0 = data
+ } else if tmp == nil {
+ arg0 = nil
+ } else {
+ return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp))
+ }
+ }
+ args["arg"] = arg0
+ var arg1 *int
+ if tmp, ok := rawArgs["arg2"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg2"))
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOInt2ᚖint(ctx, tmp) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ min, err := ec.unmarshalOInt2ᚖint(ctx, 0)
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Range == nil {
+ return nil, errors.New("directive range is not implemented")
+ }
+ return ec.directives.Range(ctx, rawArgs, directive0, min, nil)
+ }
+
+ tmp, err = directive1(ctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*int); ok {
+ arg1 = data
+ } else if tmp == nil {
+ arg1 = nil
+ } else {
+ return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp))
+ }
+ }
+ args["arg2"] = arg1
+ var arg2 *string
+ if tmp, ok := rawArgs["arg3"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg3"))
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, tmp) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.ToNull == nil {
+ return nil, errors.New("directive toNull is not implemented")
+ }
+ return ec.directives.ToNull(ctx, rawArgs, directive0)
+ }
+
+ tmp, err = directive1(ctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*string); ok {
+ arg2 = data
+ } else if tmp == nil {
+ arg2 = nil
+ } else {
+ return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp))
+ }
+ }
+ args["arg3"] = arg2
+ return args, nil
+}
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _Autobind_int(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Autobind",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Int, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Autobind_int32(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Autobind",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Int32, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int32)
+ fc.Result = res
+ return ec.marshalNInt2int32(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Autobind_int64(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Autobind",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Int64, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int64)
+ fc.Result = res
+ return ec.marshalNInt2int64(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Autobind_idStr(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Autobind",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IdStr, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Autobind_idInt(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Autobind",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IdInt, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNID2int(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "EmbeddedPointer",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "EmbeddedPointer",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Title, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ForcedResolver",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.ForcedResolver().Field(rctx, obj)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*Circle)
+ fc.Result = res
+ return ec.marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCircle(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "InnerObject",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "InvalidIdentifier",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "It",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ModelMethods",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.ModelMethods().ResolverField(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ModelMethods",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.NoContext(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ModelMethods",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.WithContext(ctx), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "OuterObject",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Inner, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*InnerObject)
+ fc.Result = res
+ return ec.marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerObject(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().InvalidIdentifier(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*invalid_packagename.InvalidIdentifier)
+ fc.Result = res
+ return ec.marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Collision(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*introspection1.It)
+ fc.Result = res
+ return ec.marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋintrospectionᚐIt(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_mapInput_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().MapInput(rctx, args["input"].(map[string]interface{}))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*bool)
+ fc.Result = res
+ return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_recursive_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Recursive(rctx, args["input"].(*RecursiveInputSlice))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*bool)
+ fc.Result = res
+ return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_nestedInputs_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().NestedInputs(rctx, args["input"].([][]*OuterInput))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*bool)
+ fc.Result = res
+ return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().NestedOutputs(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([][]*OuterObject)
+ fc.Result = res
+ return ec.marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().ModelMethods(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*ModelMethods)
+ fc.Result = res
+ return ec.marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐModelMethods(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_user_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().User(rctx, args["id"].(int))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*User)
+ fc.Result = res
+ return ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUser(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_nullableArg_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().NullableArg(rctx, args["arg"].(*int))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_inputSlice_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().InputSlice(rctx, args["arg"].([]string))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_inputNullableSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_inputNullableSlice_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().InputNullableSlice(rctx, args["arg"].([]string))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().ShapeUnion(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(ShapeUnion)
+ fc.Result = res
+ return ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShapeUnion(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Autobind(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*Autobind)
+ fc.Result = res
+ return ec.marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAutobind(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DeprecatedField(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_overlapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Overlapping(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*OverlappingFields)
+ fc.Result = res
+ return ec.marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOverlappingFields(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_defaultParameters(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_defaultParameters_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DefaultParameters(rctx, args["falsyBoolean"].(*bool), args["truthyBoolean"].(*bool))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*DefaultParametersMirror)
+ fc.Result = res
+ return ec.marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_directiveArg_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DirectiveArg(rctx, args["arg"].(string))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_directiveNullableArg_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DirectiveNullableArg(rctx, args["arg"].(*int), args["arg2"].(*int), args["arg3"].(*string))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_directiveInputNullable_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DirectiveInputNullable(rctx, args["arg"].(*InputDirectives))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_directiveInput_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DirectiveInput(rctx, args["arg"].(InputDirectives))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_directiveInputType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_directiveInputType_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DirectiveInputType(rctx, args["arg"].(InnerInput))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_directiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DirectiveObject(rctx)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ location, err := ec.unmarshalNString2string(ctx, "order1_1")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Order1 == nil {
+ return nil, errors.New("directive order1 is not implemented")
+ }
+ return ec.directives.Order1(ctx, nil, directive0, location)
+ }
+ directive2 := func(ctx context.Context) (interface{}, error) {
+ location, err := ec.unmarshalNString2string(ctx, "order1_2")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Order1 == nil {
+ return nil, errors.New("directive order1 is not implemented")
+ }
+ return ec.directives.Order1(ctx, nil, directive1, location)
+ }
+ directive3 := func(ctx context.Context) (interface{}, error) {
+ location, err := ec.unmarshalNString2string(ctx, "order2_1")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Order2 == nil {
+ return nil, errors.New("directive order2 is not implemented")
+ }
+ return ec.directives.Order2(ctx, nil, directive2, location)
+ }
+ directive4 := func(ctx context.Context) (interface{}, error) {
+ location, err := ec.unmarshalNString2string(ctx, "Query_field")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Order1 == nil {
+ return nil, errors.New("directive order1 is not implemented")
+ }
+ return ec.directives.Order1(ctx, nil, directive3, location)
+ }
+
+ tmp, err := directive4(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(*ObjectDirectives); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver/followschema.ObjectDirectives`, tmp)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*ObjectDirectives)
+ fc.Result = res
+ return ec.marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐObjectDirectives(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_directiveObjectWithCustomGoModel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DirectiveObjectWithCustomGoModel(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*ObjectDirectivesWithCustomGoModel)
+ fc.Result = res
+ return ec.marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐObjectDirectivesWithCustomGoModel(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_directiveFieldDef(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_directiveFieldDef_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DirectiveFieldDef(rctx, args["ret"].(string))
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ min, err := ec.unmarshalNInt2int(ctx, 1)
+ if err != nil {
+ return nil, err
+ }
+ message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Length == nil {
+ return nil, errors.New("directive length is not implemented")
+ }
+ return ec.directives.Length(ctx, nil, directive0, min, nil, message)
+ }
+
+ tmp, err := directive1(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(string); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_directiveField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DirectiveField(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DirectiveDouble(rctx)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive1 == nil {
+ return nil, errors.New("directive directive1 is not implemented")
+ }
+ return ec.directives.Directive1(ctx, nil, directive0)
+ }
+ directive2 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive2 == nil {
+ return nil, errors.New("directive directive2 is not implemented")
+ }
+ return ec.directives.Directive2(ctx, nil, directive1)
+ }
+
+ tmp, err := directive2(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(*string); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DirectiveUnimplemented(rctx)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Unimplemented == nil {
+ return nil, errors.New("directive unimplemented is not implemented")
+ }
+ return ec.directives.Unimplemented(ctx, nil, directive0)
+ }
+
+ tmp, err := directive1(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(*string); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_embeddedCase1(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().EmbeddedCase1(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*EmbeddedCase1)
+ fc.Result = res
+ return ec.marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase1(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_embeddedCase2(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().EmbeddedCase2(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*EmbeddedCase2)
+ fc.Result = res
+ return ec.marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase2(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_embeddedCase3(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().EmbeddedCase3(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*EmbeddedCase3)
+ fc.Result = res
+ return ec.marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase3(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_enumInInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_enumInInput_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().EnumInInput(rctx, args["input"].(*InputWithEnumValue))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(EnumTest)
+ fc.Result = res
+ return ec.marshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEnumTest(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Shapes(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]Shape)
+ fc.Result = res
+ return ec.marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_noShape(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().NoShape(rctx)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.MakeNil == nil {
+ return nil, errors.New("directive makeNil is not implemented")
+ }
+ return ec.directives.MakeNil(ctx, nil, directive0)
+ }
+
+ tmp, err := directive1(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(Shape); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver/followschema.Shape`, tmp)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(Shape)
+ fc.Result = res
+ return ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Node(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(Node)
+ fc.Result = res
+ return ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_noShapeTypedNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().NoShapeTypedNil(rctx)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.MakeTypedNil == nil {
+ return nil, errors.New("directive makeTypedNil is not implemented")
+ }
+ return ec.directives.MakeTypedNil(ctx, nil, directive0)
+ }
+
+ tmp, err := directive1(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(Shape); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver/followschema.Shape`, tmp)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(Shape)
+ fc.Result = res
+ return ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_animal(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Animal(rctx)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.MakeTypedNil == nil {
+ return nil, errors.New("directive makeTypedNil is not implemented")
+ }
+ return ec.directives.MakeTypedNil(ctx, nil, directive0)
+ }
+
+ tmp, err := directive1(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(Animal); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver/followschema.Animal`, tmp)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(Animal)
+ fc.Result = res
+ return ec.marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAnimal(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_notAnInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().NotAnInterface(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(BackedByInterface)
+ fc.Result = res
+ return ec.marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐBackedByInterface(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_issue896a(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Issue896a(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]*CheckIssue896)
+ fc.Result = res
+ return ec.marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896ᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_mapStringInterface_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().MapStringInterface(rctx, args["in"].(map[string]interface{}))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(map[string]interface{})
+ fc.Result = res
+ return ec.marshalOMapStringInterfaceType2map(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_mapNestedStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_mapNestedStringInterface_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().MapNestedStringInterface(rctx, args["in"].(*NestedMapInput))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(map[string]interface{})
+ fc.Result = res
+ return ec.marshalOMapStringInterfaceType2map(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().ErrorBubble(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*Error)
+ fc.Result = res
+ return ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_errorBubbleList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().ErrorBubbleList(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]*Error)
+ fc.Result = res
+ return ec.marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrorᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_errorList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().ErrorList(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]*Error)
+ fc.Result = res
+ return ec.marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Errors(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*Errors)
+ fc.Result = res
+ return ec.marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrors(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Valid(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Panics(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*Panics)
+ fc.Result = res
+ return ec.marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPanics(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_primitiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().PrimitiveObject(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]Primitive)
+ fc.Result = res
+ return ec.marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_primitiveStringObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().PrimitiveStringObject(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]PrimitiveString)
+ fc.Result = res
+ return ec.marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveStringᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_ptrToSliceContainer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().PtrToSliceContainer(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*PtrToSliceContainer)
+ fc.Result = res
+ return ec.marshalNPtrToSliceContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToSliceContainer(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_infinity(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Infinity(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(float64)
+ fc.Result = res
+ return ec.marshalNFloat2float64(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_stringFromContextInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().StringFromContextInterface(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*StringFromContextInterface)
+ fc.Result = res
+ return ec.marshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStringFromContextInterface(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_stringFromContextFunction(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().StringFromContextFunction(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNStringFromContextFunction2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_defaultScalar_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DefaultScalar(rctx, args["arg"].(string))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNDefaultScalarImplementation2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Slices(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*Slices)
+ fc.Result = res
+ return ec.marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSlices(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_scalarSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().ScalarSlice(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]byte)
+ fc.Result = res
+ return ec.marshalNBytes2ᚕbyte(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_fallback(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_fallback_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Fallback(rctx, args["arg"].(FallbackToStringEncoding))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(FallbackToStringEncoding)
+ fc.Result = res
+ return ec.marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFallbackToStringEncoding(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().OptionalUnion(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(TestUnion)
+ fc.Result = res
+ return ec.marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐTestUnion(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_vOkCaseValue(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().VOkCaseValue(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*VOkCaseValue)
+ fc.Result = res
+ return ec.marshalOVOkCaseValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVOkCaseValue(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_vOkCaseNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().VOkCaseNil(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*VOkCaseNil)
+ fc.Result = res
+ return ec.marshalOVOkCaseNil2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVOkCaseNil(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().ValidType(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*ValidType)
+ fc.Result = res
+ return ec.marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐValidType(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_wrappedStruct(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().WrappedStruct(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*WrappedStruct)
+ fc.Result = res
+ return ec.marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedStruct(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_wrappedScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().WrappedScalar(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(otherpkg.Scalar)
+ fc.Result = res
+ return ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_wrappedMap(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().WrappedMap(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(WrappedMap)
+ fc.Result = res
+ return ec.marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedMap(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_wrappedSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().WrappedSlice(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(WrappedSlice)
+ fc.Result = res
+ return ec.marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedSlice(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query___type_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.introspectType(args["name"].(string))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*introspection.Type)
+ fc.Result = res
+ return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.introspectSchema()
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*introspection.Schema)
+ fc.Result = res
+ return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Subscription",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Subscription().Updated(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return nil
+ }
+ return func() graphql.Marshaler {
+ res, ok := <-resTmp.(<-chan string)
+ if !ok {
+ return nil
+ }
+ return graphql.WriterFunc(func(w io.Writer) {
+ w.Write([]byte{'{'})
+ graphql.MarshalString(field.Alias).MarshalGQL(w)
+ w.Write([]byte{':'})
+ ec.marshalNString2string(ctx, field.Selections, res).MarshalGQL(w)
+ w.Write([]byte{'}'})
+ })
+ }
+}
+
+func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Subscription",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Subscription().InitPayload(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return nil
+ }
+ return func() graphql.Marshaler {
+ res, ok := <-resTmp.(<-chan string)
+ if !ok {
+ return nil
+ }
+ return graphql.WriterFunc(func(w io.Writer) {
+ w.Write([]byte{'{'})
+ graphql.MarshalString(field.Alias).MarshalGQL(w)
+ w.Write([]byte{':'})
+ ec.marshalNString2string(ctx, field.Selections, res).MarshalGQL(w)
+ w.Write([]byte{'}'})
+ })
+ }
+}
+
+func (ec *executionContext) _Subscription_directiveArg(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Subscription",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Subscription_directiveArg_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return nil
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Subscription().DirectiveArg(rctx, args["arg"].(string))
+ })
+
+ if resTmp == nil {
+ return nil
+ }
+ return func() graphql.Marshaler {
+ res, ok := <-resTmp.(<-chan *string)
+ if !ok {
+ return nil
+ }
+ return graphql.WriterFunc(func(w io.Writer) {
+ w.Write([]byte{'{'})
+ graphql.MarshalString(field.Alias).MarshalGQL(w)
+ w.Write([]byte{':'})
+ ec.marshalOString2ᚖstring(ctx, field.Selections, res).MarshalGQL(w)
+ w.Write([]byte{'}'})
+ })
+ }
+}
+
+func (ec *executionContext) _Subscription_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Subscription",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Subscription_directiveNullableArg_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return nil
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Subscription().DirectiveNullableArg(rctx, args["arg"].(*int), args["arg2"].(*int), args["arg3"].(*string))
+ })
+
+ if resTmp == nil {
+ return nil
+ }
+ return func() graphql.Marshaler {
+ res, ok := <-resTmp.(<-chan *string)
+ if !ok {
+ return nil
+ }
+ return graphql.WriterFunc(func(w io.Writer) {
+ w.Write([]byte{'{'})
+ graphql.MarshalString(field.Alias).MarshalGQL(w)
+ w.Write([]byte{':'})
+ ec.marshalOString2ᚖstring(ctx, field.Selections, res).MarshalGQL(w)
+ w.Write([]byte{'}'})
+ })
+ }
+}
+
+func (ec *executionContext) _Subscription_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Subscription",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Subscription().DirectiveDouble(rctx)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive1 == nil {
+ return nil, errors.New("directive directive1 is not implemented")
+ }
+ return ec.directives.Directive1(ctx, nil, directive0)
+ }
+ directive2 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive2 == nil {
+ return nil, errors.New("directive directive2 is not implemented")
+ }
+ return ec.directives.Directive2(ctx, nil, directive1)
+ }
+
+ tmp, err := directive2(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(<-chan *string); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be <-chan *string`, tmp)
+ })
+
+ if resTmp == nil {
+ return nil
+ }
+ return func() graphql.Marshaler {
+ res, ok := <-resTmp.(<-chan *string)
+ if !ok {
+ return nil
+ }
+ return graphql.WriterFunc(func(w io.Writer) {
+ w.Write([]byte{'{'})
+ graphql.MarshalString(field.Alias).MarshalGQL(w)
+ w.Write([]byte{':'})
+ ec.marshalOString2ᚖstring(ctx, field.Selections, res).MarshalGQL(w)
+ w.Write([]byte{'}'})
+ })
+ }
+}
+
+func (ec *executionContext) _Subscription_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Subscription",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ directive0 := func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Subscription().DirectiveUnimplemented(rctx)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Unimplemented == nil {
+ return nil, errors.New("directive unimplemented is not implemented")
+ }
+ return ec.directives.Unimplemented(ctx, nil, directive0)
+ }
+
+ tmp, err := directive1(rctx)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ if tmp == nil {
+ return nil, nil
+ }
+ if data, ok := tmp.(<-chan *string); ok {
+ return data, nil
+ }
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be <-chan *string`, tmp)
+ })
+
+ if resTmp == nil {
+ return nil
+ }
+ return func() graphql.Marshaler {
+ res, ok := <-resTmp.(<-chan *string)
+ if !ok {
+ return nil
+ }
+ return graphql.WriterFunc(func(w io.Writer) {
+ w.Write([]byte{'{'})
+ graphql.MarshalString(field.Alias).MarshalGQL(w)
+ w.Write([]byte{':'})
+ ec.marshalOString2ᚖstring(ctx, field.Selections, res).MarshalGQL(w)
+ w.Write([]byte{'}'})
+ })
+ }
+}
+
+func (ec *executionContext) _Subscription_issue896b(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Subscription",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Subscription().Issue896b(rctx)
+ })
+
+ if resTmp == nil {
+ return nil
+ }
+ return func() graphql.Marshaler {
+ res, ok := <-resTmp.(<-chan []*CheckIssue896)
+ if !ok {
+ return nil
+ }
+ return graphql.WriterFunc(func(w io.Writer) {
+ w.Write([]byte{'{'})
+ graphql.MarshalString(field.Alias).MarshalGQL(w)
+ w.Write([]byte{':'})
+ ec.marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx, field.Selections, res).MarshalGQL(w)
+ w.Write([]byte{'}'})
+ })
+ }
+}
+
+func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "User",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(int)
+ fc.Result = res
+ return ec.marshalNInt2int(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "User",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.User().Friends(rctx, obj)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]*User)
+ fc.Result = res
+ return ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUserᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "User",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Created, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(time.Time)
+ fc.Result = res
+ return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _User_updated(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "User",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Updated, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*time.Time)
+ fc.Result = res
+ return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+func (ec *executionContext) unmarshalInputInnerInput(ctx context.Context, obj interface{}) (InnerInput, error) {
+ var it InnerInput
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "id":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
+ it.ID, err = ec.unmarshalNInt2int(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, obj interface{}) (OuterInput, error) {
+ var it OuterInput
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "inner":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner"))
+ it.Inner, err = ec.unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerInput(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Context, obj interface{}) (RecursiveInputSlice, error) {
+ var it RecursiveInputSlice
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "self":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("self"))
+ it.Self, err = ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSliceᚄ(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var autobindImplementors = []string{"Autobind"}
+
+func (ec *executionContext) _Autobind(ctx context.Context, sel ast.SelectionSet, obj *Autobind) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, autobindImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Autobind")
+ case "int":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Autobind_int(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "int32":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Autobind_int32(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "int64":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Autobind_int64(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "idStr":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Autobind_idStr(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "idInt":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Autobind_idInt(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var embeddedPointerImplementors = []string{"EmbeddedPointer"}
+
+func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedPointerModel) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, embeddedPointerImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("EmbeddedPointer")
+ case "ID":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedPointer_ID(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "Title":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedPointer_Title(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var forcedResolverImplementors = []string{"ForcedResolver"}
+
+func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.SelectionSet, obj *ForcedResolver) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, forcedResolverImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("ForcedResolver")
+ case "field":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._ForcedResolver_field(ctx, field, obj)
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var innerObjectImplementors = []string{"InnerObject"}
+
+func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionSet, obj *InnerObject) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, innerObjectImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("InnerObject")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._InnerObject_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var invalidIdentifierImplementors = []string{"InvalidIdentifier"}
+
+func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.SelectionSet, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, invalidIdentifierImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("InvalidIdentifier")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._InvalidIdentifier_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var itImplementors = []string{"It"}
+
+func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection1.It) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, itImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("It")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._It_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var modelMethodsImplementors = []string{"ModelMethods"}
+
+func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.SelectionSet, obj *ModelMethods) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, modelMethodsImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("ModelMethods")
+ case "resolverField":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._ModelMethods_resolverField(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "noContext":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ModelMethods_noContext(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ case "withContext":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._ModelMethods_withContext(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var outerObjectImplementors = []string{"OuterObject"}
+
+func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionSet, obj *OuterObject) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, outerObjectImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("OuterObject")
+ case "inner":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._OuterObject_inner(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var queryImplementors = []string{"Query"}
+
+func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
+ ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
+ Object: "Query",
+ })
+
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Query")
+ case "invalidIdentifier":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_invalidIdentifier(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "collision":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_collision(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "mapInput":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_mapInput(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "recursive":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_recursive(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "nestedInputs":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_nestedInputs(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "nestedOutputs":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_nestedOutputs(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "modelMethods":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_modelMethods(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "user":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_user(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "nullableArg":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_nullableArg(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "inputSlice":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_inputSlice(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "inputNullableSlice":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_inputNullableSlice(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "shapeUnion":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_shapeUnion(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "autobind":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_autobind(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "deprecatedField":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_deprecatedField(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "overlapping":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_overlapping(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "defaultParameters":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_defaultParameters(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "directiveArg":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_directiveArg(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "directiveNullableArg":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_directiveNullableArg(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "directiveInputNullable":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_directiveInputNullable(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "directiveInput":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_directiveInput(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "directiveInputType":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_directiveInputType(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "directiveObject":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_directiveObject(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "directiveObjectWithCustomGoModel":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_directiveObjectWithCustomGoModel(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "directiveFieldDef":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_directiveFieldDef(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "directiveField":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_directiveField(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "directiveDouble":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_directiveDouble(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "directiveUnimplemented":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_directiveUnimplemented(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "embeddedCase1":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_embeddedCase1(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "embeddedCase2":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_embeddedCase2(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "embeddedCase3":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_embeddedCase3(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "enumInInput":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_enumInInput(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "shapes":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_shapes(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "noShape":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_noShape(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "node":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_node(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "noShapeTypedNil":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_noShapeTypedNil(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "animal":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_animal(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "notAnInterface":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_notAnInterface(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "issue896a":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_issue896a(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "mapStringInterface":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_mapStringInterface(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "mapNestedStringInterface":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_mapNestedStringInterface(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "errorBubble":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_errorBubble(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "errorBubbleList":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_errorBubbleList(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "errorList":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_errorList(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "errors":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_errors(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "valid":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_valid(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "panics":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_panics(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "primitiveObject":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_primitiveObject(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "primitiveStringObject":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_primitiveStringObject(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "ptrToSliceContainer":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_ptrToSliceContainer(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "infinity":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_infinity(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "stringFromContextInterface":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_stringFromContextInterface(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "stringFromContextFunction":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_stringFromContextFunction(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "defaultScalar":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_defaultScalar(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "slices":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_slices(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "scalarSlice":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_scalarSlice(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "fallback":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_fallback(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "optionalUnion":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_optionalUnion(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "vOkCaseValue":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_vOkCaseValue(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "vOkCaseNil":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_vOkCaseNil(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "validType":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_validType(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "wrappedStruct":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_wrappedStruct(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "wrappedScalar":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_wrappedScalar(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "wrappedMap":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_wrappedMap(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "wrappedSlice":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_wrappedSlice(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "__type":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
+ case "__schema":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var subscriptionImplementors = []string{"Subscription"}
+
+func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, subscriptionImplementors)
+ ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
+ Object: "Subscription",
+ })
+ if len(fields) != 1 {
+ ec.Errorf(ctx, "must subscribe to exactly one stream")
+ return nil
+ }
+
+ switch fields[0].Name {
+ case "updated":
+ return ec._Subscription_updated(ctx, fields[0])
+ case "initPayload":
+ return ec._Subscription_initPayload(ctx, fields[0])
+ case "directiveArg":
+ return ec._Subscription_directiveArg(ctx, fields[0])
+ case "directiveNullableArg":
+ return ec._Subscription_directiveNullableArg(ctx, fields[0])
+ case "directiveDouble":
+ return ec._Subscription_directiveDouble(ctx, fields[0])
+ case "directiveUnimplemented":
+ return ec._Subscription_directiveUnimplemented(ctx, fields[0])
+ case "issue896b":
+ return ec._Subscription_issue896b(ctx, fields[0])
+ default:
+ panic("unknown field " + strconv.Quote(fields[0].Name))
+ }
+}
+
+var userImplementors = []string{"User"}
+
+func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("User")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ case "friends":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._User_friends(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ case "created":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_created(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ case "updated":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_updated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerInput(ctx context.Context, v interface{}) (InnerInput, error) {
+ res, err := ec.unmarshalInputInnerInput(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerInput(ctx context.Context, v interface{}) (*InnerInput, error) {
+ res, err := ec.unmarshalInputInnerInput(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v *InnerObject) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._InnerObject(ctx, sel, v)
+}
+
+func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) {
+ res, err := ec.unmarshalInputRecursiveInputSlice(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) {
+ res, err := graphql.UnmarshalTime(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler {
+ res := graphql.MarshalTime(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) unmarshalNUUID2string(ctx context.Context, v interface{}) (string, error) {
+ res, err := graphql.UnmarshalString(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNUUID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
+ res := graphql.MarshalString(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler {
+ return ec._User(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUserᚄ(ctx context.Context, sel ast.SelectionSet, v []*User) graphql.Marshaler {
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUser(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._User(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAutobind(ctx context.Context, sel ast.SelectionSet, v *Autobind) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._Autobind(ctx, sel, v)
+}
+
+func (ec *executionContext) unmarshalOChanges2map(ctx context.Context, v interface{}) (map[string]interface{}, error) {
+ if v == nil {
+ return nil, nil
+ }
+ return v.(map[string]interface{}), nil
+}
+
+func (ec *executionContext) marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._InvalidIdentifier(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v *introspection1.It) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._It(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v *ModelMethods) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._ModelMethods(ctx, sel, v)
+}
+
+func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx context.Context, v interface{}) ([][]*OuterInput, error) {
+ if v == nil {
+ return nil, nil
+ }
+ var vSlice []interface{}
+ if v != nil {
+ if tmp1, ok := v.([]interface{}); ok {
+ vSlice = tmp1
+ } else {
+ vSlice = []interface{}{v}
+ }
+ }
+ var err error
+ res := make([][]*OuterInput, len(vSlice))
+ for i := range vSlice {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
+ res[i], err = ec.unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx, vSlice[i])
+ if err != nil {
+ return nil, err
+ }
+ }
+ return res, nil
+}
+
+func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx context.Context, v interface{}) ([]*OuterInput, error) {
+ if v == nil {
+ return nil, nil
+ }
+ var vSlice []interface{}
+ if v != nil {
+ if tmp1, ok := v.([]interface{}); ok {
+ vSlice = tmp1
+ } else {
+ vSlice = []interface{}{v}
+ }
+ }
+ var err error
+ res := make([]*OuterInput, len(vSlice))
+ for i := range vSlice {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
+ res[i], err = ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx, vSlice[i])
+ if err != nil {
+ return nil, err
+ }
+ }
+ return res, nil
+}
+
+func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx context.Context, v interface{}) (*OuterInput, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalInputOuterInput(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ return ret
+}
+
+func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v []*OuterObject) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ return ret
+}
+
+func (ec *executionContext) marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v *OuterObject) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._OuterObject(ctx, sel, v)
+}
+
+func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSliceᚄ(ctx context.Context, v interface{}) ([]RecursiveInputSlice, error) {
+ if v == nil {
+ return nil, nil
+ }
+ var vSlice []interface{}
+ if v != nil {
+ if tmp1, ok := v.([]interface{}); ok {
+ vSlice = tmp1
+ } else {
+ vSlice = []interface{}{v}
+ }
+ }
+ var err error
+ res := make([]RecursiveInputSlice, len(vSlice))
+ for i := range vSlice {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
+ res[i], err = ec.unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSlice(ctx, vSlice[i])
+ if err != nil {
+ return nil, err
+ }
+ }
+ return res, nil
+}
+
+func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSlice(ctx context.Context, v interface{}) (*RecursiveInputSlice, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalInputRecursiveInputSlice(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐThirdParty(ctx context.Context, v interface{}) (*ThirdParty, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := UnmarshalThirdParty(v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐThirdParty(ctx context.Context, sel ast.SelectionSet, v *ThirdParty) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ res := MarshalThirdParty(*v)
+ return res
+}
+
+func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := graphql.UnmarshalTime(v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ res := graphql.MarshalTime(*v)
+ return res
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/followschema/schema.graphql b/codegen/testserver/followschema/schema.graphql
new file mode 100644
index 00000000000..ceef6891ca8
--- /dev/null
+++ b/codegen/testserver/followschema/schema.graphql
@@ -0,0 +1,105 @@
+directive @goModel(
+ model: String
+ models: [String!]
+) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION
+directive @goField(
+ forceResolver: Boolean
+ name: String
+) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
+
+type Query {
+ invalidIdentifier: InvalidIdentifier
+ collision: It
+ mapInput(input: Changes): Boolean
+ recursive(input: RecursiveInputSlice): Boolean
+ nestedInputs(input: [[OuterInput]] = [[{ inner: { id: 1 } }]]): Boolean
+ nestedOutputs: [[OuterObject]]
+ modelMethods: ModelMethods
+ user(id: Int!): User!
+ nullableArg(arg: Int = 123): String
+ inputSlice(arg: [String!]!): Boolean!
+ inputNullableSlice(arg: [String!]): Boolean!
+ shapeUnion: ShapeUnion!
+ autobind: Autobind
+ deprecatedField: String! @deprecated(reason: "test deprecated directive")
+}
+
+type Subscription {
+ updated: String!
+ initPayload: String!
+}
+
+type User {
+ id: Int!
+ friends: [User!]! @goField(forceResolver: true)
+ created: Time!
+ updated: Time
+}
+
+type Autobind {
+ int: Int!
+ int32: Int!
+ int64: Int!
+
+ idStr: ID!
+ idInt: ID!
+}
+
+type ModelMethods {
+ resolverField: Boolean!
+ noContext: Boolean!
+ withContext: Boolean!
+}
+
+type InvalidIdentifier {
+ id: Int!
+}
+
+type It {
+ id: ID!
+}
+
+input Changes @goModel(model: "map[string]interface{}") {
+ a: Int
+ b: Int
+}
+
+input RecursiveInputSlice {
+ self: [RecursiveInputSlice!]
+}
+
+input InnerInput {
+ id: Int!
+}
+
+input OuterInput {
+ inner: InnerInput!
+}
+
+scalar ThirdParty @goModel(model:"followschema.ThirdParty")
+
+type OuterObject {
+ inner: InnerObject!
+}
+
+type InnerObject {
+ id: Int!
+}
+
+type ForcedResolver {
+ field: Circle @goField(forceResolver: true)
+}
+
+type EmbeddedPointer @goModel(model:"followschema.EmbeddedPointerModel") {
+ ID: String
+ Title: String
+}
+
+scalar UUID
+
+enum Status {
+ OK
+ ERROR
+}
+
+scalar Time
diff --git a/codegen/testserver/followschema/slices.generated.go b/codegen/testserver/followschema/slices.generated.go
new file mode 100644
index 00000000000..5a37fee0baa
--- /dev/null
+++ b/codegen/testserver/followschema/slices.generated.go
@@ -0,0 +1,248 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Slices",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Test1, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]*string)
+ fc.Result = res
+ return ec.marshalOString2ᚕᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Slices",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Test2, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]string)
+ fc.Result = res
+ return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Slices",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Test3, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]*string)
+ fc.Result = res
+ return ec.marshalNString2ᚕᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Slices_test4(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Slices",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Test4, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]string)
+ fc.Result = res
+ return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var slicesImplementors = []string{"Slices"}
+
+func (ec *executionContext) _Slices(ctx context.Context, sel ast.SelectionSet, obj *Slices) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, slicesImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Slices")
+ case "test1":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Slices_test1(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "test2":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Slices_test2(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "test3":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Slices_test3(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "test4":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Slices_test4(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalNBytes2ᚕbyte(ctx context.Context, v interface{}) ([]byte, error) {
+ res, err := UnmarshalBytes(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNBytes2ᚕbyte(ctx context.Context, sel ast.SelectionSet, v []byte) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := MarshalBytes(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSlices(ctx context.Context, sel ast.SelectionSet, v *Slices) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._Slices(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/slices.graphql b/codegen/testserver/followschema/slices.graphql
similarity index 53%
rename from codegen/testserver/slices.graphql
rename to codegen/testserver/followschema/slices.graphql
index 671235d0b37..b1265c56c0b 100644
--- a/codegen/testserver/slices.graphql
+++ b/codegen/testserver/followschema/slices.graphql
@@ -4,10 +4,10 @@ extend type Query {
}
type Slices {
- test1: [String]
- test2: [String!]
- test3: [String]!
- test4: [String!]!
+ test1: [String]
+ test2: [String!]
+ test3: [String]!
+ test4: [String!]!
}
scalar Bytes
diff --git a/codegen/testserver/followschema/slices_test.go b/codegen/testserver/followschema/slices_test.go
new file mode 100644
index 00000000000..19df15816ba
--- /dev/null
+++ b/codegen/testserver/followschema/slices_test.go
@@ -0,0 +1,43 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestSlices(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ t.Run("nulls vs empty slices", func(t *testing.T) {
+ resolvers.QueryResolver.Slices = func(ctx context.Context) (slices *Slices, e error) {
+ return &Slices{}, nil
+ }
+
+ var resp struct {
+ Slices Slices
+ }
+ c.MustPost(`query { slices { test1, test2, test3, test4 }}`, &resp)
+ require.Nil(t, resp.Slices.Test1)
+ require.Nil(t, resp.Slices.Test2)
+ require.NotNil(t, resp.Slices.Test3)
+ require.NotNil(t, resp.Slices.Test4)
+ })
+
+ t.Run("custom scalars to slices work", func(t *testing.T) {
+ resolvers.QueryResolver.ScalarSlice = func(ctx context.Context) ([]byte, error) {
+ return []byte("testing"), nil
+ }
+
+ var resp struct {
+ ScalarSlice string
+ }
+ c.MustPost(`query { scalarSlice }`, &resp)
+ require.Equal(t, "testing", resp.ScalarSlice)
+ })
+}
diff --git a/codegen/testserver/followschema/stub.go b/codegen/testserver/followschema/stub.go
new file mode 100644
index 00000000000..41d639d0e2d
--- /dev/null
+++ b/codegen/testserver/followschema/stub.go
@@ -0,0 +1,491 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+
+ introspection1 "github.com/99designs/gqlgen/codegen/testserver/followschema/introspection"
+ invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/followschema/invalid-packagename"
+ "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg"
+)
+
+type Stub struct {
+ BackedByInterfaceResolver struct {
+ ID func(ctx context.Context, obj BackedByInterface) (string, error)
+ }
+ ErrorsResolver struct {
+ A func(ctx context.Context, obj *Errors) (*Error, error)
+ B func(ctx context.Context, obj *Errors) (*Error, error)
+ C func(ctx context.Context, obj *Errors) (*Error, error)
+ D func(ctx context.Context, obj *Errors) (*Error, error)
+ E func(ctx context.Context, obj *Errors) (*Error, error)
+ }
+ ForcedResolverResolver struct {
+ Field func(ctx context.Context, obj *ForcedResolver) (*Circle, error)
+ }
+ ModelMethodsResolver struct {
+ ResolverField func(ctx context.Context, obj *ModelMethods) (bool, error)
+ }
+ MutationResolver struct {
+ DefaultInput func(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error)
+ UpdateSomething func(ctx context.Context, input SpecialInput) (string, error)
+ UpdatePtrToPtr func(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error)
+ }
+ OverlappingFieldsResolver struct {
+ OldFoo func(ctx context.Context, obj *OverlappingFields) (int, error)
+ }
+ PanicsResolver struct {
+ FieldScalarMarshal func(ctx context.Context, obj *Panics) ([]MarshalPanic, error)
+ ArgUnmarshal func(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error)
+ }
+ PrimitiveResolver struct {
+ Value func(ctx context.Context, obj *Primitive) (int, error)
+ }
+ PrimitiveStringResolver struct {
+ Value func(ctx context.Context, obj *PrimitiveString) (string, error)
+ Len func(ctx context.Context, obj *PrimitiveString) (int, error)
+ }
+ QueryResolver struct {
+ InvalidIdentifier func(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error)
+ Collision func(ctx context.Context) (*introspection1.It, error)
+ MapInput func(ctx context.Context, input map[string]interface{}) (*bool, error)
+ Recursive func(ctx context.Context, input *RecursiveInputSlice) (*bool, error)
+ NestedInputs func(ctx context.Context, input [][]*OuterInput) (*bool, error)
+ NestedOutputs func(ctx context.Context) ([][]*OuterObject, error)
+ ModelMethods func(ctx context.Context) (*ModelMethods, error)
+ User func(ctx context.Context, id int) (*User, error)
+ NullableArg func(ctx context.Context, arg *int) (*string, error)
+ InputSlice func(ctx context.Context, arg []string) (bool, error)
+ InputNullableSlice func(ctx context.Context, arg []string) (bool, error)
+ ShapeUnion func(ctx context.Context) (ShapeUnion, error)
+ Autobind func(ctx context.Context) (*Autobind, error)
+ DeprecatedField func(ctx context.Context) (string, error)
+ Overlapping func(ctx context.Context) (*OverlappingFields, error)
+ DefaultParameters func(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error)
+ DirectiveArg func(ctx context.Context, arg string) (*string, error)
+ DirectiveNullableArg func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error)
+ DirectiveInputNullable func(ctx context.Context, arg *InputDirectives) (*string, error)
+ DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error)
+ DirectiveInputType func(ctx context.Context, arg InnerInput) (*string, error)
+ DirectiveObject func(ctx context.Context) (*ObjectDirectives, error)
+ DirectiveObjectWithCustomGoModel func(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error)
+ DirectiveFieldDef func(ctx context.Context, ret string) (string, error)
+ DirectiveField func(ctx context.Context) (*string, error)
+ DirectiveDouble func(ctx context.Context) (*string, error)
+ DirectiveUnimplemented func(ctx context.Context) (*string, error)
+ EmbeddedCase1 func(ctx context.Context) (*EmbeddedCase1, error)
+ EmbeddedCase2 func(ctx context.Context) (*EmbeddedCase2, error)
+ EmbeddedCase3 func(ctx context.Context) (*EmbeddedCase3, error)
+ EnumInInput func(ctx context.Context, input *InputWithEnumValue) (EnumTest, error)
+ Shapes func(ctx context.Context) ([]Shape, error)
+ NoShape func(ctx context.Context) (Shape, error)
+ Node func(ctx context.Context) (Node, error)
+ NoShapeTypedNil func(ctx context.Context) (Shape, error)
+ Animal func(ctx context.Context) (Animal, error)
+ NotAnInterface func(ctx context.Context) (BackedByInterface, error)
+ Issue896a func(ctx context.Context) ([]*CheckIssue896, error)
+ MapStringInterface func(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error)
+ MapNestedStringInterface func(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error)
+ ErrorBubble func(ctx context.Context) (*Error, error)
+ ErrorBubbleList func(ctx context.Context) ([]*Error, error)
+ ErrorList func(ctx context.Context) ([]*Error, error)
+ Errors func(ctx context.Context) (*Errors, error)
+ Valid func(ctx context.Context) (string, error)
+ Panics func(ctx context.Context) (*Panics, error)
+ PrimitiveObject func(ctx context.Context) ([]Primitive, error)
+ PrimitiveStringObject func(ctx context.Context) ([]PrimitiveString, error)
+ PtrToSliceContainer func(ctx context.Context) (*PtrToSliceContainer, error)
+ Infinity func(ctx context.Context) (float64, error)
+ StringFromContextInterface func(ctx context.Context) (*StringFromContextInterface, error)
+ StringFromContextFunction func(ctx context.Context) (string, error)
+ DefaultScalar func(ctx context.Context, arg string) (string, error)
+ Slices func(ctx context.Context) (*Slices, error)
+ ScalarSlice func(ctx context.Context) ([]byte, error)
+ Fallback func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error)
+ OptionalUnion func(ctx context.Context) (TestUnion, error)
+ VOkCaseValue func(ctx context.Context) (*VOkCaseValue, error)
+ VOkCaseNil func(ctx context.Context) (*VOkCaseNil, error)
+ ValidType func(ctx context.Context) (*ValidType, error)
+ WrappedStruct func(ctx context.Context) (*WrappedStruct, error)
+ WrappedScalar func(ctx context.Context) (otherpkg.Scalar, error)
+ WrappedMap func(ctx context.Context) (WrappedMap, error)
+ WrappedSlice func(ctx context.Context) (WrappedSlice, error)
+ }
+ SubscriptionResolver struct {
+ Updated func(ctx context.Context) (<-chan string, error)
+ InitPayload func(ctx context.Context) (<-chan string, error)
+ DirectiveArg func(ctx context.Context, arg string) (<-chan *string, error)
+ DirectiveNullableArg func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error)
+ DirectiveDouble func(ctx context.Context) (<-chan *string, error)
+ DirectiveUnimplemented func(ctx context.Context) (<-chan *string, error)
+ Issue896b func(ctx context.Context) (<-chan []*CheckIssue896, error)
+ }
+ UserResolver struct {
+ Friends func(ctx context.Context, obj *User) ([]*User, error)
+ }
+ WrappedMapResolver struct {
+ Get func(ctx context.Context, obj WrappedMap, key string) (string, error)
+ }
+ WrappedSliceResolver struct {
+ Get func(ctx context.Context, obj WrappedSlice, idx int) (string, error)
+ }
+}
+
+func (r *Stub) BackedByInterface() BackedByInterfaceResolver {
+ return &stubBackedByInterface{r}
+}
+func (r *Stub) Errors() ErrorsResolver {
+ return &stubErrors{r}
+}
+func (r *Stub) ForcedResolver() ForcedResolverResolver {
+ return &stubForcedResolver{r}
+}
+func (r *Stub) ModelMethods() ModelMethodsResolver {
+ return &stubModelMethods{r}
+}
+func (r *Stub) Mutation() MutationResolver {
+ return &stubMutation{r}
+}
+func (r *Stub) OverlappingFields() OverlappingFieldsResolver {
+ return &stubOverlappingFields{r}
+}
+func (r *Stub) Panics() PanicsResolver {
+ return &stubPanics{r}
+}
+func (r *Stub) Primitive() PrimitiveResolver {
+ return &stubPrimitive{r}
+}
+func (r *Stub) PrimitiveString() PrimitiveStringResolver {
+ return &stubPrimitiveString{r}
+}
+func (r *Stub) Query() QueryResolver {
+ return &stubQuery{r}
+}
+func (r *Stub) Subscription() SubscriptionResolver {
+ return &stubSubscription{r}
+}
+func (r *Stub) User() UserResolver {
+ return &stubUser{r}
+}
+func (r *Stub) WrappedMap() WrappedMapResolver {
+ return &stubWrappedMap{r}
+}
+func (r *Stub) WrappedSlice() WrappedSliceResolver {
+ return &stubWrappedSlice{r}
+}
+
+type stubBackedByInterface struct{ *Stub }
+
+func (r *stubBackedByInterface) ID(ctx context.Context, obj BackedByInterface) (string, error) {
+ return r.BackedByInterfaceResolver.ID(ctx, obj)
+}
+
+type stubErrors struct{ *Stub }
+
+func (r *stubErrors) A(ctx context.Context, obj *Errors) (*Error, error) {
+ return r.ErrorsResolver.A(ctx, obj)
+}
+func (r *stubErrors) B(ctx context.Context, obj *Errors) (*Error, error) {
+ return r.ErrorsResolver.B(ctx, obj)
+}
+func (r *stubErrors) C(ctx context.Context, obj *Errors) (*Error, error) {
+ return r.ErrorsResolver.C(ctx, obj)
+}
+func (r *stubErrors) D(ctx context.Context, obj *Errors) (*Error, error) {
+ return r.ErrorsResolver.D(ctx, obj)
+}
+func (r *stubErrors) E(ctx context.Context, obj *Errors) (*Error, error) {
+ return r.ErrorsResolver.E(ctx, obj)
+}
+
+type stubForcedResolver struct{ *Stub }
+
+func (r *stubForcedResolver) Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) {
+ return r.ForcedResolverResolver.Field(ctx, obj)
+}
+
+type stubModelMethods struct{ *Stub }
+
+func (r *stubModelMethods) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) {
+ return r.ModelMethodsResolver.ResolverField(ctx, obj)
+}
+
+type stubMutation struct{ *Stub }
+
+func (r *stubMutation) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) {
+ return r.MutationResolver.DefaultInput(ctx, input)
+}
+func (r *stubMutation) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) {
+ return r.MutationResolver.UpdateSomething(ctx, input)
+}
+func (r *stubMutation) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) {
+ return r.MutationResolver.UpdatePtrToPtr(ctx, input)
+}
+
+type stubOverlappingFields struct{ *Stub }
+
+func (r *stubOverlappingFields) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) {
+ return r.OverlappingFieldsResolver.OldFoo(ctx, obj)
+}
+
+type stubPanics struct{ *Stub }
+
+func (r *stubPanics) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) {
+ return r.PanicsResolver.FieldScalarMarshal(ctx, obj)
+}
+func (r *stubPanics) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) {
+ return r.PanicsResolver.ArgUnmarshal(ctx, obj, u)
+}
+
+type stubPrimitive struct{ *Stub }
+
+func (r *stubPrimitive) Value(ctx context.Context, obj *Primitive) (int, error) {
+ return r.PrimitiveResolver.Value(ctx, obj)
+}
+
+type stubPrimitiveString struct{ *Stub }
+
+func (r *stubPrimitiveString) Value(ctx context.Context, obj *PrimitiveString) (string, error) {
+ return r.PrimitiveStringResolver.Value(ctx, obj)
+}
+func (r *stubPrimitiveString) Len(ctx context.Context, obj *PrimitiveString) (int, error) {
+ return r.PrimitiveStringResolver.Len(ctx, obj)
+}
+
+type stubQuery struct{ *Stub }
+
+func (r *stubQuery) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) {
+ return r.QueryResolver.InvalidIdentifier(ctx)
+}
+func (r *stubQuery) Collision(ctx context.Context) (*introspection1.It, error) {
+ return r.QueryResolver.Collision(ctx)
+}
+func (r *stubQuery) MapInput(ctx context.Context, input map[string]interface{}) (*bool, error) {
+ return r.QueryResolver.MapInput(ctx, input)
+}
+func (r *stubQuery) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) {
+ return r.QueryResolver.Recursive(ctx, input)
+}
+func (r *stubQuery) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) {
+ return r.QueryResolver.NestedInputs(ctx, input)
+}
+func (r *stubQuery) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) {
+ return r.QueryResolver.NestedOutputs(ctx)
+}
+func (r *stubQuery) ModelMethods(ctx context.Context) (*ModelMethods, error) {
+ return r.QueryResolver.ModelMethods(ctx)
+}
+func (r *stubQuery) User(ctx context.Context, id int) (*User, error) {
+ return r.QueryResolver.User(ctx, id)
+}
+func (r *stubQuery) NullableArg(ctx context.Context, arg *int) (*string, error) {
+ return r.QueryResolver.NullableArg(ctx, arg)
+}
+func (r *stubQuery) InputSlice(ctx context.Context, arg []string) (bool, error) {
+ return r.QueryResolver.InputSlice(ctx, arg)
+}
+func (r *stubQuery) InputNullableSlice(ctx context.Context, arg []string) (bool, error) {
+ return r.QueryResolver.InputNullableSlice(ctx, arg)
+}
+func (r *stubQuery) ShapeUnion(ctx context.Context) (ShapeUnion, error) {
+ return r.QueryResolver.ShapeUnion(ctx)
+}
+func (r *stubQuery) Autobind(ctx context.Context) (*Autobind, error) {
+ return r.QueryResolver.Autobind(ctx)
+}
+func (r *stubQuery) DeprecatedField(ctx context.Context) (string, error) {
+ return r.QueryResolver.DeprecatedField(ctx)
+}
+func (r *stubQuery) Overlapping(ctx context.Context) (*OverlappingFields, error) {
+ return r.QueryResolver.Overlapping(ctx)
+}
+func (r *stubQuery) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) {
+ return r.QueryResolver.DefaultParameters(ctx, falsyBoolean, truthyBoolean)
+}
+func (r *stubQuery) DirectiveArg(ctx context.Context, arg string) (*string, error) {
+ return r.QueryResolver.DirectiveArg(ctx, arg)
+}
+func (r *stubQuery) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) {
+ return r.QueryResolver.DirectiveNullableArg(ctx, arg, arg2, arg3)
+}
+func (r *stubQuery) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) {
+ return r.QueryResolver.DirectiveInputNullable(ctx, arg)
+}
+func (r *stubQuery) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) {
+ return r.QueryResolver.DirectiveInput(ctx, arg)
+}
+func (r *stubQuery) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) {
+ return r.QueryResolver.DirectiveInputType(ctx, arg)
+}
+func (r *stubQuery) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) {
+ return r.QueryResolver.DirectiveObject(ctx)
+}
+func (r *stubQuery) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) {
+ return r.QueryResolver.DirectiveObjectWithCustomGoModel(ctx)
+}
+func (r *stubQuery) DirectiveFieldDef(ctx context.Context, ret string) (string, error) {
+ return r.QueryResolver.DirectiveFieldDef(ctx, ret)
+}
+func (r *stubQuery) DirectiveField(ctx context.Context) (*string, error) {
+ return r.QueryResolver.DirectiveField(ctx)
+}
+func (r *stubQuery) DirectiveDouble(ctx context.Context) (*string, error) {
+ return r.QueryResolver.DirectiveDouble(ctx)
+}
+func (r *stubQuery) DirectiveUnimplemented(ctx context.Context) (*string, error) {
+ return r.QueryResolver.DirectiveUnimplemented(ctx)
+}
+func (r *stubQuery) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) {
+ return r.QueryResolver.EmbeddedCase1(ctx)
+}
+func (r *stubQuery) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) {
+ return r.QueryResolver.EmbeddedCase2(ctx)
+}
+func (r *stubQuery) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) {
+ return r.QueryResolver.EmbeddedCase3(ctx)
+}
+func (r *stubQuery) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) {
+ return r.QueryResolver.EnumInInput(ctx, input)
+}
+func (r *stubQuery) Shapes(ctx context.Context) ([]Shape, error) {
+ return r.QueryResolver.Shapes(ctx)
+}
+func (r *stubQuery) NoShape(ctx context.Context) (Shape, error) {
+ return r.QueryResolver.NoShape(ctx)
+}
+func (r *stubQuery) Node(ctx context.Context) (Node, error) {
+ return r.QueryResolver.Node(ctx)
+}
+func (r *stubQuery) NoShapeTypedNil(ctx context.Context) (Shape, error) {
+ return r.QueryResolver.NoShapeTypedNil(ctx)
+}
+func (r *stubQuery) Animal(ctx context.Context) (Animal, error) {
+ return r.QueryResolver.Animal(ctx)
+}
+func (r *stubQuery) NotAnInterface(ctx context.Context) (BackedByInterface, error) {
+ return r.QueryResolver.NotAnInterface(ctx)
+}
+func (r *stubQuery) Issue896a(ctx context.Context) ([]*CheckIssue896, error) {
+ return r.QueryResolver.Issue896a(ctx)
+}
+func (r *stubQuery) MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) {
+ return r.QueryResolver.MapStringInterface(ctx, in)
+}
+func (r *stubQuery) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error) {
+ return r.QueryResolver.MapNestedStringInterface(ctx, in)
+}
+func (r *stubQuery) ErrorBubble(ctx context.Context) (*Error, error) {
+ return r.QueryResolver.ErrorBubble(ctx)
+}
+func (r *stubQuery) ErrorBubbleList(ctx context.Context) ([]*Error, error) {
+ return r.QueryResolver.ErrorBubbleList(ctx)
+}
+func (r *stubQuery) ErrorList(ctx context.Context) ([]*Error, error) {
+ return r.QueryResolver.ErrorList(ctx)
+}
+func (r *stubQuery) Errors(ctx context.Context) (*Errors, error) {
+ return r.QueryResolver.Errors(ctx)
+}
+func (r *stubQuery) Valid(ctx context.Context) (string, error) {
+ return r.QueryResolver.Valid(ctx)
+}
+func (r *stubQuery) Panics(ctx context.Context) (*Panics, error) {
+ return r.QueryResolver.Panics(ctx)
+}
+func (r *stubQuery) PrimitiveObject(ctx context.Context) ([]Primitive, error) {
+ return r.QueryResolver.PrimitiveObject(ctx)
+}
+func (r *stubQuery) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) {
+ return r.QueryResolver.PrimitiveStringObject(ctx)
+}
+func (r *stubQuery) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) {
+ return r.QueryResolver.PtrToSliceContainer(ctx)
+}
+func (r *stubQuery) Infinity(ctx context.Context) (float64, error) {
+ return r.QueryResolver.Infinity(ctx)
+}
+func (r *stubQuery) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) {
+ return r.QueryResolver.StringFromContextInterface(ctx)
+}
+func (r *stubQuery) StringFromContextFunction(ctx context.Context) (string, error) {
+ return r.QueryResolver.StringFromContextFunction(ctx)
+}
+func (r *stubQuery) DefaultScalar(ctx context.Context, arg string) (string, error) {
+ return r.QueryResolver.DefaultScalar(ctx, arg)
+}
+func (r *stubQuery) Slices(ctx context.Context) (*Slices, error) {
+ return r.QueryResolver.Slices(ctx)
+}
+func (r *stubQuery) ScalarSlice(ctx context.Context) ([]byte, error) {
+ return r.QueryResolver.ScalarSlice(ctx)
+}
+func (r *stubQuery) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) {
+ return r.QueryResolver.Fallback(ctx, arg)
+}
+func (r *stubQuery) OptionalUnion(ctx context.Context) (TestUnion, error) {
+ return r.QueryResolver.OptionalUnion(ctx)
+}
+func (r *stubQuery) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) {
+ return r.QueryResolver.VOkCaseValue(ctx)
+}
+func (r *stubQuery) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) {
+ return r.QueryResolver.VOkCaseNil(ctx)
+}
+func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) {
+ return r.QueryResolver.ValidType(ctx)
+}
+func (r *stubQuery) WrappedStruct(ctx context.Context) (*WrappedStruct, error) {
+ return r.QueryResolver.WrappedStruct(ctx)
+}
+func (r *stubQuery) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) {
+ return r.QueryResolver.WrappedScalar(ctx)
+}
+func (r *stubQuery) WrappedMap(ctx context.Context) (WrappedMap, error) {
+ return r.QueryResolver.WrappedMap(ctx)
+}
+func (r *stubQuery) WrappedSlice(ctx context.Context) (WrappedSlice, error) {
+ return r.QueryResolver.WrappedSlice(ctx)
+}
+
+type stubSubscription struct{ *Stub }
+
+func (r *stubSubscription) Updated(ctx context.Context) (<-chan string, error) {
+ return r.SubscriptionResolver.Updated(ctx)
+}
+func (r *stubSubscription) InitPayload(ctx context.Context) (<-chan string, error) {
+ return r.SubscriptionResolver.InitPayload(ctx)
+}
+func (r *stubSubscription) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) {
+ return r.SubscriptionResolver.DirectiveArg(ctx, arg)
+}
+func (r *stubSubscription) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) {
+ return r.SubscriptionResolver.DirectiveNullableArg(ctx, arg, arg2, arg3)
+}
+func (r *stubSubscription) DirectiveDouble(ctx context.Context) (<-chan *string, error) {
+ return r.SubscriptionResolver.DirectiveDouble(ctx)
+}
+func (r *stubSubscription) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) {
+ return r.SubscriptionResolver.DirectiveUnimplemented(ctx)
+}
+func (r *stubSubscription) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) {
+ return r.SubscriptionResolver.Issue896b(ctx)
+}
+
+type stubUser struct{ *Stub }
+
+func (r *stubUser) Friends(ctx context.Context, obj *User) ([]*User, error) {
+ return r.UserResolver.Friends(ctx, obj)
+}
+
+type stubWrappedMap struct{ *Stub }
+
+func (r *stubWrappedMap) Get(ctx context.Context, obj WrappedMap, key string) (string, error) {
+ return r.WrappedMapResolver.Get(ctx, obj, key)
+}
+
+type stubWrappedSlice struct{ *Stub }
+
+func (r *stubWrappedSlice) Get(ctx context.Context, obj WrappedSlice, idx int) (string, error) {
+ return r.WrappedSliceResolver.Get(ctx, obj, idx)
+}
diff --git a/codegen/testserver/followschema/subscription_test.go b/codegen/testserver/followschema/subscription_test.go
new file mode 100644
index 00000000000..221cbe27288
--- /dev/null
+++ b/codegen/testserver/followschema/subscription_test.go
@@ -0,0 +1,141 @@
+package followschema
+
+import (
+ "context"
+ "fmt"
+ "runtime"
+ "sort"
+ "testing"
+ "time"
+
+ "github.com/99designs/gqlgen/graphql/handler/transport"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestSubscriptions(t *testing.T) {
+ tick := make(chan string, 1)
+
+ resolvers := &Stub{}
+
+ resolvers.SubscriptionResolver.InitPayload = func(ctx context.Context) (strings <-chan string, e error) {
+ payload := transport.GetInitPayload(ctx)
+ channel := make(chan string, len(payload)+1)
+
+ go func() {
+ <-ctx.Done()
+ close(channel)
+ }()
+
+ // Test the helper function separately
+ auth := payload.Authorization()
+ if auth != "" {
+ channel <- "AUTH:" + auth
+ } else {
+ channel <- "AUTH:NONE"
+ }
+
+ // Send them over the channel in alphabetic order
+ keys := make([]string, 0, len(payload))
+ for key := range payload {
+ keys = append(keys, key)
+ }
+ sort.Strings(keys)
+ for _, key := range keys {
+ channel <- fmt.Sprintf("%s = %#+v", key, payload[key])
+ }
+
+ return channel, nil
+ }
+
+ resolvers.SubscriptionResolver.Updated = func(ctx context.Context) (<-chan string, error) {
+ res := make(chan string, 1)
+
+ go func() {
+ for {
+ select {
+ case t := <-tick:
+ res <- t
+ case <-ctx.Done():
+ close(res)
+ return
+ }
+ }
+ }()
+ return res, nil
+ }
+
+ srv := handler.NewDefaultServer(
+ NewExecutableSchema(Config{Resolvers: resolvers}),
+ )
+ srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
+ path, _ := ctx.Value(ckey("path")).([]int)
+ return next(context.WithValue(ctx, ckey("path"), append(path, 1)))
+ })
+
+ srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
+ path, _ := ctx.Value(ckey("path")).([]int)
+ return next(context.WithValue(ctx, ckey("path"), append(path, 2)))
+ })
+
+ c := client.New(srv)
+
+ t.Run("wont leak goroutines", func(t *testing.T) {
+ runtime.GC() // ensure no go-routines left from preceding tests
+ initialGoroutineCount := runtime.NumGoroutine()
+
+ sub := c.Websocket(`subscription { updated }`)
+
+ tick <- "message"
+
+ var msg struct {
+ resp struct {
+ Updated string
+ }
+ }
+
+ err := sub.Next(&msg.resp)
+ require.NoError(t, err)
+ require.Equal(t, "message", msg.resp.Updated)
+ sub.Close()
+
+ // need a little bit of time for goroutines to settle
+ start := time.Now()
+ for time.Since(start).Seconds() < 2 && initialGoroutineCount != runtime.NumGoroutine() {
+ time.Sleep(5 * time.Millisecond)
+ }
+
+ require.Equal(t, initialGoroutineCount, runtime.NumGoroutine())
+ })
+
+ t.Run("will parse init payload", func(t *testing.T) {
+ sub := c.WebsocketWithPayload(`subscription { initPayload }`, map[string]interface{}{
+ "Authorization": "Bearer of the curse",
+ "number": 32,
+ "strings": []string{"hello", "world"},
+ })
+
+ var msg struct {
+ resp struct {
+ InitPayload string
+ }
+ }
+
+ err := sub.Next(&msg.resp)
+ require.NoError(t, err)
+ require.Equal(t, "AUTH:Bearer of the curse", msg.resp.InitPayload)
+ err = sub.Next(&msg.resp)
+ require.NoError(t, err)
+ require.Equal(t, "Authorization = \"Bearer of the curse\"", msg.resp.InitPayload)
+ err = sub.Next(&msg.resp)
+ require.NoError(t, err)
+ require.Equal(t, "number = 32", msg.resp.InitPayload)
+ err = sub.Next(&msg.resp)
+ require.NoError(t, err)
+ require.Equal(t, "strings = []interface {}{\"hello\", \"world\"}", msg.resp.InitPayload)
+ sub.Close()
+ })
+}
diff --git a/codegen/testserver/followschema/thirdparty.go b/codegen/testserver/followschema/thirdparty.go
new file mode 100644
index 00000000000..615196d7d61
--- /dev/null
+++ b/codegen/testserver/followschema/thirdparty.go
@@ -0,0 +1,31 @@
+package followschema
+
+import (
+ "fmt"
+ "io"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+)
+
+type ThirdParty struct {
+ str string
+}
+
+func MarshalThirdParty(tp ThirdParty) graphql.Marshaler {
+ return graphql.WriterFunc(func(w io.Writer) {
+ _, err := io.WriteString(w, strconv.Quote(tp.str))
+ if err != nil {
+ panic(err)
+ }
+ })
+}
+
+func UnmarshalThirdParty(input interface{}) (ThirdParty, error) {
+ switch input := input.(type) {
+ case string:
+ return ThirdParty{str: input}, nil
+ default:
+ return ThirdParty{}, fmt.Errorf("unknown type for input: %s", input)
+ }
+}
diff --git a/codegen/testserver/followschema/time_test.go b/codegen/testserver/followschema/time_test.go
new file mode 100644
index 00000000000..8b33b29041d
--- /dev/null
+++ b/codegen/testserver/followschema/time_test.go
@@ -0,0 +1,68 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+ "time"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestTime(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) {
+ return &User{}, nil
+ }
+
+ t.Run("zero value in nullable field", func(t *testing.T) {
+ var resp struct {
+ User struct {
+ Updated *string
+ }
+ }
+
+ err := c.Post(`query { user(id: 1) { updated } }`, &resp)
+ require.NoError(t, err)
+
+ require.Nil(t, resp.User.Updated)
+ })
+
+ t.Run("zero value in non nullable field", func(t *testing.T) {
+ var resp struct {
+ User struct {
+ Created *string
+ }
+ }
+
+ err := c.Post(`query { user(id: 1) { created } }`, &resp)
+ require.EqualError(t, err, `[{"message":"must not be null","path":["user","created"]}]`)
+ })
+
+ t.Run("with values", func(t *testing.T) {
+ resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) {
+ updated := time.Date(2010, 1, 1, 0, 0, 20, 1, time.UTC)
+ return &User{
+ Created: time.Date(2010, 1, 1, 0, 0, 10, 1, time.UTC),
+ Updated: &updated,
+ }, nil
+ }
+
+ var resp struct {
+ User struct {
+ Created string
+ Updated string
+ }
+ }
+
+ err := c.Post(`query { user(id: 1) { created, updated } }`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, "2010-01-01T00:00:10.000000001Z", resp.User.Created)
+ require.Equal(t, "2010-01-01T00:00:20.000000001Z", resp.User.Updated)
+ })
+}
diff --git a/codegen/testserver/followschema/typefallback.generated.go b/codegen/testserver/followschema/typefallback.generated.go
new file mode 100644
index 00000000000..143f5c46e75
--- /dev/null
+++ b/codegen/testserver/followschema/typefallback.generated.go
@@ -0,0 +1,58 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFallbackToStringEncoding(ctx context.Context, v interface{}) (FallbackToStringEncoding, error) {
+ tmp, err := graphql.UnmarshalString(v)
+ res := FallbackToStringEncoding(tmp)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFallbackToStringEncoding(ctx context.Context, sel ast.SelectionSet, v FallbackToStringEncoding) graphql.Marshaler {
+ res := graphql.MarshalString(string(v))
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/typefallback.graphql b/codegen/testserver/followschema/typefallback.graphql
similarity index 100%
rename from codegen/testserver/typefallback.graphql
rename to codegen/testserver/followschema/typefallback.graphql
diff --git a/codegen/testserver/followschema/typefallback_test.go b/codegen/testserver/followschema/typefallback_test.go
new file mode 100644
index 00000000000..764661f84b8
--- /dev/null
+++ b/codegen/testserver/followschema/typefallback_test.go
@@ -0,0 +1,28 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestTypeFallback(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.QueryResolver.Fallback = func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) {
+ return arg, nil
+ }
+
+ t.Run("fallback to string passthrough", func(t *testing.T) {
+ var resp struct {
+ Fallback string
+ }
+ c.MustPost(`query { fallback(arg: A) }`, &resp)
+ require.Equal(t, "A", resp.Fallback)
+ })
+}
diff --git a/codegen/testserver/followschema/useptr.generated.go b/codegen/testserver/followschema/useptr.generated.go
new file mode 100644
index 00000000000..8d480352d4e
--- /dev/null
+++ b/codegen/testserver/followschema/useptr.generated.go
@@ -0,0 +1,200 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "fmt"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _A_id(ctx context.Context, field graphql.CollectedField, obj *A) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "A",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _B_id(ctx context.Context, field graphql.CollectedField, obj *B) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "B",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+func (ec *executionContext) _TestUnion(ctx context.Context, sel ast.SelectionSet, obj TestUnion) graphql.Marshaler {
+ switch obj := (obj).(type) {
+ case nil:
+ return graphql.Null
+ case A:
+ return ec._A(ctx, sel, &obj)
+ case *A:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._A(ctx, sel, obj)
+ case B:
+ return ec._B(ctx, sel, &obj)
+ case *B:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._B(ctx, sel, obj)
+ default:
+ panic(fmt.Errorf("unexpected type %T", obj))
+ }
+}
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var aImplementors = []string{"A", "TestUnion"}
+
+func (ec *executionContext) _A(ctx context.Context, sel ast.SelectionSet, obj *A) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, aImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("A")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._A_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var bImplementors = []string{"B", "TestUnion"}
+
+func (ec *executionContext) _B(ctx context.Context, sel ast.SelectionSet, obj *B) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, bImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("B")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._B_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐTestUnion(ctx context.Context, sel ast.SelectionSet, v TestUnion) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._TestUnion(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/useptr.graphql b/codegen/testserver/followschema/useptr.graphql
similarity index 100%
rename from codegen/testserver/useptr.graphql
rename to codegen/testserver/followschema/useptr.graphql
diff --git a/codegen/testserver/followschema/useptr_test.go b/codegen/testserver/followschema/useptr_test.go
new file mode 100644
index 00000000000..6fdf35c606a
--- /dev/null
+++ b/codegen/testserver/followschema/useptr_test.go
@@ -0,0 +1,14 @@
+package followschema
+
+import (
+ "reflect"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestUserPtr(t *testing.T) {
+ s := &Stub{}
+ r := reflect.TypeOf(s.QueryResolver.OptionalUnion)
+ require.True(t, r.Out(0).Kind() == reflect.Interface)
+}
diff --git a/codegen/testserver/followschema/v-ok.generated.go b/codegen/testserver/followschema/v-ok.generated.go
new file mode 100644
index 00000000000..a495f3fc6ab
--- /dev/null
+++ b/codegen/testserver/followschema/v-ok.generated.go
@@ -0,0 +1,179 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _VOkCaseNil_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseNil) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "VOkCaseNil",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ v, ok := obj.Value()
+ if !ok {
+ return nil, nil
+ }
+ return v, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _VOkCaseValue_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseValue) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "VOkCaseValue",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ v, ok := obj.Value()
+ if !ok {
+ return nil, nil
+ }
+ return v, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var vOkCaseNilImplementors = []string{"VOkCaseNil"}
+
+func (ec *executionContext) _VOkCaseNil(ctx context.Context, sel ast.SelectionSet, obj *VOkCaseNil) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, vOkCaseNilImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("VOkCaseNil")
+ case "value":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._VOkCaseNil_value(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var vOkCaseValueImplementors = []string{"VOkCaseValue"}
+
+func (ec *executionContext) _VOkCaseValue(ctx context.Context, sel ast.SelectionSet, obj *VOkCaseValue) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, vOkCaseValueImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("VOkCaseValue")
+ case "value":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._VOkCaseValue_value(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalOVOkCaseNil2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVOkCaseNil(ctx context.Context, sel ast.SelectionSet, v *VOkCaseNil) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._VOkCaseNil(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOVOkCaseValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVOkCaseValue(ctx context.Context, sel ast.SelectionSet, v *VOkCaseValue) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._VOkCaseValue(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/followschema/v-ok.go b/codegen/testserver/followschema/v-ok.go
new file mode 100644
index 00000000000..7e2aab62dc9
--- /dev/null
+++ b/codegen/testserver/followschema/v-ok.go
@@ -0,0 +1,17 @@
+package followschema
+
+// VOkCaseValue model
+type VOkCaseValue struct {
+}
+
+func (v VOkCaseValue) Value() (string, bool) {
+ return "hi", true
+}
+
+// VOkCaseNil model
+type VOkCaseNil struct {
+}
+
+func (v VOkCaseNil) Value() (string, bool) {
+ return "", false
+}
diff --git a/codegen/testserver/followschema/v-ok.graphql b/codegen/testserver/followschema/v-ok.graphql
new file mode 100644
index 00000000000..9139cf8aa91
--- /dev/null
+++ b/codegen/testserver/followschema/v-ok.graphql
@@ -0,0 +1,12 @@
+extend type Query {
+ vOkCaseValue: VOkCaseValue
+ vOkCaseNil: VOkCaseNil
+}
+
+type VOkCaseValue @goModel(model:"followschema.VOkCaseValue") {
+ value: String
+}
+
+type VOkCaseNil @goModel(model:"followschema.VOkCaseNil") {
+ value: String
+}
diff --git a/codegen/testserver/followschema/v-ok_test.go b/codegen/testserver/followschema/v-ok_test.go
new file mode 100644
index 00000000000..6c22368fda2
--- /dev/null
+++ b/codegen/testserver/followschema/v-ok_test.go
@@ -0,0 +1,47 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+)
+
+func TestOk(t *testing.T) {
+ resolver := &Stub{}
+ resolver.QueryResolver.VOkCaseValue = func(ctx context.Context) (*VOkCaseValue, error) {
+ return &VOkCaseValue{}, nil
+ }
+ resolver.QueryResolver.VOkCaseNil = func(ctx context.Context) (*VOkCaseNil, error) {
+ return &VOkCaseNil{}, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(
+ NewExecutableSchema(Config{Resolvers: resolver}),
+ ))
+
+ t.Run("v ok case value", func(t *testing.T) {
+ var resp struct {
+ VOkCaseValue struct {
+ Value string
+ }
+ }
+ err := c.Post(`query { vOkCaseValue { value } }`, &resp)
+ require.NoError(t, err)
+ require.Equal(t, resp.VOkCaseValue.Value, "hi")
+ })
+
+ t.Run("v ok case nil", func(t *testing.T) {
+ var resp struct {
+ VOkCaseNil struct {
+ Value *string
+ }
+ }
+ err := c.Post(`query { vOkCaseNil { value } }`, &resp)
+ require.NoError(t, err)
+ require.Equal(t, true, resp.VOkCaseNil.Value == nil)
+ })
+}
diff --git a/codegen/testserver/followschema/validtypes.generated.go b/codegen/testserver/followschema/validtypes.generated.go
new file mode 100644
index 00000000000..2f9e0117a3a
--- /dev/null
+++ b/codegen/testserver/followschema/validtypes.generated.go
@@ -0,0 +1,877 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "fmt"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+func (ec *executionContext) field_ValidType_validArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["break"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("break"))
+ arg0, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["break"] = arg0
+ var arg1 string
+ if tmp, ok := rawArgs["default"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("default"))
+ arg1, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["default"] = arg1
+ var arg2 string
+ if tmp, ok := rawArgs["func"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("func"))
+ arg2, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["func"] = arg2
+ var arg3 string
+ if tmp, ok := rawArgs["interface"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interface"))
+ arg3, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["interface"] = arg3
+ var arg4 string
+ if tmp, ok := rawArgs["select"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("select"))
+ arg4, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["select"] = arg4
+ var arg5 string
+ if tmp, ok := rawArgs["case"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("case"))
+ arg5, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["case"] = arg5
+ var arg6 string
+ if tmp, ok := rawArgs["defer"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("defer"))
+ arg6, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["defer"] = arg6
+ var arg7 string
+ if tmp, ok := rawArgs["go"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("go"))
+ arg7, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["go"] = arg7
+ var arg8 string
+ if tmp, ok := rawArgs["map"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map"))
+ arg8, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["map"] = arg8
+ var arg9 string
+ if tmp, ok := rawArgs["struct"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("struct"))
+ arg9, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["struct"] = arg9
+ var arg10 string
+ if tmp, ok := rawArgs["chan"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chan"))
+ arg10, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["chan"] = arg10
+ var arg11 string
+ if tmp, ok := rawArgs["else"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("else"))
+ arg11, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["else"] = arg11
+ var arg12 string
+ if tmp, ok := rawArgs["goto"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("goto"))
+ arg12, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["goto"] = arg12
+ var arg13 string
+ if tmp, ok := rawArgs["package"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("package"))
+ arg13, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["package"] = arg13
+ var arg14 string
+ if tmp, ok := rawArgs["switch"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("switch"))
+ arg14, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["switch"] = arg14
+ var arg15 string
+ if tmp, ok := rawArgs["const"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("const"))
+ arg15, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["const"] = arg15
+ var arg16 string
+ if tmp, ok := rawArgs["fallthrough"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fallthrough"))
+ arg16, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["fallthrough"] = arg16
+ var arg17 string
+ if tmp, ok := rawArgs["if"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("if"))
+ arg17, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["if"] = arg17
+ var arg18 string
+ if tmp, ok := rawArgs["range"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("range"))
+ arg18, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["range"] = arg18
+ var arg19 string
+ if tmp, ok := rawArgs["type"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type"))
+ arg19, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["type"] = arg19
+ var arg20 string
+ if tmp, ok := rawArgs["continue"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("continue"))
+ arg20, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["continue"] = arg20
+ var arg21 string
+ if tmp, ok := rawArgs["for"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("for"))
+ arg21, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["for"] = arg21
+ var arg22 string
+ if tmp, ok := rawArgs["import"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("import"))
+ arg22, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["import"] = arg22
+ var arg23 string
+ if tmp, ok := rawArgs["return"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("return"))
+ arg23, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["return"] = arg23
+ var arg24 string
+ if tmp, ok := rawArgs["var"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("var"))
+ arg24, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["var"] = arg24
+ var arg25 string
+ if tmp, ok := rawArgs["_"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("_"))
+ arg25, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["_"] = arg25
+ return args, nil
+}
+
+func (ec *executionContext) field_ValidType_validInputKeywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 *ValidInput
+ if tmp, ok := rawArgs["input"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
+ arg0, err = ec.unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐValidInput(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["input"] = arg0
+ return args, nil
+}
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _Content_Post_foo(ctx context.Context, field graphql.CollectedField, obj *ContentPost) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Content_Post",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Foo, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Content_User_foo(ctx context.Context, field graphql.CollectedField, obj *ContentUser) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Content_User",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Foo, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ValidType",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.DifferentCase, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ValidType_different_case(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ValidType",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.DifferentCaseOld, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ValidType",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_ValidType_validInputKeywords_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ValidInputKeywords, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ValidType",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_ValidType_validArgs_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ValidArgs, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+func (ec *executionContext) unmarshalInputValidInput(ctx context.Context, obj interface{}) (ValidInput, error) {
+ var it ValidInput
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "break":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("break"))
+ it.Break, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "default":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("default"))
+ it.Default, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "func":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("func"))
+ it.Func, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "interface":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interface"))
+ it.Interface, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "select":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("select"))
+ it.Select, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "case":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("case"))
+ it.Case, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "defer":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("defer"))
+ it.Defer, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "go":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("go"))
+ it.Go, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "map":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map"))
+ it.Map, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "struct":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("struct"))
+ it.Struct, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "chan":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chan"))
+ it.Chan, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "else":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("else"))
+ it.Else, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "goto":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("goto"))
+ it.Goto, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "package":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("package"))
+ it.Package, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "switch":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("switch"))
+ it.Switch, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "const":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("const"))
+ it.Const, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "fallthrough":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fallthrough"))
+ it.Fallthrough, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "if":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("if"))
+ it.If, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "range":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("range"))
+ it.Range, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "type":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type"))
+ it.Type, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "continue":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("continue"))
+ it.Continue, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "for":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("for"))
+ it.For, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "import":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("import"))
+ it.Import, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "return":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("return"))
+ it.Return, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "var":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("var"))
+ it.Var, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "_":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("_"))
+ it.Underscore, err = ec.unmarshalNString2string(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+func (ec *executionContext) _Content_Child(ctx context.Context, sel ast.SelectionSet, obj ContentChild) graphql.Marshaler {
+ switch obj := (obj).(type) {
+ case nil:
+ return graphql.Null
+ case ContentUser:
+ return ec._Content_User(ctx, sel, &obj)
+ case *ContentUser:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._Content_User(ctx, sel, obj)
+ case ContentPost:
+ return ec._Content_Post(ctx, sel, &obj)
+ case *ContentPost:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._Content_Post(ctx, sel, obj)
+ default:
+ panic(fmt.Errorf("unexpected type %T", obj))
+ }
+}
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var content_PostImplementors = []string{"Content_Post", "Content_Child"}
+
+func (ec *executionContext) _Content_Post(ctx context.Context, sel ast.SelectionSet, obj *ContentPost) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, content_PostImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Content_Post")
+ case "foo":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Content_Post_foo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var content_UserImplementors = []string{"Content_User", "Content_Child"}
+
+func (ec *executionContext) _Content_User(ctx context.Context, sel ast.SelectionSet, obj *ContentUser) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, content_UserImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Content_User")
+ case "foo":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Content_User_foo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var validTypeImplementors = []string{"ValidType"}
+
+func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet, obj *ValidType) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, validTypeImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("ValidType")
+ case "differentCase":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ValidType_differentCase(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "different_case":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ValidType_different_case(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "validInputKeywords":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ValidType_validInputKeywords(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "validArgs":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ValidType_validArgs(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐValidInput(ctx context.Context, v interface{}) (*ValidInput, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalInputValidInput(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐValidType(ctx context.Context, sel ast.SelectionSet, v *ValidType) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._ValidType(ctx, sel, v)
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/validtypes.graphql b/codegen/testserver/followschema/validtypes.graphql
similarity index 100%
rename from codegen/testserver/validtypes.graphql
rename to codegen/testserver/followschema/validtypes.graphql
diff --git a/codegen/testserver/followschema/validtypes_test.go b/codegen/testserver/followschema/validtypes_test.go
new file mode 100644
index 00000000000..2c0e67942a0
--- /dev/null
+++ b/codegen/testserver/followschema/validtypes_test.go
@@ -0,0 +1,36 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestValidType(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.ValidType = func(ctx context.Context) (validType *ValidType, e error) {
+ return &ValidType{
+ DifferentCase: "new",
+ DifferentCaseOld: "old",
+ }, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ t.Run("fields with differing cases can be distinguished", func(t *testing.T) {
+ var resp struct {
+ ValidType struct {
+ New string `json:"differentCase"`
+ Old string `json:"different_case"`
+ }
+ }
+ err := c.Post(`query { validType { differentCase, different_case } }`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, "new", resp.ValidType.New)
+ require.Equal(t, "old", resp.ValidType.Old)
+ })
+}
diff --git a/codegen/testserver/followschema/weird_type_cases.generated.go b/codegen/testserver/followschema/weird_type_cases.generated.go
new file mode 100644
index 00000000000..181cb582158
--- /dev/null
+++ b/codegen/testserver/followschema/weird_type_cases.generated.go
@@ -0,0 +1,421 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _AIt_id(ctx context.Context, field graphql.CollectedField, obj *AIt) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "AIt",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _AbIt_id(ctx context.Context, field graphql.CollectedField, obj *AbIt) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "AbIt",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.CollectedField, obj *XXIt) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "XXIt",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _XxIt_id(ctx context.Context, field graphql.CollectedField, obj *XxIt) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "XxIt",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _asdfIt_id(ctx context.Context, field graphql.CollectedField, obj *AsdfIt) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "asdfIt",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.CollectedField, obj *IIt) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "iIt",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNID2string(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var aItImplementors = []string{"AIt"}
+
+func (ec *executionContext) _AIt(ctx context.Context, sel ast.SelectionSet, obj *AIt) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, aItImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("AIt")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._AIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var abItImplementors = []string{"AbIt"}
+
+func (ec *executionContext) _AbIt(ctx context.Context, sel ast.SelectionSet, obj *AbIt) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, abItImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("AbIt")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._AbIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var xXItImplementors = []string{"XXIt"}
+
+func (ec *executionContext) _XXIt(ctx context.Context, sel ast.SelectionSet, obj *XXIt) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, xXItImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("XXIt")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._XXIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var xxItImplementors = []string{"XxIt"}
+
+func (ec *executionContext) _XxIt(ctx context.Context, sel ast.SelectionSet, obj *XxIt) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, xxItImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("XxIt")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._XxIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var asdfItImplementors = []string{"asdfIt"}
+
+func (ec *executionContext) _asdfIt(ctx context.Context, sel ast.SelectionSet, obj *AsdfIt) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, asdfItImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("asdfIt")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._asdfIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var iItImplementors = []string{"iIt"}
+
+func (ec *executionContext) _iIt(ctx context.Context, sel ast.SelectionSet, obj *IIt) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, iItImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("iIt")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._iIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/weird_type_cases.graphql b/codegen/testserver/followschema/weird_type_cases.graphql
similarity index 100%
rename from codegen/testserver/weird_type_cases.graphql
rename to codegen/testserver/followschema/weird_type_cases.graphql
diff --git a/codegen/testserver/followschema/wrapped_type.generated.go b/codegen/testserver/followschema/wrapped_type.generated.go
new file mode 100644
index 00000000000..529421ee708
--- /dev/null
+++ b/codegen/testserver/followschema/wrapped_type.generated.go
@@ -0,0 +1,408 @@
+// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
+
+package followschema
+
+import (
+ "context"
+ "strconv"
+ "sync/atomic"
+
+ "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg"
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser/v2/ast"
+)
+
+// region ************************** generated!.gotpl **************************
+
+type WrappedMapResolver interface {
+ Get(ctx context.Context, obj WrappedMap, key string) (string, error)
+}
+type WrappedSliceResolver interface {
+ Get(ctx context.Context, obj WrappedSlice, idx int) (string, error)
+}
+
+// endregion ************************** generated!.gotpl **************************
+
+// region ***************************** args.gotpl *****************************
+
+func (ec *executionContext) field_WrappedMap_get_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["key"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key"))
+ arg0, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["key"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_WrappedSlice_get_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 int
+ if tmp, ok := rawArgs["idx"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idx"))
+ arg0, err = ec.unmarshalNInt2int(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["idx"] = arg0
+ return args, nil
+}
+
+// endregion ***************************** args.gotpl *****************************
+
+// region ************************** directives.gotpl **************************
+
+// endregion ************************** directives.gotpl **************************
+
+// region **************************** field.gotpl *****************************
+
+func (ec *executionContext) _WrappedMap_get(ctx context.Context, field graphql.CollectedField, obj WrappedMap) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "WrappedMap",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_WrappedMap_get_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.WrappedMap().Get(rctx, obj, args["key"].(string))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _WrappedSlice_get(ctx context.Context, field graphql.CollectedField, obj WrappedSlice) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "WrappedSlice",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_WrappedSlice_get_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.WrappedSlice().Get(rctx, obj, args["idx"].(int))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _WrappedStruct_name(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "WrappedStruct",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Name, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(otherpkg.Scalar)
+ fc.Result = res
+ return ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _WrappedStruct_desc(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "WrappedStruct",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Desc, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*otherpkg.Scalar)
+ fc.Result = res
+ return ec.marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx, field.Selections, res)
+}
+
+// endregion **************************** field.gotpl *****************************
+
+// region **************************** input.gotpl *****************************
+
+// endregion **************************** input.gotpl *****************************
+
+// region ************************** interface.gotpl ***************************
+
+// endregion ************************** interface.gotpl ***************************
+
+// region **************************** object.gotpl ****************************
+
+var wrappedMapImplementors = []string{"WrappedMap"}
+
+func (ec *executionContext) _WrappedMap(ctx context.Context, sel ast.SelectionSet, obj WrappedMap) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, wrappedMapImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("WrappedMap")
+ case "get":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._WrappedMap_get(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var wrappedSliceImplementors = []string{"WrappedSlice"}
+
+func (ec *executionContext) _WrappedSlice(ctx context.Context, sel ast.SelectionSet, obj WrappedSlice) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, wrappedSliceImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("WrappedSlice")
+ case "get":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._WrappedSlice_get(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var wrappedStructImplementors = []string{"WrappedStruct"}
+
+func (ec *executionContext) _WrappedStruct(ctx context.Context, sel ast.SelectionSet, obj *WrappedStruct) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, wrappedStructImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("WrappedStruct")
+ case "name":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._WrappedStruct_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "desc":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._WrappedStruct_desc(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+// endregion **************************** object.gotpl ****************************
+
+// region ***************************** type.gotpl *****************************
+
+func (ec *executionContext) marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedMap(ctx context.Context, sel ast.SelectionSet, v WrappedMap) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._WrappedMap(ctx, sel, v)
+}
+
+func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, v interface{}) (otherpkg.Scalar, error) {
+ tmp, err := graphql.UnmarshalString(v)
+ res := otherpkg.Scalar(tmp)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v otherpkg.Scalar) graphql.Marshaler {
+ res := graphql.MarshalString(string(v))
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return res
+}
+
+func (ec *executionContext) marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedSlice(ctx context.Context, sel ast.SelectionSet, v WrappedSlice) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._WrappedSlice(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalNWrappedStruct2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v WrappedStruct) graphql.Marshaler {
+ return ec._WrappedStruct(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v *WrappedStruct) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._WrappedStruct(ctx, sel, v)
+}
+
+func (ec *executionContext) unmarshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, v interface{}) (*otherpkg.Scalar, error) {
+ if v == nil {
+ return nil, nil
+ }
+ tmp, err := graphql.UnmarshalString(v)
+ res := otherpkg.Scalar(tmp)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v *otherpkg.Scalar) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ res := graphql.MarshalString(string(*v))
+ return res
+}
+
+// endregion ***************************** type.gotpl *****************************
diff --git a/codegen/testserver/followschema/wrapped_type.go b/codegen/testserver/followschema/wrapped_type.go
new file mode 100644
index 00000000000..911bf27ebb1
--- /dev/null
+++ b/codegen/testserver/followschema/wrapped_type.go
@@ -0,0 +1,8 @@
+package followschema
+
+import "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg"
+
+type WrappedScalar = otherpkg.Scalar
+type WrappedStruct otherpkg.Struct
+type WrappedMap otherpkg.Map
+type WrappedSlice otherpkg.Slice
diff --git a/codegen/testserver/wrapped_type.graphql b/codegen/testserver/followschema/wrapped_type.graphql
similarity index 100%
rename from codegen/testserver/wrapped_type.graphql
rename to codegen/testserver/followschema/wrapped_type.graphql
diff --git a/codegen/testserver/followschema/wrapped_type_test.go b/codegen/testserver/followschema/wrapped_type_test.go
new file mode 100644
index 00000000000..95280b3d952
--- /dev/null
+++ b/codegen/testserver/followschema/wrapped_type_test.go
@@ -0,0 +1,98 @@
+package followschema
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestWrappedTypes(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.QueryResolver.WrappedScalar = func(ctx context.Context) (scalar WrappedScalar, e error) {
+ return "hello", nil
+ }
+
+ resolvers.QueryResolver.WrappedStruct = func(ctx context.Context) (wrappedStruct *WrappedStruct, e error) {
+ wrapped := WrappedStruct(otherpkg.Struct{
+ Name: "hello",
+ })
+ return &wrapped, nil
+ }
+
+ resolvers.QueryResolver.WrappedMap = func(ctx context.Context) (wrappedMap WrappedMap, e error) {
+ wrapped := WrappedMap(map[string]string{
+ "name": "hello",
+ })
+ return wrapped, nil
+ }
+
+ resolvers.QueryResolver.WrappedSlice = func(ctx context.Context) (slice WrappedSlice, err error) {
+ wrapped := WrappedSlice([]string{"hello"})
+ return wrapped, nil
+ }
+
+ resolvers.WrappedMapResolver.Get = func(ctx context.Context, obj WrappedMap, key string) (s string, err error) {
+ return obj[key], nil
+ }
+
+ resolvers.WrappedSliceResolver.Get = func(ctx context.Context, obj WrappedSlice, idx int) (s string, err error) {
+ return obj[idx], nil
+ }
+
+ t.Run("wrapped struct", func(t *testing.T) {
+ var resp struct {
+ WrappedStruct struct {
+ Name string
+ }
+ }
+
+ err := c.Post(`query { wrappedStruct { name } }`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, "hello", resp.WrappedStruct.Name)
+ })
+
+ t.Run("wrapped scalar", func(t *testing.T) {
+ var resp struct {
+ WrappedScalar string
+ }
+
+ err := c.Post(`query { wrappedScalar }`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, "hello", resp.WrappedScalar)
+ })
+
+ t.Run("wrapped map", func(t *testing.T) {
+ var resp struct {
+ WrappedMap struct {
+ Name string
+ }
+ }
+
+ err := c.Post(`query { wrappedMap { name: get(key: "name") } }`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, "hello", resp.WrappedMap.Name)
+ })
+
+ t.Run("wrapped slice", func(t *testing.T) {
+ var resp struct {
+ WrappedSlice struct {
+ First string
+ }
+ }
+
+ err := c.Post(`query { wrappedSlice { first: get(idx: 0) } }`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, "hello", resp.WrappedSlice.First)
+ })
+}
diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go
index edc961a8f26..5270830df9d 100644
--- a/codegen/testserver/generated_test.go
+++ b/codegen/testserver/generated_test.go
@@ -1,80 +1,65 @@
-//go:generate rm -f resolver.go
-//go:generate go run ../../testdata/gqlgen.go -stub stub.go
-
package testserver
import (
- "context"
- "reflect"
+ "fmt"
+ "go/ast"
+ "go/parser"
+ "go/token"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
"testing"
- "github.com/99designs/gqlgen/client"
- "github.com/99designs/gqlgen/graphql/handler"
+ eqgo "github.com/kevinmbeaulieu/eq-go/eq-go"
"github.com/stretchr/testify/require"
)
-func TestForcedResolverFieldIsPointer(t *testing.T) {
- field, ok := reflect.TypeOf((*ForcedResolverResolver)(nil)).Elem().MethodByName("Field")
- require.True(t, ok)
- require.Equal(t, "*testserver.Circle", field.Type.Out(0).String())
-}
+func TestLayouts(t *testing.T) {
+ singlefileFSet := token.NewFileSet()
+ singlefilePkg := loadPackage("singlefile", singlefileFSet)
-func TestEnums(t *testing.T) {
- t.Run("list of enums", func(t *testing.T) {
- require.Equal(t, StatusOk, AllStatus[0])
- require.Equal(t, StatusError, AllStatus[1])
- })
+ followschemaFSet := token.NewFileSet()
+ followschemaPkg := loadPackage("followschema", followschemaFSet)
- t.Run("invalid enum values", func(t *testing.T) {
- require.Equal(t, StatusOk, AllStatus[0])
- require.Equal(t, StatusError, AllStatus[1])
- })
+ eq, msg := eqgo.PackagesEquivalent(singlefilePkg, singlefileFSet, followschemaPkg, followschemaFSet, nil)
+ if !eq {
+ // When msg is too long, require.True(...) omits it entirely.
+ // Therefore use fmt.Fprintln to print it manually instead.
+ fmt.Fprintln(os.Stderr, msg)
+ require.Fail(t, "Packages not equivalent")
+ }
}
-func TestUnionFragments(t *testing.T) {
- resolvers := &Stub{}
- resolvers.QueryResolver.ShapeUnion = func(ctx context.Context) (ShapeUnion, error) {
- return &Circle{Radius: 32}, nil
+func loadPackage(name string, fset *token.FileSet) *ast.Package {
+ path, err := filepath.Abs(name)
+ if err != nil {
+ panic(err)
+ }
+ files, err := ioutil.ReadDir(path)
+ if err != nil {
+ panic(err)
}
- srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))
- c := client.New(srv)
-
- t.Run("inline fragment on union", func(t *testing.T) {
- var resp struct {
- ShapeUnion struct {
- Radius float64
- }
- }
- c.MustPost(`query {
- shapeUnion {
- ... on Circle {
- radius
- }
- }
- }
- `, &resp)
- require.NotEmpty(t, resp.ShapeUnion.Radius)
- })
-
- t.Run("named fragment", func(t *testing.T) {
- var resp struct {
- ShapeUnion struct {
- Radius float64
- }
- }
- c.MustPost(`query {
- shapeUnion {
- ...C
+ pkg := ast.Package{
+ Name: name,
+ Files: make(map[string]*ast.File),
+ }
+ for _, f := range files {
+ // Only compare generated files.
+ if strings.HasSuffix(f.Name(), ".generated.go") ||
+ f.Name() == "generated.go" ||
+ f.Name() == "resolver.go" ||
+ f.Name() == "stub.go" ||
+ f.Name() == "models-gen.go" {
+ filename := filepath.Join(path, f.Name())
+ src, err := parser.ParseFile(fset, filename, nil, parser.AllErrors)
+ if err != nil {
+ panic(err)
}
+ pkg.Files[filename] = src
}
+ }
- fragment C on ShapeUnion {
- ... on Circle {
- radius
- }
- }
- `, &resp)
- require.NotEmpty(t, resp.ShapeUnion.Radius)
- })
+ return &pkg
}
diff --git a/codegen/testserver/gqlgen.yml b/codegen/testserver/gqlgen.yml
deleted file mode 100644
index d9d4f0c5b17..00000000000
--- a/codegen/testserver/gqlgen.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-schema:
- - "*.graphql"
-skip_validation: true
-exec:
- filename: generated.go
-model:
- filename: models-gen.go
-resolver:
- filename: resolver.go
- type: Resolver
-
-autobind:
- - "github.com/99designs/gqlgen/codegen/testserver"
- - "github.com/99designs/gqlgen/codegen/testserver/introspection"
- - "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename"
-
-models:
- Email:
- model: "github.com/99designs/gqlgen/codegen/testserver.Email"
diff --git a/codegen/testserver/singlefile/builtinscalar.graphql b/codegen/testserver/singlefile/builtinscalar.graphql
new file mode 100644
index 00000000000..deb8a9f6242
--- /dev/null
+++ b/codegen/testserver/singlefile/builtinscalar.graphql
@@ -0,0 +1,8 @@
+
+"""
+Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_
+added to the TypeMap
+"""
+type Map {
+ id: ID!
+}
diff --git a/codegen/testserver/bytes.go b/codegen/testserver/singlefile/bytes.go
similarity index 96%
rename from codegen/testserver/bytes.go
rename to codegen/testserver/singlefile/bytes.go
index 42a4541f9d4..9a2414b422d 100644
--- a/codegen/testserver/bytes.go
+++ b/codegen/testserver/singlefile/bytes.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"fmt"
diff --git a/codegen/testserver/singlefile/complexity.graphql b/codegen/testserver/singlefile/complexity.graphql
new file mode 100644
index 00000000000..c6a1868a8e6
--- /dev/null
+++ b/codegen/testserver/singlefile/complexity.graphql
@@ -0,0 +1,11 @@
+extend type Query {
+ overlapping: OverlappingFields
+}
+
+type OverlappingFields {
+ oneFoo: Int! @goField(name: "foo")
+ twoFoo: Int! @goField(name: "foo")
+ oldFoo: Int! @goField(name: "foo", forceResolver: true)
+ newFoo: Int!
+ new_foo: Int!
+}
diff --git a/codegen/testserver/complexity_test.go b/codegen/testserver/singlefile/complexity_test.go
similarity index 99%
rename from codegen/testserver/complexity_test.go
rename to codegen/testserver/singlefile/complexity_test.go
index 26e1d85f8de..ac8e05a8c35 100644
--- a/codegen/testserver/complexity_test.go
+++ b/codegen/testserver/singlefile/complexity_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/singlefile/defaults.graphql b/codegen/testserver/singlefile/defaults.graphql
new file mode 100644
index 00000000000..1c9a9ebf03d
--- /dev/null
+++ b/codegen/testserver/singlefile/defaults.graphql
@@ -0,0 +1,20 @@
+extend type Query {
+ defaultParameters(
+ falsyBoolean: Boolean = false
+ truthyBoolean: Boolean = true
+ ): DefaultParametersMirror!
+}
+
+extend type Mutation {
+ defaultInput(input: DefaultInput!): DefaultParametersMirror!
+}
+
+input DefaultInput {
+ falsyBoolean: Boolean = false
+ truthyBoolean: Boolean = true
+}
+
+type DefaultParametersMirror {
+ falsyBoolean: Boolean
+ truthyBoolean: Boolean
+}
diff --git a/codegen/testserver/singlefile/defaults_test.go b/codegen/testserver/singlefile/defaults_test.go
new file mode 100644
index 00000000000..4b403ad1515
--- /dev/null
+++ b/codegen/testserver/singlefile/defaults_test.go
@@ -0,0 +1,68 @@
+package singlefile
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func assertDefaults(t *testing.T, ret *DefaultParametersMirror) {
+ require.NotNil(t, ret)
+ require.NotNil(t, ret.FalsyBoolean)
+ require.Equal(t, *ret.FalsyBoolean, false)
+ require.NotNil(t, ret.TruthyBoolean)
+ require.Equal(t, *ret.TruthyBoolean, true)
+}
+
+func TestDefaults(t *testing.T) {
+ resolvers := &Stub{}
+ srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))
+ c := client.New(srv)
+
+ t.Run("default field parameters", func(t *testing.T) {
+ resolvers.QueryResolver.DefaultParameters = func(
+ ctx context.Context,
+ falsyBoolean, truthyBoolean *bool,
+ ) (*DefaultParametersMirror, error) {
+ return &DefaultParametersMirror{
+ FalsyBoolean: falsyBoolean,
+ TruthyBoolean: truthyBoolean,
+ }, nil
+ }
+
+ var resp struct{ DefaultParameters *DefaultParametersMirror }
+ err := c.Post(`query {
+ defaultParameters {
+ falsyBoolean
+ truthyBoolean
+ }
+ }`, &resp)
+ require.NoError(t, err)
+ assertDefaults(t, resp.DefaultParameters)
+ })
+
+ t.Run("default input fields", func(t *testing.T) {
+ resolvers.MutationResolver.DefaultInput = func(
+ ctx context.Context,
+ input DefaultInput,
+ ) (*DefaultParametersMirror, error) {
+ return &DefaultParametersMirror{
+ FalsyBoolean: input.FalsyBoolean,
+ TruthyBoolean: input.TruthyBoolean,
+ }, nil
+ }
+
+ var resp struct{ DefaultInput *DefaultParametersMirror }
+ err := c.Post(`mutation {
+ defaultInput(input: {}) {
+ falsyBoolean
+ truthyBoolean
+ }
+ }`, &resp)
+ require.NoError(t, err)
+ assertDefaults(t, resp.DefaultInput)
+ })
+}
diff --git a/codegen/testserver/singlefile/directive.graphql b/codegen/testserver/singlefile/directive.graphql
new file mode 100644
index 00000000000..8cf2470986e
--- /dev/null
+++ b/codegen/testserver/singlefile/directive.graphql
@@ -0,0 +1,54 @@
+directive @length(min: Int!, max: Int, message: String) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION
+directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION
+directive @custom on ARGUMENT_DEFINITION
+directive @logged(id: UUID!) on FIELD
+directive @toNull on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION
+directive @directive1 on FIELD_DEFINITION
+directive @directive2 on FIELD_DEFINITION
+directive @directive3 on INPUT_OBJECT
+directive @unimplemented on FIELD_DEFINITION
+directive @order1(location: String!) repeatable on FIELD_DEFINITION | OBJECT
+directive @order2(location: String!) on OBJECT
+
+extend type Query {
+ directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String
+ directiveNullableArg(arg: Int @range(min:0), arg2: Int @range, arg3: String @toNull): String
+ directiveInputNullable(arg: InputDirectives): String
+ directiveInput(arg: InputDirectives!): String
+ directiveInputType(arg: InnerInput! @custom): String
+ directiveObject: ObjectDirectives @order1(location: "Query_field")
+ directiveObjectWithCustomGoModel: ObjectDirectivesWithCustomGoModel
+ directiveFieldDef(ret: String!): String! @length(min: 1, message: "not valid")
+ directiveField: String
+ directiveDouble: String @directive1 @directive2
+ directiveUnimplemented: String @unimplemented
+}
+
+extend type Subscription {
+ directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String
+ directiveNullableArg(arg: Int @range(min:0), arg2: Int @range, arg3: String @toNull): String
+ directiveDouble: String @directive1 @directive2
+ directiveUnimplemented: String @unimplemented
+}
+
+input InputDirectives @directive3 {
+ text: String! @length(min: 0, max: 7, message: "not valid")
+ nullableText: String @toNull
+ inner: InnerDirectives!
+ innerNullable: InnerDirectives
+ thirdParty: ThirdParty @length(min: 0, max: 7)
+}
+
+input InnerDirectives {
+ message: String! @length(min: 1, message: "not valid")
+}
+
+type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2") @order2(location: "order2_1") {
+ text: String! @length(min: 0, max: 7, message: "not valid")
+ nullableText: String @toNull
+ order: [String!]!
+}
+
+type ObjectDirectivesWithCustomGoModel {
+ nullableText: String @toNull
+}
diff --git a/codegen/testserver/directive_test.go b/codegen/testserver/singlefile/directive_test.go
similarity index 97%
rename from codegen/testserver/directive_test.go
rename to codegen/testserver/singlefile/directive_test.go
index 32015005104..69f9bab337d 100644
--- a/codegen/testserver/directive_test.go
+++ b/codegen/testserver/singlefile/directive_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
@@ -162,6 +162,9 @@ func TestDirectives(t *testing.T) {
Directive2: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
return next(ctx)
},
+ Directive3: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
+ return next(ctx)
+ },
Order1: func(ctx context.Context, obj interface{}, next graphql.Resolver, location string) (res interface{}, err error) {
order := []string{location}
res, err = next(ctx)
@@ -387,8 +390,9 @@ func TestDirectives(t *testing.T) {
require.Equal(t, "Ok", resp.DirectiveObject.Text)
require.True(t, resp.DirectiveObject.NullableText == nil)
require.Equal(t, "Query_field", resp.DirectiveObject.Order[0])
- require.Equal(t, "ObjectDirectives_object_2", resp.DirectiveObject.Order[1])
- require.Equal(t, "ObjectDirectives_object_1", resp.DirectiveObject.Order[2])
+ require.Equal(t, "order2_1", resp.DirectiveObject.Order[1])
+ require.Equal(t, "order1_2", resp.DirectiveObject.Order[2])
+ require.Equal(t, "order1_1", resp.DirectiveObject.Order[3])
})
t.Run("when directive returns nil & custom go field is not nilable", func(t *testing.T) {
var resp struct {
diff --git a/codegen/testserver/embedded.go b/codegen/testserver/singlefile/embedded.go
similarity index 98%
rename from codegen/testserver/embedded.go
rename to codegen/testserver/singlefile/embedded.go
index 2052281d884..76206737b92 100644
--- a/codegen/testserver/embedded.go
+++ b/codegen/testserver/singlefile/embedded.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
// EmbeddedCase1 model
type EmbeddedCase1 struct {
diff --git a/codegen/testserver/embedded.graphql b/codegen/testserver/singlefile/embedded.graphql
similarity index 60%
rename from codegen/testserver/embedded.graphql
rename to codegen/testserver/singlefile/embedded.graphql
index 99cbd61c7c3..8445c056b6a 100644
--- a/codegen/testserver/embedded.graphql
+++ b/codegen/testserver/singlefile/embedded.graphql
@@ -4,14 +4,14 @@ extend type Query {
embeddedCase3: EmbeddedCase3
}
-type EmbeddedCase1 @goModel(model:"testserver.EmbeddedCase1") {
+type EmbeddedCase1 @goModel(model:"singlefile.EmbeddedCase1") {
exportedEmbeddedPointerExportedMethod: String!
}
-type EmbeddedCase2 @goModel(model:"testserver.EmbeddedCase2") {
+type EmbeddedCase2 @goModel(model:"singlefile.EmbeddedCase2") {
unexportedEmbeddedPointerExportedMethod: String!
}
-type EmbeddedCase3 @goModel(model:"testserver.EmbeddedCase3") {
+type EmbeddedCase3 @goModel(model:"singlefile.EmbeddedCase3") {
unexportedEmbeddedInterfaceExportedMethod: String!
}
diff --git a/codegen/testserver/embedded_test.go b/codegen/testserver/singlefile/embedded_test.go
similarity index 99%
rename from codegen/testserver/embedded_test.go
rename to codegen/testserver/singlefile/embedded_test.go
index 7760375fb7f..dd9ededd14a 100644
--- a/codegen/testserver/embedded_test.go
+++ b/codegen/testserver/singlefile/embedded_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/singlefile/enum.graphql b/codegen/testserver/singlefile/enum.graphql
new file mode 100644
index 00000000000..08559b65c6f
--- /dev/null
+++ b/codegen/testserver/singlefile/enum.graphql
@@ -0,0 +1,12 @@
+enum EnumTest {
+ OK
+ NG
+}
+
+input InputWithEnumValue {
+ enum: EnumTest!
+}
+
+extend type Query {
+ enumInInput(input: InputWithEnumValue): EnumTest!
+}
diff --git a/codegen/testserver/enums_test.go b/codegen/testserver/singlefile/enums_test.go
similarity index 98%
rename from codegen/testserver/enums_test.go
rename to codegen/testserver/singlefile/enums_test.go
index e16c34c849b..af13aa1a49a 100644
--- a/codegen/testserver/enums_test.go
+++ b/codegen/testserver/singlefile/enums_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/generated.go b/codegen/testserver/singlefile/generated.go
similarity index 75%
rename from codegen/testserver/generated.go
rename to codegen/testserver/singlefile/generated.go
index ea3c2f48547..6452652234e 100644
--- a/codegen/testserver/generated.go
+++ b/codegen/testserver/singlefile/generated.go
@@ -1,6 +1,6 @@
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
-package testserver
+package singlefile
import (
"bytes"
@@ -13,9 +13,9 @@ import (
"sync/atomic"
"time"
- introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection"
- invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename"
- "github.com/99designs/gqlgen/codegen/testserver/otherpkg"
+ introspection1 "github.com/99designs/gqlgen/codegen/testserver/singlefile/introspection"
+ invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/singlefile/invalid-packagename"
+ "github.com/99designs/gqlgen/codegen/testserver/singlefile/otherpkg"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
gqlparser "github.com/vektah/gqlparser/v2"
@@ -60,6 +60,7 @@ type DirectiveRoot struct {
Custom func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
Directive1 func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
Directive2 func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
+ Directive3 func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message *string) (res interface{}, err error)
Logged func(ctx context.Context, obj interface{}, next graphql.Resolver, id string) (res interface{}, err error)
MakeNil func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
@@ -112,8 +113,9 @@ type ComplexityRoot struct {
}
Circle struct {
- Area func(childComplexity int) int
- Radius func(childComplexity int) int
+ Area func(childComplexity int) int
+ Coordinates func(childComplexity int) int
+ Radius func(childComplexity int) int
}
ConcreteNodeA struct {
@@ -127,14 +129,24 @@ type ComplexityRoot struct {
ID func(childComplexity int) int
}
- ContentPost struct {
+ Content_Post struct {
Foo func(childComplexity int) int
}
- ContentUser struct {
+ Content_User struct {
Foo func(childComplexity int) int
}
+ Coordinates struct {
+ X func(childComplexity int) int
+ Y func(childComplexity int) int
+ }
+
+ DefaultParametersMirror struct {
+ FalsyBoolean func(childComplexity int) int
+ TruthyBoolean func(childComplexity int) int
+ }
+
Dog struct {
DogBreed func(childComplexity int) int
Species func(childComplexity int) int
@@ -216,6 +228,8 @@ type ComplexityRoot struct {
}
Mutation struct {
+ DefaultInput func(childComplexity int, input DefaultInput) int
+ UpdatePtrToPtr func(childComplexity int, input UpdatePtrToPtrOuter) int
UpdateSomething func(childComplexity int, input SpecialInput) int
}
@@ -256,10 +270,26 @@ type ComplexityRoot struct {
Value func(childComplexity int) int
}
+ PtrToPtrInner struct {
+ Key func(childComplexity int) int
+ Value func(childComplexity int) int
+ }
+
+ PtrToPtrOuter struct {
+ Inner func(childComplexity int) int
+ Name func(childComplexity int) int
+ StupidInner func(childComplexity int) int
+ }
+
+ PtrToSliceContainer struct {
+ PtrToSlice func(childComplexity int) int
+ }
+
Query struct {
Animal func(childComplexity int) int
Autobind func(childComplexity int) int
Collision func(childComplexity int) int
+ DefaultParameters func(childComplexity int, falsyBoolean *bool, truthyBoolean *bool) int
DefaultScalar func(childComplexity int, arg string) int
DeprecatedField func(childComplexity int) int
DirectiveArg func(childComplexity int, arg string) int
@@ -278,8 +308,11 @@ type ComplexityRoot struct {
EmbeddedCase3 func(childComplexity int) int
EnumInInput func(childComplexity int, input *InputWithEnumValue) int
ErrorBubble func(childComplexity int) int
+ ErrorBubbleList func(childComplexity int) int
+ ErrorList func(childComplexity int) int
Errors func(childComplexity int) int
Fallback func(childComplexity int, arg FallbackToStringEncoding) int
+ Infinity func(childComplexity int) int
InputNullableSlice func(childComplexity int, arg []string) int
InputSlice func(childComplexity int, arg []string) int
InvalidIdentifier func(childComplexity int) int
@@ -300,12 +333,17 @@ type ComplexityRoot struct {
Panics func(childComplexity int) int
PrimitiveObject func(childComplexity int) int
PrimitiveStringObject func(childComplexity int) int
+ PtrToSliceContainer func(childComplexity int) int
Recursive func(childComplexity int, input *RecursiveInputSlice) int
ScalarSlice func(childComplexity int) int
ShapeUnion func(childComplexity int) int
Shapes func(childComplexity int) int
Slices func(childComplexity int) int
+ StringFromContextFunction func(childComplexity int) int
+ StringFromContextInterface func(childComplexity int) int
User func(childComplexity int, id int) int
+ VOkCaseNil func(childComplexity int) int
+ VOkCaseValue func(childComplexity int) int
Valid func(childComplexity int) int
ValidType func(childComplexity int) int
WrappedMap func(childComplexity int) int
@@ -315,9 +353,10 @@ type ComplexityRoot struct {
}
Rectangle struct {
- Area func(childComplexity int) int
- Length func(childComplexity int) int
- Width func(childComplexity int) int
+ Area func(childComplexity int) int
+ Coordinates func(childComplexity int) int
+ Length func(childComplexity int) int
+ Width func(childComplexity int) int
}
Slices struct {
@@ -344,6 +383,14 @@ type ComplexityRoot struct {
Updated func(childComplexity int) int
}
+ VOkCaseNil struct {
+ Value func(childComplexity int) int
+ }
+
+ VOkCaseValue struct {
+ Value func(childComplexity int) int
+ }
+
ValidType struct {
DifferentCase func(childComplexity int) int
DifferentCaseOld func(childComplexity int) int
@@ -398,7 +445,9 @@ type ModelMethodsResolver interface {
ResolverField(ctx context.Context, obj *ModelMethods) (bool, error)
}
type MutationResolver interface {
+ DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error)
UpdateSomething(ctx context.Context, input SpecialInput) (string, error)
+ UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error)
}
type OverlappingFieldsResolver interface {
OldFoo(ctx context.Context, obj *OverlappingFields) (int, error)
@@ -432,6 +481,7 @@ type QueryResolver interface {
Autobind(ctx context.Context) (*Autobind, error)
DeprecatedField(ctx context.Context) (string, error)
Overlapping(ctx context.Context) (*OverlappingFields, error)
+ DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error)
DirectiveArg(ctx context.Context, arg string) (*string, error)
DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error)
DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error)
@@ -457,16 +507,24 @@ type QueryResolver interface {
MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error)
MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error)
ErrorBubble(ctx context.Context) (*Error, error)
+ ErrorBubbleList(ctx context.Context) ([]*Error, error)
+ ErrorList(ctx context.Context) ([]*Error, error)
Errors(ctx context.Context) (*Errors, error)
Valid(ctx context.Context) (string, error)
Panics(ctx context.Context) (*Panics, error)
PrimitiveObject(ctx context.Context) ([]Primitive, error)
PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error)
+ PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error)
+ Infinity(ctx context.Context) (float64, error)
+ StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error)
+ StringFromContextFunction(ctx context.Context) (string, error)
DefaultScalar(ctx context.Context, arg string) (string, error)
Slices(ctx context.Context) (*Slices, error)
ScalarSlice(ctx context.Context) ([]byte, error)
Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error)
OptionalUnion(ctx context.Context) (TestUnion, error)
+ VOkCaseValue(ctx context.Context) (*VOkCaseValue, error)
+ VOkCaseNil(ctx context.Context) (*VOkCaseNil, error)
ValidType(ctx context.Context) (*ValidType, error)
WrappedStruct(ctx context.Context) (*WrappedStruct, error)
WrappedScalar(ctx context.Context) (otherpkg.Scalar, error)
@@ -619,6 +677,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Circle.Area(childComplexity), true
+ case "Circle.coordinates":
+ if e.complexity.Circle.Coordinates == nil {
+ break
+ }
+
+ return e.complexity.Circle.Coordinates(childComplexity), true
+
case "Circle.radius":
if e.complexity.Circle.Radius == nil {
break
@@ -662,18 +727,46 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.ConcreteNodeInterface.ID(childComplexity), true
case "Content_Post.foo":
- if e.complexity.ContentPost.Foo == nil {
+ if e.complexity.Content_Post.Foo == nil {
break
}
- return e.complexity.ContentPost.Foo(childComplexity), true
+ return e.complexity.Content_Post.Foo(childComplexity), true
case "Content_User.foo":
- if e.complexity.ContentUser.Foo == nil {
+ if e.complexity.Content_User.Foo == nil {
+ break
+ }
+
+ return e.complexity.Content_User.Foo(childComplexity), true
+
+ case "Coordinates.x":
+ if e.complexity.Coordinates.X == nil {
+ break
+ }
+
+ return e.complexity.Coordinates.X(childComplexity), true
+
+ case "Coordinates.y":
+ if e.complexity.Coordinates.Y == nil {
+ break
+ }
+
+ return e.complexity.Coordinates.Y(childComplexity), true
+
+ case "DefaultParametersMirror.falsyBoolean":
+ if e.complexity.DefaultParametersMirror.FalsyBoolean == nil {
+ break
+ }
+
+ return e.complexity.DefaultParametersMirror.FalsyBoolean(childComplexity), true
+
+ case "DefaultParametersMirror.truthyBoolean":
+ if e.complexity.DefaultParametersMirror.TruthyBoolean == nil {
break
}
- return e.complexity.ContentUser.Foo(childComplexity), true
+ return e.complexity.DefaultParametersMirror.TruthyBoolean(childComplexity), true
case "Dog.dogBreed":
if e.complexity.Dog.DogBreed == nil {
@@ -878,6 +971,30 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.ModelMethods.WithContext(childComplexity), true
+ case "Mutation.defaultInput":
+ if e.complexity.Mutation.DefaultInput == nil {
+ break
+ }
+
+ args, err := ec.field_Mutation_defaultInput_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Mutation.DefaultInput(childComplexity, args["input"].(DefaultInput)), true
+
+ case "Mutation.updatePtrToPtr":
+ if e.complexity.Mutation.UpdatePtrToPtr == nil {
+ break
+ }
+
+ args, err := ec.field_Mutation_updatePtrToPtr_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Mutation.UpdatePtrToPtr(childComplexity, args["input"].(UpdatePtrToPtrOuter)), true
+
case "Mutation.updateSomething":
if e.complexity.Mutation.UpdateSomething == nil {
break
@@ -1012,6 +1129,48 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.PrimitiveString.Value(childComplexity), true
+ case "PtrToPtrInner.key":
+ if e.complexity.PtrToPtrInner.Key == nil {
+ break
+ }
+
+ return e.complexity.PtrToPtrInner.Key(childComplexity), true
+
+ case "PtrToPtrInner.value":
+ if e.complexity.PtrToPtrInner.Value == nil {
+ break
+ }
+
+ return e.complexity.PtrToPtrInner.Value(childComplexity), true
+
+ case "PtrToPtrOuter.inner":
+ if e.complexity.PtrToPtrOuter.Inner == nil {
+ break
+ }
+
+ return e.complexity.PtrToPtrOuter.Inner(childComplexity), true
+
+ case "PtrToPtrOuter.name":
+ if e.complexity.PtrToPtrOuter.Name == nil {
+ break
+ }
+
+ return e.complexity.PtrToPtrOuter.Name(childComplexity), true
+
+ case "PtrToPtrOuter.stupidInner":
+ if e.complexity.PtrToPtrOuter.StupidInner == nil {
+ break
+ }
+
+ return e.complexity.PtrToPtrOuter.StupidInner(childComplexity), true
+
+ case "PtrToSliceContainer.ptrToSlice":
+ if e.complexity.PtrToSliceContainer.PtrToSlice == nil {
+ break
+ }
+
+ return e.complexity.PtrToSliceContainer.PtrToSlice(childComplexity), true
+
case "Query.animal":
if e.complexity.Query.Animal == nil {
break
@@ -1033,6 +1192,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.Collision(childComplexity), true
+ case "Query.defaultParameters":
+ if e.complexity.Query.DefaultParameters == nil {
+ break
+ }
+
+ args, err := ec.field_Query_defaultParameters_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Query.DefaultParameters(childComplexity, args["falsyBoolean"].(*bool), args["truthyBoolean"].(*bool)), true
+
case "Query.defaultScalar":
if e.complexity.Query.DefaultScalar == nil {
break
@@ -1199,6 +1370,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.ErrorBubble(childComplexity), true
+ case "Query.errorBubbleList":
+ if e.complexity.Query.ErrorBubbleList == nil {
+ break
+ }
+
+ return e.complexity.Query.ErrorBubbleList(childComplexity), true
+
+ case "Query.errorList":
+ if e.complexity.Query.ErrorList == nil {
+ break
+ }
+
+ return e.complexity.Query.ErrorList(childComplexity), true
+
case "Query.errors":
if e.complexity.Query.Errors == nil {
break
@@ -1218,6 +1403,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.Fallback(childComplexity, args["arg"].(FallbackToStringEncoding)), true
+ case "Query.infinity":
+ if e.complexity.Query.Infinity == nil {
+ break
+ }
+
+ return e.complexity.Query.Infinity(childComplexity), true
+
case "Query.inputNullableSlice":
if e.complexity.Query.InputNullableSlice == nil {
break
@@ -1393,6 +1585,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.PrimitiveStringObject(childComplexity), true
+ case "Query.ptrToSliceContainer":
+ if e.complexity.Query.PtrToSliceContainer == nil {
+ break
+ }
+
+ return e.complexity.Query.PtrToSliceContainer(childComplexity), true
+
case "Query.recursive":
if e.complexity.Query.Recursive == nil {
break
@@ -1433,6 +1632,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.Slices(childComplexity), true
+ case "Query.stringFromContextFunction":
+ if e.complexity.Query.StringFromContextFunction == nil {
+ break
+ }
+
+ return e.complexity.Query.StringFromContextFunction(childComplexity), true
+
+ case "Query.stringFromContextInterface":
+ if e.complexity.Query.StringFromContextInterface == nil {
+ break
+ }
+
+ return e.complexity.Query.StringFromContextInterface(childComplexity), true
+
case "Query.user":
if e.complexity.Query.User == nil {
break
@@ -1445,6 +1658,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.User(childComplexity, args["id"].(int)), true
+ case "Query.vOkCaseNil":
+ if e.complexity.Query.VOkCaseNil == nil {
+ break
+ }
+
+ return e.complexity.Query.VOkCaseNil(childComplexity), true
+
+ case "Query.vOkCaseValue":
+ if e.complexity.Query.VOkCaseValue == nil {
+ break
+ }
+
+ return e.complexity.Query.VOkCaseValue(childComplexity), true
+
case "Query.valid":
if e.complexity.Query.Valid == nil {
break
@@ -1494,6 +1721,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Rectangle.Area(childComplexity), true
+ case "Rectangle.coordinates":
+ if e.complexity.Rectangle.Coordinates == nil {
+ break
+ }
+
+ return e.complexity.Rectangle.Coordinates(childComplexity), true
+
case "Rectangle.length":
if e.complexity.Rectangle.Length == nil {
break
@@ -1623,6 +1857,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.User.Updated(childComplexity), true
+ case "VOkCaseNil.value":
+ if e.complexity.VOkCaseNil.Value == nil {
+ break
+ }
+
+ return e.complexity.VOkCaseNil.Value(childComplexity), true
+
+ case "VOkCaseValue.value":
+ if e.complexity.VOkCaseValue.Value == nil {
+ break
+ }
+
+ return e.complexity.VOkCaseValue.Value(childComplexity), true
+
case "ValidType.differentCase":
if e.complexity.ValidType.DifferentCase == nil {
break
@@ -1828,6 +2076,27 @@ type OverlappingFields {
newFoo: Int!
new_foo: Int!
}
+`, BuiltIn: false},
+ {Name: "defaults.graphql", Input: `extend type Query {
+ defaultParameters(
+ falsyBoolean: Boolean = false
+ truthyBoolean: Boolean = true
+ ): DefaultParametersMirror!
+}
+
+extend type Mutation {
+ defaultInput(input: DefaultInput!): DefaultParametersMirror!
+}
+
+input DefaultInput {
+ falsyBoolean: Boolean = false
+ truthyBoolean: Boolean = true
+}
+
+type DefaultParametersMirror {
+ falsyBoolean: Boolean
+ truthyBoolean: Boolean
+}
`, BuiltIn: false},
{Name: "directive.graphql", Input: `directive @length(min: Int!, max: Int, message: String) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION
directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION
@@ -1836,8 +2105,9 @@ directive @logged(id: UUID!) on FIELD
directive @toNull on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION
directive @directive1 on FIELD_DEFINITION
directive @directive2 on FIELD_DEFINITION
+directive @directive3 on INPUT_OBJECT
directive @unimplemented on FIELD_DEFINITION
-directive @order1(location: String!) on FIELD_DEFINITION | OBJECT
+directive @order1(location: String!) repeatable on FIELD_DEFINITION | OBJECT
directive @order2(location: String!) on OBJECT
extend type Query {
@@ -1861,7 +2131,7 @@ extend type Subscription {
directiveUnimplemented: String @unimplemented
}
-input InputDirectives {
+input InputDirectives @directive3 {
text: String! @length(min: 0, max: 7, message: "not valid")
nullableText: String @toNull
inner: InnerDirectives!
@@ -1873,7 +2143,7 @@ input InnerDirectives {
message: String! @length(min: 1, message: "not valid")
}
-type ObjectDirectives @order1(location: "ObjectDirectives_object_1") @order2(location: "ObjectDirectives_object_2") {
+type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2") @order2(location: "order2_1") {
text: String! @length(min: 0, max: 7, message: "not valid")
nullableText: String @toNull
order: [String!]!
@@ -1889,15 +2159,15 @@ type ObjectDirectivesWithCustomGoModel {
embeddedCase3: EmbeddedCase3
}
-type EmbeddedCase1 @goModel(model:"testserver.EmbeddedCase1") {
+type EmbeddedCase1 @goModel(model:"singlefile.EmbeddedCase1") {
exportedEmbeddedPointerExportedMethod: String!
}
-type EmbeddedCase2 @goModel(model:"testserver.EmbeddedCase2") {
+type EmbeddedCase2 @goModel(model:"singlefile.EmbeddedCase2") {
unexportedEmbeddedPointerExportedMethod: String!
}
-type EmbeddedCase3 @goModel(model:"testserver.EmbeddedCase3") {
+type EmbeddedCase3 @goModel(model:"singlefile.EmbeddedCase3") {
unexportedEmbeddedInterfaceExportedMethod: String!
}
`, BuiltIn: false},
@@ -1943,19 +2213,27 @@ type Cat implements Animal {
catBreed: String!
}
+type Coordinates {
+ x: Float!
+ y: Float!
+}
interface Shape {
area: Float
+ coordinates: Coordinates
}
+
type Circle implements Shape {
radius: Float
area: Float
+ coordinates: Coordinates
}
type Rectangle implements Shape {
length: Float
width: Float
area: Float
+ coordinates: Coordinates
}
-union ShapeUnion @goModel(model:"testserver.ShapeUnion") = Circle | Rectangle
+union ShapeUnion @goModel(model: "singlefile.ShapeUnion") = Circle | Rectangle
directive @makeNil on FIELD_DEFINITION
directive @makeTypedNil on FIELD_DEFINITION
@@ -1971,7 +2249,7 @@ type ConcreteNodeA implements Node {
name: String!
}
-""" Implements the Node interface with another interface """
+" Implements the Node interface with another interface "
type ConcreteNodeInterface implements Node {
id: ID!
child: Node!
@@ -2039,6 +2317,8 @@ input NestedInput {
`, BuiltIn: false},
{Name: "nulls.graphql", Input: `extend type Query {
errorBubble: Error
+ errorBubbleList: [Error!]
+ errorList: [Error]
errors: Errors
valid: String!
}
@@ -2086,6 +2366,49 @@ type PrimitiveString {
doubled: String!
len: Int!
}
+`, BuiltIn: false},
+ {Name: "ptr_to_ptr_input.graphql", Input: `type PtrToPtrOuter {
+ name: String!
+ inner: PtrToPtrInner
+ stupidInner: PtrToPtrInner
+}
+
+type PtrToPtrInner {
+ key: String!
+ value: String!
+}
+
+input UpdatePtrToPtrOuter {
+ name: String
+ inner: UpdatePtrToPtrInner
+ stupidInner: UpdatePtrToPtrInner
+}
+
+input UpdatePtrToPtrInner {
+ key: String
+ value: String
+}
+
+extend type Mutation {
+ updatePtrToPtr(input: UpdatePtrToPtrOuter!): PtrToPtrOuter!
+}
+`, BuiltIn: false},
+ {Name: "ptr_to_slice.graphql", Input: `type PtrToSliceContainer {
+ ptrToSlice: [String!]
+}
+
+extend type Query {
+ ptrToSliceContainer: PtrToSliceContainer!
+}
+`, BuiltIn: false},
+ {Name: "scalar_context.graphql", Input: `extend type Query {
+ infinity: Float!
+ stringFromContextInterface: StringFromContextInterface!
+ stringFromContextFunction: StringFromContextFunction!
+}
+
+scalar StringFromContextInterface
+scalar StringFromContextFunction
`, BuiltIn: false},
{Name: "scalar_default.graphql", Input: `extend type Query {
defaultScalar(arg: DefaultScalarImplementation! = "default"): DefaultScalarImplementation!
@@ -2098,15 +2421,21 @@ type EmbeddedDefaultScalar {
value: DefaultScalarImplementation
}
`, BuiltIn: false},
- {Name: "schema.graphql", Input: `directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION
-directive @goField(forceResolver: Boolean, name: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
+ {Name: "schema.graphql", Input: `directive @goModel(
+ model: String
+ models: [String!]
+) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION
+directive @goField(
+ forceResolver: Boolean
+ name: String
+) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
type Query {
invalidIdentifier: InvalidIdentifier
collision: It
mapInput(input: Changes): Boolean
recursive(input: RecursiveInputSlice): Boolean
- nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean
+ nestedInputs(input: [[OuterInput]] = [[{ inner: { id: 1 } }]]): Boolean
nestedOutputs: [[OuterObject]]
modelMethods: ModelMethods
user(id: Int!): User!
@@ -2153,7 +2482,7 @@ type It {
id: ID!
}
-input Changes @goModel(model:"map[string]interface{}") {
+input Changes @goModel(model: "map[string]interface{}") {
a: Int
b: Int
}
@@ -2163,14 +2492,14 @@ input RecursiveInputSlice {
}
input InnerInput {
- id:Int!
+ id: Int!
}
input OuterInput {
inner: InnerInput!
}
-scalar ThirdParty @goModel(model:"testserver.ThirdParty")
+scalar ThirdParty @goModel(model:"singlefile.ThirdParty")
type OuterObject {
inner: InnerObject!
@@ -2184,7 +2513,7 @@ type ForcedResolver {
field: Circle @goField(forceResolver: true)
}
-type EmbeddedPointer @goModel(model:"testserver.EmbeddedPointerModel") {
+type EmbeddedPointer @goModel(model:"singlefile.EmbeddedPointerModel") {
ID: String
Title: String
}
@@ -2204,10 +2533,10 @@ scalar Time
}
type Slices {
- test1: [String]
- test2: [String!]
- test3: [String]!
- test4: [String!]!
+ test1: [String]
+ test2: [String!]
+ test3: [String]!
+ test4: [String!]!
}
scalar Bytes
@@ -2235,6 +2564,19 @@ union TestUnion = A | B
extend type Query {
optionalUnion: TestUnion
}
+`, BuiltIn: false},
+ {Name: "v-ok.graphql", Input: `extend type Query {
+ vOkCaseValue: VOkCaseValue
+ vOkCaseNil: VOkCaseNil
+}
+
+type VOkCaseValue @goModel(model:"singlefile.VOkCaseValue") {
+ value: String
+}
+
+type VOkCaseNil @goModel(model:"singlefile.VOkCaseNil") {
+ value: String
+}
`, BuiltIn: false},
{Name: "validtypes.graphql", Input: `extend type Query {
validType: ValidType
@@ -2447,13 +2789,43 @@ func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[stri
return args, nil
}
+func (ec *executionContext) field_Mutation_defaultInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 DefaultInput
+ if tmp, ok := rawArgs["input"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
+ arg0, err = ec.unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultInput(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["input"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Mutation_updatePtrToPtr_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 UpdatePtrToPtrOuter
+ if tmp, ok := rawArgs["input"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
+ arg0, err = ec.unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrOuter(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["input"] = arg0
+ return args, nil
+}
+
func (ec *executionContext) field_Mutation_updateSomething_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 SpecialInput
if tmp, ok := rawArgs["input"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
- arg0, err = ec.unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSpecialInput(ctx, tmp)
+ arg0, err = ec.unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSpecialInput(ctx, tmp)
if err != nil {
return nil, err
}
@@ -2468,7 +2840,7 @@ func (ec *executionContext) field_Panics_argUnmarshal_args(ctx context.Context,
var arg0 []MarshalPanic
if tmp, ok := rawArgs["u"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("u"))
- arg0, err = ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanicᚄ(ctx, tmp)
+ arg0, err = ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx, tmp)
if err != nil {
return nil, err
}
@@ -2483,7 +2855,7 @@ func (ec *executionContext) field_Panics_fieldFuncMarshal_args(ctx context.Conte
var arg0 []MarshalPanic
if tmp, ok := rawArgs["u"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("u"))
- arg0, err = ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanicᚄ(ctx, tmp)
+ arg0, err = ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx, tmp)
if err != nil {
return nil, err
}
@@ -2507,6 +2879,30 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs
return args, nil
}
+func (ec *executionContext) field_Query_defaultParameters_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 *bool
+ if tmp, ok := rawArgs["falsyBoolean"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("falsyBoolean"))
+ arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["falsyBoolean"] = arg0
+ var arg1 *bool
+ if tmp, ok := rawArgs["truthyBoolean"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("truthyBoolean"))
+ arg1, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["truthyBoolean"] = arg1
+ return args, nil
+}
+
func (ec *executionContext) field_Query_defaultScalar_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
@@ -2583,7 +2979,7 @@ func (ec *executionContext) field_Query_directiveInputNullable_args(ctx context.
var arg0 *InputDirectives
if tmp, ok := rawArgs["arg"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
- arg0, err = ec.unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx, tmp)
+ arg0, err = ec.unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputDirectives(ctx, tmp)
if err != nil {
return nil, err
}
@@ -2599,7 +2995,7 @@ func (ec *executionContext) field_Query_directiveInputType_args(ctx context.Cont
if tmp, ok := rawArgs["arg"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
directive0 := func(ctx context.Context) (interface{}, error) {
- return ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx, tmp)
+ return ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerInput(ctx, tmp)
}
directive1 := func(ctx context.Context) (interface{}, error) {
if ec.directives.Custom == nil {
@@ -2615,7 +3011,7 @@ func (ec *executionContext) field_Query_directiveInputType_args(ctx context.Cont
if data, ok := tmp.(InnerInput); ok {
arg0 = data
} else {
- return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver.InnerInput`, tmp))
+ return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver/singlefile.InnerInput`, tmp))
}
}
args["arg"] = arg0
@@ -2628,7 +3024,7 @@ func (ec *executionContext) field_Query_directiveInput_args(ctx context.Context,
var arg0 InputDirectives
if tmp, ok := rawArgs["arg"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
- arg0, err = ec.unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx, tmp)
+ arg0, err = ec.unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputDirectives(ctx, tmp)
if err != nil {
return nil, err
}
@@ -2729,7 +3125,7 @@ func (ec *executionContext) field_Query_enumInInput_args(ctx context.Context, ra
var arg0 *InputWithEnumValue
if tmp, ok := rawArgs["input"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
- arg0, err = ec.unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputWithEnumValue(ctx, tmp)
+ arg0, err = ec.unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputWithEnumValue(ctx, tmp)
if err != nil {
return nil, err
}
@@ -2744,7 +3140,7 @@ func (ec *executionContext) field_Query_fallback_args(ctx context.Context, rawAr
var arg0 FallbackToStringEncoding
if tmp, ok := rawArgs["arg"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg"))
- arg0, err = ec.unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx, tmp)
+ arg0, err = ec.unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFallbackToStringEncoding(ctx, tmp)
if err != nil {
return nil, err
}
@@ -2804,7 +3200,7 @@ func (ec *executionContext) field_Query_mapNestedStringInterface_args(ctx contex
var arg0 *NestedMapInput
if tmp, ok := rawArgs["in"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("in"))
- arg0, err = ec.unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNestedMapInput(ctx, tmp)
+ arg0, err = ec.unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNestedMapInput(ctx, tmp)
if err != nil {
return nil, err
}
@@ -2834,7 +3230,7 @@ func (ec *executionContext) field_Query_nestedInputs_args(ctx context.Context, r
var arg0 [][]*OuterInput
if tmp, ok := rawArgs["input"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
- arg0, err = ec.unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx, tmp)
+ arg0, err = ec.unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx, tmp)
if err != nil {
return nil, err
}
@@ -2864,7 +3260,7 @@ func (ec *executionContext) field_Query_recursive_args(ctx context.Context, rawA
var arg0 *RecursiveInputSlice
if tmp, ok := rawArgs["input"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
- arg0, err = ec.unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx, tmp)
+ arg0, err = ec.unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSlice(ctx, tmp)
if err != nil {
return nil, err
}
@@ -3260,7 +3656,7 @@ func (ec *executionContext) field_ValidType_validInputKeywords_args(ctx context.
var arg0 *ValidInput
if tmp, ok := rawArgs["input"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
- arg0, err = ec.unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidInput(ctx, tmp)
+ arg0, err = ec.unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐValidInput(ctx, tmp)
if err != nil {
return nil, err
}
@@ -3900,6 +4296,35 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll
return ec.marshalOFloat2float64(ctx, field.Selections, res)
}
+func (ec *executionContext) _Circle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Circle",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Coordinates, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(Coordinates)
+ fc.Result = res
+ return ec.marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCoordinates(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _ConcreteNodeA_id(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -3961,7 +4386,7 @@ func (ec *executionContext) _ConcreteNodeA_child(ctx context.Context, field grap
}
res := resTmp.(Node)
fc.Result = res
- return ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNode(ctx, field.Selections, res)
+ return ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNode(ctx, field.Selections, res)
}
func (ec *executionContext) _ConcreteNodeA_name(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) {
@@ -4057,7 +4482,7 @@ func (ec *executionContext) _ConcreteNodeInterface_child(ctx context.Context, fi
}
res := resTmp.(Node)
fc.Result = res
- return ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNode(ctx, field.Selections, res)
+ return ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNode(ctx, field.Selections, res)
}
func (ec *executionContext) _Content_Post_foo(ctx context.Context, field graphql.CollectedField, obj *ContentPost) (ret graphql.Marshaler) {
@@ -4118,7 +4543,7 @@ func (ec *executionContext) _Content_User_foo(ctx context.Context, field graphql
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
-func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) {
+func (ec *executionContext) _Coordinates_x(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -4126,7 +4551,7 @@ func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.Coll
}
}()
fc := &graphql.FieldContext{
- Object: "Dog",
+ Object: "Coordinates",
Field: field,
Args: nil,
IsMethod: false,
@@ -4136,7 +4561,7 @@ func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.Coll
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return obj.Species, nil
+ return obj.X, nil
})
if resTmp == nil {
@@ -4145,12 +4570,12 @@ func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.Coll
}
return graphql.Null
}
- res := resTmp.(string)
+ res := resTmp.(float64)
fc.Result = res
- return ec.marshalNString2string(ctx, field.Selections, res)
+ return ec.marshalNFloat2float64(ctx, field.Selections, res)
}
-func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) {
+func (ec *executionContext) _Coordinates_y(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -4158,7 +4583,7 @@ func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.Col
}
}()
fc := &graphql.FieldContext{
- Object: "Dog",
+ Object: "Coordinates",
Field: field,
Args: nil,
IsMethod: false,
@@ -4168,7 +4593,7 @@ func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.Col
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return obj.DogBreed, nil
+ return obj.Y, nil
})
if resTmp == nil {
@@ -4177,12 +4602,12 @@ func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.Col
}
return graphql.Null
}
- res := resTmp.(string)
+ res := resTmp.(float64)
fc.Result = res
- return ec.marshalNString2string(ctx, field.Selections, res)
+ return ec.marshalNFloat2float64(ctx, field.Selections, res)
}
-func (ec *executionContext) _EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase1) (ret graphql.Marshaler) {
+func (ec *executionContext) _DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -4190,31 +4615,28 @@ func (ec *executionContext) _EmbeddedCase1_exportedEmbeddedPointerExportedMethod
}
}()
fc := &graphql.FieldContext{
- Object: "EmbeddedCase1",
+ Object: "DefaultParametersMirror",
Field: field,
Args: nil,
- IsMethod: true,
+ IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return obj.ExportedEmbeddedPointerExportedMethod(), nil
+ return obj.FalsyBoolean, nil
})
if resTmp == nil {
- if !graphql.HasFieldError(ctx, fc) {
- ec.Errorf(ctx, "must not be null")
- }
return graphql.Null
}
- res := resTmp.(string)
+ res := resTmp.(*bool)
fc.Result = res
- return ec.marshalNString2string(ctx, field.Selections, res)
+ return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
}
-func (ec *executionContext) _EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase2) (ret graphql.Marshaler) {
+func (ec *executionContext) _DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -4222,10 +4644,135 @@ func (ec *executionContext) _EmbeddedCase2_unexportedEmbeddedPointerExportedMeth
}
}()
fc := &graphql.FieldContext{
- Object: "EmbeddedCase2",
+ Object: "DefaultParametersMirror",
Field: field,
Args: nil,
- IsMethod: true,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.TruthyBoolean, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*bool)
+ fc.Result = res
+ return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Dog",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Species, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Dog",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.DogBreed, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase1) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "EmbeddedCase1",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ExportedEmbeddedPointerExportedMethod(), nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase2) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "EmbeddedCase2",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
IsResolver: false,
}
@@ -4519,7 +5066,7 @@ func (ec *executionContext) _Errors_a(ctx context.Context, field graphql.Collect
}
res := resTmp.(*Error)
fc.Result = res
- return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res)
+ return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res)
}
func (ec *executionContext) _Errors_b(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
@@ -4551,7 +5098,7 @@ func (ec *executionContext) _Errors_b(ctx context.Context, field graphql.Collect
}
res := resTmp.(*Error)
fc.Result = res
- return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res)
+ return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res)
}
func (ec *executionContext) _Errors_c(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
@@ -4583,7 +5130,7 @@ func (ec *executionContext) _Errors_c(ctx context.Context, field graphql.Collect
}
res := resTmp.(*Error)
fc.Result = res
- return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res)
+ return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res)
}
func (ec *executionContext) _Errors_d(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
@@ -4615,7 +5162,7 @@ func (ec *executionContext) _Errors_d(ctx context.Context, field graphql.Collect
}
res := resTmp.(*Error)
fc.Result = res
- return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res)
+ return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res)
}
func (ec *executionContext) _Errors_e(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
@@ -4647,7 +5194,7 @@ func (ec *executionContext) _Errors_e(ctx context.Context, field graphql.Collect
}
res := resTmp.(*Error)
fc.Result = res
- return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res)
+ return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res)
}
func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) (ret graphql.Marshaler) {
@@ -4676,7 +5223,7 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra
}
res := resTmp.(*Circle)
fc.Result = res
- return ec.marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx, field.Selections, res)
+ return ec.marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCircle(ctx, field.Selections, res)
}
func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) (ret graphql.Marshaler) {
@@ -4804,7 +5351,7 @@ func (ec *executionContext) _LoopA_b(ctx context.Context, field graphql.Collecte
}
res := resTmp.(*LoopB)
fc.Result = res
- return ec.marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopB(ctx, field.Selections, res)
+ return ec.marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐLoopB(ctx, field.Selections, res)
}
func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.CollectedField, obj *LoopB) (ret graphql.Marshaler) {
@@ -4836,7 +5383,7 @@ func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.Collecte
}
res := resTmp.(*LoopA)
fc.Result = res
- return ec.marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopA(ctx, field.Selections, res)
+ return ec.marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐLoopA(ctx, field.Selections, res)
}
func (ec *executionContext) _Map_id(ctx context.Context, field graphql.CollectedField, obj *Map) (ret graphql.Marshaler) {
@@ -5043,6 +5590,45 @@ func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
}
+func (ec *executionContext) _Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Mutation",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Mutation_defaultInput_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Mutation().DefaultInput(rctx, args["input"].(DefaultInput))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*DefaultParametersMirror)
+ fc.Result = res
+ return ec.marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultParametersMirror(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -5082,6 +5668,45 @@ func (ec *executionContext) _Mutation_updateSomething(ctx context.Context, field
return ec.marshalNString2string(ctx, field.Selections, res)
}
+func (ec *executionContext) _Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Mutation",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Mutation_updatePtrToPtr_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Mutation().UpdatePtrToPtr(rctx, args["input"].(UpdatePtrToPtrOuter))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*PtrToPtrOuter)
+ fc.Result = res
+ return ec.marshalNPtrToPtrOuter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrOuter(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _ObjectDirectives_text(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -5305,7 +5930,7 @@ func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphq
}
res := resTmp.(*InnerObject)
fc.Result = res
- return ec.marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx, field.Selections, res)
+ return ec.marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerObject(ctx, field.Selections, res)
}
func (ec *executionContext) _OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) {
@@ -5497,7 +6122,7 @@ func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, fiel
}
res := resTmp.([]MarshalPanic)
fc.Result = res
- return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanicᚄ(ctx, field.Selections, res)
+ return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) {
@@ -5536,7 +6161,7 @@ func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field
}
res := resTmp.([]MarshalPanic)
fc.Result = res
- return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanicᚄ(ctx, field.Selections, res)
+ return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) {
@@ -5738,7 +6363,7 @@ func (ec *executionContext) _PrimitiveString_len(ctx context.Context, field grap
return ec.marshalNInt2int(ctx, field.Selections, res)
}
-func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _PtrToPtrInner_key(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrInner) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -5746,28 +6371,31 @@ func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field
}
}()
fc := &graphql.FieldContext{
- Object: "Query",
+ Object: "PtrToPtrInner",
Field: field,
Args: nil,
- IsMethod: true,
- IsResolver: true,
+ IsMethod: false,
+ IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
- resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Query().InvalidIdentifier(rctx)
+ return obj.Key, nil
})
if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
return graphql.Null
}
- res := resTmp.(*invalid_packagename.InvalidIdentifier)
+ res := resTmp.(string)
fc.Result = res
- return ec.marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx, field.Selections, res)
+ return ec.marshalNString2string(ctx, field.Selections, res)
}
-func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _PtrToPtrInner_value(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrInner) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -5775,28 +6403,31 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.
}
}()
fc := &graphql.FieldContext{
- Object: "Query",
+ Object: "PtrToPtrInner",
Field: field,
Args: nil,
- IsMethod: true,
- IsResolver: true,
+ IsMethod: false,
+ IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
- resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Query().Collision(rctx)
+ return obj.Value, nil
})
if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
return graphql.Null
}
- res := resTmp.(*introspection1.It)
+ res := resTmp.(string)
fc.Result = res
- return ec.marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx, field.Selections, res)
+ return ec.marshalNString2string(ctx, field.Selections, res)
}
-func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _PtrToPtrOuter_name(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -5804,35 +6435,31 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C
}
}()
fc := &graphql.FieldContext{
- Object: "Query",
+ Object: "PtrToPtrOuter",
Field: field,
Args: nil,
- IsMethod: true,
- IsResolver: true,
+ IsMethod: false,
+ IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
- rawArgs := field.ArgumentMap(ec.Variables)
- args, err := ec.field_Query_mapInput_args(ctx, rawArgs)
- if err != nil {
- ec.Error(ctx, err)
- return graphql.Null
- }
- fc.Args = args
- resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Query().MapInput(rctx, args["input"].(map[string]interface{}))
+ return obj.Name, nil
})
if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
return graphql.Null
}
- res := resTmp.(*bool)
+ res := resTmp.(string)
fc.Result = res
- return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
+ return ec.marshalNString2string(ctx, field.Selections, res)
}
-func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _PtrToPtrOuter_inner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -5840,17 +6467,198 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.
}
}()
fc := &graphql.FieldContext{
- Object: "Query",
+ Object: "PtrToPtrOuter",
Field: field,
Args: nil,
- IsMethod: true,
- IsResolver: true,
+ IsMethod: false,
+ IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
- rawArgs := field.ArgumentMap(ec.Variables)
- args, err := ec.field_Query_recursive_args(ctx, rawArgs)
- if err != nil {
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Inner, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*PtrToPtrInner)
+ fc.Result = res
+ return ec.marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _PtrToPtrOuter_stupidInner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PtrToPtrOuter",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.StupidInner, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*******PtrToPtrInner)
+ fc.Result = res
+ return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _PtrToSliceContainer_ptrToSlice(ctx context.Context, field graphql.CollectedField, obj *PtrToSliceContainer) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PtrToSliceContainer",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.PtrToSlice, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*[]string)
+ fc.Result = res
+ return ec.marshalOString2ᚖᚕstringᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().InvalidIdentifier(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*invalid_packagename.InvalidIdentifier)
+ fc.Result = res
+ return ec.marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Collision(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*introspection1.It)
+ fc.Result = res
+ return ec.marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋintrospectionᚐIt(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_mapInput_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().MapInput(rctx, args["input"].(map[string]interface{}))
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*bool)
+ fc.Result = res
+ return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_recursive_args(ctx, rawArgs)
+ if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
@@ -5930,7 +6738,7 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap
}
res := resTmp.([][]*OuterObject)
fc.Result = res
- return ec.marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, field.Selections, res)
+ return ec.marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -5959,7 +6767,7 @@ func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graph
}
res := resTmp.(*ModelMethods)
fc.Result = res
- return ec.marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx, field.Selections, res)
+ return ec.marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐModelMethods(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -5998,7 +6806,7 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle
}
res := resTmp.(*User)
fc.Result = res
- return ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res)
+ return ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUser(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6144,7 +6952,7 @@ func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql
}
res := resTmp.(ShapeUnion)
fc.Result = res
- return ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShapeUnion(ctx, field.Selections, res)
+ return ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShapeUnion(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6173,7 +6981,7 @@ func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.C
}
res := resTmp.(*Autobind)
fc.Result = res
- return ec.marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAutobind(ctx, field.Selections, res)
+ return ec.marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐAutobind(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6234,7 +7042,46 @@ func (ec *executionContext) _Query_overlapping(ctx context.Context, field graphq
}
res := resTmp.(*OverlappingFields)
fc.Result = res
- return ec.marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOverlappingFields(ctx, field.Selections, res)
+ return ec.marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOverlappingFields(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_defaultParameters(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_defaultParameters_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DefaultParameters(rctx, args["falsyBoolean"].(*bool), args["truthyBoolean"].(*bool))
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*DefaultParametersMirror)
+ fc.Result = res
+ return ec.marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultParametersMirror(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6439,7 +7286,7 @@ func (ec *executionContext) _Query_directiveObject(ctx context.Context, field gr
return ec.resolvers.Query().DirectiveObject(rctx)
}
directive1 := func(ctx context.Context) (interface{}, error) {
- location, err := ec.unmarshalNString2string(ctx, "ObjectDirectives_object_1")
+ location, err := ec.unmarshalNString2string(ctx, "order1_1")
if err != nil {
return nil, err
}
@@ -6449,16 +7296,26 @@ func (ec *executionContext) _Query_directiveObject(ctx context.Context, field gr
return ec.directives.Order1(ctx, nil, directive0, location)
}
directive2 := func(ctx context.Context) (interface{}, error) {
- location, err := ec.unmarshalNString2string(ctx, "ObjectDirectives_object_2")
+ location, err := ec.unmarshalNString2string(ctx, "order1_2")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Order1 == nil {
+ return nil, errors.New("directive order1 is not implemented")
+ }
+ return ec.directives.Order1(ctx, nil, directive1, location)
+ }
+ directive3 := func(ctx context.Context) (interface{}, error) {
+ location, err := ec.unmarshalNString2string(ctx, "order2_1")
if err != nil {
return nil, err
}
if ec.directives.Order2 == nil {
return nil, errors.New("directive order2 is not implemented")
}
- return ec.directives.Order2(ctx, nil, directive1, location)
+ return ec.directives.Order2(ctx, nil, directive2, location)
}
- directive3 := func(ctx context.Context) (interface{}, error) {
+ directive4 := func(ctx context.Context) (interface{}, error) {
location, err := ec.unmarshalNString2string(ctx, "Query_field")
if err != nil {
return nil, err
@@ -6466,10 +7323,10 @@ func (ec *executionContext) _Query_directiveObject(ctx context.Context, field gr
if ec.directives.Order1 == nil {
return nil, errors.New("directive order1 is not implemented")
}
- return ec.directives.Order1(ctx, nil, directive2, location)
+ return ec.directives.Order1(ctx, nil, directive3, location)
}
- tmp, err := directive3(rctx)
+ tmp, err := directive4(rctx)
if err != nil {
return nil, graphql.ErrorOnPath(ctx, err)
}
@@ -6479,7 +7336,7 @@ func (ec *executionContext) _Query_directiveObject(ctx context.Context, field gr
if data, ok := tmp.(*ObjectDirectives); ok {
return data, nil
}
- return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver.ObjectDirectives`, tmp)
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver/singlefile.ObjectDirectives`, tmp)
})
if resTmp == nil {
@@ -6487,7 +7344,7 @@ func (ec *executionContext) _Query_directiveObject(ctx context.Context, field gr
}
res := resTmp.(*ObjectDirectives)
fc.Result = res
- return ec.marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐObjectDirectives(ctx, field.Selections, res)
+ return ec.marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐObjectDirectives(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_directiveObjectWithCustomGoModel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6516,7 +7373,7 @@ func (ec *executionContext) _Query_directiveObjectWithCustomGoModel(ctx context.
}
res := resTmp.(*ObjectDirectivesWithCustomGoModel)
fc.Result = res
- return ec.marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐObjectDirectivesWithCustomGoModel(ctx, field.Selections, res)
+ return ec.marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐObjectDirectivesWithCustomGoModel(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_directiveFieldDef(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6745,7 +7602,7 @@ func (ec *executionContext) _Query_embeddedCase1(ctx context.Context, field grap
}
res := resTmp.(*EmbeddedCase1)
fc.Result = res
- return ec.marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase1(ctx, field.Selections, res)
+ return ec.marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase1(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_embeddedCase2(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6774,7 +7631,7 @@ func (ec *executionContext) _Query_embeddedCase2(ctx context.Context, field grap
}
res := resTmp.(*EmbeddedCase2)
fc.Result = res
- return ec.marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase2(ctx, field.Selections, res)
+ return ec.marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase2(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_embeddedCase3(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6803,7 +7660,7 @@ func (ec *executionContext) _Query_embeddedCase3(ctx context.Context, field grap
}
res := resTmp.(*EmbeddedCase3)
fc.Result = res
- return ec.marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase3(ctx, field.Selections, res)
+ return ec.marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase3(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_enumInInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6842,7 +7699,7 @@ func (ec *executionContext) _Query_enumInInput(ctx context.Context, field graphq
}
res := resTmp.(EnumTest)
fc.Result = res
- return ec.marshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEnumTest(ctx, field.Selections, res)
+ return ec.marshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEnumTest(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6871,7 +7728,7 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col
}
res := resTmp.([]Shape)
fc.Result = res
- return ec.marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, field.Selections, res)
+ return ec.marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_noShape(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6912,7 +7769,7 @@ func (ec *executionContext) _Query_noShape(ctx context.Context, field graphql.Co
if data, ok := tmp.(Shape); ok {
return data, nil
}
- return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver.Shape`, tmp)
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver/singlefile.Shape`, tmp)
})
if resTmp == nil {
@@ -6920,7 +7777,7 @@ func (ec *executionContext) _Query_noShape(ctx context.Context, field graphql.Co
}
res := resTmp.(Shape)
fc.Result = res
- return ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, field.Selections, res)
+ return ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6952,7 +7809,7 @@ func (ec *executionContext) _Query_node(ctx context.Context, field graphql.Colle
}
res := resTmp.(Node)
fc.Result = res
- return ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNode(ctx, field.Selections, res)
+ return ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNode(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_noShapeTypedNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -6993,7 +7850,7 @@ func (ec *executionContext) _Query_noShapeTypedNil(ctx context.Context, field gr
if data, ok := tmp.(Shape); ok {
return data, nil
}
- return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver.Shape`, tmp)
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver/singlefile.Shape`, tmp)
})
if resTmp == nil {
@@ -7001,7 +7858,7 @@ func (ec *executionContext) _Query_noShapeTypedNil(ctx context.Context, field gr
}
res := resTmp.(Shape)
fc.Result = res
- return ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, field.Selections, res)
+ return ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_animal(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7042,7 +7899,7 @@ func (ec *executionContext) _Query_animal(ctx context.Context, field graphql.Col
if data, ok := tmp.(Animal); ok {
return data, nil
}
- return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver.Animal`, tmp)
+ return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver/singlefile.Animal`, tmp)
})
if resTmp == nil {
@@ -7050,7 +7907,7 @@ func (ec *executionContext) _Query_animal(ctx context.Context, field graphql.Col
}
res := resTmp.(Animal)
fc.Result = res
- return ec.marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAnimal(ctx, field.Selections, res)
+ return ec.marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐAnimal(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_notAnInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7079,7 +7936,7 @@ func (ec *executionContext) _Query_notAnInterface(ctx context.Context, field gra
}
res := resTmp.(BackedByInterface)
fc.Result = res
- return ec.marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐBackedByInterface(ctx, field.Selections, res)
+ return ec.marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐBackedByInterface(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_issue896a(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7108,7 +7965,7 @@ func (ec *executionContext) _Query_issue896a(ctx context.Context, field graphql.
}
res := resTmp.([]*CheckIssue896)
fc.Result = res
- return ec.marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896ᚄ(ctx, field.Selections, res)
+ return ec.marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896ᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7209,10 +8066,10 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq
}
res := resTmp.(*Error)
fc.Result = res
- return ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res)
+ return ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res)
}
-func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _Query_errorBubbleList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -7230,18 +8087,18 @@ func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.Col
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Query().Errors(rctx)
+ return ec.resolvers.Query().ErrorBubbleList(rctx)
})
if resTmp == nil {
return graphql.Null
}
- res := resTmp.(*Errors)
+ res := resTmp.([]*Error)
fc.Result = res
- return ec.marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐErrors(ctx, field.Selections, res)
+ return ec.marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐErrorᚄ(ctx, field.Selections, res)
}
-func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _Query_errorList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -7259,21 +8116,18 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Query().Valid(rctx)
+ return ec.resolvers.Query().ErrorList(rctx)
})
if resTmp == nil {
- if !graphql.HasFieldError(ctx, fc) {
- ec.Errorf(ctx, "must not be null")
- }
return graphql.Null
}
- res := resTmp.(string)
+ res := resTmp.([]*Error)
fc.Result = res
- return ec.marshalNString2string(ctx, field.Selections, res)
+ return ec.marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res)
}
-func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -7291,18 +8145,18 @@ func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.Col
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Query().Panics(rctx)
+ return ec.resolvers.Query().Errors(rctx)
})
if resTmp == nil {
return graphql.Null
}
- res := resTmp.(*Panics)
+ res := resTmp.(*Errors)
fc.Result = res
- return ec.marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx, field.Selections, res)
+ return ec.marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐErrors(ctx, field.Selections, res)
}
-func (ec *executionContext) _Query_primitiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -7320,7 +8174,7 @@ func (ec *executionContext) _Query_primitiveObject(ctx context.Context, field gr
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Query().PrimitiveObject(rctx)
+ return ec.resolvers.Query().Valid(rctx)
})
if resTmp == nil {
@@ -7329,12 +8183,12 @@ func (ec *executionContext) _Query_primitiveObject(ctx context.Context, field gr
}
return graphql.Null
}
- res := resTmp.([]Primitive)
+ res := resTmp.(string)
fc.Result = res
- return ec.marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPrimitiveᚄ(ctx, field.Selections, res)
+ return ec.marshalNString2string(ctx, field.Selections, res)
}
-func (ec *executionContext) _Query_primitiveStringObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -7352,21 +8206,18 @@ func (ec *executionContext) _Query_primitiveStringObject(ctx context.Context, fi
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Query().PrimitiveStringObject(rctx)
+ return ec.resolvers.Query().Panics(rctx)
})
if resTmp == nil {
- if !graphql.HasFieldError(ctx, fc) {
- ec.Errorf(ctx, "must not be null")
- }
return graphql.Null
}
- res := resTmp.([]PrimitiveString)
+ res := resTmp.(*Panics)
fc.Result = res
- return ec.marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPrimitiveStringᚄ(ctx, field.Selections, res)
+ return ec.marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPanics(ctx, field.Selections, res)
}
-func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _Query_primitiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -7382,16 +8233,208 @@ func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field grap
}
ctx = graphql.WithFieldContext(ctx, fc)
- rawArgs := field.ArgumentMap(ec.Variables)
- args, err := ec.field_Query_defaultScalar_args(ctx, rawArgs)
- if err != nil {
- ec.Error(ctx, err)
- return graphql.Null
- }
- fc.Args = args
resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Query().DefaultScalar(rctx, args["arg"].(string))
+ return ec.resolvers.Query().PrimitiveObject(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]Primitive)
+ fc.Result = res
+ return ec.marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_primitiveStringObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().PrimitiveStringObject(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]PrimitiveString)
+ fc.Result = res
+ return ec.marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveStringᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_ptrToSliceContainer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().PtrToSliceContainer(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*PtrToSliceContainer)
+ fc.Result = res
+ return ec.marshalNPtrToSliceContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToSliceContainer(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_infinity(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().Infinity(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(float64)
+ fc.Result = res
+ return ec.marshalNFloat2float64(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_stringFromContextInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().StringFromContextInterface(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*StringFromContextInterface)
+ fc.Result = res
+ return ec.marshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStringFromContextInterface(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_stringFromContextFunction(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().StringFromContextFunction(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNStringFromContextFunction2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Query_defaultScalar_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().DefaultScalar(rctx, args["arg"].(string))
})
if resTmp == nil {
@@ -7431,7 +8474,7 @@ func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.Col
}
res := resTmp.(*Slices)
fc.Result = res
- return ec.marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSlices(ctx, field.Selections, res)
+ return ec.marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSlices(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_scalarSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7502,7 +8545,7 @@ func (ec *executionContext) _Query_fallback(ctx context.Context, field graphql.C
}
res := resTmp.(FallbackToStringEncoding)
fc.Result = res
- return ec.marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx, field.Selections, res)
+ return ec.marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFallbackToStringEncoding(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7531,7 +8574,65 @@ func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field grap
}
res := resTmp.(TestUnion)
fc.Result = res
- return ec.marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐTestUnion(ctx, field.Selections, res)
+ return ec.marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐTestUnion(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_vOkCaseValue(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().VOkCaseValue(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*VOkCaseValue)
+ fc.Result = res
+ return ec.marshalOVOkCaseValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVOkCaseValue(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_vOkCaseNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().VOkCaseNil(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*VOkCaseNil)
+ fc.Result = res
+ return ec.marshalOVOkCaseNil2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVOkCaseNil(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7560,7 +8661,7 @@ func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.
}
res := resTmp.(*ValidType)
fc.Result = res
- return ec.marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidType(ctx, field.Selections, res)
+ return ec.marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐValidType(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_wrappedStruct(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7592,7 +8693,7 @@ func (ec *executionContext) _Query_wrappedStruct(ctx context.Context, field grap
}
res := resTmp.(*WrappedStruct)
fc.Result = res
- return ec.marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedStruct(ctx, field.Selections, res)
+ return ec.marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedStruct(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_wrappedScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7624,7 +8725,7 @@ func (ec *executionContext) _Query_wrappedScalar(ctx context.Context, field grap
}
res := resTmp.(otherpkg.Scalar)
fc.Result = res
- return ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx, field.Selections, res)
+ return ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_wrappedMap(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7656,7 +8757,7 @@ func (ec *executionContext) _Query_wrappedMap(ctx context.Context, field graphql
}
res := resTmp.(WrappedMap)
fc.Result = res
- return ec.marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedMap(ctx, field.Selections, res)
+ return ec.marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedMap(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_wrappedSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7688,7 +8789,7 @@ func (ec *executionContext) _Query_wrappedSlice(ctx context.Context, field graph
}
res := resTmp.(WrappedSlice)
fc.Result = res
- return ec.marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedSlice(ctx, field.Selections, res)
+ return ec.marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedSlice(ctx, field.Selections, res)
}
func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@@ -7843,7 +8944,7 @@ func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.C
return ec.marshalOFloat2float64(ctx, field.Selections, res)
}
-func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
+func (ec *executionContext) _Rectangle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -7851,7 +8952,7 @@ func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.Col
}
}()
fc := &graphql.FieldContext{
- Object: "Slices",
+ Object: "Rectangle",
Field: field,
Args: nil,
IsMethod: false,
@@ -7861,18 +8962,18 @@ func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.Col
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return obj.Test1, nil
+ return obj.Coordinates, nil
})
if resTmp == nil {
return graphql.Null
}
- res := resTmp.([]*string)
+ res := resTmp.(Coordinates)
fc.Result = res
- return ec.marshalOString2ᚕᚖstring(ctx, field.Selections, res)
+ return ec.marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCoordinates(ctx, field.Selections, res)
}
-func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
+func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -7890,18 +8991,18 @@ func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.Col
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return obj.Test2, nil
+ return obj.Test1, nil
})
if resTmp == nil {
return graphql.Null
}
- res := resTmp.([]string)
+ res := resTmp.([]*string)
fc.Result = res
- return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res)
+ return ec.marshalOString2ᚕᚖstring(ctx, field.Selections, res)
}
-func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
+func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -7919,16 +9020,45 @@ func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.Col
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return obj.Test3, nil
+ return obj.Test2, nil
})
if resTmp == nil {
- if !graphql.HasFieldError(ctx, fc) {
- ec.Errorf(ctx, "must not be null")
- }
return graphql.Null
}
- res := resTmp.([]*string)
+ res := resTmp.([]string)
+ fc.Result = res
+ return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Slices",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Test3, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.([]*string)
fc.Result = res
return ec.marshalNString2ᚕᚖstring(ctx, field.Selections, res)
}
@@ -8298,7 +9428,7 @@ func (ec *executionContext) _Subscription_issue896b(ctx context.Context, field g
w.Write([]byte{'{'})
graphql.MarshalString(field.Alias).MarshalGQL(w)
w.Write([]byte{':'})
- ec.marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896(ctx, field.Selections, res).MarshalGQL(w)
+ ec.marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx, field.Selections, res).MarshalGQL(w)
w.Write([]byte{'}'})
})
}
@@ -8365,7 +9495,7 @@ func (ec *executionContext) _User_friends(ctx context.Context, field graphql.Col
}
res := resTmp.([]*User)
fc.Result = res
- return ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUserᚄ(ctx, field.Selections, res)
+ return ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUserᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
@@ -8429,6 +9559,72 @@ func (ec *executionContext) _User_updated(ctx context.Context, field graphql.Col
return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res)
}
+func (ec *executionContext) _VOkCaseNil_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseNil) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "VOkCaseNil",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ v, ok := obj.Value()
+ if !ok {
+ return nil, nil
+ }
+ return v, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _VOkCaseValue_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseValue) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "VOkCaseValue",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ v, ok := obj.Value()
+ if !ok {
+ return nil, nil
+ }
+ return v, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalOString2string(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -8678,7 +9874,7 @@ func (ec *executionContext) _WrappedStruct_name(ctx context.Context, field graph
}
res := resTmp.(otherpkg.Scalar)
fc.Result = res
- return ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx, field.Selections, res)
+ return ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx, field.Selections, res)
}
func (ec *executionContext) _WrappedStruct_desc(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) {
@@ -8707,7 +9903,7 @@ func (ec *executionContext) _WrappedStruct_desc(ctx context.Context, field graph
}
res := resTmp.(*otherpkg.Scalar)
fc.Result = res
- return ec.marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx, field.Selections, res)
+ return ec.marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx, field.Selections, res)
}
func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.CollectedField, obj *XXIt) (ret graphql.Marshaler) {
@@ -8899,6 +10095,38 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -9829,9 +11057,50 @@ func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.Collected
// region **************************** input.gotpl *****************************
+func (ec *executionContext) unmarshalInputDefaultInput(ctx context.Context, obj interface{}) (DefaultInput, error) {
+ var it DefaultInput
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ if _, present := asMap["falsyBoolean"]; !present {
+ asMap["falsyBoolean"] = false
+ }
+ if _, present := asMap["truthyBoolean"]; !present {
+ asMap["truthyBoolean"] = true
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "falsyBoolean":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("falsyBoolean"))
+ it.FalsyBoolean, err = ec.unmarshalOBoolean2ᚖbool(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "truthyBoolean":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("truthyBoolean"))
+ it.TruthyBoolean, err = ec.unmarshalOBoolean2ᚖbool(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
func (ec *executionContext) unmarshalInputInnerDirectives(ctx context.Context, obj interface{}) (InnerDirectives, error) {
var it InnerDirectives
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -9873,7 +11142,10 @@ func (ec *executionContext) unmarshalInputInnerDirectives(ctx context.Context, o
func (ec *executionContext) unmarshalInputInnerInput(ctx context.Context, obj interface{}) (InnerInput, error) {
var it InnerInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -9893,7 +11165,10 @@ func (ec *executionContext) unmarshalInputInnerInput(ctx context.Context, obj in
func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, obj interface{}) (InputDirectives, error) {
var it InputDirectives
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -9903,6 +11178,12 @@ func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, o
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text"))
directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, v) }
directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive3 == nil {
+ return nil, errors.New("directive directive3 is not implemented")
+ }
+ return ec.directives.Directive3(ctx, obj, directive0)
+ }
+ directive2 := func(ctx context.Context) (interface{}, error) {
min, err := ec.unmarshalNInt2int(ctx, 0)
if err != nil {
return nil, err
@@ -9918,10 +11199,10 @@ func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, o
if ec.directives.Length == nil {
return nil, errors.New("directive length is not implemented")
}
- return ec.directives.Length(ctx, obj, directive0, min, max, message)
+ return ec.directives.Length(ctx, obj, directive1, min, max, message)
}
- tmp, err := directive1(ctx)
+ tmp, err := directive2(ctx)
if err != nil {
return it, graphql.ErrorOnPath(ctx, err)
}
@@ -9937,13 +11218,19 @@ func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, o
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nullableText"))
directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) }
directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive3 == nil {
+ return nil, errors.New("directive directive3 is not implemented")
+ }
+ return ec.directives.Directive3(ctx, obj, directive0)
+ }
+ directive2 := func(ctx context.Context) (interface{}, error) {
if ec.directives.ToNull == nil {
return nil, errors.New("directive toNull is not implemented")
}
- return ec.directives.ToNull(ctx, obj, directive0)
+ return ec.directives.ToNull(ctx, obj, directive1)
}
- tmp, err := directive1(ctx)
+ tmp, err := directive2(ctx)
if err != nil {
return it, graphql.ErrorOnPath(ctx, err)
}
@@ -9959,26 +11246,68 @@ func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, o
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner"))
- it.Inner, err = ec.unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx, v)
+ directive0 := func(ctx context.Context) (interface{}, error) {
+ return ec.unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerDirectives(ctx, v)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive3 == nil {
+ return nil, errors.New("directive directive3 is not implemented")
+ }
+ return ec.directives.Directive3(ctx, obj, directive0)
+ }
+
+ tmp, err := directive1(ctx)
if err != nil {
- return it, err
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*InnerDirectives); ok {
+ it.Inner = data
+ } else if tmp == nil {
+ it.Inner = nil
+ } else {
+ err := fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver/singlefile.InnerDirectives`, tmp)
+ return it, graphql.ErrorOnPath(ctx, err)
}
case "innerNullable":
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("innerNullable"))
- it.InnerNullable, err = ec.unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx, v)
+ directive0 := func(ctx context.Context) (interface{}, error) {
+ return ec.unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerDirectives(ctx, v)
+ }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive3 == nil {
+ return nil, errors.New("directive directive3 is not implemented")
+ }
+ return ec.directives.Directive3(ctx, obj, directive0)
+ }
+
+ tmp, err := directive1(ctx)
if err != nil {
- return it, err
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(*InnerDirectives); ok {
+ it.InnerNullable = data
+ } else if tmp == nil {
+ it.InnerNullable = nil
+ } else {
+ err := fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver/singlefile.InnerDirectives`, tmp)
+ return it, graphql.ErrorOnPath(ctx, err)
}
case "thirdParty":
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("thirdParty"))
directive0 := func(ctx context.Context) (interface{}, error) {
- return ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx, v)
+ return ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐThirdParty(ctx, v)
}
directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.Directive3 == nil {
+ return nil, errors.New("directive directive3 is not implemented")
+ }
+ return ec.directives.Directive3(ctx, obj, directive0)
+ }
+ directive2 := func(ctx context.Context) (interface{}, error) {
min, err := ec.unmarshalNInt2int(ctx, 0)
if err != nil {
return nil, err
@@ -9990,10 +11319,10 @@ func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, o
if ec.directives.Length == nil {
return nil, errors.New("directive length is not implemented")
}
- return ec.directives.Length(ctx, obj, directive0, min, max, nil)
+ return ec.directives.Length(ctx, obj, directive1, min, max, nil)
}
- tmp, err := directive1(ctx)
+ tmp, err := directive2(ctx)
if err != nil {
return it, graphql.ErrorOnPath(ctx, err)
}
@@ -10002,7 +11331,7 @@ func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, o
} else if tmp == nil {
it.ThirdParty = nil
} else {
- err := fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver.ThirdParty`, tmp)
+ err := fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver/singlefile.ThirdParty`, tmp)
return it, graphql.ErrorOnPath(ctx, err)
}
}
@@ -10013,7 +11342,10 @@ func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, o
func (ec *executionContext) unmarshalInputInputWithEnumValue(ctx context.Context, obj interface{}) (InputWithEnumValue, error) {
var it InputWithEnumValue
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10021,7 +11353,7 @@ func (ec *executionContext) unmarshalInputInputWithEnumValue(ctx context.Context
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enum"))
- it.Enum, err = ec.unmarshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEnumTest(ctx, v)
+ it.Enum, err = ec.unmarshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEnumTest(ctx, v)
if err != nil {
return it, err
}
@@ -10033,7 +11365,10 @@ func (ec *executionContext) unmarshalInputInputWithEnumValue(ctx context.Context
func (ec *executionContext) unmarshalInputNestedInput(ctx context.Context, obj interface{}) (NestedInput, error) {
var it NestedInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10041,7 +11376,7 @@ func (ec *executionContext) unmarshalInputNestedInput(ctx context.Context, obj i
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field"))
- it.Field, err = ec.unmarshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmail(ctx, v)
+ it.Field, err = ec.unmarshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmail(ctx, v)
if err != nil {
return it, err
}
@@ -10053,7 +11388,10 @@ func (ec *executionContext) unmarshalInputNestedInput(ctx context.Context, obj i
func (ec *executionContext) unmarshalInputNestedMapInput(ctx context.Context, obj interface{}) (NestedMapInput, error) {
var it NestedMapInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10073,7 +11411,10 @@ func (ec *executionContext) unmarshalInputNestedMapInput(ctx context.Context, ob
func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, obj interface{}) (OuterInput, error) {
var it OuterInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10081,7 +11422,7 @@ func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, obj in
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner"))
- it.Inner, err = ec.unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx, v)
+ it.Inner, err = ec.unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerInput(ctx, v)
if err != nil {
return it, err
}
@@ -10093,7 +11434,10 @@ func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, obj in
func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Context, obj interface{}) (RecursiveInputSlice, error) {
var it RecursiveInputSlice
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10101,7 +11445,7 @@ func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Contex
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("self"))
- it.Self, err = ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSliceᚄ(ctx, v)
+ it.Self, err = ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSliceᚄ(ctx, v)
if err != nil {
return it, err
}
@@ -10113,7 +11457,10 @@ func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Contex
func (ec *executionContext) unmarshalInputSpecialInput(ctx context.Context, obj interface{}) (SpecialInput, error) {
var it SpecialInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10121,7 +11468,77 @@ func (ec *executionContext) unmarshalInputSpecialInput(ctx context.Context, obj
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nesting"))
- it.Nesting, err = ec.unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNestedInput(ctx, v)
+ it.Nesting, err = ec.unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNestedInput(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+func (ec *executionContext) unmarshalInputUpdatePtrToPtrInner(ctx context.Context, obj interface{}) (UpdatePtrToPtrInner, error) {
+ var it UpdatePtrToPtrInner
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "key":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key"))
+ it.Key, err = ec.unmarshalOString2ᚖstring(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "value":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value"))
+ it.Value, err = ec.unmarshalOString2ᚖstring(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ }
+ }
+
+ return it, nil
+}
+
+func (ec *executionContext) unmarshalInputUpdatePtrToPtrOuter(ctx context.Context, obj interface{}) (UpdatePtrToPtrOuter, error) {
+ var it UpdatePtrToPtrOuter
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
+
+ for k, v := range asMap {
+ switch k {
+ case "name":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name"))
+ it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "inner":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner"))
+ it.Inner, err = ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ case "stupidInner":
+ var err error
+
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stupidInner"))
+ it.StupidInner, err = ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v)
if err != nil {
return it, err
}
@@ -10133,7 +11550,10 @@ func (ec *executionContext) unmarshalInputSpecialInput(ctx context.Context, obj
func (ec *executionContext) unmarshalInputValidInput(ctx context.Context, obj interface{}) (ValidInput, error) {
var it ValidInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10489,7 +11909,6 @@ var aImplementors = []string{"A", "TestUnion"}
func (ec *executionContext) _A(ctx context.Context, sel ast.SelectionSet, obj *A) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, aImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10497,7 +11916,12 @@ func (ec *executionContext) _A(ctx context.Context, sel ast.SelectionSet, obj *A
case "__typename":
out.Values[i] = graphql.MarshalString("A")
case "id":
- out.Values[i] = ec._A_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._A_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -10516,7 +11940,6 @@ var aItImplementors = []string{"AIt"}
func (ec *executionContext) _AIt(ctx context.Context, sel ast.SelectionSet, obj *AIt) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, aItImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10524,7 +11947,12 @@ func (ec *executionContext) _AIt(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("AIt")
case "id":
- out.Values[i] = ec._AIt_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._AIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -10543,7 +11971,6 @@ var abItImplementors = []string{"AbIt"}
func (ec *executionContext) _AbIt(ctx context.Context, sel ast.SelectionSet, obj *AbIt) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, abItImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10551,7 +11978,12 @@ func (ec *executionContext) _AbIt(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("AbIt")
case "id":
- out.Values[i] = ec._AbIt_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._AbIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -10570,7 +12002,6 @@ var autobindImplementors = []string{"Autobind"}
func (ec *executionContext) _Autobind(ctx context.Context, sel ast.SelectionSet, obj *Autobind) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, autobindImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10578,27 +12009,52 @@ func (ec *executionContext) _Autobind(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("Autobind")
case "int":
- out.Values[i] = ec._Autobind_int(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Autobind_int(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "int32":
- out.Values[i] = ec._Autobind_int32(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Autobind_int32(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "int64":
- out.Values[i] = ec._Autobind_int64(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Autobind_int64(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "idStr":
- out.Values[i] = ec._Autobind_idStr(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Autobind_idStr(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "idInt":
- out.Values[i] = ec._Autobind_idInt(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Autobind_idInt(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -10617,7 +12073,6 @@ var bImplementors = []string{"B", "TestUnion"}
func (ec *executionContext) _B(ctx context.Context, sel ast.SelectionSet, obj *B) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, bImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10625,7 +12080,12 @@ func (ec *executionContext) _B(ctx context.Context, sel ast.SelectionSet, obj *B
case "__typename":
out.Values[i] = graphql.MarshalString("B")
case "id":
- out.Values[i] = ec._B_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._B_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -10644,7 +12104,6 @@ var backedByInterfaceImplementors = []string{"BackedByInterface"}
func (ec *executionContext) _BackedByInterface(ctx context.Context, sel ast.SelectionSet, obj BackedByInterface) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, backedByInterfaceImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10653,7 +12112,8 @@ func (ec *executionContext) _BackedByInterface(ctx context.Context, sel ast.Sele
out.Values[i] = graphql.MarshalString("BackedByInterface")
case "id":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -10664,14 +12124,29 @@ func (ec *executionContext) _BackedByInterface(ctx context.Context, sel ast.Sele
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "thisShouldBind":
- out.Values[i] = ec._BackedByInterface_thisShouldBind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._BackedByInterface_thisShouldBind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "thisShouldBindWithError":
- out.Values[i] = ec._BackedByInterface_thisShouldBindWithError(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._BackedByInterface_thisShouldBindWithError(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
@@ -10690,7 +12165,6 @@ var catImplementors = []string{"Cat", "Animal"}
func (ec *executionContext) _Cat(ctx context.Context, sel ast.SelectionSet, obj *Cat) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, catImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10698,12 +12172,22 @@ func (ec *executionContext) _Cat(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("Cat")
case "species":
- out.Values[i] = ec._Cat_species(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Cat_species(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "catBreed":
- out.Values[i] = ec._Cat_catBreed(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Cat_catBreed(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -10722,7 +12206,6 @@ var checkIssue896Implementors = []string{"CheckIssue896"}
func (ec *executionContext) _CheckIssue896(ctx context.Context, sel ast.SelectionSet, obj *CheckIssue896) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, checkIssue896Implementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10730,7 +12213,12 @@ func (ec *executionContext) _CheckIssue896(ctx context.Context, sel ast.Selectio
case "__typename":
out.Values[i] = graphql.MarshalString("CheckIssue896")
case "id":
- out.Values[i] = ec._CheckIssue896_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._CheckIssue896_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -10746,7 +12234,6 @@ var circleImplementors = []string{"Circle", "Shape", "ShapeUnion"}
func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, circleImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10754,9 +12241,26 @@ func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("Circle")
case "radius":
- out.Values[i] = ec._Circle_radius(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Circle_radius(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "area":
- out.Values[i] = ec._Circle_area(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Circle_area(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "coordinates":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Circle_coordinates(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -10772,7 +12276,6 @@ var concreteNodeAImplementors = []string{"ConcreteNodeA", "Node"}
func (ec *executionContext) _ConcreteNodeA(ctx context.Context, sel ast.SelectionSet, obj *ConcreteNodeA) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeAImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10780,17 +12283,32 @@ func (ec *executionContext) _ConcreteNodeA(ctx context.Context, sel ast.Selectio
case "__typename":
out.Values[i] = graphql.MarshalString("ConcreteNodeA")
case "id":
- out.Values[i] = ec._ConcreteNodeA_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ConcreteNodeA_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "child":
- out.Values[i] = ec._ConcreteNodeA_child(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ConcreteNodeA_child(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec._ConcreteNodeA_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ConcreteNodeA_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -10809,7 +12327,6 @@ var concreteNodeInterfaceImplementors = []string{"ConcreteNodeInterface", "Node"
func (ec *executionContext) _ConcreteNodeInterface(ctx context.Context, sel ast.SelectionSet, obj ConcreteNodeInterface) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeInterfaceImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10817,12 +12334,22 @@ func (ec *executionContext) _ConcreteNodeInterface(ctx context.Context, sel ast.
case "__typename":
out.Values[i] = graphql.MarshalString("ConcreteNodeInterface")
case "id":
- out.Values[i] = ec._ConcreteNodeInterface_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ConcreteNodeInterface_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "child":
- out.Values[i] = ec._ConcreteNodeInterface_child(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ConcreteNodeInterface_child(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -10841,7 +12368,6 @@ var content_PostImplementors = []string{"Content_Post", "Content_Child"}
func (ec *executionContext) _Content_Post(ctx context.Context, sel ast.SelectionSet, obj *ContentPost) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, content_PostImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10849,7 +12375,12 @@ func (ec *executionContext) _Content_Post(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("Content_Post")
case "foo":
- out.Values[i] = ec._Content_Post_foo(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Content_Post_foo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -10865,7 +12396,6 @@ var content_UserImplementors = []string{"Content_User", "Content_Child"}
func (ec *executionContext) _Content_User(ctx context.Context, sel ast.SelectionSet, obj *ContentUser) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, content_UserImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10873,7 +12403,88 @@ func (ec *executionContext) _Content_User(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("Content_User")
case "foo":
- out.Values[i] = ec._Content_User_foo(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Content_User_foo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var coordinatesImplementors = []string{"Coordinates"}
+
+func (ec *executionContext) _Coordinates(ctx context.Context, sel ast.SelectionSet, obj *Coordinates) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, coordinatesImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Coordinates")
+ case "x":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Coordinates_x(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "y":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Coordinates_y(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var defaultParametersMirrorImplementors = []string{"DefaultParametersMirror"}
+
+func (ec *executionContext) _DefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, obj *DefaultParametersMirror) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, defaultParametersMirrorImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("DefaultParametersMirror")
+ case "falsyBoolean":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._DefaultParametersMirror_falsyBoolean(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "truthyBoolean":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._DefaultParametersMirror_truthyBoolean(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -10889,7 +12500,6 @@ var dogImplementors = []string{"Dog", "Animal"}
func (ec *executionContext) _Dog(ctx context.Context, sel ast.SelectionSet, obj *Dog) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, dogImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10897,12 +12507,22 @@ func (ec *executionContext) _Dog(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("Dog")
case "species":
- out.Values[i] = ec._Dog_species(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Dog_species(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "dogBreed":
- out.Values[i] = ec._Dog_dogBreed(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Dog_dogBreed(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -10921,7 +12541,6 @@ var embeddedCase1Implementors = []string{"EmbeddedCase1"}
func (ec *executionContext) _EmbeddedCase1(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase1) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase1Implementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10929,7 +12548,12 @@ func (ec *executionContext) _EmbeddedCase1(ctx context.Context, sel ast.Selectio
case "__typename":
out.Values[i] = graphql.MarshalString("EmbeddedCase1")
case "exportedEmbeddedPointerExportedMethod":
- out.Values[i] = ec._EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -10948,7 +12572,6 @@ var embeddedCase2Implementors = []string{"EmbeddedCase2"}
func (ec *executionContext) _EmbeddedCase2(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase2) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase2Implementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10956,7 +12579,12 @@ func (ec *executionContext) _EmbeddedCase2(ctx context.Context, sel ast.Selectio
case "__typename":
out.Values[i] = graphql.MarshalString("EmbeddedCase2")
case "unexportedEmbeddedPointerExportedMethod":
- out.Values[i] = ec._EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -10975,7 +12603,6 @@ var embeddedCase3Implementors = []string{"EmbeddedCase3"}
func (ec *executionContext) _EmbeddedCase3(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase3) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase3Implementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -10983,7 +12610,12 @@ func (ec *executionContext) _EmbeddedCase3(ctx context.Context, sel ast.Selectio
case "__typename":
out.Values[i] = graphql.MarshalString("EmbeddedCase3")
case "unexportedEmbeddedInterfaceExportedMethod":
- out.Values[i] = ec._EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -11002,7 +12634,6 @@ var embeddedDefaultScalarImplementors = []string{"EmbeddedDefaultScalar"}
func (ec *executionContext) _EmbeddedDefaultScalar(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedDefaultScalar) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, embeddedDefaultScalarImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11010,7 +12641,12 @@ func (ec *executionContext) _EmbeddedDefaultScalar(ctx context.Context, sel ast.
case "__typename":
out.Values[i] = graphql.MarshalString("EmbeddedDefaultScalar")
case "value":
- out.Values[i] = ec._EmbeddedDefaultScalar_value(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedDefaultScalar_value(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -11026,7 +12662,6 @@ var embeddedPointerImplementors = []string{"EmbeddedPointer"}
func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedPointerModel) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, embeddedPointerImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11034,9 +12669,19 @@ func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.Select
case "__typename":
out.Values[i] = graphql.MarshalString("EmbeddedPointer")
case "ID":
- out.Values[i] = ec._EmbeddedPointer_ID(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedPointer_ID(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "Title":
- out.Values[i] = ec._EmbeddedPointer_Title(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmbeddedPointer_Title(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -11052,7 +12697,6 @@ var errorImplementors = []string{"Error"}
func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *Error) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, errorImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11060,19 +12704,39 @@ func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, ob
case "__typename":
out.Values[i] = graphql.MarshalString("Error")
case "id":
- out.Values[i] = ec._Error_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Error_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "errorOnNonRequiredField":
- out.Values[i] = ec._Error_errorOnNonRequiredField(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Error_errorOnNonRequiredField(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "errorOnRequiredField":
- out.Values[i] = ec._Error_errorOnRequiredField(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Error_errorOnRequiredField(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "nilOnRequiredField":
- out.Values[i] = ec._Error_nilOnRequiredField(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Error_nilOnRequiredField(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -11091,7 +12755,6 @@ var errorsImplementors = []string{"Errors"}
func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, obj *Errors) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, errorsImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11100,7 +12763,8 @@ func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, o
out.Values[i] = graphql.MarshalString("Errors")
case "a":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11111,10 +12775,16 @@ func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, o
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "b":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11125,10 +12795,16 @@ func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, o
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "c":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11139,10 +12815,16 @@ func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, o
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "d":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11153,10 +12835,16 @@ func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, o
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "e":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11167,6 +12855,11 @@ func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, o
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -11183,7 +12876,6 @@ var forcedResolverImplementors = []string{"ForcedResolver"}
func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.SelectionSet, obj *ForcedResolver) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, forcedResolverImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11192,7 +12884,8 @@ func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.Selecti
out.Values[i] = graphql.MarshalString("ForcedResolver")
case "field":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11200,6 +12893,11 @@ func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.Selecti
}()
res = ec._ForcedResolver_field(ctx, field, obj)
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -11216,7 +12914,6 @@ var innerObjectImplementors = []string{"InnerObject"}
func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionSet, obj *InnerObject) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, innerObjectImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11224,7 +12921,12 @@ func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("InnerObject")
case "id":
- out.Values[i] = ec._InnerObject_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._InnerObject_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -11243,7 +12945,6 @@ var invalidIdentifierImplementors = []string{"InvalidIdentifier"}
func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.SelectionSet, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, invalidIdentifierImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11251,7 +12952,12 @@ func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.Sele
case "__typename":
out.Values[i] = graphql.MarshalString("InvalidIdentifier")
case "id":
- out.Values[i] = ec._InvalidIdentifier_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._InvalidIdentifier_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -11270,7 +12976,6 @@ var itImplementors = []string{"It"}
func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection1.It) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, itImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11278,7 +12983,12 @@ func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *
case "__typename":
out.Values[i] = graphql.MarshalString("It")
case "id":
- out.Values[i] = ec._It_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._It_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -11297,7 +13007,6 @@ var loopAImplementors = []string{"LoopA"}
func (ec *executionContext) _LoopA(ctx context.Context, sel ast.SelectionSet, obj *LoopA) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, loopAImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11305,7 +13014,12 @@ func (ec *executionContext) _LoopA(ctx context.Context, sel ast.SelectionSet, ob
case "__typename":
out.Values[i] = graphql.MarshalString("LoopA")
case "b":
- out.Values[i] = ec._LoopA_b(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._LoopA_b(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -11324,7 +13038,6 @@ var loopBImplementors = []string{"LoopB"}
func (ec *executionContext) _LoopB(ctx context.Context, sel ast.SelectionSet, obj *LoopB) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, loopBImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11332,7 +13045,12 @@ func (ec *executionContext) _LoopB(ctx context.Context, sel ast.SelectionSet, ob
case "__typename":
out.Values[i] = graphql.MarshalString("LoopB")
case "a":
- out.Values[i] = ec._LoopB_a(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._LoopB_a(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -11351,7 +13069,6 @@ var mapImplementors = []string{"Map"}
func (ec *executionContext) _Map(ctx context.Context, sel ast.SelectionSet, obj *Map) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, mapImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11359,7 +13076,12 @@ func (ec *executionContext) _Map(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("Map")
case "id":
- out.Values[i] = ec._Map_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Map_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -11378,7 +13100,6 @@ var mapStringInterfaceTypeImplementors = []string{"MapStringInterfaceType"}
func (ec *executionContext) _MapStringInterfaceType(ctx context.Context, sel ast.SelectionSet, obj map[string]interface{}) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, mapStringInterfaceTypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11386,9 +13107,19 @@ func (ec *executionContext) _MapStringInterfaceType(ctx context.Context, sel ast
case "__typename":
out.Values[i] = graphql.MarshalString("MapStringInterfaceType")
case "a":
- out.Values[i] = ec._MapStringInterfaceType_a(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._MapStringInterfaceType_a(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "b":
- out.Values[i] = ec._MapStringInterfaceType_b(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._MapStringInterfaceType_b(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -11404,7 +13135,6 @@ var modelMethodsImplementors = []string{"ModelMethods"}
func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.SelectionSet, obj *ModelMethods) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, modelMethodsImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11413,7 +13143,8 @@ func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.Selection
out.Values[i] = graphql.MarshalString("ModelMethods")
case "resolverField":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11424,15 +13155,26 @@ func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.Selection
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "noContext":
- out.Values[i] = ec._ModelMethods_noContext(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ModelMethods_noContext(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "withContext":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11443,6 +13185,11 @@ func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.Selection
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -11459,7 +13206,6 @@ var mutationImplementors = []string{"Mutation"}
func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Mutation",
})
@@ -11467,11 +13213,41 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Mutation")
+ case "defaultInput":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_defaultInput(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
case "updateSomething":
- out.Values[i] = ec._Mutation_updateSomething(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_updateSomething(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "updatePtrToPtr":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_updatePtrToPtr(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -11490,7 +13266,6 @@ var objectDirectivesImplementors = []string{"ObjectDirectives"}
func (ec *executionContext) _ObjectDirectives(ctx context.Context, sel ast.SelectionSet, obj *ObjectDirectives) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, objectDirectivesImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11498,14 +13273,29 @@ func (ec *executionContext) _ObjectDirectives(ctx context.Context, sel ast.Selec
case "__typename":
out.Values[i] = graphql.MarshalString("ObjectDirectives")
case "text":
- out.Values[i] = ec._ObjectDirectives_text(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ObjectDirectives_text(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "nullableText":
- out.Values[i] = ec._ObjectDirectives_nullableText(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ObjectDirectives_nullableText(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "order":
- out.Values[i] = ec._ObjectDirectives_order(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ObjectDirectives_order(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -11524,7 +13314,6 @@ var objectDirectivesWithCustomGoModelImplementors = []string{"ObjectDirectivesWi
func (ec *executionContext) _ObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, obj *ObjectDirectivesWithCustomGoModel) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, objectDirectivesWithCustomGoModelImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11532,7 +13321,12 @@ func (ec *executionContext) _ObjectDirectivesWithCustomGoModel(ctx context.Conte
case "__typename":
out.Values[i] = graphql.MarshalString("ObjectDirectivesWithCustomGoModel")
case "nullableText":
- out.Values[i] = ec._ObjectDirectivesWithCustomGoModel_nullableText(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ObjectDirectivesWithCustomGoModel_nullableText(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -11548,7 +13342,6 @@ var outerObjectImplementors = []string{"OuterObject"}
func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionSet, obj *OuterObject) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, outerObjectImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11556,7 +13349,12 @@ func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("OuterObject")
case "inner":
- out.Values[i] = ec._OuterObject_inner(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._OuterObject_inner(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -11575,7 +13373,6 @@ var overlappingFieldsImplementors = []string{"OverlappingFields"}
func (ec *executionContext) _OverlappingFields(ctx context.Context, sel ast.SelectionSet, obj *OverlappingFields) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, overlappingFieldsImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11583,18 +13380,29 @@ func (ec *executionContext) _OverlappingFields(ctx context.Context, sel ast.Sele
case "__typename":
out.Values[i] = graphql.MarshalString("OverlappingFields")
case "oneFoo":
- out.Values[i] = ec._OverlappingFields_oneFoo(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._OverlappingFields_oneFoo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "twoFoo":
- out.Values[i] = ec._OverlappingFields_twoFoo(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._OverlappingFields_twoFoo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "oldFoo":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11605,14 +13413,29 @@ func (ec *executionContext) _OverlappingFields(ctx context.Context, sel ast.Sele
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "newFoo":
- out.Values[i] = ec._OverlappingFields_newFoo(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._OverlappingFields_newFoo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "new_foo":
- out.Values[i] = ec._OverlappingFields_new_foo(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._OverlappingFields_new_foo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
@@ -11631,7 +13454,6 @@ var panicsImplementors = []string{"Panics"}
func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, obj *Panics) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, panicsImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11640,7 +13462,8 @@ func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, o
out.Values[i] = graphql.MarshalString("Panics")
case "fieldScalarMarshal":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11651,10 +13474,16 @@ func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, o
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "fieldFuncMarshal":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11665,10 +13494,16 @@ func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, o
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "argUnmarshal":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11679,6 +13514,11 @@ func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, o
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -11695,7 +13535,6 @@ var primitiveImplementors = []string{"Primitive"}
func (ec *executionContext) _Primitive(ctx context.Context, sel ast.SelectionSet, obj *Primitive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, primitiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11704,7 +13543,8 @@ func (ec *executionContext) _Primitive(ctx context.Context, sel ast.SelectionSet
out.Values[i] = graphql.MarshalString("Primitive")
case "value":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11715,9 +13555,19 @@ func (ec *executionContext) _Primitive(ctx context.Context, sel ast.SelectionSet
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "squared":
- out.Values[i] = ec._Primitive_squared(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Primitive_squared(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
@@ -11736,7 +13586,6 @@ var primitiveStringImplementors = []string{"PrimitiveString"}
func (ec *executionContext) _PrimitiveString(ctx context.Context, sel ast.SelectionSet, obj *PrimitiveString) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, primitiveStringImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -11745,7 +13594,8 @@ func (ec *executionContext) _PrimitiveString(ctx context.Context, sel ast.Select
out.Values[i] = graphql.MarshalString("PrimitiveString")
case "value":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11756,15 +13606,26 @@ func (ec *executionContext) _PrimitiveString(ctx context.Context, sel ast.Select
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "doubled":
- out.Values[i] = ec._PrimitiveString_doubled(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PrimitiveString_doubled(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "len":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11775,6 +13636,11 @@ func (ec *executionContext) _PrimitiveString(ctx context.Context, sel ast.Select
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -11787,11 +13653,124 @@ func (ec *executionContext) _PrimitiveString(ctx context.Context, sel ast.Select
return out
}
+var ptrToPtrInnerImplementors = []string{"PtrToPtrInner"}
+
+func (ec *executionContext) _PtrToPtrInner(ctx context.Context, sel ast.SelectionSet, obj *PtrToPtrInner) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, ptrToPtrInnerImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("PtrToPtrInner")
+ case "key":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToPtrInner_key(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "value":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToPtrInner_value(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var ptrToPtrOuterImplementors = []string{"PtrToPtrOuter"}
+
+func (ec *executionContext) _PtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, obj *PtrToPtrOuter) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, ptrToPtrOuterImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("PtrToPtrOuter")
+ case "name":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToPtrOuter_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "inner":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToPtrOuter_inner(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "stupidInner":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToPtrOuter_stupidInner(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var ptrToSliceContainerImplementors = []string{"PtrToSliceContainer"}
+
+func (ec *executionContext) _PtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, obj *PtrToSliceContainer) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, ptrToSliceContainerImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("PtrToSliceContainer")
+ case "ptrToSlice":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PtrToSliceContainer_ptrToSlice(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Query",
})
@@ -11799,12 +13778,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Query")
case "invalidIdentifier":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11812,10 +13797,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_invalidIdentifier(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "collision":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11823,10 +13817,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_collision(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "mapInput":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11834,10 +13837,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_mapInput(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "recursive":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11845,10 +13857,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_recursive(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "nestedInputs":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11856,10 +13877,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_nestedInputs(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "nestedOutputs":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11867,10 +13897,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_nestedOutputs(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "modelMethods":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11878,10 +13917,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_modelMethods(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "user":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11892,10 +13940,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "nullableArg":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11903,10 +13960,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_nullableArg(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "inputSlice":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11917,10 +13983,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "inputNullableSlice":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11931,10 +14006,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "shapeUnion":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11945,10 +14029,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "autobind":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11956,10 +14049,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_autobind(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "deprecatedField":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11970,10 +14072,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "overlapping":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11981,10 +14092,42 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_overlapping(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "defaultParameters":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_defaultParameters(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "directiveArg":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -11992,10 +14135,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_directiveArg(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "directiveNullableArg":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12003,10 +14155,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_directiveNullableArg(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "directiveInputNullable":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12014,10 +14175,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_directiveInputNullable(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "directiveInput":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12025,10 +14195,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_directiveInput(ctx, field)
return res
- })
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
case "directiveInputType":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12036,10 +14215,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_directiveInputType(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "directiveObject":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12047,10 +14235,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_directiveObject(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "directiveObjectWithCustomGoModel":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12058,10 +14255,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_directiveObjectWithCustomGoModel(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "directiveFieldDef":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12072,10 +14278,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "directiveField":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12083,10 +14298,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_directiveField(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "directiveDouble":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12094,10 +14318,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_directiveDouble(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "directiveUnimplemented":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12105,10 +14338,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_directiveUnimplemented(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "embeddedCase1":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12116,10 +14358,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_embeddedCase1(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "embeddedCase2":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12127,10 +14378,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_embeddedCase2(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "embeddedCase3":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12138,10 +14398,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_embeddedCase3(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "enumInInput":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12152,10 +14421,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "shapes":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12163,10 +14441,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_shapes(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "noShape":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12174,10 +14461,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_noShape(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "node":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12188,10 +14484,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "noShapeTypedNil":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12199,10 +14504,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_noShapeTypedNil(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "animal":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12210,10 +14524,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_animal(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "notAnInterface":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12221,10 +14544,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_notAnInterface(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "issue896a":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12232,10 +14564,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_issue896a(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "mapStringInterface":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12243,10 +14584,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_mapStringInterface(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "mapNestedStringInterface":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12254,10 +14604,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_mapNestedStringInterface(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "errorBubble":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12265,10 +14624,59 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_errorBubble(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "errorBubbleList":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_errorBubbleList(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "errorList":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_errorList(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "errors":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12276,10 +14684,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_errors(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "valid":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12290,10 +14707,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "panics":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12301,10 +14727,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_panics(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "primitiveObject":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12315,10 +14750,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "primitiveStringObject":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12329,10 +14773,111 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "ptrToSliceContainer":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_ptrToSliceContainer(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "infinity":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_infinity(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "stringFromContextInterface":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_stringFromContextInterface(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "stringFromContextFunction":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_stringFromContextFunction(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "defaultScalar":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12343,10 +14888,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "slices":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12354,10 +14908,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_slices(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "scalarSlice":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12368,10 +14931,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "fallback":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12382,10 +14954,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "optionalUnion":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12393,10 +14974,59 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_optionalUnion(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "vOkCaseValue":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_vOkCaseValue(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "vOkCaseNil":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_vOkCaseNil(ctx, field)
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "validType":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12404,10 +15034,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_validType(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "wrappedStruct":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12418,10 +15057,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "wrappedScalar":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12432,10 +15080,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "wrappedMap":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12446,10 +15103,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "wrappedSlice":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12460,11 +15126,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._Query___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._Query___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -12480,7 +15164,6 @@ var rectangleImplementors = []string{"Rectangle", "Shape", "ShapeUnion"}
func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, rectangleImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12488,11 +15171,33 @@ func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet
case "__typename":
out.Values[i] = graphql.MarshalString("Rectangle")
case "length":
- out.Values[i] = ec._Rectangle_length(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Rectangle_length(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "width":
- out.Values[i] = ec._Rectangle_width(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Rectangle_width(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "area":
- out.Values[i] = ec._Rectangle_area(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Rectangle_area(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ case "coordinates":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Rectangle_coordinates(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -12508,7 +15213,6 @@ var slicesImplementors = []string{"Slices"}
func (ec *executionContext) _Slices(ctx context.Context, sel ast.SelectionSet, obj *Slices) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, slicesImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12516,16 +15220,36 @@ func (ec *executionContext) _Slices(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("Slices")
case "test1":
- out.Values[i] = ec._Slices_test1(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Slices_test1(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "test2":
- out.Values[i] = ec._Slices_test2(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Slices_test2(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "test3":
- out.Values[i] = ec._Slices_test3(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Slices_test3(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "test4":
- out.Values[i] = ec._Slices_test4(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Slices_test4(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -12576,7 +15300,6 @@ var userImplementors = []string{"User"}
func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12584,13 +15307,19 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("User")
case "id":
- out.Values[i] = ec._User_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "friends":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12601,14 +15330,85 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "created":
- out.Values[i] = ec._User_created(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_created(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "updated":
- out.Values[i] = ec._User_updated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_updated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var vOkCaseNilImplementors = []string{"VOkCaseNil"}
+
+func (ec *executionContext) _VOkCaseNil(ctx context.Context, sel ast.SelectionSet, obj *VOkCaseNil) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, vOkCaseNilImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("VOkCaseNil")
+ case "value":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._VOkCaseNil_value(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var vOkCaseValueImplementors = []string{"VOkCaseValue"}
+
+func (ec *executionContext) _VOkCaseValue(ctx context.Context, sel ast.SelectionSet, obj *VOkCaseValue) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, vOkCaseValueImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("VOkCaseValue")
+ case "value":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._VOkCaseValue_value(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -12624,7 +15424,6 @@ var validTypeImplementors = []string{"ValidType"}
func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet, obj *ValidType) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, validTypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12632,22 +15431,42 @@ func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet
case "__typename":
out.Values[i] = graphql.MarshalString("ValidType")
case "differentCase":
- out.Values[i] = ec._ValidType_differentCase(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ValidType_differentCase(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "different_case":
- out.Values[i] = ec._ValidType_different_case(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ValidType_different_case(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "validInputKeywords":
- out.Values[i] = ec._ValidType_validInputKeywords(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ValidType_validInputKeywords(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "validArgs":
- out.Values[i] = ec._ValidType_validArgs(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._ValidType_validArgs(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -12666,7 +15485,6 @@ var wrappedMapImplementors = []string{"WrappedMap"}
func (ec *executionContext) _WrappedMap(ctx context.Context, sel ast.SelectionSet, obj WrappedMap) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, wrappedMapImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12675,7 +15493,8 @@ func (ec *executionContext) _WrappedMap(ctx context.Context, sel ast.SelectionSe
out.Values[i] = graphql.MarshalString("WrappedMap")
case "get":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12686,6 +15505,11 @@ func (ec *executionContext) _WrappedMap(ctx context.Context, sel ast.SelectionSe
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -12702,7 +15526,6 @@ var wrappedSliceImplementors = []string{"WrappedSlice"}
func (ec *executionContext) _WrappedSlice(ctx context.Context, sel ast.SelectionSet, obj WrappedSlice) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, wrappedSliceImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12711,7 +15534,8 @@ func (ec *executionContext) _WrappedSlice(ctx context.Context, sel ast.Selection
out.Values[i] = graphql.MarshalString("WrappedSlice")
case "get":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -12722,6 +15546,11 @@ func (ec *executionContext) _WrappedSlice(ctx context.Context, sel ast.Selection
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -12738,7 +15567,6 @@ var wrappedStructImplementors = []string{"WrappedStruct"}
func (ec *executionContext) _WrappedStruct(ctx context.Context, sel ast.SelectionSet, obj *WrappedStruct) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, wrappedStructImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12746,12 +15574,22 @@ func (ec *executionContext) _WrappedStruct(ctx context.Context, sel ast.Selectio
case "__typename":
out.Values[i] = graphql.MarshalString("WrappedStruct")
case "name":
- out.Values[i] = ec._WrappedStruct_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._WrappedStruct_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "desc":
- out.Values[i] = ec._WrappedStruct_desc(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._WrappedStruct_desc(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -12767,7 +15605,6 @@ var xXItImplementors = []string{"XXIt"}
func (ec *executionContext) _XXIt(ctx context.Context, sel ast.SelectionSet, obj *XXIt) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, xXItImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12775,7 +15612,12 @@ func (ec *executionContext) _XXIt(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("XXIt")
case "id":
- out.Values[i] = ec._XXIt_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._XXIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -12794,7 +15636,6 @@ var xxItImplementors = []string{"XxIt"}
func (ec *executionContext) _XxIt(ctx context.Context, sel ast.SelectionSet, obj *XxIt) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, xxItImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12802,7 +15643,12 @@ func (ec *executionContext) _XxIt(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("XxIt")
case "id":
- out.Values[i] = ec._XxIt_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._XxIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -12821,7 +15667,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12829,19 +15674,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -12860,7 +15735,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12868,19 +15742,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -12896,7 +15790,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12904,29 +15797,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -12942,7 +15865,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12950,19 +15872,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -12978,7 +15920,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -12986,21 +15927,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -13019,7 +15985,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -13027,26 +15992,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -13062,7 +16072,6 @@ var asdfItImplementors = []string{"asdfIt"}
func (ec *executionContext) _asdfIt(ctx context.Context, sel ast.SelectionSet, obj *AsdfIt) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, asdfItImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -13070,7 +16079,12 @@ func (ec *executionContext) _asdfIt(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("asdfIt")
case "id":
- out.Values[i] = ec._asdfIt_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._asdfIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -13089,7 +16103,6 @@ var iItImplementors = []string{"iIt"}
func (ec *executionContext) _iIt(ctx context.Context, sel ast.SelectionSet, obj *IIt) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, iItImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -13097,7 +16110,12 @@ func (ec *executionContext) _iIt(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("iIt")
case "id":
- out.Values[i] = ec._iIt_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._iIt_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -13152,7 +16170,7 @@ func (ec *executionContext) marshalNBytes2ᚕbyte(ctx context.Context, sel ast.S
return res
}
-func (ec *executionContext) marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler {
+func (ec *executionContext) marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
@@ -13162,6 +16180,25 @@ func (ec *executionContext) marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋ
return ec._CheckIssue896(ctx, sel, v)
}
+func (ec *executionContext) unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultInput(ctx context.Context, v interface{}) (DefaultInput, error) {
+ res, err := ec.unmarshalInputDefaultInput(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNDefaultParametersMirror2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v DefaultParametersMirror) graphql.Marshaler {
+ return ec._DefaultParametersMirror(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v *DefaultParametersMirror) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._DefaultParametersMirror(ctx, sel, v)
+}
+
func (ec *executionContext) unmarshalNDefaultScalarImplementation2string(ctx context.Context, v interface{}) (string, error) {
res, err := graphql.UnmarshalString(v)
return res, graphql.ErrorOnPath(ctx, err)
@@ -13177,31 +16214,31 @@ func (ec *executionContext) marshalNDefaultScalarImplementation2string(ctx conte
return res
}
-func (ec *executionContext) unmarshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmail(ctx context.Context, v interface{}) (Email, error) {
+func (ec *executionContext) unmarshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmail(ctx context.Context, v interface{}) (Email, error) {
var res Email
err := res.UnmarshalGQL(v)
return res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmail(ctx context.Context, sel ast.SelectionSet, v Email) graphql.Marshaler {
+func (ec *executionContext) marshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmail(ctx context.Context, sel ast.SelectionSet, v Email) graphql.Marshaler {
return v
}
-func (ec *executionContext) unmarshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEnumTest(ctx context.Context, v interface{}) (EnumTest, error) {
+func (ec *executionContext) unmarshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEnumTest(ctx context.Context, v interface{}) (EnumTest, error) {
var res EnumTest
err := res.UnmarshalGQL(v)
return res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEnumTest(ctx context.Context, sel ast.SelectionSet, v EnumTest) graphql.Marshaler {
+func (ec *executionContext) marshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEnumTest(ctx context.Context, sel ast.SelectionSet, v EnumTest) graphql.Marshaler {
return v
}
-func (ec *executionContext) marshalNError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler {
+func (ec *executionContext) marshalNError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler {
return ec._Error(ctx, sel, &v)
}
-func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler {
+func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
@@ -13211,13 +16248,13 @@ func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgen
return ec._Error(ctx, sel, v)
}
-func (ec *executionContext) unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx context.Context, v interface{}) (FallbackToStringEncoding, error) {
+func (ec *executionContext) unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFallbackToStringEncoding(ctx context.Context, v interface{}) (FallbackToStringEncoding, error) {
tmp, err := graphql.UnmarshalString(v)
res := FallbackToStringEncoding(tmp)
return res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx context.Context, sel ast.SelectionSet, v FallbackToStringEncoding) graphql.Marshaler {
+func (ec *executionContext) marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFallbackToStringEncoding(ctx context.Context, sel ast.SelectionSet, v FallbackToStringEncoding) graphql.Marshaler {
res := graphql.MarshalString(string(v))
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
@@ -13227,6 +16264,21 @@ func (ec *executionContext) marshalNFallbackToStringEncoding2githubᚗcomᚋ99de
return res
}
+func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v interface{}) (float64, error) {
+ res, err := graphql.UnmarshalFloatContext(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler {
+ res := graphql.MarshalFloatContext(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return graphql.WrapContextMarshaler(ctx, res)
+}
+
func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) {
res, err := graphql.UnmarshalIntID(v)
return res, graphql.ErrorOnPath(ctx, err)
@@ -13257,22 +16309,22 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec
return res
}
-func (ec *executionContext) unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) {
+func (ec *executionContext) unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) {
res, err := ec.unmarshalInputInnerDirectives(ctx, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx context.Context, v interface{}) (InnerInput, error) {
+func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerInput(ctx context.Context, v interface{}) (InnerInput, error) {
res, err := ec.unmarshalInputInnerInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx context.Context, v interface{}) (*InnerInput, error) {
+func (ec *executionContext) unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerInput(ctx context.Context, v interface{}) (*InnerInput, error) {
res, err := ec.unmarshalInputInnerInput(ctx, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v *InnerObject) graphql.Marshaler {
+func (ec *executionContext) marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v *InnerObject) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
@@ -13282,7 +16334,7 @@ func (ec *executionContext) marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgq
return ec._InnerObject(ctx, sel, v)
}
-func (ec *executionContext) unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx context.Context, v interface{}) (InputDirectives, error) {
+func (ec *executionContext) unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputDirectives(ctx context.Context, v interface{}) (InputDirectives, error) {
res, err := ec.unmarshalInputInputDirectives(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
@@ -13332,7 +16384,7 @@ func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.Selec
return res
}
-func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopA(ctx context.Context, sel ast.SelectionSet, v *LoopA) graphql.Marshaler {
+func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐLoopA(ctx context.Context, sel ast.SelectionSet, v *LoopA) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
@@ -13342,7 +16394,7 @@ func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgen
return ec._LoopA(ctx, sel, v)
}
-func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopB(ctx context.Context, sel ast.SelectionSet, v *LoopB) graphql.Marshaler {
+func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐLoopB(ctx context.Context, sel ast.SelectionSet, v *LoopB) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
@@ -13352,17 +16404,17 @@ func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgen
return ec._LoopB(ctx, sel, v)
}
-func (ec *executionContext) unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx context.Context, v interface{}) (MarshalPanic, error) {
+func (ec *executionContext) unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanic(ctx context.Context, v interface{}) (MarshalPanic, error) {
var res MarshalPanic
err := res.UnmarshalGQL(v)
return res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx context.Context, sel ast.SelectionSet, v MarshalPanic) graphql.Marshaler {
+func (ec *executionContext) marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanic(ctx context.Context, sel ast.SelectionSet, v MarshalPanic) graphql.Marshaler {
return v
}
-func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanicᚄ(ctx context.Context, v interface{}) ([]MarshalPanic, error) {
+func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx context.Context, v interface{}) ([]MarshalPanic, error) {
var vSlice []interface{}
if v != nil {
if tmp1, ok := v.([]interface{}); ok {
@@ -13375,7 +16427,7 @@ func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designs
res := make([]MarshalPanic, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
- res[i], err = ec.unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, vSlice[i])
+ res[i], err = ec.unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanic(ctx, vSlice[i])
if err != nil {
return nil, err
}
@@ -13383,21 +16435,27 @@ func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designs
return res, nil
}
-func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanicᚄ(ctx context.Context, sel ast.SelectionSet, v []MarshalPanic) graphql.Marshaler {
+func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx context.Context, sel ast.SelectionSet, v []MarshalPanic) graphql.Marshaler {
ret := make(graphql.Array, len(v))
for i := range v {
- ret[i] = ec.marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, sel, v[i])
+ ret[i] = ec.marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanic(ctx, sel, v[i])
+ }
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
}
return ret
}
-func (ec *executionContext) unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNestedInput(ctx context.Context, v interface{}) (*NestedInput, error) {
+func (ec *executionContext) unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNestedInput(ctx context.Context, v interface{}) (*NestedInput, error) {
res, err := ec.unmarshalInputNestedInput(ctx, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNode(ctx context.Context, sel ast.SelectionSet, v Node) graphql.Marshaler {
+func (ec *executionContext) marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNode(ctx context.Context, sel ast.SelectionSet, v Node) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
@@ -13407,11 +16465,11 @@ func (ec *executionContext) marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcod
return ec._Node(ctx, sel, v)
}
-func (ec *executionContext) marshalNPrimitive2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPrimitive(ctx context.Context, sel ast.SelectionSet, v Primitive) graphql.Marshaler {
+func (ec *executionContext) marshalNPrimitive2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitive(ctx context.Context, sel ast.SelectionSet, v Primitive) graphql.Marshaler {
return ec._Primitive(ctx, sel, &v)
}
-func (ec *executionContext) marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPrimitiveᚄ(ctx context.Context, sel ast.SelectionSet, v []Primitive) graphql.Marshaler {
+func (ec *executionContext) marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveᚄ(ctx context.Context, sel ast.SelectionSet, v []Primitive) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
@@ -13435,7 +16493,7 @@ func (ec *executionContext) marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlg
if !isLen1 {
defer wg.Done()
}
- ret[i] = ec.marshalNPrimitive2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPrimitive(ctx, sel, v[i])
+ ret[i] = ec.marshalNPrimitive2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitive(ctx, sel, v[i])
}
if isLen1 {
f(i)
@@ -13445,14 +16503,21 @@ func (ec *executionContext) marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
-func (ec *executionContext) marshalNPrimitiveString2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPrimitiveString(ctx context.Context, sel ast.SelectionSet, v PrimitiveString) graphql.Marshaler {
+func (ec *executionContext) marshalNPrimitiveString2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveString(ctx context.Context, sel ast.SelectionSet, v PrimitiveString) graphql.Marshaler {
return ec._PrimitiveString(ctx, sel, &v)
}
-func (ec *executionContext) marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPrimitiveStringᚄ(ctx context.Context, sel ast.SelectionSet, v []PrimitiveString) graphql.Marshaler {
+func (ec *executionContext) marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveStringᚄ(ctx context.Context, sel ast.SelectionSet, v []PrimitiveString) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
@@ -13476,7 +16541,7 @@ func (ec *executionContext) marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designs
if !isLen1 {
defer wg.Done()
}
- ret[i] = ec.marshalNPrimitiveString2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPrimitiveString(ctx, sel, v[i])
+ ret[i] = ec.marshalNPrimitiveString2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveString(ctx, sel, v[i])
}
if isLen1 {
f(i)
@@ -13486,15 +16551,50 @@ func (ec *executionContext) marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designs
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
-func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) {
+func (ec *executionContext) marshalNPtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, v PtrToPtrOuter) graphql.Marshaler {
+ return ec._PtrToPtrOuter(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNPtrToPtrOuter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, v *PtrToPtrOuter) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._PtrToPtrOuter(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalNPtrToSliceContainer2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, v PtrToSliceContainer) graphql.Marshaler {
+ return ec._PtrToSliceContainer(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNPtrToSliceContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, v *PtrToSliceContainer) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._PtrToSliceContainer(ctx, sel, v)
+}
+
+func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) {
res, err := ec.unmarshalInputRecursiveInputSlice(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShapeUnion(ctx context.Context, sel ast.SelectionSet, v ShapeUnion) graphql.Marshaler {
+func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShapeUnion(ctx context.Context, sel ast.SelectionSet, v ShapeUnion) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
@@ -13504,7 +16604,7 @@ func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgen
return ec._ShapeUnion(ctx, sel, v)
}
-func (ec *executionContext) unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSpecialInput(ctx context.Context, v interface{}) (SpecialInput, error) {
+func (ec *executionContext) unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSpecialInput(ctx context.Context, v interface{}) (SpecialInput, error) {
res, err := ec.unmarshalInputSpecialInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
@@ -13551,6 +16651,12 @@ func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel
ret[i] = ec.marshalNString2string(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -13605,6 +16711,47 @@ func (ec *executionContext) marshalNString2ᚖstring(ctx context.Context, sel as
return res
}
+func (ec *executionContext) unmarshalNStringFromContextFunction2string(ctx context.Context, v interface{}) (string, error) {
+ res, err := UnmarshalStringFromContextFunction(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNStringFromContextFunction2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
+ res := MarshalStringFromContextFunction(v)
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ }
+ return graphql.WrapContextMarshaler(ctx, res)
+}
+
+func (ec *executionContext) unmarshalNStringFromContextInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStringFromContextInterface(ctx context.Context, v interface{}) (StringFromContextInterface, error) {
+ var res StringFromContextInterface
+ err := res.UnmarshalGQLContext(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNStringFromContextInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStringFromContextInterface(ctx context.Context, sel ast.SelectionSet, v StringFromContextInterface) graphql.Marshaler {
+ return graphql.WrapContextMarshaler(ctx, v)
+}
+
+func (ec *executionContext) unmarshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStringFromContextInterface(ctx context.Context, v interface{}) (*StringFromContextInterface, error) {
+ var res = new(StringFromContextInterface)
+ err := res.UnmarshalGQLContext(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStringFromContextInterface(ctx context.Context, sel ast.SelectionSet, v *StringFromContextInterface) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return graphql.WrapContextMarshaler(ctx, v)
+}
+
func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) {
res, err := graphql.UnmarshalTime(v)
return res, graphql.ErrorOnPath(ctx, err)
@@ -13635,11 +16782,16 @@ func (ec *executionContext) marshalNUUID2string(ctx context.Context, sel ast.Sel
return res
}
-func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler {
+func (ec *executionContext) unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrOuter(ctx context.Context, v interface{}) (UpdatePtrToPtrOuter, error) {
+ res, err := ec.unmarshalInputUpdatePtrToPtrOuter(ctx, v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler {
return ec._User(ctx, sel, &v)
}
-func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUserᚄ(ctx context.Context, sel ast.SelectionSet, v []*User) graphql.Marshaler {
+func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUserᚄ(ctx context.Context, sel ast.SelectionSet, v []*User) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
@@ -13663,7 +16815,7 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
if !isLen1 {
defer wg.Done()
}
- ret[i] = ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, sel, v[i])
+ ret[i] = ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUser(ctx, sel, v[i])
}
if isLen1 {
f(i)
@@ -13673,10 +16825,17 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
-func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler {
+func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
@@ -13686,7 +16845,7 @@ func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ
return ec._User(ctx, sel, v)
}
-func (ec *executionContext) marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedMap(ctx context.Context, sel ast.SelectionSet, v WrappedMap) graphql.Marshaler {
+func (ec *executionContext) marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedMap(ctx context.Context, sel ast.SelectionSet, v WrappedMap) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
@@ -13696,13 +16855,13 @@ func (ec *executionContext) marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgen
return ec._WrappedMap(ctx, sel, v)
}
-func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx context.Context, v interface{}) (otherpkg.Scalar, error) {
+func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx context.Context, v interface{}) (otherpkg.Scalar, error) {
tmp, err := graphql.UnmarshalString(v)
res := otherpkg.Scalar(tmp)
return res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v otherpkg.Scalar) graphql.Marshaler {
+func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v otherpkg.Scalar) graphql.Marshaler {
res := graphql.MarshalString(string(v))
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
@@ -13712,7 +16871,7 @@ func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgql
return res
}
-func (ec *executionContext) marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedSlice(ctx context.Context, sel ast.SelectionSet, v WrappedSlice) graphql.Marshaler {
+func (ec *executionContext) marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedSlice(ctx context.Context, sel ast.SelectionSet, v WrappedSlice) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
@@ -13722,11 +16881,11 @@ func (ec *executionContext) marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlg
return ec._WrappedSlice(ctx, sel, v)
}
-func (ec *executionContext) marshalNWrappedStruct2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v WrappedStruct) graphql.Marshaler {
+func (ec *executionContext) marshalNWrappedStruct2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v WrappedStruct) graphql.Marshaler {
return ec._WrappedStruct(ctx, sel, &v)
}
-func (ec *executionContext) marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v *WrappedStruct) graphql.Marshaler {
+func (ec *executionContext) marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v *WrappedStruct) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
@@ -13771,9 +16930,16 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
} else {
go f(i)
}
-
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
}
- wg.Wait()
+
return ret
}
@@ -13847,6 +17013,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -13896,6 +17069,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -13937,6 +17117,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -13965,21 +17152,21 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a
return res
}
-func (ec *executionContext) marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAnimal(ctx context.Context, sel ast.SelectionSet, v Animal) graphql.Marshaler {
+func (ec *executionContext) marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐAnimal(ctx context.Context, sel ast.SelectionSet, v Animal) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Animal(ctx, sel, v)
}
-func (ec *executionContext) marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAutobind(ctx context.Context, sel ast.SelectionSet, v *Autobind) graphql.Marshaler {
+func (ec *executionContext) marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐAutobind(ctx context.Context, sel ast.SelectionSet, v *Autobind) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Autobind(ctx, sel, v)
}
-func (ec *executionContext) marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐBackedByInterface(ctx context.Context, sel ast.SelectionSet, v BackedByInterface) graphql.Marshaler {
+func (ec *executionContext) marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐBackedByInterface(ctx context.Context, sel ast.SelectionSet, v BackedByInterface) graphql.Marshaler {
if v == nil {
return graphql.Null
}
@@ -13992,7 +17179,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -14007,7 +17195,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) unmarshalOChanges2map(ctx context.Context, v interface{}) (map[string]interface{}, error) {
@@ -14017,7 +17206,7 @@ func (ec *executionContext) unmarshalOChanges2map(ctx context.Context, v interfa
return v.(map[string]interface{}), nil
}
-func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v []*CheckIssue896) graphql.Marshaler {
+func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v []*CheckIssue896) graphql.Marshaler {
if v == nil {
return graphql.Null
}
@@ -14044,7 +17233,7 @@ func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designs
if !isLen1 {
defer wg.Done()
}
- ret[i] = ec.marshalOCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896(ctx, sel, v[i])
+ ret[i] = ec.marshalOCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx, sel, v[i])
}
if isLen1 {
f(i)
@@ -14054,10 +17243,11 @@ func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designs
}
wg.Wait()
+
return ret
}
-func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896ᚄ(ctx context.Context, sel ast.SelectionSet, v []*CheckIssue896) graphql.Marshaler {
+func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896ᚄ(ctx context.Context, sel ast.SelectionSet, v []*CheckIssue896) graphql.Marshaler {
if v == nil {
return graphql.Null
}
@@ -14084,7 +17274,7 @@ func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designs
if !isLen1 {
defer wg.Done()
}
- ret[i] = ec.marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896(ctx, sel, v[i])
+ ret[i] = ec.marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx, sel, v[i])
}
if isLen1 {
f(i)
@@ -14094,23 +17284,34 @@ func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designs
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
-func (ec *executionContext) marshalOCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler {
+func (ec *executionContext) marshalOCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._CheckIssue896(ctx, sel, v)
}
-func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler {
+func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Circle(ctx, sel, v)
}
+func (ec *executionContext) marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCoordinates(ctx context.Context, sel ast.SelectionSet, v Coordinates) graphql.Marshaler {
+ return ec._Coordinates(ctx, sel, &v)
+}
+
func (ec *executionContext) unmarshalODefaultScalarImplementation2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
if v == nil {
return nil, nil
@@ -14123,38 +17324,127 @@ func (ec *executionContext) marshalODefaultScalarImplementation2ᚖstring(ctx co
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
-func (ec *executionContext) marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase1(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase1) graphql.Marshaler {
+func (ec *executionContext) marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase1(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase1) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._EmbeddedCase1(ctx, sel, v)
}
-func (ec *executionContext) marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase2(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase2) graphql.Marshaler {
+func (ec *executionContext) marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase2(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase2) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._EmbeddedCase2(ctx, sel, v)
}
-func (ec *executionContext) marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase3(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase3) graphql.Marshaler {
+func (ec *executionContext) marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase3(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase3) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._EmbeddedCase3(ctx, sel, v)
}
-func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler {
+func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ return ret
+}
+
+func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐErrorᚄ(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
+func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Error(ctx, sel, v)
}
-func (ec *executionContext) marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐErrors(ctx context.Context, sel ast.SelectionSet, v *Errors) graphql.Marshaler {
+func (ec *executionContext) marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐErrors(ctx context.Context, sel ast.SelectionSet, v *Errors) graphql.Marshaler {
if v == nil {
return graphql.Null
}
@@ -14162,15 +17452,16 @@ func (ec *executionContext) marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgen
}
func (ec *executionContext) unmarshalOFloat2float64(ctx context.Context, v interface{}) (float64, error) {
- res, err := graphql.UnmarshalFloat(v)
+ res, err := graphql.UnmarshalFloatContext(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler {
- return graphql.MarshalFloat(v)
+ res := graphql.MarshalFloatContext(v)
+ return graphql.WrapContextMarshaler(ctx, res)
}
-func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) {
+func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) {
if v == nil {
return nil, nil
}
@@ -14178,7 +17469,7 @@ func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99design
return &res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx context.Context, v interface{}) (*InputDirectives, error) {
+func (ec *executionContext) unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputDirectives(ctx context.Context, v interface{}) (*InputDirectives, error) {
if v == nil {
return nil, nil
}
@@ -14186,7 +17477,7 @@ func (ec *executionContext) unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99design
return &res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputWithEnumValue(ctx context.Context, v interface{}) (*InputWithEnumValue, error) {
+func (ec *executionContext) unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputWithEnumValue(ctx context.Context, v interface{}) (*InputWithEnumValue, error) {
if v == nil {
return nil, nil
}
@@ -14206,17 +17497,18 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele
if v == nil {
return graphql.Null
}
- return graphql.MarshalInt(*v)
+ res := graphql.MarshalInt(*v)
+ return res
}
-func (ec *executionContext) marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler {
+func (ec *executionContext) marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._InvalidIdentifier(ctx, sel, v)
}
-func (ec *executionContext) marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v *introspection1.It) graphql.Marshaler {
+func (ec *executionContext) marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v *introspection1.It) graphql.Marshaler {
if v == nil {
return graphql.Null
}
@@ -14237,14 +17529,14 @@ func (ec *executionContext) marshalOMapStringInterfaceType2map(ctx context.Conte
return ec._MapStringInterfaceType(ctx, sel, v)
}
-func (ec *executionContext) marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v *ModelMethods) graphql.Marshaler {
+func (ec *executionContext) marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v *ModelMethods) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._ModelMethods(ctx, sel, v)
}
-func (ec *executionContext) unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNestedMapInput(ctx context.Context, v interface{}) (*NestedMapInput, error) {
+func (ec *executionContext) unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNestedMapInput(ctx context.Context, v interface{}) (*NestedMapInput, error) {
if v == nil {
return nil, nil
}
@@ -14252,21 +17544,21 @@ func (ec *executionContext) unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designs
return &res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐObjectDirectives(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectives) graphql.Marshaler {
+func (ec *executionContext) marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐObjectDirectives(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectives) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._ObjectDirectives(ctx, sel, v)
}
-func (ec *executionContext) marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectivesWithCustomGoModel) graphql.Marshaler {
+func (ec *executionContext) marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectivesWithCustomGoModel) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._ObjectDirectivesWithCustomGoModel(ctx, sel, v)
}
-func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx context.Context, v interface{}) ([][]*OuterInput, error) {
+func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx context.Context, v interface{}) ([][]*OuterInput, error) {
if v == nil {
return nil, nil
}
@@ -14282,7 +17574,7 @@ func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99desig
res := make([][]*OuterInput, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
- res[i], err = ec.unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx, vSlice[i])
+ res[i], err = ec.unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
@@ -14290,7 +17582,7 @@ func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99desig
return res, nil
}
-func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx context.Context, v interface{}) ([]*OuterInput, error) {
+func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx context.Context, v interface{}) ([]*OuterInput, error) {
if v == nil {
return nil, nil
}
@@ -14306,7 +17598,7 @@ func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designs
res := make([]*OuterInput, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
- res[i], err = ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx, vSlice[i])
+ res[i], err = ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
@@ -14314,7 +17606,7 @@ func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designs
return res, nil
}
-func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx context.Context, v interface{}) (*OuterInput, error) {
+func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx context.Context, v interface{}) (*OuterInput, error) {
if v == nil {
return nil, nil
}
@@ -14322,7 +17614,7 @@ func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋg
return &res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler {
+func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler {
if v == nil {
return graphql.Null
}
@@ -14349,7 +17641,7 @@ func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99design
if !isLen1 {
defer wg.Done()
}
- ret[i] = ec.marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, sel, v[i])
+ ret[i] = ec.marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx, sel, v[i])
}
if isLen1 {
f(i)
@@ -14359,10 +17651,11 @@ func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99design
}
wg.Wait()
+
return ret
}
-func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v []*OuterObject) graphql.Marshaler {
+func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v []*OuterObject) graphql.Marshaler {
if v == nil {
return graphql.Null
}
@@ -14389,7 +17682,7 @@ func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designs
if !isLen1 {
defer wg.Done()
}
- ret[i] = ec.marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, sel, v[i])
+ ret[i] = ec.marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx, sel, v[i])
}
if isLen1 {
f(i)
@@ -14399,31 +17692,81 @@ func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designs
}
wg.Wait()
+
return ret
}
-func (ec *executionContext) marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v *OuterObject) graphql.Marshaler {
+func (ec *executionContext) marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v *OuterObject) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._OuterObject(ctx, sel, v)
}
-func (ec *executionContext) marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOverlappingFields(ctx context.Context, sel ast.SelectionSet, v *OverlappingFields) graphql.Marshaler {
+func (ec *executionContext) marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOverlappingFields(ctx context.Context, sel ast.SelectionSet, v *OverlappingFields) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._OverlappingFields(ctx, sel, v)
}
-func (ec *executionContext) marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx context.Context, sel ast.SelectionSet, v *Panics) graphql.Marshaler {
+func (ec *executionContext) marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPanics(ctx context.Context, sel ast.SelectionSet, v *Panics) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Panics(ctx, sel, v)
}
-func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSliceᚄ(ctx context.Context, v interface{}) ([]RecursiveInputSlice, error) {
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._PtrToPtrInner(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v **PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ***PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ****PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *****PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ******PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *******PtrToPtrInner) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v)
+}
+
+func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSliceᚄ(ctx context.Context, v interface{}) ([]RecursiveInputSlice, error) {
if v == nil {
return nil, nil
}
@@ -14439,7 +17782,7 @@ func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99de
res := make([]RecursiveInputSlice, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
- res[i], err = ec.unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx, vSlice[i])
+ res[i], err = ec.unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSlice(ctx, vSlice[i])
if err != nil {
return nil, err
}
@@ -14447,7 +17790,7 @@ func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99de
return res, nil
}
-func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx context.Context, v interface{}) (*RecursiveInputSlice, error) {
+func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSlice(ctx context.Context, v interface{}) (*RecursiveInputSlice, error) {
if v == nil {
return nil, nil
}
@@ -14455,14 +17798,14 @@ func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99de
return &res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler {
+func (ec *executionContext) marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Shape(ctx, sel, v)
}
-func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler {
+func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler {
if v == nil {
return graphql.Null
}
@@ -14489,7 +17832,7 @@ func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgen
if !isLen1 {
defer wg.Done()
}
- ret[i] = ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, sel, v[i])
+ ret[i] = ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx, sel, v[i])
}
if isLen1 {
f(i)
@@ -14499,10 +17842,11 @@ func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
return ret
}
-func (ec *executionContext) marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSlices(ctx context.Context, sel ast.SelectionSet, v *Slices) graphql.Marshaler {
+func (ec *executionContext) marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSlices(ctx context.Context, sel ast.SelectionSet, v *Slices) graphql.Marshaler {
if v == nil {
return graphql.Null
}
@@ -14515,7 +17859,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) {
@@ -14551,6 +17896,12 @@ func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel
ret[i] = ec.marshalNString2string(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -14602,17 +17953,30 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
+}
+
+func (ec *executionContext) unmarshalOString2ᚖᚕstringᚄ(ctx context.Context, v interface{}) (*[]string, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOString2ᚖᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v *[]string) graphql.Marshaler {
+ return ec.marshalOString2ᚕstringᚄ(ctx, sel, *v)
}
-func (ec *executionContext) marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐTestUnion(ctx context.Context, sel ast.SelectionSet, v TestUnion) graphql.Marshaler {
+func (ec *executionContext) marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐTestUnion(ctx context.Context, sel ast.SelectionSet, v TestUnion) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._TestUnion(ctx, sel, v)
}
-func (ec *executionContext) unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, v interface{}) (*ThirdParty, error) {
+func (ec *executionContext) unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐThirdParty(ctx context.Context, v interface{}) (*ThirdParty, error) {
if v == nil {
return nil, nil
}
@@ -14620,11 +17984,12 @@ func (ec *executionContext) unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋg
return &res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, sel ast.SelectionSet, v *ThirdParty) graphql.Marshaler {
+func (ec *executionContext) marshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐThirdParty(ctx context.Context, sel ast.SelectionSet, v *ThirdParty) graphql.Marshaler {
if v == nil {
return graphql.Null
}
- return MarshalThirdParty(*v)
+ res := MarshalThirdParty(*v)
+ return res
}
func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) {
@@ -14639,10 +18004,117 @@ func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel
if v == nil {
return graphql.Null
}
- return graphql.MarshalTime(*v)
+ res := graphql.MarshalTime(*v)
+ return res
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (*UpdatePtrToPtrInner, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalInputUpdatePtrToPtrInner(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (**UpdatePtrToPtrInner, error) {
+ var pres *UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (***UpdatePtrToPtrInner, error) {
+ var pres **UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (****UpdatePtrToPtrInner, error) {
+ var pres ***UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (*****UpdatePtrToPtrInner, error) {
+ var pres ****UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (******UpdatePtrToPtrInner, error) {
+ var pres *****UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (*******UpdatePtrToPtrInner, error) {
+ var pres ******UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (********UpdatePtrToPtrInner, error) {
+ var pres *******UpdatePtrToPtrInner
+ if v != nil {
+ res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
+}
+
+func (ec *executionContext) marshalOVOkCaseNil2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVOkCaseNil(ctx context.Context, sel ast.SelectionSet, v *VOkCaseNil) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._VOkCaseNil(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOVOkCaseValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVOkCaseValue(ctx context.Context, sel ast.SelectionSet, v *VOkCaseValue) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._VOkCaseValue(ctx, sel, v)
}
-func (ec *executionContext) unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidInput(ctx context.Context, v interface{}) (*ValidInput, error) {
+func (ec *executionContext) unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐValidInput(ctx context.Context, v interface{}) (*ValidInput, error) {
if v == nil {
return nil, nil
}
@@ -14650,14 +18122,14 @@ func (ec *executionContext) unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋg
return &res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidType(ctx context.Context, sel ast.SelectionSet, v *ValidType) graphql.Marshaler {
+func (ec *executionContext) marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐValidType(ctx context.Context, sel ast.SelectionSet, v *ValidType) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._ValidType(ctx, sel, v)
}
-func (ec *executionContext) unmarshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx context.Context, v interface{}) (*otherpkg.Scalar, error) {
+func (ec *executionContext) unmarshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx context.Context, v interface{}) (*otherpkg.Scalar, error) {
if v == nil {
return nil, nil
}
@@ -14666,11 +18138,12 @@ func (ec *executionContext) unmarshalOWrappedScalar2ᚖgithubᚗcomᚋ99designs
return &res, graphql.ErrorOnPath(ctx, err)
}
-func (ec *executionContext) marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v *otherpkg.Scalar) graphql.Marshaler {
+func (ec *executionContext) marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v *otherpkg.Scalar) graphql.Marshaler {
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(string(*v))
+ res := graphql.MarshalString(string(*v))
+ return res
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
@@ -14710,6 +18183,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -14750,6 +18230,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -14790,6 +18277,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -14837,6 +18331,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/codegen/testserver/singlefile/generated_test.go b/codegen/testserver/singlefile/generated_test.go
new file mode 100644
index 00000000000..6d1dfa7e3cc
--- /dev/null
+++ b/codegen/testserver/singlefile/generated_test.go
@@ -0,0 +1,80 @@
+//go:generate rm -f resolver.go
+//go:generate go run ../../../testdata/gqlgen.go -config gqlgen.yml -stub stub.go
+
+package singlefile
+
+import (
+ "context"
+ "reflect"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestForcedResolverFieldIsPointer(t *testing.T) {
+ field, ok := reflect.TypeOf((*ForcedResolverResolver)(nil)).Elem().MethodByName("Field")
+ require.True(t, ok)
+ require.Equal(t, "*singlefile.Circle", field.Type.Out(0).String())
+}
+
+func TestEnums(t *testing.T) {
+ t.Run("list of enums", func(t *testing.T) {
+ require.Equal(t, StatusOk, AllStatus[0])
+ require.Equal(t, StatusError, AllStatus[1])
+ })
+
+ t.Run("invalid enum values", func(t *testing.T) {
+ require.Equal(t, StatusOk, AllStatus[0])
+ require.Equal(t, StatusError, AllStatus[1])
+ })
+}
+
+func TestUnionFragments(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.ShapeUnion = func(ctx context.Context) (ShapeUnion, error) {
+ return &Circle{Radius: 32}, nil
+ }
+
+ srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))
+ c := client.New(srv)
+
+ t.Run("inline fragment on union", func(t *testing.T) {
+ var resp struct {
+ ShapeUnion struct {
+ Radius float64
+ }
+ }
+ c.MustPost(`query {
+ shapeUnion {
+ ... on Circle {
+ radius
+ }
+ }
+ }
+ `, &resp)
+ require.NotEmpty(t, resp.ShapeUnion.Radius)
+ })
+
+ t.Run("named fragment", func(t *testing.T) {
+ var resp struct {
+ ShapeUnion struct {
+ Radius float64
+ }
+ }
+ c.MustPost(`query {
+ shapeUnion {
+ ...C
+ }
+ }
+
+ fragment C on ShapeUnion {
+ ... on Circle {
+ radius
+ }
+ }
+ `, &resp)
+ require.NotEmpty(t, resp.ShapeUnion.Radius)
+ })
+}
diff --git a/codegen/testserver/singlefile/gqlgen.yml b/codegen/testserver/singlefile/gqlgen.yml
new file mode 100644
index 00000000000..afd3fb90dd8
--- /dev/null
+++ b/codegen/testserver/singlefile/gqlgen.yml
@@ -0,0 +1,25 @@
+schema:
+ - "*.graphql"
+skip_validation: true
+exec:
+ filename: generated.go
+ package: singlefile
+model:
+ filename: models-gen.go
+ package: singlefile
+resolver:
+ filename: resolver.go
+ package: singlefile
+ type: Resolver
+
+autobind:
+ - "github.com/99designs/gqlgen/codegen/testserver"
+ - "github.com/99designs/gqlgen/codegen/testserver/singlefile"
+ - "github.com/99designs/gqlgen/codegen/testserver/singlefile/introspection"
+ - "github.com/99designs/gqlgen/codegen/testserver/singlefile/invalid-packagename"
+
+models:
+ Email:
+ model: "github.com/99designs/gqlgen/codegen/testserver/singlefile.Email"
+ StringFromContextFunction:
+ model: "github.com/99designs/gqlgen/codegen/testserver/singlefile.StringFromContextFunction"
diff --git a/codegen/testserver/input_test.go b/codegen/testserver/singlefile/input_test.go
similarity index 70%
rename from codegen/testserver/input_test.go
rename to codegen/testserver/singlefile/input_test.go
index 1a54508d721..454ee615900 100644
--- a/codegen/testserver/input_test.go
+++ b/codegen/testserver/singlefile/input_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
@@ -46,4 +46,24 @@ func TestInput(t *testing.T) {
require.NoError(t, err)
require.False(t, resp.InputNullableSlice)
})
+
+ t.Run("coerce single value to slice", func(t *testing.T) {
+ check := func(ctx context.Context, arg []string) (b bool, e error) {
+ return len(arg) == 1 && arg[0] == "coerced", nil
+ }
+ resolvers.QueryResolver.InputSlice = check
+ resolvers.QueryResolver.InputNullableSlice = check
+
+ var resp struct {
+ Coerced bool
+ }
+ var err error
+ err = c.Post(`query { coerced: inputSlice(arg: "coerced") }`, &resp)
+ require.NoError(t, err)
+ require.True(t, resp.Coerced)
+
+ err = c.Post(`query { coerced: inputNullableSlice(arg: "coerced") }`, &resp)
+ require.NoError(t, err)
+ require.True(t, resp.Coerced)
+ })
}
diff --git a/codegen/testserver/interfaces.go b/codegen/testserver/singlefile/interfaces.go
similarity index 96%
rename from codegen/testserver/interfaces.go
rename to codegen/testserver/singlefile/interfaces.go
index 87243965a2f..1115fabdbac 100644
--- a/codegen/testserver/interfaces.go
+++ b/codegen/testserver/singlefile/interfaces.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import "math"
@@ -14,6 +14,7 @@ type ShapeUnion interface {
type Circle struct {
Radius float64
+ Coordinates
}
func (c *Circle) Area() float64 {
@@ -25,6 +26,7 @@ func (c *Circle) isShape() {}
type Rectangle struct {
Length, Width float64
+ Coordinates
}
func (r *Rectangle) Area() float64 {
@@ -79,6 +81,7 @@ type BackedByInterfaceImpl struct {
func (b *BackedByInterfaceImpl) ThisShouldBind() string {
return b.Value
}
+
func (b *BackedByInterfaceImpl) ThisShouldBindWithError() (string, error) {
return b.Value, b.Error
}
diff --git a/codegen/testserver/interfaces.graphql b/codegen/testserver/singlefile/interfaces.graphql
similarity index 78%
rename from codegen/testserver/interfaces.graphql
rename to codegen/testserver/singlefile/interfaces.graphql
index 8db93578173..4b6480be83c 100644
--- a/codegen/testserver/interfaces.graphql
+++ b/codegen/testserver/singlefile/interfaces.graphql
@@ -27,19 +27,27 @@ type Cat implements Animal {
catBreed: String!
}
+type Coordinates {
+ x: Float!
+ y: Float!
+}
interface Shape {
area: Float
+ coordinates: Coordinates
}
+
type Circle implements Shape {
radius: Float
area: Float
+ coordinates: Coordinates
}
type Rectangle implements Shape {
length: Float
width: Float
area: Float
+ coordinates: Coordinates
}
-union ShapeUnion @goModel(model:"testserver.ShapeUnion") = Circle | Rectangle
+union ShapeUnion @goModel(model: "singlefile.ShapeUnion") = Circle | Rectangle
directive @makeNil on FIELD_DEFINITION
directive @makeTypedNil on FIELD_DEFINITION
@@ -55,7 +63,7 @@ type ConcreteNodeA implements Node {
name: String!
}
-""" Implements the Node interface with another interface """
+" Implements the Node interface with another interface "
type ConcreteNodeInterface implements Node {
id: ID!
child: Node!
diff --git a/codegen/testserver/interfaces_test.go b/codegen/testserver/singlefile/interfaces_test.go
similarity index 82%
rename from codegen/testserver/interfaces_test.go
rename to codegen/testserver/singlefile/interfaces_test.go
index b8ae9129b1a..6093a8d7024 100644
--- a/codegen/testserver/interfaces_test.go
+++ b/codegen/testserver/singlefile/interfaces_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
@@ -16,7 +16,7 @@ func TestInterfaces(t *testing.T) {
t.Run("slices of interfaces are not pointers", func(t *testing.T) {
field, ok := reflect.TypeOf((*QueryResolver)(nil)).Elem().MethodByName("Shapes")
require.True(t, ok)
- require.Equal(t, "[]testserver.Shape", field.Type.Out(0).String())
+ require.Equal(t, "[]singlefile.Shape", field.Type.Out(0).String())
})
t.Run("models returning interfaces", func(t *testing.T) {
@@ -197,4 +197,60 @@ func TestInterfaces(t *testing.T) {
require.Equal(t, "CNII", resp.Node.ID)
require.Equal(t, "Child", resp.Node.Child.ID)
})
+
+ t.Run("interface implementors should return merged base fields", func(t *testing.T) {
+ resolvers := &Stub{}
+ resolvers.QueryResolver.Shapes = func(ctx context.Context) (shapes []Shape, err error) {
+ return []Shape{
+ &Rectangle{
+ Coordinates: Coordinates{
+ X: -1,
+ Y: -1,
+ },
+ },
+ &Circle{
+ Coordinates: Coordinates{
+ X: 1,
+ Y: 1,
+ },
+ },
+ }, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+ var resp struct {
+ Shapes []struct {
+ Coordinates struct {
+ X float64
+ Y float64
+ }
+ }
+ }
+
+ c.MustPost(`
+ {
+ shapes {
+ coordinates {
+ x
+ }
+ ... on Rectangle {
+ coordinates {
+ x
+ }
+ }
+ ... on Circle {
+ coordinates {
+ y
+ }
+ }
+ }
+ }
+ `, &resp)
+
+ require.Equal(t, 2, len(resp.Shapes))
+ require.Equal(t, float64(-1), resp.Shapes[0].Coordinates.X)
+ require.Equal(t, float64(0), resp.Shapes[0].Coordinates.Y)
+ require.Equal(t, float64(1), resp.Shapes[1].Coordinates.X)
+ require.Equal(t, float64(1), resp.Shapes[1].Coordinates.Y)
+ })
}
diff --git a/codegen/testserver/singlefile/introspection/it.go b/codegen/testserver/singlefile/introspection/it.go
new file mode 100644
index 00000000000..e1849681a8b
--- /dev/null
+++ b/codegen/testserver/singlefile/introspection/it.go
@@ -0,0 +1,5 @@
+package introspection
+
+type It struct {
+ ID string
+}
diff --git a/codegen/testserver/introspection_test.go b/codegen/testserver/singlefile/introspection_test.go
similarity index 99%
rename from codegen/testserver/introspection_test.go
rename to codegen/testserver/singlefile/introspection_test.go
index e98dbe93e2a..f78a8202c10 100644
--- a/codegen/testserver/introspection_test.go
+++ b/codegen/testserver/singlefile/introspection_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/singlefile/invalid-packagename/invalid-identifier.go b/codegen/testserver/singlefile/invalid-packagename/invalid-identifier.go
new file mode 100644
index 00000000000..fe0feb7165b
--- /dev/null
+++ b/codegen/testserver/singlefile/invalid-packagename/invalid-identifier.go
@@ -0,0 +1,5 @@
+package invalid_packagename
+
+type InvalidIdentifier struct {
+ ID int
+}
diff --git a/codegen/testserver/singlefile/issue896.graphql b/codegen/testserver/singlefile/issue896.graphql
new file mode 100644
index 00000000000..ed324f54ed9
--- /dev/null
+++ b/codegen/testserver/singlefile/issue896.graphql
@@ -0,0 +1,18 @@
+# This example should build stable output. If the file content starts
+# alternating nondeterministically between two outputs, then see
+# https://github.com/99designs/gqlgen/issues/896.
+
+extend schema {
+ query: Query
+ subscription: Subscription
+}
+
+type CheckIssue896 {id: Int}
+
+extend type Query {
+ issue896a: [CheckIssue896!] # Note the "!" or lack thereof.
+}
+
+extend type Subscription {
+ issue896b: [CheckIssue896] # Note the "!" or lack thereof.
+}
diff --git a/codegen/testserver/singlefile/loops.graphql b/codegen/testserver/singlefile/loops.graphql
new file mode 100644
index 00000000000..0254ef4a0e6
--- /dev/null
+++ b/codegen/testserver/singlefile/loops.graphql
@@ -0,0 +1,7 @@
+type LoopA {
+ b: LoopB!
+}
+
+type LoopB {
+ a: LoopA!
+}
diff --git a/codegen/testserver/singlefile/maps.graphql b/codegen/testserver/singlefile/maps.graphql
new file mode 100644
index 00000000000..0fd639b0c48
--- /dev/null
+++ b/codegen/testserver/singlefile/maps.graphql
@@ -0,0 +1,18 @@
+extend type Query {
+ mapStringInterface(in: MapStringInterfaceInput): MapStringInterfaceType
+ mapNestedStringInterface(in: NestedMapInput): MapStringInterfaceType
+}
+
+type MapStringInterfaceType @goModel(model: "map[string]interface{}") {
+ a: String
+ b: Int
+}
+
+input MapStringInterfaceInput @goModel(model: "map[string]interface{}") {
+ a: String
+ b: Int
+}
+
+input NestedMapInput {
+ map: MapStringInterfaceInput
+}
diff --git a/codegen/testserver/maps_test.go b/codegen/testserver/singlefile/maps_test.go
similarity index 99%
rename from codegen/testserver/maps_test.go
rename to codegen/testserver/singlefile/maps_test.go
index 85b964d9eb8..0c7129ae61f 100644
--- a/codegen/testserver/maps_test.go
+++ b/codegen/testserver/singlefile/maps_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/middleware_test.go b/codegen/testserver/singlefile/middleware_test.go
similarity index 99%
rename from codegen/testserver/middleware_test.go
rename to codegen/testserver/singlefile/middleware_test.go
index 891280b9e21..4a8babd5ee1 100644
--- a/codegen/testserver/middleware_test.go
+++ b/codegen/testserver/singlefile/middleware_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/modelmethod_test.go b/codegen/testserver/singlefile/modelmethod_test.go
similarity index 98%
rename from codegen/testserver/modelmethod_test.go
rename to codegen/testserver/singlefile/modelmethod_test.go
index 6455a8cef44..aefb14aa7b7 100644
--- a/codegen/testserver/modelmethod_test.go
+++ b/codegen/testserver/singlefile/modelmethod_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/singlefile/models-gen.go
similarity index 94%
rename from codegen/testserver/models-gen.go
rename to codegen/testserver/singlefile/models-gen.go
index 3bae2a74c69..6e59b20b8b8 100644
--- a/codegen/testserver/models-gen.go
+++ b/codegen/testserver/singlefile/models-gen.go
@@ -1,6 +1,6 @@
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
-package testserver
+package singlefile
import (
"fmt"
@@ -64,6 +64,21 @@ type ContentUser struct {
func (ContentUser) IsContentChild() {}
+type Coordinates struct {
+ X float64 `json:"x"`
+ Y float64 `json:"y"`
+}
+
+type DefaultInput struct {
+ FalsyBoolean *bool `json:"falsyBoolean"`
+ TruthyBoolean *bool `json:"truthyBoolean"`
+}
+
+type DefaultParametersMirror struct {
+ FalsyBoolean *bool `json:"falsyBoolean"`
+ TruthyBoolean *bool `json:"truthyBoolean"`
+}
+
type Dog struct {
Species string `json:"species"`
DogBreed string `json:"dogBreed"`
diff --git a/codegen/testserver/models.go b/codegen/testserver/singlefile/models.go
similarity index 98%
rename from codegen/testserver/models.go
rename to codegen/testserver/singlefile/models.go
index 9bdc3a8d0de..556f80a62a1 100644
--- a/codegen/testserver/models.go
+++ b/codegen/testserver/singlefile/models.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/mutation_with_custom_scalar.go b/codegen/testserver/singlefile/mutation_with_custom_scalar.go
similarity index 96%
rename from codegen/testserver/mutation_with_custom_scalar.go
rename to codegen/testserver/singlefile/mutation_with_custom_scalar.go
index c2de6a9049e..22c4586f29c 100644
--- a/codegen/testserver/mutation_with_custom_scalar.go
+++ b/codegen/testserver/singlefile/mutation_with_custom_scalar.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"encoding/json"
diff --git a/codegen/testserver/singlefile/mutation_with_custom_scalar.graphql b/codegen/testserver/singlefile/mutation_with_custom_scalar.graphql
new file mode 100644
index 00000000000..e9896ddb537
--- /dev/null
+++ b/codegen/testserver/singlefile/mutation_with_custom_scalar.graphql
@@ -0,0 +1,13 @@
+extend type Mutation {
+ updateSomething(input: SpecialInput!): String!
+}
+
+scalar Email
+
+input SpecialInput {
+ nesting: NestedInput!
+}
+
+input NestedInput {
+ field: Email!
+}
diff --git a/codegen/testserver/mutation_with_custom_scalar_test.go b/codegen/testserver/singlefile/mutation_with_custom_scalar_test.go
similarity index 98%
rename from codegen/testserver/mutation_with_custom_scalar_test.go
rename to codegen/testserver/singlefile/mutation_with_custom_scalar_test.go
index 6cc022172c2..3290b373e26 100644
--- a/codegen/testserver/mutation_with_custom_scalar_test.go
+++ b/codegen/testserver/singlefile/mutation_with_custom_scalar_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/singlefile/nulls.graphql b/codegen/testserver/singlefile/nulls.graphql
new file mode 100644
index 00000000000..a1fea680ce2
--- /dev/null
+++ b/codegen/testserver/singlefile/nulls.graphql
@@ -0,0 +1,22 @@
+extend type Query {
+ errorBubble: Error
+ errorBubbleList: [Error!]
+ errorList: [Error]
+ errors: Errors
+ valid: String!
+}
+
+type Errors {
+ a: Error!
+ b: Error!
+ c: Error!
+ d: Error!
+ e: Error!
+}
+
+type Error {
+ id: ID!
+ errorOnNonRequiredField: String
+ errorOnRequiredField: String!
+ nilOnRequiredField: String!
+}
diff --git a/codegen/testserver/nulls_test.go b/codegen/testserver/singlefile/nulls_test.go
similarity index 76%
rename from codegen/testserver/nulls_test.go
rename to codegen/testserver/singlefile/nulls_test.go
index e79eecc283a..615c89ba968 100644
--- a/codegen/testserver/nulls_test.go
+++ b/codegen/testserver/singlefile/nulls_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
@@ -14,13 +14,18 @@ func TestNullBubbling(t *testing.T) {
resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) {
return "Ok", nil
}
-
resolvers.QueryResolver.Errors = func(ctx context.Context) (errors *Errors, e error) {
return &Errors{}, nil
}
resolvers.QueryResolver.ErrorBubble = func(ctx context.Context) (i *Error, e error) {
return &Error{ID: "E1234"}, nil
}
+ resolvers.QueryResolver.ErrorBubbleList = func(ctx context.Context) (i []*Error, e error) {
+ return []*Error{nil}, nil
+ }
+ resolvers.QueryResolver.ErrorList = func(ctx context.Context) (i []*Error, e error) {
+ return []*Error{nil}, nil
+ }
c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
@@ -68,6 +73,31 @@ func TestNullBubbling(t *testing.T) {
require.Equal(t, "Ok", resp.Valid)
})
+ t.Run("when list element is null", func(t *testing.T) {
+ var resp struct {
+ Valid string
+ ErrorList []*struct{}
+ }
+ err := c.Post(`query { valid, errorList { id } }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, len(resp.ErrorList), 1)
+ require.Nil(t, resp.ErrorList[0])
+ require.Equal(t, "Ok", resp.Valid)
+ })
+
+ t.Run("when non-null list element is null", func(t *testing.T) {
+ var resp struct {
+ Valid string
+ ErrorBubbleList []*struct{}
+ }
+ err := c.Post(`query { valid, errorBubbleList { id } }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"must not be null","path":["errorBubbleList",0]}]`)
+ require.Nil(t, resp.ErrorBubbleList)
+ require.Equal(t, "Ok", resp.Valid)
+ })
+
t.Run("null args", func(t *testing.T) {
var resp struct {
NullableArg *string
@@ -90,7 +120,7 @@ func TestNullBubbling(t *testing.T) {
resolvers.ErrorsResolver.D = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil }
resolvers.ErrorsResolver.E = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil }
- err := c.Post(`{ errors {
+ err := c.Post(`{ errors {
a { id },
b { id },
c { id },
diff --git a/codegen/testserver/singlefile/otherpkg/model.go b/codegen/testserver/singlefile/otherpkg/model.go
new file mode 100644
index 00000000000..f2cc202ede0
--- /dev/null
+++ b/codegen/testserver/singlefile/otherpkg/model.go
@@ -0,0 +1,12 @@
+package otherpkg
+
+type (
+ Scalar string
+ Map map[string]string
+ Slice []string
+)
+
+type Struct struct {
+ Name Scalar
+ Desc *Scalar
+}
diff --git a/codegen/testserver/singlefile/panics.graphql b/codegen/testserver/singlefile/panics.graphql
new file mode 100644
index 00000000000..8895fca82c8
--- /dev/null
+++ b/codegen/testserver/singlefile/panics.graphql
@@ -0,0 +1,12 @@
+extend type Query {
+ panics: Panics
+}
+
+type Panics {
+ fieldScalarMarshal: [MarshalPanic!]!
+ fieldFuncMarshal(u: [MarshalPanic!]!): [MarshalPanic!]!
+ argUnmarshal(u: [MarshalPanic!]!): Boolean!
+
+}
+
+scalar MarshalPanic
diff --git a/codegen/testserver/panics_test.go b/codegen/testserver/singlefile/panics_test.go
similarity index 99%
rename from codegen/testserver/panics_test.go
rename to codegen/testserver/singlefile/panics_test.go
index 0e1cf838004..209344d79d8 100644
--- a/codegen/testserver/panics_test.go
+++ b/codegen/testserver/singlefile/panics_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/singlefile/primitive_objects.graphql b/codegen/testserver/singlefile/primitive_objects.graphql
new file mode 100644
index 00000000000..c53702c2c89
--- /dev/null
+++ b/codegen/testserver/singlefile/primitive_objects.graphql
@@ -0,0 +1,15 @@
+extend type Query {
+ primitiveObject: [Primitive!]!
+ primitiveStringObject: [PrimitiveString!]!
+}
+
+type Primitive {
+ value: Int!
+ squared: Int!
+}
+
+type PrimitiveString {
+ value: String!
+ doubled: String!
+ len: Int!
+}
diff --git a/codegen/testserver/primitive_objects_test.go b/codegen/testserver/singlefile/primitive_objects_test.go
similarity index 99%
rename from codegen/testserver/primitive_objects_test.go
rename to codegen/testserver/singlefile/primitive_objects_test.go
index c52a8979d73..80e7a96d7af 100644
--- a/codegen/testserver/primitive_objects_test.go
+++ b/codegen/testserver/singlefile/primitive_objects_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/singlefile/ptr_to_ptr_input.go b/codegen/testserver/singlefile/ptr_to_ptr_input.go
new file mode 100644
index 00000000000..9fd10328ce8
--- /dev/null
+++ b/codegen/testserver/singlefile/ptr_to_ptr_input.go
@@ -0,0 +1,23 @@
+package singlefile
+
+type PtrToPtrOuter struct {
+ Name string
+ Inner *PtrToPtrInner
+ StupidInner *******PtrToPtrInner
+}
+
+type PtrToPtrInner struct {
+ Key string
+ Value string
+}
+
+type UpdatePtrToPtrOuter struct {
+ Name *string
+ Inner **UpdatePtrToPtrInner
+ StupidInner ********UpdatePtrToPtrInner
+}
+
+type UpdatePtrToPtrInner struct {
+ Key *string
+ Value *string
+}
diff --git a/codegen/testserver/singlefile/ptr_to_ptr_input.graphql b/codegen/testserver/singlefile/ptr_to_ptr_input.graphql
new file mode 100644
index 00000000000..c34b5c56fc5
--- /dev/null
+++ b/codegen/testserver/singlefile/ptr_to_ptr_input.graphql
@@ -0,0 +1,25 @@
+type PtrToPtrOuter {
+ name: String!
+ inner: PtrToPtrInner
+ stupidInner: PtrToPtrInner
+}
+
+type PtrToPtrInner {
+ key: String!
+ value: String!
+}
+
+input UpdatePtrToPtrOuter {
+ name: String
+ inner: UpdatePtrToPtrInner
+ stupidInner: UpdatePtrToPtrInner
+}
+
+input UpdatePtrToPtrInner {
+ key: String
+ value: String
+}
+
+extend type Mutation {
+ updatePtrToPtr(input: UpdatePtrToPtrOuter!): PtrToPtrOuter!
+}
diff --git a/codegen/testserver/singlefile/ptr_to_ptr_input_test.go b/codegen/testserver/singlefile/ptr_to_ptr_input_test.go
new file mode 100644
index 00000000000..75bed1266ce
--- /dev/null
+++ b/codegen/testserver/singlefile/ptr_to_ptr_input_test.go
@@ -0,0 +1,174 @@
+package singlefile
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+type UpdatePtrToPtrResults struct {
+ UpdatedPtrToPtr PtrToPtrOuter `json:"updatePtrToPtr"`
+}
+
+func TestPtrToPtr(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.MutationResolver.UpdatePtrToPtr = func(ctx context.Context, in UpdatePtrToPtrOuter) (ret *PtrToPtrOuter, err error) {
+ ret = &PtrToPtrOuter{
+ Name: "oldName",
+ Inner: &PtrToPtrInner{
+ Key: "oldKey",
+ Value: "oldValue",
+ },
+ StupidInner: nest7(&PtrToPtrInner{
+ Key: "oldStupidKey",
+ Value: "oldStupidValue",
+ }),
+ }
+
+ if in.Name != nil {
+ ret.Name = *in.Name
+ }
+
+ if in.Inner != nil {
+ inner := *in.Inner
+ if inner == nil {
+ ret.Inner = nil
+ } else {
+ if in.Inner == nil {
+ ret.Inner = &PtrToPtrInner{}
+ }
+ if inner.Key != nil {
+ ret.Inner.Key = *inner.Key
+ }
+ if inner.Value != nil {
+ ret.Inner.Value = *inner.Value
+ }
+ }
+ }
+
+ if in.StupidInner != nil {
+ si := *in.StupidInner
+ if si == nil {
+ ret.StupidInner = nil
+ } else {
+ deepIn := ******si
+ deepOut := ******ret.StupidInner
+ if deepIn.Key != nil {
+ deepOut.Key = *deepIn.Key
+ }
+ if deepIn.Value != nil {
+ deepOut.Value = *deepIn.Value
+ }
+ }
+ }
+ return
+ }
+
+ t.Run("pointer to pointer input missing", func(t *testing.T) {
+ var resp UpdatePtrToPtrResults
+
+ err := c.Post(`mutation { updatePtrToPtr(input: { name: "newName" }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, resp.UpdatedPtrToPtr.Name, "newName")
+ require.NotNil(t, resp.UpdatedPtrToPtr.Inner)
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Key, "oldKey")
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Value, "oldValue")
+ require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner)
+ require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner)
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Key, "oldStupidKey")
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Value, "oldStupidValue")
+ })
+
+ t.Run("pointer to pointer input non-null", func(t *testing.T) {
+ var resp UpdatePtrToPtrResults
+
+ err := c.Post(`mutation {
+ updatePtrToPtr(input: {
+ inner: {
+ key: "newKey"
+ value: "newValue"
+ }
+ })
+ { name, inner { key, value }, stupidInner { key, value }}
+ }`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, resp.UpdatedPtrToPtr.Name, "oldName")
+ require.NotNil(t, resp.UpdatedPtrToPtr.Inner)
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Key, "newKey")
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Value, "newValue")
+ require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner)
+ require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner)
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Key, "oldStupidKey")
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Value, "oldStupidValue")
+ })
+
+ t.Run("pointer to pointer input null", func(t *testing.T) {
+ var resp UpdatePtrToPtrResults
+
+ err := c.Post(`mutation { updatePtrToPtr(input: { inner: null }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, resp.UpdatedPtrToPtr.Name, "oldName")
+ require.Nil(t, resp.UpdatedPtrToPtr.Inner)
+ require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner)
+ require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner)
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Key, "oldStupidKey")
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Value, "oldStupidValue")
+ })
+
+ t.Run("many pointers input non-null", func(t *testing.T) {
+ var resp UpdatePtrToPtrResults
+
+ err := c.Post(`mutation {
+ updatePtrToPtr(input: {
+ stupidInner: {
+ key: "newKey"
+ value: "newValue"
+ }
+ })
+ { name, inner { key, value }, stupidInner { key, value }}
+ }`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, resp.UpdatedPtrToPtr.Name, "oldName")
+ require.NotNil(t, resp.UpdatedPtrToPtr.Inner)
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Key, "oldKey")
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Value, "oldValue")
+ require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner)
+ require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner)
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Key, "newKey")
+ require.Equal(t, (******resp.UpdatedPtrToPtr.StupidInner).Value, "newValue")
+ })
+
+ t.Run("many pointers input null", func(t *testing.T) {
+ var resp UpdatePtrToPtrResults
+
+ err := c.Post(`mutation { updatePtrToPtr(input: { stupidInner: null }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, resp.UpdatedPtrToPtr.Name, "oldName")
+ require.NotNil(t, resp.UpdatedPtrToPtr.Inner)
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Key, "oldKey")
+ require.Equal(t, resp.UpdatedPtrToPtr.Inner.Value, "oldValue")
+ require.Nil(t, resp.UpdatedPtrToPtr.StupidInner)
+ })
+}
+
+func nest7(in *PtrToPtrInner) *******PtrToPtrInner {
+ si2 := &in
+ si3 := &si2
+ si4 := &si3
+ si5 := &si4
+ si6 := &si5
+ si7 := &si6
+
+ return si7
+}
diff --git a/codegen/testserver/singlefile/ptr_to_slice.go b/codegen/testserver/singlefile/ptr_to_slice.go
new file mode 100644
index 00000000000..b4e46d01a19
--- /dev/null
+++ b/codegen/testserver/singlefile/ptr_to_slice.go
@@ -0,0 +1,5 @@
+package singlefile
+
+type PtrToSliceContainer struct {
+ PtrToSlice *[]string
+}
diff --git a/codegen/testserver/singlefile/ptr_to_slice.graphql b/codegen/testserver/singlefile/ptr_to_slice.graphql
new file mode 100644
index 00000000000..b773d83d428
--- /dev/null
+++ b/codegen/testserver/singlefile/ptr_to_slice.graphql
@@ -0,0 +1,7 @@
+type PtrToSliceContainer {
+ ptrToSlice: [String!]
+}
+
+extend type Query {
+ ptrToSliceContainer: PtrToSliceContainer!
+}
diff --git a/codegen/testserver/singlefile/ptr_to_slice_test.go b/codegen/testserver/singlefile/ptr_to_slice_test.go
new file mode 100644
index 00000000000..86fc004626d
--- /dev/null
+++ b/codegen/testserver/singlefile/ptr_to_slice_test.go
@@ -0,0 +1,37 @@
+package singlefile
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestPtrToSlice(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.QueryResolver.PtrToSliceContainer = func(ctx context.Context) (wrappedStruct *PtrToSliceContainer, e error) {
+ ptrToSliceContainer := PtrToSliceContainer{
+ PtrToSlice: &[]string{"hello"},
+ }
+ return &ptrToSliceContainer, nil
+ }
+
+ t.Run("pointer to slice", func(t *testing.T) {
+ var resp struct {
+ PtrToSliceContainer struct {
+ PtrToSlice []string
+ }
+ }
+
+ err := c.Post(`query { ptrToSliceContainer { ptrToSlice }}`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, []string{"hello"}, resp.PtrToSliceContainer.PtrToSlice)
+
+ })
+}
diff --git a/codegen/testserver/recursive.go b/codegen/testserver/singlefile/recursive.go
similarity index 77%
rename from codegen/testserver/recursive.go
rename to codegen/testserver/singlefile/recursive.go
index a9d4ac0511e..728fbd911ae 100644
--- a/codegen/testserver/recursive.go
+++ b/codegen/testserver/singlefile/recursive.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
type RecursiveInputSlice struct {
Self []RecursiveInputSlice
diff --git a/codegen/testserver/resolver.go b/codegen/testserver/singlefile/resolver.go
similarity index 89%
rename from codegen/testserver/resolver.go
rename to codegen/testserver/singlefile/resolver.go
index 952d20943e8..90d5c07a226 100644
--- a/codegen/testserver/resolver.go
+++ b/codegen/testserver/singlefile/resolver.go
@@ -1,13 +1,13 @@
-package testserver
+package singlefile
// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.
import (
"context"
- introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection"
- invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename"
- "github.com/99designs/gqlgen/codegen/testserver/otherpkg"
+ introspection1 "github.com/99designs/gqlgen/codegen/testserver/singlefile/introspection"
+ invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/singlefile/invalid-packagename"
+ "github.com/99designs/gqlgen/codegen/testserver/singlefile/otherpkg"
)
type Resolver struct{}
@@ -44,10 +44,18 @@ func (r *modelMethodsResolver) ResolverField(ctx context.Context, obj *ModelMeth
panic("not implemented")
}
+func (r *mutationResolver) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) {
+ panic("not implemented")
+}
+
func (r *mutationResolver) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) {
panic("not implemented")
}
+func (r *mutationResolver) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) {
+ panic("not implemented")
+}
+
func (r *overlappingFieldsResolver) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) {
panic("not implemented")
}
@@ -132,6 +140,10 @@ func (r *queryResolver) Overlapping(ctx context.Context) (*OverlappingFields, er
panic("not implemented")
}
+func (r *queryResolver) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) {
+ panic("not implemented")
+}
+
func (r *queryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) {
panic("not implemented")
}
@@ -232,6 +244,14 @@ func (r *queryResolver) ErrorBubble(ctx context.Context) (*Error, error) {
panic("not implemented")
}
+func (r *queryResolver) ErrorBubbleList(ctx context.Context) ([]*Error, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) ErrorList(ctx context.Context) ([]*Error, error) {
+ panic("not implemented")
+}
+
func (r *queryResolver) Errors(ctx context.Context) (*Errors, error) {
panic("not implemented")
}
@@ -252,6 +272,22 @@ func (r *queryResolver) PrimitiveStringObject(ctx context.Context) ([]PrimitiveS
panic("not implemented")
}
+func (r *queryResolver) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) Infinity(ctx context.Context) (float64, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) StringFromContextFunction(ctx context.Context) (string, error) {
+ panic("not implemented")
+}
+
func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, error) {
panic("not implemented")
}
@@ -272,6 +308,14 @@ func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) {
panic("not implemented")
}
+func (r *queryResolver) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) {
+ panic("not implemented")
+}
+
func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) {
panic("not implemented")
}
diff --git a/codegen/testserver/response_extension_test.go b/codegen/testserver/singlefile/response_extension_test.go
similarity index 97%
rename from codegen/testserver/response_extension_test.go
rename to codegen/testserver/singlefile/response_extension_test.go
index 692327d0f2c..9e570dbda06 100644
--- a/codegen/testserver/response_extension_test.go
+++ b/codegen/testserver/singlefile/response_extension_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/singlefile/scalar_context.go b/codegen/testserver/singlefile/scalar_context.go
new file mode 100644
index 00000000000..fc002caf5e3
--- /dev/null
+++ b/codegen/testserver/singlefile/scalar_context.go
@@ -0,0 +1,36 @@
+package singlefile
+
+import (
+ "context"
+ "io"
+ "strconv"
+
+ "github.com/99designs/gqlgen/graphql"
+)
+
+type StringFromContextInterface struct {
+ OperationName string
+}
+
+var _ graphql.ContextMarshaler = StringFromContextInterface{}
+var _ graphql.ContextUnmarshaler = (*StringFromContextInterface)(nil)
+
+func (StringFromContextInterface) MarshalGQLContext(ctx context.Context, w io.Writer) error {
+ io.WriteString(w, strconv.Quote(graphql.GetFieldContext(ctx).Field.Name))
+ return nil
+}
+func (i *StringFromContextInterface) UnmarshalGQLContext(ctx context.Context, v interface{}) error {
+ i.OperationName = graphql.GetFieldContext(ctx).Field.Name
+ return nil
+}
+
+func MarshalStringFromContextFunction(v string) graphql.ContextMarshaler {
+ return graphql.ContextWriterFunc(func(ctx context.Context, w io.Writer) error {
+ io.WriteString(w, strconv.Quote(graphql.GetFieldContext(ctx).Field.Name))
+ return nil
+ })
+}
+
+func UnmarshalStringFromContextFunction(ctx context.Context, v interface{}) (string, error) {
+ return graphql.GetFieldContext(ctx).Field.Name, nil
+}
diff --git a/codegen/testserver/singlefile/scalar_context.graphql b/codegen/testserver/singlefile/scalar_context.graphql
new file mode 100644
index 00000000000..f49fa553139
--- /dev/null
+++ b/codegen/testserver/singlefile/scalar_context.graphql
@@ -0,0 +1,8 @@
+extend type Query {
+ infinity: Float!
+ stringFromContextInterface: StringFromContextInterface!
+ stringFromContextFunction: StringFromContextFunction!
+}
+
+scalar StringFromContextInterface
+scalar StringFromContextFunction
diff --git a/codegen/testserver/singlefile/scalar_context_test.go b/codegen/testserver/singlefile/scalar_context_test.go
new file mode 100644
index 00000000000..8a235b1d439
--- /dev/null
+++ b/codegen/testserver/singlefile/scalar_context_test.go
@@ -0,0 +1,52 @@
+package singlefile
+
+import (
+ "context"
+ "math"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestFloatInfAndNaN(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.QueryResolver.Infinity = func(ctx context.Context) (float64, error) {
+ return math.Inf(-1), nil
+ }
+
+ t.Run("errors on marshaller with context", func(t *testing.T) {
+ err := c.Post(`query { infinity }`, nil)
+ require.Error(t, err)
+ })
+
+}
+
+func TestContextPassedToMarshal(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.QueryResolver.StringFromContextInterface = func(ctx context.Context) (*StringFromContextInterface, error) {
+ return &StringFromContextInterface{}, nil
+ }
+ resolvers.QueryResolver.StringFromContextFunction = func(ctx context.Context) (string, error) {
+ return "", nil
+ }
+
+ var res struct {
+ StringFromContextInterface string
+ StringFromContextFunction string
+ }
+ err := c.Post(`query my_name {
+ stringFromContextInterface
+ stringFromContextFunction
+ }`, &res)
+ require.NoError(t, err)
+ require.Equal(t, "stringFromContextInterface", res.StringFromContextInterface)
+ require.Equal(t, "stringFromContextFunction", res.StringFromContextFunction)
+}
diff --git a/codegen/testserver/singlefile/scalar_default.graphql b/codegen/testserver/singlefile/scalar_default.graphql
new file mode 100644
index 00000000000..5e3a9c08fd1
--- /dev/null
+++ b/codegen/testserver/singlefile/scalar_default.graphql
@@ -0,0 +1,10 @@
+extend type Query {
+ defaultScalar(arg: DefaultScalarImplementation! = "default"): DefaultScalarImplementation!
+}
+
+""" This doesnt have an implementation in the typemap, so it should act like a string """
+scalar DefaultScalarImplementation
+
+type EmbeddedDefaultScalar {
+ value: DefaultScalarImplementation
+}
diff --git a/codegen/testserver/scalar_default_test.go b/codegen/testserver/singlefile/scalar_default_test.go
similarity index 97%
rename from codegen/testserver/scalar_default_test.go
rename to codegen/testserver/singlefile/scalar_default_test.go
index c510ca46671..556a3eccb4c 100644
--- a/codegen/testserver/scalar_default_test.go
+++ b/codegen/testserver/singlefile/scalar_default_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/singlefile/schema.graphql
similarity index 73%
rename from codegen/testserver/schema.graphql
rename to codegen/testserver/singlefile/schema.graphql
index 1672d7be8a2..d15b291cda0 100644
--- a/codegen/testserver/schema.graphql
+++ b/codegen/testserver/singlefile/schema.graphql
@@ -1,12 +1,18 @@
-directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION
-directive @goField(forceResolver: Boolean, name: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
+directive @goModel(
+ model: String
+ models: [String!]
+) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION
+directive @goField(
+ forceResolver: Boolean
+ name: String
+) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
type Query {
invalidIdentifier: InvalidIdentifier
collision: It
mapInput(input: Changes): Boolean
recursive(input: RecursiveInputSlice): Boolean
- nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean
+ nestedInputs(input: [[OuterInput]] = [[{ inner: { id: 1 } }]]): Boolean
nestedOutputs: [[OuterObject]]
modelMethods: ModelMethods
user(id: Int!): User!
@@ -53,7 +59,7 @@ type It {
id: ID!
}
-input Changes @goModel(model:"map[string]interface{}") {
+input Changes @goModel(model: "map[string]interface{}") {
a: Int
b: Int
}
@@ -63,14 +69,14 @@ input RecursiveInputSlice {
}
input InnerInput {
- id:Int!
+ id: Int!
}
input OuterInput {
inner: InnerInput!
}
-scalar ThirdParty @goModel(model:"testserver.ThirdParty")
+scalar ThirdParty @goModel(model:"singlefile.ThirdParty")
type OuterObject {
inner: InnerObject!
@@ -84,7 +90,7 @@ type ForcedResolver {
field: Circle @goField(forceResolver: true)
}
-type EmbeddedPointer @goModel(model:"testserver.EmbeddedPointerModel") {
+type EmbeddedPointer @goModel(model:"singlefile.EmbeddedPointerModel") {
ID: String
Title: String
}
diff --git a/codegen/testserver/singlefile/slices.graphql b/codegen/testserver/singlefile/slices.graphql
new file mode 100644
index 00000000000..b1265c56c0b
--- /dev/null
+++ b/codegen/testserver/singlefile/slices.graphql
@@ -0,0 +1,13 @@
+extend type Query {
+ slices: Slices
+ scalarSlice: Bytes!
+}
+
+type Slices {
+ test1: [String]
+ test2: [String!]
+ test3: [String]!
+ test4: [String!]!
+}
+
+scalar Bytes
diff --git a/codegen/testserver/slices_test.go b/codegen/testserver/singlefile/slices_test.go
similarity index 98%
rename from codegen/testserver/slices_test.go
rename to codegen/testserver/singlefile/slices_test.go
index 783a4a49b00..b6c3e37b9ae 100644
--- a/codegen/testserver/slices_test.go
+++ b/codegen/testserver/singlefile/slices_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/stub.go b/codegen/testserver/singlefile/stub.go
similarity index 87%
rename from codegen/testserver/stub.go
rename to codegen/testserver/singlefile/stub.go
index daf4052ea08..fc5e2325b4b 100644
--- a/codegen/testserver/stub.go
+++ b/codegen/testserver/singlefile/stub.go
@@ -1,13 +1,13 @@
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
-package testserver
+package singlefile
import (
"context"
- introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection"
- invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename"
- "github.com/99designs/gqlgen/codegen/testserver/otherpkg"
+ introspection1 "github.com/99designs/gqlgen/codegen/testserver/singlefile/introspection"
+ invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/singlefile/invalid-packagename"
+ "github.com/99designs/gqlgen/codegen/testserver/singlefile/otherpkg"
)
type Stub struct {
@@ -28,7 +28,9 @@ type Stub struct {
ResolverField func(ctx context.Context, obj *ModelMethods) (bool, error)
}
MutationResolver struct {
+ DefaultInput func(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error)
UpdateSomething func(ctx context.Context, input SpecialInput) (string, error)
+ UpdatePtrToPtr func(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error)
}
OverlappingFieldsResolver struct {
OldFoo func(ctx context.Context, obj *OverlappingFields) (int, error)
@@ -60,6 +62,7 @@ type Stub struct {
Autobind func(ctx context.Context) (*Autobind, error)
DeprecatedField func(ctx context.Context) (string, error)
Overlapping func(ctx context.Context) (*OverlappingFields, error)
+ DefaultParameters func(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error)
DirectiveArg func(ctx context.Context, arg string) (*string, error)
DirectiveNullableArg func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error)
DirectiveInputNullable func(ctx context.Context, arg *InputDirectives) (*string, error)
@@ -85,16 +88,24 @@ type Stub struct {
MapStringInterface func(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error)
MapNestedStringInterface func(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error)
ErrorBubble func(ctx context.Context) (*Error, error)
+ ErrorBubbleList func(ctx context.Context) ([]*Error, error)
+ ErrorList func(ctx context.Context) ([]*Error, error)
Errors func(ctx context.Context) (*Errors, error)
Valid func(ctx context.Context) (string, error)
Panics func(ctx context.Context) (*Panics, error)
PrimitiveObject func(ctx context.Context) ([]Primitive, error)
PrimitiveStringObject func(ctx context.Context) ([]PrimitiveString, error)
+ PtrToSliceContainer func(ctx context.Context) (*PtrToSliceContainer, error)
+ Infinity func(ctx context.Context) (float64, error)
+ StringFromContextInterface func(ctx context.Context) (*StringFromContextInterface, error)
+ StringFromContextFunction func(ctx context.Context) (string, error)
DefaultScalar func(ctx context.Context, arg string) (string, error)
Slices func(ctx context.Context) (*Slices, error)
ScalarSlice func(ctx context.Context) ([]byte, error)
Fallback func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error)
OptionalUnion func(ctx context.Context) (TestUnion, error)
+ VOkCaseValue func(ctx context.Context) (*VOkCaseValue, error)
+ VOkCaseNil func(ctx context.Context) (*VOkCaseNil, error)
ValidType func(ctx context.Context) (*ValidType, error)
WrappedStruct func(ctx context.Context) (*WrappedStruct, error)
WrappedScalar func(ctx context.Context) (otherpkg.Scalar, error)
@@ -202,9 +213,15 @@ func (r *stubModelMethods) ResolverField(ctx context.Context, obj *ModelMethods)
type stubMutation struct{ *Stub }
+func (r *stubMutation) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) {
+ return r.MutationResolver.DefaultInput(ctx, input)
+}
func (r *stubMutation) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) {
return r.MutationResolver.UpdateSomething(ctx, input)
}
+func (r *stubMutation) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) {
+ return r.MutationResolver.UpdatePtrToPtr(ctx, input)
+}
type stubOverlappingFields struct{ *Stub }
@@ -283,6 +300,9 @@ func (r *stubQuery) DeprecatedField(ctx context.Context) (string, error) {
func (r *stubQuery) Overlapping(ctx context.Context) (*OverlappingFields, error) {
return r.QueryResolver.Overlapping(ctx)
}
+func (r *stubQuery) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) {
+ return r.QueryResolver.DefaultParameters(ctx, falsyBoolean, truthyBoolean)
+}
func (r *stubQuery) DirectiveArg(ctx context.Context, arg string) (*string, error) {
return r.QueryResolver.DirectiveArg(ctx, arg)
}
@@ -358,6 +378,12 @@ func (r *stubQuery) MapNestedStringInterface(ctx context.Context, in *NestedMapI
func (r *stubQuery) ErrorBubble(ctx context.Context) (*Error, error) {
return r.QueryResolver.ErrorBubble(ctx)
}
+func (r *stubQuery) ErrorBubbleList(ctx context.Context) ([]*Error, error) {
+ return r.QueryResolver.ErrorBubbleList(ctx)
+}
+func (r *stubQuery) ErrorList(ctx context.Context) ([]*Error, error) {
+ return r.QueryResolver.ErrorList(ctx)
+}
func (r *stubQuery) Errors(ctx context.Context) (*Errors, error) {
return r.QueryResolver.Errors(ctx)
}
@@ -373,6 +399,18 @@ func (r *stubQuery) PrimitiveObject(ctx context.Context) ([]Primitive, error) {
func (r *stubQuery) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) {
return r.QueryResolver.PrimitiveStringObject(ctx)
}
+func (r *stubQuery) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) {
+ return r.QueryResolver.PtrToSliceContainer(ctx)
+}
+func (r *stubQuery) Infinity(ctx context.Context) (float64, error) {
+ return r.QueryResolver.Infinity(ctx)
+}
+func (r *stubQuery) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) {
+ return r.QueryResolver.StringFromContextInterface(ctx)
+}
+func (r *stubQuery) StringFromContextFunction(ctx context.Context) (string, error) {
+ return r.QueryResolver.StringFromContextFunction(ctx)
+}
func (r *stubQuery) DefaultScalar(ctx context.Context, arg string) (string, error) {
return r.QueryResolver.DefaultScalar(ctx, arg)
}
@@ -388,6 +426,12 @@ func (r *stubQuery) Fallback(ctx context.Context, arg FallbackToStringEncoding)
func (r *stubQuery) OptionalUnion(ctx context.Context) (TestUnion, error) {
return r.QueryResolver.OptionalUnion(ctx)
}
+func (r *stubQuery) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) {
+ return r.QueryResolver.VOkCaseValue(ctx)
+}
+func (r *stubQuery) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) {
+ return r.QueryResolver.VOkCaseNil(ctx)
+}
func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) {
return r.QueryResolver.ValidType(ctx)
}
diff --git a/codegen/testserver/subscription_test.go b/codegen/testserver/singlefile/subscription_test.go
similarity index 99%
rename from codegen/testserver/subscription_test.go
rename to codegen/testserver/singlefile/subscription_test.go
index d855fcc69bf..dd53ba15afa 100644
--- a/codegen/testserver/subscription_test.go
+++ b/codegen/testserver/singlefile/subscription_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/thirdparty.go b/codegen/testserver/singlefile/thirdparty.go
similarity index 96%
rename from codegen/testserver/thirdparty.go
rename to codegen/testserver/singlefile/thirdparty.go
index aa3424d9060..4b19bb98987 100644
--- a/codegen/testserver/thirdparty.go
+++ b/codegen/testserver/singlefile/thirdparty.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"fmt"
diff --git a/codegen/testserver/time_test.go b/codegen/testserver/singlefile/time_test.go
similarity index 82%
rename from codegen/testserver/time_test.go
rename to codegen/testserver/singlefile/time_test.go
index 291567e7a1b..473d48d95d7 100644
--- a/codegen/testserver/time_test.go
+++ b/codegen/testserver/singlefile/time_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
@@ -45,9 +45,9 @@ func TestTime(t *testing.T) {
t.Run("with values", func(t *testing.T) {
resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) {
- updated := time.Date(2010, 1, 1, 0, 0, 20, 0, time.UTC)
+ updated := time.Date(2010, 1, 1, 0, 0, 20, 1, time.UTC)
return &User{
- Created: time.Date(2010, 1, 1, 0, 0, 10, 0, time.UTC),
+ Created: time.Date(2010, 1, 1, 0, 0, 10, 1, time.UTC),
Updated: &updated,
}, nil
}
@@ -62,7 +62,7 @@ func TestTime(t *testing.T) {
err := c.Post(`query { user(id: 1) { created, updated } }`, &resp)
require.NoError(t, err)
- require.Equal(t, "2010-01-01T00:00:10Z", resp.User.Created)
- require.Equal(t, "2010-01-01T00:00:20Z", resp.User.Updated)
+ require.Equal(t, "2010-01-01T00:00:10.000000001Z", resp.User.Created)
+ require.Equal(t, "2010-01-01T00:00:20.000000001Z", resp.User.Updated)
})
}
diff --git a/codegen/testserver/singlefile/typefallback.graphql b/codegen/testserver/singlefile/typefallback.graphql
new file mode 100644
index 00000000000..e1ff1a59d7c
--- /dev/null
+++ b/codegen/testserver/singlefile/typefallback.graphql
@@ -0,0 +1,9 @@
+extend type Query {
+ fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding!
+}
+
+enum FallbackToStringEncoding {
+ A
+ B
+ C
+}
diff --git a/codegen/testserver/typefallback_test.go b/codegen/testserver/singlefile/typefallback_test.go
similarity index 97%
rename from codegen/testserver/typefallback_test.go
rename to codegen/testserver/singlefile/typefallback_test.go
index 8ebd091e9ef..13ba74449c9 100644
--- a/codegen/testserver/typefallback_test.go
+++ b/codegen/testserver/singlefile/typefallback_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/singlefile/useptr.graphql b/codegen/testserver/singlefile/useptr.graphql
new file mode 100644
index 00000000000..23c1af0b421
--- /dev/null
+++ b/codegen/testserver/singlefile/useptr.graphql
@@ -0,0 +1,13 @@
+type A {
+ id: ID!
+}
+
+type B {
+ id: ID!
+}
+
+union TestUnion = A | B
+
+extend type Query {
+ optionalUnion: TestUnion
+}
diff --git a/codegen/testserver/useptr_test.go b/codegen/testserver/singlefile/useptr_test.go
similarity index 92%
rename from codegen/testserver/useptr_test.go
rename to codegen/testserver/singlefile/useptr_test.go
index ba088f49dc0..e4f2039239c 100644
--- a/codegen/testserver/useptr_test.go
+++ b/codegen/testserver/singlefile/useptr_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"reflect"
diff --git a/codegen/testserver/singlefile/v-ok.go b/codegen/testserver/singlefile/v-ok.go
new file mode 100644
index 00000000000..a4de4736d8f
--- /dev/null
+++ b/codegen/testserver/singlefile/v-ok.go
@@ -0,0 +1,17 @@
+package singlefile
+
+// VOkCaseValue model
+type VOkCaseValue struct {
+}
+
+func (v VOkCaseValue) Value() (string, bool) {
+ return "hi", true
+}
+
+// VOkCaseNil model
+type VOkCaseNil struct {
+}
+
+func (v VOkCaseNil) Value() (string, bool) {
+ return "", false
+}
diff --git a/codegen/testserver/singlefile/v-ok.graphql b/codegen/testserver/singlefile/v-ok.graphql
new file mode 100644
index 00000000000..f0c1ae8fb3f
--- /dev/null
+++ b/codegen/testserver/singlefile/v-ok.graphql
@@ -0,0 +1,12 @@
+extend type Query {
+ vOkCaseValue: VOkCaseValue
+ vOkCaseNil: VOkCaseNil
+}
+
+type VOkCaseValue @goModel(model:"singlefile.VOkCaseValue") {
+ value: String
+}
+
+type VOkCaseNil @goModel(model:"singlefile.VOkCaseNil") {
+ value: String
+}
diff --git a/codegen/testserver/singlefile/v-ok_test.go b/codegen/testserver/singlefile/v-ok_test.go
new file mode 100644
index 00000000000..8e3d10723e4
--- /dev/null
+++ b/codegen/testserver/singlefile/v-ok_test.go
@@ -0,0 +1,47 @@
+package singlefile
+
+import (
+ "context"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+)
+
+func TestOk(t *testing.T) {
+ resolver := &Stub{}
+ resolver.QueryResolver.VOkCaseValue = func(ctx context.Context) (*VOkCaseValue, error) {
+ return &VOkCaseValue{}, nil
+ }
+ resolver.QueryResolver.VOkCaseNil = func(ctx context.Context) (*VOkCaseNil, error) {
+ return &VOkCaseNil{}, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(
+ NewExecutableSchema(Config{Resolvers: resolver}),
+ ))
+
+ t.Run("v ok case value", func(t *testing.T) {
+ var resp struct {
+ VOkCaseValue struct {
+ Value string
+ }
+ }
+ err := c.Post(`query { vOkCaseValue { value } }`, &resp)
+ require.NoError(t, err)
+ require.Equal(t, resp.VOkCaseValue.Value, "hi")
+ })
+
+ t.Run("v ok case nil", func(t *testing.T) {
+ var resp struct {
+ VOkCaseNil struct {
+ Value *string
+ }
+ }
+ err := c.Post(`query { vOkCaseNil { value } }`, &resp)
+ require.NoError(t, err)
+ require.Equal(t, true, resp.VOkCaseNil.Value == nil)
+ })
+}
diff --git a/codegen/testserver/singlefile/validtypes.graphql b/codegen/testserver/singlefile/validtypes.graphql
new file mode 100644
index 00000000000..9912e9a9515
--- /dev/null
+++ b/codegen/testserver/singlefile/validtypes.graphql
@@ -0,0 +1,78 @@
+extend type Query {
+ validType: ValidType
+}
+
+""" These things are all valid, but without care generate invalid go code """
+type ValidType {
+ differentCase: String!
+ different_case: String! @goField(name:"DifferentCaseOld")
+ validInputKeywords(input: ValidInput): Boolean!
+ validArgs(
+ break: String!,
+ default: String!,
+ func: String!,
+ interface: String!,
+ select: String!,
+ case: String!,
+ defer: String!,
+ go: String!,
+ map: String!,
+ struct: String!,
+ chan: String!,
+ else: String!,
+ goto: String!,
+ package: String!,
+ switch: String!,
+ const: String!,
+ fallthrough: String!,
+ if: String!,
+ range: String!,
+ type: String!,
+ continue: String!,
+ for: String!,
+ import: String!,
+ return: String!,
+ var: String!,
+ _: String!,
+ ): Boolean!
+}
+
+input ValidInput {
+ break: String!
+ default: String!
+ func: String!
+ interface: String!
+ select: String!
+ case: String!
+ defer: String!
+ go: String!
+ map: String!
+ struct: String!
+ chan: String!
+ else: String!
+ goto: String!
+ package: String!
+ switch: String!
+ const: String!
+ fallthrough: String!
+ if: String!
+ range: String!
+ type: String!
+ continue: String!
+ for: String!
+ import: String!
+ return: String!
+ var: String!
+ _: String! @goField(name: "Underscore")
+}
+
+# see https://github.com/99designs/gqlgen/issues/694
+type Content_User {
+ foo: String
+}
+
+type Content_Post {
+ foo: String
+}
+
+union Content_Child = Content_User | Content_Post
diff --git a/codegen/testserver/validtypes_test.go b/codegen/testserver/singlefile/validtypes_test.go
similarity index 97%
rename from codegen/testserver/validtypes_test.go
rename to codegen/testserver/singlefile/validtypes_test.go
index 6ae9f1bff1c..28c5f07974c 100644
--- a/codegen/testserver/validtypes_test.go
+++ b/codegen/testserver/singlefile/validtypes_test.go
@@ -1,4 +1,4 @@
-package testserver
+package singlefile
import (
"context"
diff --git a/codegen/testserver/singlefile/weird_type_cases.graphql b/codegen/testserver/singlefile/weird_type_cases.graphql
new file mode 100644
index 00000000000..afd440f1d12
--- /dev/null
+++ b/codegen/testserver/singlefile/weird_type_cases.graphql
@@ -0,0 +1,8 @@
+# regression test for https://github.com/99designs/gqlgen/issues/583
+
+type asdfIt { id: ID! }
+type iIt { id: ID! }
+type AIt { id: ID! }
+type XXIt { id: ID! }
+type AbIt { id: ID! }
+type XxIt { id: ID! }
diff --git a/codegen/testserver/wrapped_type.go b/codegen/testserver/singlefile/wrapped_type.go
similarity index 58%
rename from codegen/testserver/wrapped_type.go
rename to codegen/testserver/singlefile/wrapped_type.go
index d17436045b6..54554d2f2f6 100644
--- a/codegen/testserver/wrapped_type.go
+++ b/codegen/testserver/singlefile/wrapped_type.go
@@ -1,6 +1,6 @@
-package testserver
+package singlefile
-import "github.com/99designs/gqlgen/codegen/testserver/otherpkg"
+import "github.com/99designs/gqlgen/codegen/testserver/singlefile/otherpkg"
type WrappedScalar = otherpkg.Scalar
type WrappedStruct otherpkg.Struct
diff --git a/codegen/testserver/singlefile/wrapped_type.graphql b/codegen/testserver/singlefile/wrapped_type.graphql
new file mode 100644
index 00000000000..116147432cb
--- /dev/null
+++ b/codegen/testserver/singlefile/wrapped_type.graphql
@@ -0,0 +1,13 @@
+# regression test for https://github.com/99designs/gqlgen/issues/721
+
+extend type Query {
+ wrappedStruct: WrappedStruct!
+ wrappedScalar: WrappedScalar!
+ wrappedMap: WrappedMap!
+ wrappedSlice: WrappedSlice!
+}
+
+type WrappedStruct { name: WrappedScalar!, desc: WrappedScalar }
+scalar WrappedScalar
+type WrappedMap { get(key: String!): String! }
+type WrappedSlice { get(idx: Int!): String! }
diff --git a/codegen/testserver/wrapped_type_test.go b/codegen/testserver/singlefile/wrapped_type_test.go
similarity index 96%
rename from codegen/testserver/wrapped_type_test.go
rename to codegen/testserver/singlefile/wrapped_type_test.go
index 0841061a1d4..13a9ccab840 100644
--- a/codegen/testserver/wrapped_type_test.go
+++ b/codegen/testserver/singlefile/wrapped_type_test.go
@@ -1,11 +1,11 @@
-package testserver
+package singlefile
import (
"context"
"testing"
"github.com/99designs/gqlgen/client"
- "github.com/99designs/gqlgen/codegen/testserver/otherpkg"
+ "github.com/99designs/gqlgen/codegen/testserver/singlefile/otherpkg"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/stretchr/testify/require"
)
diff --git a/codegen/type.go b/codegen/type.go
index 06b370be7f2..20b09dc9755 100644
--- a/codegen/type.go
+++ b/codegen/type.go
@@ -26,7 +26,7 @@ func processType(ret map[string]*config.TypeReference, ref *config.TypeReference
}
ret[key] = ref
- if ref.IsSlice() {
+ if ref.IsSlice() || ref.IsPtrToSlice() || ref.IsPtrToPtr() {
processType(ret, ref.Elem())
}
}
diff --git a/codegen/type.gotpl b/codegen/type.gotpl
index bd5c8435113..b82eef3cf1c 100644
--- a/codegen/type.gotpl
+++ b/codegen/type.gotpl
@@ -1,10 +1,13 @@
{{- range $type := .ReferencedTypes }}
{{ with $type.UnmarshalFunc }}
func (ec *executionContext) {{ . }}(ctx context.Context, v interface{}) ({{ $type.GO | ref }}, error) {
- {{- if and $type.IsNilable (not $type.GQL.NonNull) }}
+ {{- if and $type.IsNilable (not $type.GQL.NonNull) (not $type.IsPtrToPtr) }}
if v == nil { return nil, nil }
{{- end }}
- {{- if $type.IsSlice }}
+ {{- if $type.IsPtrToSlice }}
+ res, err := ec.{{ $type.Elem.UnmarshalFunc }}(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+ {{- else if $type.IsSlice }}
var vSlice []interface{}
if v != nil {
if tmp1, ok := v.([]interface{}); ok {
@@ -23,17 +26,35 @@
}
}
return res, nil
+ {{- else if and $type.IsPtrToPtr (not $type.Unmarshaler) (not $type.IsMarshaler) }}
+ var pres {{ $type.Elem.GO | ref }}
+ if v != nil {
+ res, err := ec.{{ $type.Elem.UnmarshalFunc }}(ctx, v)
+ if err != nil {
+ return nil, graphql.ErrorOnPath(ctx, err)
+ }
+ pres = res
+ }
+ return &pres, nil
{{- else }}
{{- if $type.Unmarshaler }}
{{- if $type.CastType }}
- tmp, err := {{ $type.Unmarshaler | call }}(v)
- {{- if $type.IsNilable }}
+ {{- if $type.IsContext }}
+ tmp, err := {{ $type.Unmarshaler | call }}(ctx, v)
+ {{- else }}
+ tmp, err := {{ $type.Unmarshaler | call }}(v)
+ {{- end }}
+ {{- if and $type.IsNilable $type.Elem }}
res := {{ $type.Elem.GO | ref }}(tmp)
{{- else}}
res := {{ $type.GO | ref }}(tmp)
{{- end }}
{{- else}}
- res, err := {{ $type.Unmarshaler | call }}(v)
+ {{- if $type.IsContext }}
+ res, err := {{ $type.Unmarshaler | call }}(ctx, v)
+ {{- else }}
+ res, err := {{ $type.Unmarshaler | call }}(v)
+ {{- end }}
{{- end }}
{{- if and $type.IsTargetNilable (not $type.IsNilable) }}
return *res, graphql.ErrorOnPath(ctx, err)
@@ -45,12 +66,16 @@
{{- else if eq ($type.GO | ref) "map[string]interface{}" }}
return v.(map[string]interface{}), nil
{{- else if $type.IsMarshaler }}
- {{- if $type.IsNilable }}
+ {{- if and $type.IsNilable $type.Elem }}
var res = new({{ $type.Elem.GO | ref }})
{{- else}}
var res {{ $type.GO | ref }}
{{- end }}
- err := res.UnmarshalGQL(v)
+ {{- if $type.IsContext }}
+ err := res.UnmarshalGQLContext(ctx, v)
+ {{- else }}
+ err := res.UnmarshalGQL(v)
+ {{- end }}
return res, graphql.ErrorOnPath(ctx, err)
{{- else }}
res, err := ec.unmarshalInput{{ $type.GQL.Name }}(ctx, v)
@@ -66,7 +91,9 @@
{{ with $type.MarshalFunc }}
func (ec *executionContext) {{ . }}(ctx context.Context, sel ast.SelectionSet, v {{ $type.GO | ref }}) graphql.Marshaler {
- {{- if $type.IsSlice }}
+ {{- if $type.IsPtrToSlice }}
+ return ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, *v)
+ {{- else if $type.IsSlice }}
{{- if not $type.GQL.NonNull }}
if v == nil {
return graphql.Null
@@ -90,11 +117,11 @@
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
- if r := recover(); r != nil {
- ec.Error(ctx, ec.Recover(ctx, r))
- ret = nil
- }
- }()
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
if !isLen1 {
defer wg.Done()
}
@@ -107,10 +134,22 @@
}
{{ else }}
ret[i] = ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, v[i])
- {{- end}}
+ {{- end }}
}
{{ if not $type.IsScalar }} wg.Wait() {{ end }}
+ {{ if $type.Elem.GQL.NonNull }}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+ {{ end }}
return ret
+ {{- else if and $type.IsPtrToPtr (not $type.Unmarshaler) (not $type.IsMarshaler) }}
+ if v == nil {
+ return graphql.Null
+ }
+ return ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, *v)
{{- else }}
{{- if $type.IsNilable }}
if v == nil {
@@ -123,7 +162,11 @@
}
{{- end }}
{{- if $type.IsMarshaler }}
- return v
+ {{- if $type.IsContext }}
+ return graphql.WrapContextMarshaler(ctx, v)
+ {{- else }}
+ return v
+ {{- end }}
{{- else if $type.Marshaler }}
{{- $v := "v" }}
{{- if and $type.IsTargetNilable (not $type.IsNilable) }}
@@ -131,16 +174,18 @@
{{- else if and (not $type.IsTargetNilable) $type.IsNilable }}
{{- $v = "*v" }}
{{- end }}
+ res := {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}({{ $v }}){{else}}{{ $v }}{{- end }})
{{- if $type.GQL.NonNull }}
- res := {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}({{ $v }}){{else}}{{ $v }}{{- end }})
- if res == graphql.Null {
- if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
- ec.Errorf(ctx, "must not be null")
- }
+ if res == graphql.Null {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
}
- return res
+ }
+ {{- end }}
+ {{- if $type.IsContext }}
+ return graphql.WrapContextMarshaler(ctx, res)
{{- else }}
- return {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}({{ $v }}){{else}}{{ $v }}{{- end }})
+ return res
{{- end }}
{{- else }}
return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsNilable}}&{{end}} v)
diff --git a/codegen/util.go b/codegen/util.go
index 59dfde08cdc..fa2ceed3dfe 100644
--- a/codegen/util.go
+++ b/codegen/util.go
@@ -1,10 +1,9 @@
package codegen
import (
+ "fmt"
"go/types"
"strings"
-
- "github.com/pkg/errors"
)
func findGoNamedType(def types.Type) (*types.Named, error) {
@@ -14,7 +13,7 @@ func findGoNamedType(def types.Type) (*types.Named, error) {
namedType, ok := def.(*types.Named)
if !ok {
- return nil, errors.Errorf("expected %s to be a named type, instead found %T\n", def.String(), def)
+ return nil, fmt.Errorf("expected %s to be a named type, instead found %T\n", def.String(), def)
}
return namedType, nil
@@ -34,14 +33,14 @@ func findGoInterface(def types.Type) (*types.Interface, error) {
underlying, ok := namedType.Underlying().(*types.Interface)
if !ok {
- return nil, errors.Errorf("expected %s to be a named interface, instead found %s", def.String(), namedType.String())
+ return nil, fmt.Errorf("expected %s to be a named interface, instead found %s", def.String(), namedType.String())
}
return underlying, nil
}
func equalFieldName(source, target string) bool {
- source = strings.Replace(source, "_", "", -1)
- target = strings.Replace(target, "_", "", -1)
+ source = strings.ReplaceAll(source, "_", "")
+ target = strings.ReplaceAll(target, "_", "")
return strings.EqualFold(source, target)
}
diff --git a/complexity/complexity.go b/complexity/complexity.go
index 1877aae5fbd..e3ecf7612d5 100644
--- a/complexity/complexity.go
+++ b/complexity/complexity.go
@@ -26,6 +26,11 @@ func (cw complexityWalker) selectionSetComplexity(selectionSet ast.SelectionSet)
switch s := selection.(type) {
case *ast.Field:
fieldDefinition := cw.schema.Types[s.Definition.Type.Name()]
+
+ if fieldDefinition.Name == "__Schema" {
+ continue
+ }
+
var childComplexity int
switch fieldDefinition.Kind {
case ast.Object, ast.Interface, ast.Union:
diff --git a/docs/build.sh b/docs/build.sh
index 02f3174d801..d677f22f72c 100755
--- a/docs/build.sh
+++ b/docs/build.sh
@@ -10,8 +10,9 @@ RESET='\033[0m'
HOST=https://gqlgen.com
VERSIONS_ARRAY=(
- 'v0.13.0'
+ 'v0.14.0'
'origin/master'
+ 'v0.13.0'
'v0.12.2'
'v0.11.3'
'v0.10.2'
diff --git a/docs/config.yml b/docs/config.yml
index 57d47d5a035..f99a6731bdf 100644
--- a/docs/config.yml
+++ b/docs/config.yml
@@ -21,3 +21,6 @@ menu:
- name: Recipes
identifier: recipes
weight: 10
+ - name: pkg.go.dev →
+ parent: reference
+ url: https://pkg.go.dev/github.com/99designs/gqlgen
diff --git a/docs/content/config.md b/docs/content/config.md
index f4e16b3a08d..2c7e415b972 100644
--- a/docs/content/config.md
+++ b/docs/content/config.md
@@ -17,7 +17,8 @@ schema:
# Where should the generated server code go?
exec:
- filename: graph/generated/generated.go
+ layout: follow-schema
+ dir: graph/generated
package: generated
# Enable Apollo federation support
@@ -46,6 +47,9 @@ resolver:
# Optional: set to speed up generation time by not performing a final validation pass.
# skip_validation: true
+# Optional: set to skip running `go mod tidy` when generating server code
+# skip_mod_tidy: true
+
# gqlgen will search for any type names in the schema in these go packages
# if they match it will use them, otherwise it will generate them.
autobind:
@@ -89,6 +93,9 @@ directive @goModel(model: String, models: [String!]) on OBJECT
directive @goField(forceResolver: Boolean, name: String) on INPUT_FIELD_DEFINITION
| FIELD_DEFINITION
+
+directive @extraTag on INPUT_FIELD_DEFINITION
+ | FIELD_DEFINITION
```
> Here be dragons
@@ -101,6 +108,6 @@ Now you can use these directives when defining types in your schema:
```graphql
type User @goModel(model: "github.com/my/app/models.User") {
id: ID! @goField(name: "todoId")
- name: String! @goField(forceResolver: true)
+ name: String! @goField(forceResolver: true) @extraTag(xorm: "-")
}
```
diff --git a/docs/content/getting-started.md b/docs/content/getting-started.md
index 99a3be37270..45534c68e98 100644
--- a/docs/content/getting-started.md
+++ b/docs/content/getting-started.md
@@ -14,23 +14,45 @@ This tutorial will take you through the process of building a GraphQL server wit
You can find the finished code for this tutorial [here](https://github.com/vektah/gqlgen-tutorials/tree/master/gettingstarted)
-## Setup Project
+## Set up Project
-Create a directory for your project, and initialise it as a Go Module:
+Create a directory for your project, and [initialise it as a Go Module](https://golang.org/doc/tutorial/create-module):
-```sh
-$ mkdir gqlgen-todos
-$ cd gqlgen-todos
-$ go mod init github.com/[username]/gqlgen-todos
-$ go get github.com/99designs/gqlgen
+```shell
+mkdir gqlgen-todos
+cd gqlgen-todos
+go mod init github.com/[username]/gqlgen-todos
+```
+
+Next, create a `tools.go` file and add gqlgen as a [tool dependency for your module](https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module).
+
+```go
+//go:build tools
+// +build tools
+
+package tools
+
+import (
+ _ "github.com/99designs/gqlgen"
+)
+```
+
+To automatically add the dependency to your `go.mod` run
+```shell
+go mod tidy
+```
+
+If you want to specify a particular version of gqlgen, you can use `go get`. For example
+```shell
+go get -d github.com/99designs/gqlgen@v0.14.0
```
## Building the server
### Create the project skeleton
-```bash
-$ go run github.com/99designs/gqlgen init
+```shell
+go run github.com/99designs/gqlgen init
```
This will create our suggested package layout. You can modify these paths in gqlgen.yml if you need to.
@@ -85,8 +107,8 @@ type Mutation {
### Implement the resolvers
-`gqlgen generate` compares the schema file (`graph/schema.graphqls`) with the models `graph/model/*` and wherever it
-can it will bind directly to the model.
+When executed, gqlgen's `generate` command compares the schema file (`graph/schema.graphqls`) with the models `graph/model/*`, and, wherever it
+can, it will bind directly to the model. That was done already when `init` was run. We'll edit the schema later in the tutorial, but for now, let's look at what was generated already.
If we take a look in `graph/schema.resolvers.go` we will see all the times that gqlgen couldn't match them up. For us
it was twice:
@@ -103,14 +125,15 @@ func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) {
We just need to implement these two methods to get our server working:
-First we need somewhere to track our state, lets put it in `graph/resolver.go`:
+First we need somewhere to track our state, lets put it in `graph/resolver.go`. The `graph/resolver.go` file is where we declare our app's dependencies, like our database. It gets initialized once in `server.go` when we create the graph.
+
```go
type Resolver struct{
todos []*model.Todo
}
```
-This is where we declare any dependencies for our app like our database, it gets initialized once in `server.go` when
-we create the graph.
+
+Returning to `graph/schema.resolvers.go`, let's implement the bodies of those automatically generated resolver functions. For `CreateTodo`, we'll use `math.rand` to simply return a todo with a randomly generated ID and store that in the in-memory todos list --- in a real app, you're likely to use a database or some other backend service.
```go
func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) {
@@ -128,15 +151,17 @@ func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) {
}
```
+### Run the server
+
We now have a working server, to start it:
```bash
go run server.go
```
-then open http://localhost:8080 in a browser. here are some queries to try:
+Open http://localhost:8080 in a browser. Here are some queries to try, starting with creating a todo:
```graphql
mutation createTodo {
- createTodo(input:{text:"todo", userId:"1"}) {
+ createTodo(input: { text: "todo", userId: "1" }) {
user {
id
}
@@ -144,15 +169,19 @@ mutation createTodo {
done
}
}
+```
+
+And then querying for it:
+```graphql
query findTodos {
- todos {
- text
- done
- user {
- name
- }
+ todos {
+ text
+ done
+ user {
+ name
}
+ }
}
```
@@ -202,10 +231,10 @@ func (r *todoResolver) User(ctx context.Context, obj *model.Todo) (*model.User,
At the top of our `resolver.go`, between `package` and `import`, add the following line:
```go
-//go:generate go run github.com/99designs/gqlgen
+//go:generate go run github.com/99designs/gqlgen generate
```
-This magic comment tells `go generate` what command to run when we want to regenerate our code. To run go generate recursively over your entire project, use this command:
+This magic comment tells `go generate` what command to run when we want to regenerate our code. To run go generate recursively over your entire project, use this command:
```go
go generate ./...
diff --git a/docs/content/recipes/authentication.md b/docs/content/recipes/authentication.md
index 6ae59e73b8d..c77f5d9dd07 100644
--- a/docs/content/recipes/authentication.md
+++ b/docs/content/recipes/authentication.md
@@ -88,7 +88,7 @@ func main() {
router.Use(auth.Middleware(db))
- srv := handler.NewDefaultServer(starwars.NewExecutableSchema(starwars.NewResolver()))
+ srv := handler.NewDefaultServer(starwars.NewExecutableSchema(starwars.NewResolver()))
router.Handle("/", playground.Handler("Starwars", "/query"))
router.Handle("/query", srv)
diff --git a/docs/content/recipes/cors.md b/docs/content/recipes/cors.md
index 9e36110e7e7..0b0ac114bfa 100644
--- a/docs/content/recipes/cors.md
+++ b/docs/content/recipes/cors.md
@@ -22,6 +22,8 @@ import (
"github.com/99designs/gqlgen/graphql/handler"
"github.com/go-chi/chi"
"github.com/rs/cors"
+ "github.com/gorilla/websocket"
+ "github.com/99designs/gqlgen/graphql/playground"
)
func main() {
@@ -48,7 +50,7 @@ func main() {
},
})
- router.Handle("/", handler.Playground("Starwars", "/query"))
+ router.Handle("/", playground.Handler("Starwars", "/query"))
router.Handle("/query", srv)
err := http.ListenAndServe(":8080", router)
diff --git a/docs/content/recipes/gin.md b/docs/content/recipes/gin.md
index 155cc76e05e..27b073aca78 100644
--- a/docs/content/recipes/gin.md
+++ b/docs/content/recipes/gin.md
@@ -16,10 +16,12 @@ Install Gin:
$ go get github.com/gin-gonic/gin
```
-In your router file, define the handlers for the GraphQL and Playground endpoints in two different methods and tie then together in the Gin router:
+In your router file, define the handlers for the GraphQL and Playground endpoints in two different methods and tie them together in the Gin router:
```go
import (
+ "github.com/[username]/gqlgen-todos/graph" // Replace username with your github username
+ "github.com/[username]/gqlgen-todos/graph/generated" // Replace username with your github username
"github.com/gin-gonic/gin"
"github.com/99designs/gqlgen/graphql/handler"
@@ -30,7 +32,7 @@ import (
func graphqlHandler() gin.HandlerFunc {
// NewExecutableSchema and Config are in the generated.go file
// Resolver is in the resolver.go file
- h := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{}}))
+ h := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}}))
return func(c *gin.Context) {
h.ServeHTTP(c.Writer, c.Request)
diff --git a/docs/content/recipes/modelgen-hook.md b/docs/content/recipes/modelgen-hook.md
index 88d9fd967de..695ca74cb92 100644
--- a/docs/content/recipes/modelgen-hook.md
+++ b/docs/content/recipes/modelgen-hook.md
@@ -5,6 +5,8 @@ linkTitle: "Modelgen hook"
menu: { main: { parent: 'recipes' } }
---
+## BuildMutateHook
+
The following recipe shows how to use a `modelgen` plugin hook to mutate generated
models before they are rendered into a resulting file. This feature has many uses but
the example focuses only on inserting ORM-specific tags into generated struct fields. This
@@ -47,10 +49,8 @@ func main() {
MutateHook: mutateHook,
}
- err = api.Generate(cfg,
- api.NoPlugins(),
- api.AddPlugin(&p),
- )
+ err = api.Generate(cfg, api.ReplacePlugin(&p))
+
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(3)
@@ -77,3 +77,86 @@ type Object struct {
field2 *int `json:"field2" orm_binding:"Object.field2"`
}
```
+
+## FieldMutateHook
+
+For more fine grained control over model generation, a graphql schema aware a FieldHook can be provided. This hook has access to type and field graphql definitions enabling the hook to modify the `modelgen.Field` using directives defined within the schema.
+
+The below recipe uses this feature to add validate tags to the generated model for use with `go-playground/validator` where the validate tags are defined in a constraint directive in the schema.
+
+``` go
+import (
+ "fmt"
+ "github.com/vektah/gqlparser/v2/ast"
+ "os"
+
+ "github.com/99designs/gqlgen/api"
+ "github.com/99designs/gqlgen/codegen/config"
+ "github.com/99designs/gqlgen/plugin/modelgen"
+)
+
+// Defining mutation function
+func constraintFieldHook(td *ast.Definition, fd *ast.FieldDefinition, f *modelgen.Field) (*modelgen.Field, error) {
+
+ c := fd.Directives.ForName("constraint")
+ if c != nil {
+ formatConstraint := c.Arguments.ForName("format")
+
+ if formatConstraint != nil{
+ f.Tag += " validate:"+formatConstraint.Value.String()
+ }
+
+ }
+
+ return f, nil
+}
+
+func main() {
+ cfg, err := config.LoadConfigFromDefaultLocations()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "failed to load config", err.Error())
+ os.Exit(2)
+ }
+
+ // Attaching the mutation function onto modelgen plugin
+ p := modelgen.Plugin{
+ FieldHook: constraintFieldHook,
+ }
+
+ err = api.Generate(cfg, api.ReplacePlugin(&p))
+
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(3)
+ }
+}
+```
+
+This schema:
+
+```graphql
+directive @constraint(
+ format: String
+) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
+
+input ObjectInput {
+ contactEmail: String @constraint(format: "email")
+ website: String @constraint(format: "uri")
+}
+```
+
+Will generate the model:
+
+```go
+type ObjectInput struct {
+ contactEmail *string `json:"contactEmail" validate:"email"`
+ website *string `json:"website" validate:"uri"`
+}
+```
+
+If a constraint being used during generation shoud not be published during introspection, the directive should be listed with `skip_runtime:true` in gqlgen.yml
+```yaml
+directives:
+ constraint:
+ skip_runtime: true
+```
diff --git a/docs/content/reference/apq.md b/docs/content/reference/apq.md
index 32df5effc04..f0482949278 100644
--- a/docs/content/reference/apq.md
+++ b/docs/content/reference/apq.md
@@ -14,10 +14,10 @@ to register query hash with original query on a server.
## Usage
In order to enable Automatic Persisted Queries you need to change your client. For more information see
-[Automatic Persisted Queries Link](https://github.com/apollographql/apollo-link-persisted-queries) documentation.
+[Automatic Persisted Queries Link](https://www.apollographql.com/docs/resources/graphql-glossary/#automatic-persisted-queries-apq) documentation.
-For the server you need to implement `PersistedQueryCache` interface and pass instance to
-`handler.EnablePersistedQueryCache` option.
+For the server you need to implement the `graphql.Cache` interface and pass an instance to
+the `extension.AutomaticPersistedQuery` type. Make sure the extension is applied to your GraphQL handler.
See example using [go-redis](https://github.com/go-redis/redis) package below:
```go
@@ -38,7 +38,7 @@ type Cache struct {
const apqPrefix = "apq:"
-func NewCache(redisAddress string, password string, ttl time.Duration) (*Cache, error) {
+func NewCache(redisAddress string, ttl time.Duration) (*Cache, error) {
client := redis.NewClient(&redis.Options{
Addr: redisAddress,
})
diff --git a/docs/content/reference/changesets.md b/docs/content/reference/changesets.md
index 243ab30eb6a..329206ba5ef 100644
--- a/docs/content/reference/changesets.md
+++ b/docs/content/reference/changesets.md
@@ -9,7 +9,7 @@ Occasionally you need to distinguish presence from nil (undefined vs null). In g
```graphql
-type Query {
+type Mutation {
updateUser(id: ID!, changes: UserChanges!): User
}
@@ -28,7 +28,7 @@ models:
After running go generate you should end up with a resolver that looks like this:
```go
-func (r *queryResolver) UpdateUser(ctx context.Context, id int, changes map[string]interface{}) (*User, error) {
+func (r *mutationResolver) UpdateUser(ctx context.Context, id int, changes map[string]interface{}) (*User, error) {
u := fetchFromDb(id)
/// apply the changes
saveToDb(u)
diff --git a/docs/content/reference/complexity.md b/docs/content/reference/complexity.md
index 81367c1cccd..e99ac130587 100644
--- a/docs/content/reference/complexity.md
+++ b/docs/content/reference/complexity.md
@@ -13,13 +13,13 @@ Consider a schema that allows listing blog posts. Each blog post is also related
```graphql
type Query {
- posts(count: Int = 10): [Post!]!
+ posts(count: Int = 10): [Post!]!
}
type Post {
- title: String!
- text: String!
- related(count: Int = 10): [Post!]!
+ title: String!
+ text: String!
+ related(count: Int = 10): [Post!]!
}
```
@@ -27,15 +27,15 @@ It's not too hard to craft a query that will cause a very large response:
```graphql
{
- posts(count: 100) {
- related(count: 100) {
- related(count: 100) {
- related(count: 100) {
- title
- }
- }
- }
- }
+ posts(count: 100) {
+ related(count: 100) {
+ related(count: 100) {
+ related(count: 100) {
+ title
+ }
+ }
+ }
+ }
}
```
@@ -47,12 +47,12 @@ Limiting query complexity is as simple as specifying it with the provided extens
```go
func main() {
- c := Config{ Resolvers: &resolvers{} }
+ c := Config{ Resolvers: &resolvers{} }
srv := handler.NewDefaultServer(blog.NewExecutableSchema(c))
srv.Use(extension.FixedComplexityLimit(5)) // This line is key
- r.Handle("/query", srv)
+ r.Handle("/query", srv)
}
```
@@ -66,17 +66,17 @@ To apply higher costs to certain fields, we can use custom complexity functions.
```go
func main() {
- c := Config{ Resolvers: &resolvers{} }
+ c := Config{ Resolvers: &resolvers{} }
- countComplexity := func(childComplexity, count int) int {
- return count * childComplexity
- }
- c.Complexity.Query.Posts = countComplexity
- c.Complexity.Post.Related = countComplexity
+ countComplexity := func(childComplexity, count int) int {
+ return count * childComplexity
+ }
+ c.Complexity.Query.Posts = countComplexity
+ c.Complexity.Post.Related = countComplexity
- srv := handler.NewDefaultServer(blog.NewExecutableSchema(c))
+ srv := handler.NewDefaultServer(blog.NewExecutableSchema(c))
srv.Use(extension.FixedComplexityLimit(5))
- http.Handle("/query", gqlHandler)
+ http.Handle("/query", gqlHandler)
}
```
diff --git a/docs/content/reference/dataloaders.md b/docs/content/reference/dataloaders.md
index d5ece00e21a..42910cbd29b 100644
--- a/docs/content/reference/dataloaders.md
+++ b/docs/content/reference/dataloaders.md
@@ -83,6 +83,7 @@ doesnt have generics. Instead we generate the code manually for our instance.
go get github.com/vektah/dataloaden
mkdir dataloader
cd dataloader
+echo 'package dataloader' > gen.go
go run github.com/vektah/dataloaden UserLoader int *gqlgen-tutorials/dataloader/graph/model.User
```
@@ -157,7 +158,7 @@ func (r *todoResolver) UserLoader(ctx context.Context, obj *model.Todo) (*model.
}
```
-The end result? just 2 queries!
+The end result? Just 2 queries!
```sql
SELECT id, todo, user_id FROM todo
SELECT id, name from user WHERE id IN (?,?,?,?,?)
diff --git a/docs/content/reference/directives.md b/docs/content/reference/directives.md
index 44a485f1880..7cee2d1ae0e 100644
--- a/docs/content/reference/directives.md
+++ b/docs/content/reference/directives.md
@@ -5,13 +5,22 @@ linkTitle: Schema Directives
menu: { main: { parent: 'reference', weight: 10 } }
---
-Directives are a bit like annotations in any other language. They give you a way to specify some behaviour without directly binding to the implementation. This can be really useful for cross cutting concerns like permission checks.
+Directives act a bit like annotations, decorators, or HTTP middleware. They give you a way to specify some behaviour based on a field or argument in a generic and reusable way. This can be really useful for cross-cutting concerns like permission checks which can be applied broadly across your API.
**Note**: The current directives implementation is still fairly limited, and is designed to cover the most common "field middleware" case.
-## Declare it in the schema
+## Restricting access based on user role
-Directives are declared in your schema, along with all your other types. Lets define a @hasRole directive:
+For example, we might want to restrict which mutations or queries a client can make based on the authenticated user's role:
+```graphql
+type Mutation {
+ deleteUser(userID: ID!): Bool @hasRole(role: ADMIN)
+}
+```
+
+### Declare it in the schema
+
+Before we can use a directive we must declare it in the schema. Here's how we would define the `@hasRole` directive:
```graphql
directive @hasRole(role: Role!) on FIELD_DEFINITION
@@ -22,7 +31,7 @@ enum Role {
}
```
-When we next run go generate, gqlgen will add this directive to the DirectiveRoot
+Next, run `go generate` and gqlgen will add the directive to the DirectiveRoot:
```go
type DirectiveRoot struct {
HasRole func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (res interface{}, err error)
@@ -31,31 +40,22 @@ type DirectiveRoot struct {
The arguments are:
- *ctx*: the parent context
- - *obj*: the object containing the value this was applied to, eg:
- - for field definition directives, the object/input object that contains the field
- - for argument directives, a map containing all arguments
+ - *obj*: the object containing the value this was applied to, e.g.:
+ - for field definition directives (`FIELD_DEFINITION`), the object/input object that contains the field
+ - for argument directives (`ARGUMENT_DEFINITION`), a map containing all arguments
- *next*: the next directive in the directive chain, or the field resolver. This should be called to get the
- value of the field/argument/whatever. You can block access to the field by not calling next for permission
- checks etc.
- - *...args*: Any args to the directive will be passed in too.
-
-## Use it in the schema
-
-We can call this on any field definition now:
-```graphql
-type Mutation {
- deleteUser(userID: ID!): Bool @hasRole(role: ADMIN)
-}
-```
+ value of the field/argument/whatever. You can block access to the field by not calling `next(ctx)`
+ after checking whether a user has a required permission, for example.
+ - *...args*: finally, any args defined in the directive schema definition are passed in
## Implement the directive
-Finally, we need to implement the directive, and pass it in when starting the server:
+Now we must implement the directive. The directive function is assigned to the Config object before registering the GraphQL handler.
```go
package main
func main() {
- c := Config{ Resolvers: &resolvers{} }
+ c := generated.Config{ Resolvers: &resolvers{} }
c.Directives.HasRole = func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (interface{}, error) {
if !getCurrentUser(ctx).HasRole(role) {
// block calling the next resolver
@@ -66,7 +66,9 @@ func main() {
return next(ctx)
}
- http.Handle("/query", handler.GraphQL(todo.NewExecutableSchema(c), ))
+ http.Handle("/query", handler.NewDefaultServer(generated.NewExecutableSchema(c), ))
log.Fatal(http.ListenAndServe(":8081", nil))
}
```
+
+That's it! You can now apply the `@hasRole` directive to any mutation or query in your schema.
diff --git a/docs/content/reference/errors.md b/docs/content/reference/errors.md
index fa1a7f89508..69acbf89713 100644
--- a/docs/content/reference/errors.md
+++ b/docs/content/reference/errors.md
@@ -114,7 +114,7 @@ server := handler.NewDefaultServer(MakeExecutableSchema(resolvers)
server.SetRecoverFunc(func(ctx context.Context, err interface{}) error {
// notify bug tracker...
- return errors.New("Internal server error!")
+ return gqlerror.Errorf("Internal server error!")
})
```
diff --git a/docs/content/reference/godoc.md b/docs/content/reference/godoc.md
deleted file mode 100644
index d6c864e85fa..00000000000
--- a/docs/content/reference/godoc.md
+++ /dev/null
@@ -1,18 +0,0 @@
----
-title: "godoc"
-description:
-linkTitle: |
- godoc
-
-
-
-
-menu:
- main:
- parent: 'reference'
- weight: 0
- url: https://godoc.org/github.com/99designs/gqlgen
----
diff --git a/docs/content/reference/scalars.md b/docs/content/reference/scalars.md
index 9bda307f553..21ffe180838 100644
--- a/docs/content/reference/scalars.md
+++ b/docs/content/reference/scalars.md
@@ -15,7 +15,7 @@ gqlgen ships with some built-in helpers for common custom scalar use-cases, `Tim
scalar Time
```
-Maps a `Time` GraphQL scalar to a Go `time.Time` struct.
+Maps a `Time` GraphQL scalar to a Go `time.Time` struct. This scalar adheres to the [time.RFC3339Nano](https://pkg.go.dev/time#pkg-constants) format.
### Map
@@ -52,16 +52,22 @@ Maps an arbitrary GraphQL value to a `interface{}` Go type.
## Custom scalars with user defined types
-For user defined types you can implement the graphql.Marshaler and graphql.Unmarshaler interfaces and they will be called.
+For user defined types you can implement the [graphql.Marshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#Marshaler) and [graphql.Unmarshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#Unmarshaler) or implement the [graphql.ContextMarshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#ContextMarshaler) and [graphql.ContextUnmarshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#ContextUnmarshaler) interfaces and they will be called.
```go
package mypkg
import (
+ "context"
"fmt"
"io"
+ "strconv"
)
+//
+// Most common scalars
+//
+
type YesNo bool
// UnmarshalGQL implements the graphql.Unmarshaler interface
@@ -87,6 +93,42 @@ func (y YesNo) MarshalGQL(w io.Writer) {
w.Write([]byte(`"no"`))
}
}
+
+//
+// Scalars that need access to the request context
+//
+
+type Length float64
+
+// UnmarshalGQLContext implements the graphql.ContextUnmarshaler interface
+func (l *Length) UnmarshalGQLContext(ctx context.Context, v interface{}) error {
+ s, ok := v.(string)
+ if !ok {
+ return fmt.Errorf("Length must be a string")
+ }
+ length, err := ParseLength(s)
+ if err != nil {
+ return err
+ }
+ *l = length
+ return nil
+}
+
+// MarshalGQLContext implements the graphql.ContextMarshaler interface
+func (l Length) MarshalGQLContext(ctx context.Context, w io.Writer) error {
+ s, err := l.FormatContext(ctx)
+ if err != nil {
+ return err
+ }
+ w.Write([]byte(strconv.Quote(s)))
+ return nil
+}
+
+// ParseLength parses a length measurement string with unit on the end (eg: "12.45in")
+func ParseLength(string) (Length, error)
+
+// ParseLength formats the string using a value in the context to specify format
+func (l Length) FormatContext(ctx context.Context) (string, error)
```
and then wire up the type in .gqlgen.yml or via directives like normal:
@@ -149,11 +191,14 @@ models:
**Note:** you also can un/marshal to pointer types via this approach, simply accept a pointer in your
`Marshal...` func and return one in your `Unmarshal...` func.
+**Note:** you can also un/marshal with a context by having your custom marshal function return a
+`graphql.ContextMarshaler` _and_ your unmarshal function take a `context.Context` as the first argument.
+
See the [example/scalars](https://github.com/99designs/gqlgen/tree/master/example/scalars) package for more examples.
-## Unmarshaling Errors
+## Marshaling/Unmarshaling Errors
-The errors that occur as part of custom scalar unmarshaling will return a full path to the field.
+The errors that occur as part of custom scalar marshaling/unmarshaling will return a full path to the field.
For example, given the following schema ...
```graphql
@@ -203,4 +248,4 @@ input ContactDetailsInput {
}
```
-
+**Note:** Marshaling errors can only be returned when using the `graphql.ContextMarshaler` style interface.
diff --git a/example/chat/generated.go b/example/chat/generated.go
index 842b3e31ff9..067b1d01bf9 100644
--- a/example/chat/generated.go
+++ b/example/chat/generated.go
@@ -1010,6 +1010,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1972,7 +2007,6 @@ var chatroomImplementors = []string{"Chatroom"}
func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, obj *Chatroom) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, chatroomImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1980,12 +2014,22 @@ func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("Chatroom")
case "name":
- out.Values[i] = ec._Chatroom_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Chatroom_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "messages":
- out.Values[i] = ec._Chatroom_messages(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Chatroom_messages(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2004,7 +2048,6 @@ var messageImplementors = []string{"Message"}
func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, obj *Message) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, messageImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2012,22 +2055,42 @@ func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("Message")
case "id":
- out.Values[i] = ec._Message_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Message_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "text":
- out.Values[i] = ec._Message_text(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Message_text(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "createdBy":
- out.Values[i] = ec._Message_createdBy(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Message_createdBy(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "createdAt":
- out.Values[i] = ec._Message_createdAt(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Message_createdAt(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2046,7 +2109,6 @@ var mutationImplementors = []string{"Mutation"}
func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Mutation",
})
@@ -2054,11 +2116,21 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Mutation")
case "post":
- out.Values[i] = ec._Mutation_post(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_post(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2077,7 +2149,6 @@ var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Query",
})
@@ -2085,12 +2156,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Query")
case "room":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2098,11 +2175,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_room(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._Query___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._Query___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2138,7 +2233,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2146,19 +2240,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2177,7 +2301,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2185,19 +2308,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2213,7 +2356,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2221,29 +2363,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2259,7 +2431,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2267,19 +2438,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2295,7 +2486,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2303,21 +2493,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2336,7 +2551,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2344,26 +2558,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2447,6 +2706,13 @@ func (ec *executionContext) marshalNMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2528,6 +2794,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2601,6 +2874,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2650,6 +2930,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2691,6 +2978,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2725,7 +3019,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -2740,7 +3035,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) marshalOChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v *Chatroom) graphql.Marshaler {
@@ -2756,7 +3052,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
@@ -2771,7 +3068,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
@@ -2811,6 +3109,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2851,6 +3156,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2891,6 +3203,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2938,6 +3257,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/chat/readme.md b/example/chat/readme.md
index be1925cbb4e..95b944fd826 100644
--- a/example/chat/readme.md
+++ b/example/chat/readme.md
@@ -4,12 +4,11 @@ Example app using subscriptions to build a chat room.
to run this server
```bash
-go run ./example/chat/server/server.go
+go run ./server/server.go
```
to run the react app
```bash
-cd ./example/chat
npm install
npm run start
```
diff --git a/example/config/generated.go b/example/config/generated.go
index 4e985ada6b1..c85a2564fc9 100644
--- a/example/config/generated.go
+++ b/example/config/generated.go
@@ -37,6 +37,7 @@ type ResolverRoot interface {
Mutation() MutationResolver
Query() QueryResolver
Todo() TodoResolver
+ Role() RoleResolver
}
type DirectiveRoot struct {
@@ -62,6 +63,11 @@ type ComplexityRoot struct {
User struct {
FullName func(childComplexity int) int
ID func(childComplexity int) int
+ Role func(childComplexity int) int
+ }
+
+ Role struct {
+ Name func(childComplexity int) int
}
}
@@ -74,6 +80,9 @@ type QueryResolver interface {
type TodoResolver interface {
ID(ctx context.Context, obj *Todo) (string, error)
}
+type RoleResolver interface {
+ Name(ctx context.Context, obj *UserRole) (string, error)
+}
type executableSchema struct {
resolvers ResolverRoot
@@ -158,6 +167,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.User.ID(childComplexity), true
+ case "User.role":
+ if e.complexity.User.Role == nil {
+ break
+ }
+
+ return e.complexity.User.Role(childComplexity), true
+
+ case "role.name":
+ if e.complexity.Role.Name == nil {
+ break
+ }
+
+ return e.complexity.Role.Name(childComplexity), true
+
}
return 0, false
}
@@ -250,6 +273,12 @@ input NewTodo {
@goModel(model:"github.com/99designs/gqlgen/example/config.User") {
id: ID!
name: String! @goField(name:"FullName")
+ role: role!
+}
+
+type role
+@goModel(model:"github.com/99designs/gqlgen/example/config.UserRole") {
+ name: String!
}
`, BuiltIn: false},
}
@@ -720,6 +749,41 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec
return ec.marshalNString2string(ctx, field.Selections, res)
}
+func (ec *executionContext) _User_role(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "User",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Role, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(UserRole)
+ fc.Result = res
+ return ec.marshalNrole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUserRole(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -857,6 +921,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1803,13 +1902,51 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
}
+func (ec *executionContext) _role_name(ctx context.Context, field graphql.CollectedField, obj *UserRole) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "role",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Role().Name(rctx, obj)
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
// endregion **************************** field.gotpl *****************************
// region **************************** input.gotpl *****************************
func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, obj interface{}) (NewTodo, error) {
var it NewTodo
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -1847,7 +1984,6 @@ var mutationImplementors = []string{"Mutation"}
func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Mutation",
})
@@ -1855,11 +1991,21 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Mutation")
case "createTodo":
- out.Values[i] = ec._Mutation_createTodo(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_createTodo(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -1878,7 +2024,6 @@ var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Query",
})
@@ -1886,12 +2031,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Query")
case "todos":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1902,11 +2053,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._Query___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._Query___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -1922,7 +2091,6 @@ var todoImplementors = []string{"Todo"}
func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1931,7 +2099,8 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj
out.Values[i] = graphql.MarshalString("Todo")
case "id":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1942,24 +2111,49 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "databaseId":
- out.Values[i] = ec._Todo_databaseId(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Todo_databaseId(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "text":
- out.Values[i] = ec._Todo_text(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Todo_text(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "done":
- out.Values[i] = ec._Todo_done(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Todo_done(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "user":
- out.Values[i] = ec._Todo_user(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Todo_user(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
@@ -1978,7 +2172,6 @@ var userImplementors = []string{"User"}
func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1986,12 +2179,32 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("User")
case "id":
- out.Values[i] = ec._User_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec._User_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "role":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_role(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2010,7 +2223,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2018,19 +2230,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2049,7 +2291,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2057,19 +2298,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2085,7 +2346,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2093,29 +2353,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2131,7 +2421,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2139,19 +2428,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2167,7 +2476,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2175,21 +2483,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2208,7 +2541,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2216,26 +2548,112 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var roleImplementors = []string{"role"}
+
+func (ec *executionContext) _role(ctx context.Context, sel ast.SelectionSet, obj *UserRole) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, roleImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("role")
+ case "name":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._role_name(ctx, field, obj)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
+ })
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2354,6 +2772,13 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2415,6 +2840,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2488,6 +2920,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2537,6 +2976,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2578,6 +3024,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2606,13 +3059,18 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a
return res
}
+func (ec *executionContext) marshalNrole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUserRole(ctx context.Context, sel ast.SelectionSet, v UserRole) graphql.Marshaler {
+ return ec._role(ctx, sel, &v)
+}
+
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) {
res, err := graphql.UnmarshalBoolean(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -2627,7 +3085,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) {
@@ -2636,7 +3095,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) {
@@ -2672,6 +3132,12 @@ func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel
ret[i] = ec.marshalNString2string(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2687,7 +3153,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
@@ -2727,6 +3194,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2767,6 +3241,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2807,6 +3288,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2854,6 +3342,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/config/model.go b/example/config/model.go
index 46038be7f88..4632c4eadef 100644
--- a/example/config/model.go
+++ b/example/config/model.go
@@ -5,8 +5,13 @@ import "fmt"
type User struct {
ID string
FirstName, LastName string
+ Role UserRole
}
func (user *User) FullName() string {
return fmt.Sprintf("%s %s", user.FirstName, user.LastName)
}
+
+type UserRole struct {
+ RoleName string
+}
diff --git a/example/config/user.graphql b/example/config/user.graphql
index 52c688bd331..5fb3772fc2f 100644
--- a/example/config/user.graphql
+++ b/example/config/user.graphql
@@ -2,4 +2,10 @@ type User
@goModel(model:"github.com/99designs/gqlgen/example/config.User") {
id: ID!
name: String! @goField(name:"FullName")
+ role: role!
+}
+
+type role
+@goModel(model:"github.com/99designs/gqlgen/example/config.UserRole") {
+ name: String!
}
diff --git a/example/config/user.resolvers.go b/example/config/user.resolvers.go
new file mode 100644
index 00000000000..1d819f99433
--- /dev/null
+++ b/example/config/user.resolvers.go
@@ -0,0 +1,20 @@
+package config
+
+// This file will be automatically regenerated based on the schema, any resolver implementations
+// will be copied through when generating and any unknown code will be moved to the end.
+
+import (
+ "context"
+)
+
+func (r *roleResolver) Name(ctx context.Context, obj *UserRole) (string, error) {
+ if obj == nil {
+ return "", nil
+ }
+ return obj.RoleName, nil
+}
+
+// Role returns RoleResolver implementation.
+func (r *Resolver) Role() RoleResolver { return &roleResolver{r} }
+
+type roleResolver struct{ *Resolver }
diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go
index ef964a60ae8..45bcce22bb2 100644
--- a/example/dataloader/generated.go
+++ b/example/dataloader/generated.go
@@ -1120,6 +1120,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -2082,7 +2117,6 @@ var addressImplementors = []string{"Address"}
func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *Address) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, addressImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2090,17 +2124,32 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("Address")
case "id":
- out.Values[i] = ec._Address_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Address_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "street":
- out.Values[i] = ec._Address_street(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Address_street(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "country":
- out.Values[i] = ec._Address_country(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Address_country(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2119,7 +2168,6 @@ var customerImplementors = []string{"Customer"}
func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, obj *Customer) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, customerImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2127,18 +2175,29 @@ func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("Customer")
case "id":
- out.Values[i] = ec._Customer_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Customer_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "name":
- out.Values[i] = ec._Customer_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Customer_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "address":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2146,10 +2205,16 @@ func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet,
}()
res = ec._Customer_address(ctx, field, obj)
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "orders":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2157,6 +2222,11 @@ func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet,
}()
res = ec._Customer_orders(ctx, field, obj)
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -2173,7 +2243,6 @@ var itemImplementors = []string{"Item"}
func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj *Item) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, itemImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2181,7 +2250,12 @@ func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("Item")
case "name":
- out.Values[i] = ec._Item_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Item_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2200,7 +2274,6 @@ var orderImplementors = []string{"Order"}
func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, obj *Order) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, orderImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2208,23 +2281,39 @@ func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, ob
case "__typename":
out.Values[i] = graphql.MarshalString("Order")
case "id":
- out.Values[i] = ec._Order_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Order_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "date":
- out.Values[i] = ec._Order_date(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Order_date(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "amount":
- out.Values[i] = ec._Order_amount(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Order_amount(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "items":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2232,6 +2321,11 @@ func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, ob
}()
res = ec._Order_items(ctx, field, obj)
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -2248,7 +2342,6 @@ var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Query",
})
@@ -2256,12 +2349,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Query")
case "customers":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2269,10 +2368,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_customers(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "torture1d":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2280,10 +2388,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_torture1d(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "torture2d":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2291,11 +2408,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_torture2d(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._Query___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._Query___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2311,7 +2446,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2319,19 +2453,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2350,7 +2514,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2358,19 +2521,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2386,7 +2569,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2394,29 +2576,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2432,7 +2644,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2440,19 +2651,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2468,7 +2699,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2476,21 +2706,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2509,7 +2764,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2517,26 +2771,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2578,18 +2877,18 @@ func (ec *executionContext) marshalNCustomer2ᚖgithubᚗcomᚋ99designsᚋgqlge
}
func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v interface{}) (float64, error) {
- res, err := graphql.UnmarshalFloat(v)
+ res, err := graphql.UnmarshalFloatContext(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler {
- res := graphql.MarshalFloat(v)
+ res := graphql.MarshalFloatContext(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
}
}
- return res
+ return graphql.WrapContextMarshaler(ctx, res)
}
func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) {
@@ -2695,6 +2994,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2768,6 +3074,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2817,6 +3130,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2858,6 +3178,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2899,7 +3226,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -2914,7 +3242,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) marshalOCustomer2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v [][]*Customer) graphql.Marshaler {
@@ -2954,6 +3283,7 @@ func (ec *executionContext) marshalOCustomer2ᚕᚕᚖgithubᚗcomᚋ99designs
}
wg.Wait()
+
return ret
}
@@ -2994,6 +3324,13 @@ func (ec *executionContext) marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3030,6 +3367,12 @@ func (ec *executionContext) marshalOInt2ᚕintᚄ(ctx context.Context, sel ast.S
ret[i] = ec.marshalNInt2int(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3106,6 +3449,13 @@ func (ec *executionContext) marshalOItem2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3146,6 +3496,13 @@ func (ec *executionContext) marshalOOrder2ᚕᚖgithubᚗcomᚋ99designsᚋgqlge
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3155,7 +3512,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
@@ -3170,7 +3528,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
@@ -3210,6 +3569,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3250,6 +3616,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3290,6 +3663,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3337,6 +3717,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/dataloader/server/server.go b/example/dataloader/server/server.go
index d599330ff90..a11d46a0fe5 100644
--- a/example/dataloader/server/server.go
+++ b/example/dataloader/server/server.go
@@ -7,12 +7,10 @@ import (
"github.com/99designs/gqlgen/example/dataloader"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/playground"
- "github.com/go-chi/chi"
)
func main() {
- router := chi.NewRouter()
- router.Use(dataloader.LoaderMiddleware)
+ router := http.NewServeMux()
router.Handle("/", playground.Handler("Dataloader", "/query"))
router.Handle("/query", handler.NewDefaultServer(
@@ -20,5 +18,5 @@ func main() {
))
log.Println("connect to http://localhost:8082/ for graphql playground")
- log.Fatal(http.ListenAndServe(":8082", router))
+ log.Fatal(http.ListenAndServe(":8082", dataloader.LoaderMiddleware(router)))
}
diff --git a/example/federation/accounts/graph/entity.resolvers.go b/example/federation/accounts/graph/entity.resolvers.go
index 79f530cc046..aa6cfb3a9da 100644
--- a/example/federation/accounts/graph/entity.resolvers.go
+++ b/example/federation/accounts/graph/entity.resolvers.go
@@ -10,6 +10,13 @@ import (
"github.com/99designs/gqlgen/example/federation/accounts/graph/model"
)
+func (r *entityResolver) FindEmailHostByID(ctx context.Context, id string) (*model.EmailHost, error) {
+ return &model.EmailHost{
+ ID: id,
+ Name: "Email Host " + id,
+ }, nil
+}
+
func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.User, error) {
name := "User " + id
if id == "1234" {
diff --git a/example/federation/accounts/graph/generated/federation.go b/example/federation/accounts/graph/generated/federation.go
index 6c574a8a863..1d7ee7ca52a 100644
--- a/example/federation/accounts/graph/generated/federation.go
+++ b/example/federation/accounts/graph/generated/federation.go
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"strings"
+ "sync"
"github.com/99designs/gqlgen/plugin/federation/fedruntime"
)
@@ -30,32 +31,82 @@ func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.
}, nil
}
-func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) ([]fedruntime.Entity, error) {
- list := []fedruntime.Entity{}
- for _, rep := range representations {
+func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity {
+ list := make([]fedruntime.Entity, len(representations))
+ resolveEntity := func(ctx context.Context, i int, rep map[string]interface{}) (err error) {
+ // we need to do our own panic handling, because we may be called in a
+ // goroutine, where the usual panic handling can't catch us
+ defer func() {
+ if r := recover(); r != nil {
+ err = ec.Recover(ctx, r)
+ }
+ }()
+
typeName, ok := rep["__typename"].(string)
if !ok {
- return nil, errors.New("__typename must be an existing string")
+ return errors.New("__typename must be an existing string")
}
switch typeName {
+ case "EmailHost":
+ id0, err := ec.unmarshalNString2string(ctx, rep["id"])
+ if err != nil {
+ return errors.New(fmt.Sprintf("Field %s undefined in schema.", "id"))
+ }
+
+ entity, err := ec.resolvers.Entity().FindEmailHostByID(ctx,
+ id0)
+ if err != nil {
+ return err
+ }
+
+ list[i] = entity
+ return nil
+
case "User":
id0, err := ec.unmarshalNID2string(ctx, rep["id"])
if err != nil {
- return nil, errors.New(fmt.Sprintf("Field %s undefined in schema.", "id"))
+ return errors.New(fmt.Sprintf("Field %s undefined in schema.", "id"))
}
entity, err := ec.resolvers.Entity().FindUserByID(ctx,
id0)
if err != nil {
- return nil, err
+ return err
}
- list = append(list, entity)
+ list[i] = entity
+ return nil
default:
- return nil, errors.New("unknown type: " + typeName)
+ return errors.New("unknown type: " + typeName)
+ }
+ }
+
+ // if there are multiple entities to resolve, parallelize (similar to
+ // graphql.FieldSet.Dispatch)
+ switch len(representations) {
+ case 0:
+ return list
+ case 1:
+ err := resolveEntity(ctx, 0, representations[0])
+ if err != nil {
+ ec.Error(ctx, err)
+ }
+ return list
+ default:
+ var g sync.WaitGroup
+ g.Add(len(representations))
+ for i, rep := range representations {
+ go func(i int, rep map[string]interface{}) {
+ err := resolveEntity(ctx, i, rep)
+ if err != nil {
+ ec.Error(ctx, err)
+ }
+ g.Done()
+ }(i, rep)
}
+ g.Wait()
+ return list
}
- return list, nil
}
diff --git a/example/federation/accounts/graph/generated/generated.go b/example/federation/accounts/graph/generated/generated.go
index ddc536f26b8..d1598942b42 100644
--- a/example/federation/accounts/graph/generated/generated.go
+++ b/example/federation/accounts/graph/generated/generated.go
@@ -45,8 +45,14 @@ type DirectiveRoot struct {
}
type ComplexityRoot struct {
+ EmailHost struct {
+ ID func(childComplexity int) int
+ Name func(childComplexity int) int
+ }
+
Entity struct {
- FindUserByID func(childComplexity int, id string) int
+ FindEmailHostByID func(childComplexity int, id string) int
+ FindUserByID func(childComplexity int, id string) int
}
Query struct {
@@ -56,16 +62,19 @@ type ComplexityRoot struct {
}
User struct {
+ Email func(childComplexity int) int
+ Host func(childComplexity int) int
ID func(childComplexity int) int
Username func(childComplexity int) int
}
- Service struct {
+ _Service struct {
SDL func(childComplexity int) int
}
}
type EntityResolver interface {
+ FindEmailHostByID(ctx context.Context, id string) (*model.EmailHost, error)
FindUserByID(ctx context.Context, id string) (*model.User, error)
}
type QueryResolver interface {
@@ -87,6 +96,32 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
_ = ec
switch typeName + "." + field {
+ case "EmailHost.id":
+ if e.complexity.EmailHost.ID == nil {
+ break
+ }
+
+ return e.complexity.EmailHost.ID(childComplexity), true
+
+ case "EmailHost.name":
+ if e.complexity.EmailHost.Name == nil {
+ break
+ }
+
+ return e.complexity.EmailHost.Name(childComplexity), true
+
+ case "Entity.findEmailHostByID":
+ if e.complexity.Entity.FindEmailHostByID == nil {
+ break
+ }
+
+ args, err := ec.field_Entity_findEmailHostByID_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Entity.FindEmailHostByID(childComplexity, args["id"].(string)), true
+
case "Entity.findUserByID":
if e.complexity.Entity.FindUserByID == nil {
break
@@ -125,6 +160,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]interface{})), true
+ case "User.email":
+ if e.complexity.User.Email == nil {
+ break
+ }
+
+ return e.complexity.User.Email(childComplexity), true
+
+ case "User.host":
+ if e.complexity.User.Host == nil {
+ break
+ }
+
+ return e.complexity.User.Host(childComplexity), true
+
case "User.id":
if e.complexity.User.ID == nil {
break
@@ -140,11 +189,11 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.User.Username(childComplexity), true
case "_Service.sdl":
- if e.complexity.Service.SDL == nil {
+ if e.complexity._Service.SDL == nil {
break
}
- return e.complexity.Service.SDL(childComplexity), true
+ return e.complexity._Service.SDL(childComplexity), true
}
return 0, false
@@ -200,8 +249,15 @@ var sources = []*ast.Source{
me: User
}
+type EmailHost @key(fields: "id") {
+ id: String!
+ name: String!
+}
+
type User @key(fields: "id") {
id: ID!
+ host: EmailHost!
+ email: String!
username: String!
}
`, BuiltIn: false},
@@ -212,16 +268,17 @@ scalar _FieldSet
directive @external on FIELD_DEFINITION
directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
-directive @key(fields: _FieldSet!) on OBJECT | INTERFACE
-directive @extends on OBJECT
+directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE
+directive @extends on OBJECT | INTERFACE
`, BuiltIn: true},
{Name: "federation/entity.graphql", Input: `
# a union of all types that use the @key directive
-union _Entity = User
+union _Entity = EmailHost | User
# fake type to build resolver interfaces for users to implement
type Entity {
- findUserByID(id: ID!,): User!
+ findEmailHostByID(id: String!,): EmailHost!
+ findUserByID(id: ID!,): User!
}
@@ -241,6 +298,21 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...)
// region ***************************** args.gotpl *****************************
+func (ec *executionContext) field_Entity_findEmailHostByID_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["id"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
+ arg0, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["id"] = arg0
+ return args, nil
+}
+
func (ec *executionContext) field_Entity_findUserByID_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
@@ -324,6 +396,118 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg
// region **************************** field.gotpl *****************************
+func (ec *executionContext) _EmailHost_id(ctx context.Context, field graphql.CollectedField, obj *model.EmailHost) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "EmailHost",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _EmailHost_name(ctx context.Context, field graphql.CollectedField, obj *model.EmailHost) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "EmailHost",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Name, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Entity_findEmailHostByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Entity",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Entity_findEmailHostByID_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Entity().FindEmailHostByID(rctx, args["id"].(string))
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*model.EmailHost)
+ fc.Result = res
+ return ec.marshalNEmailHost2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋaccountsᚋgraphᚋmodelᚐEmailHost(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -423,7 +607,7 @@ func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.__resolve_entities(ctx, args["representations"].([]map[string]interface{}))
+ return ec.__resolve_entities(ctx, args["representations"].([]map[string]interface{})), nil
})
if err != nil {
ec.Error(ctx, err)
@@ -581,6 +765,76 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte
return ec.marshalNID2string(ctx, field.Selections, res)
}
+func (ec *executionContext) _User_host(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "User",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Host, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*model.EmailHost)
+ fc.Result = res
+ return ec.marshalNEmailHost2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋaccountsᚋgraphᚋmodelᚐEmailHost(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "User",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Email, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -785,6 +1039,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1743,6 +2032,13 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet,
switch obj := (obj).(type) {
case nil:
return graphql.Null
+ case model.EmailHost:
+ return ec._EmailHost(ctx, sel, &obj)
+ case *model.EmailHost:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._EmailHost(ctx, sel, obj)
case model.User:
return ec._User(ctx, sel, &obj)
case *model.User:
@@ -1759,24 +2055,93 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet,
// region **************************** object.gotpl ****************************
-var entityImplementors = []string{"Entity"}
-
-func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
- fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors)
-
- ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
- Object: "Entity",
- })
+var emailHostImplementors = []string{"EmailHost", "_Entity"}
+func (ec *executionContext) _EmailHost(ctx context.Context, sel ast.SelectionSet, obj *model.EmailHost) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, emailHostImplementors)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
switch field.Name {
case "__typename":
- out.Values[i] = graphql.MarshalString("Entity")
- case "findUserByID":
- field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+ out.Values[i] = graphql.MarshalString("EmailHost")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmailHost_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "name":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmailHost_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var entityImplementors = []string{"Entity"}
+
+func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors)
+ ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
+ Object: "Entity",
+ })
+
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Entity")
+ case "findEmailHostByID":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Entity_findEmailHostByID(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ case "findUserByID":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1787,6 +2152,14 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -1803,7 +2176,6 @@ var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Query",
})
@@ -1811,12 +2183,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Query")
case "me":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1824,10 +2202,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_me(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "_entities":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1838,10 +2225,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "_service":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1852,11 +2248,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._Query___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._Query___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -1872,7 +2286,6 @@ var userImplementors = []string{"User", "_Entity"}
func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1880,12 +2293,42 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("User")
case "id":
- out.Values[i] = ec._User_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "host":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_host(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "email":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_email(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "username":
- out.Values[i] = ec._User_username(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_username(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -1904,7 +2347,6 @@ var _ServiceImplementors = []string{"_Service"}
func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, obj *fedruntime.Service) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, _ServiceImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1912,7 +2354,12 @@ func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("_Service")
case "sdl":
- out.Values[i] = ec.__Service_sdl(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.__Service_sdl(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -1928,7 +2375,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1936,19 +2382,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -1967,7 +2443,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1975,19 +2450,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2003,7 +2498,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2011,29 +2505,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2049,7 +2573,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2057,19 +2580,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2085,7 +2628,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2093,21 +2635,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2126,7 +2693,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2134,26 +2700,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2184,6 +2795,20 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se
return res
}
+func (ec *executionContext) marshalNEmailHost2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋaccountsᚋgraphᚋmodelᚐEmailHost(ctx context.Context, sel ast.SelectionSet, v model.EmailHost) graphql.Marshaler {
+ return ec._EmailHost(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNEmailHost2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋaccountsᚋgraphᚋmodelᚐEmailHost(ctx context.Context, sel ast.SelectionSet, v *model.EmailHost) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._EmailHost(ctx, sel, v)
+}
+
func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) {
res, err := graphql.UnmarshalID(v)
return res, graphql.ErrorOnPath(ctx, err)
@@ -2276,6 +2901,12 @@ func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.
ret[i] = ec.marshalN_Any2map(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2313,6 +2944,7 @@ func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
return ret
}
@@ -2373,6 +3005,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2446,6 +3085,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2495,6 +3141,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2536,6 +3189,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2570,7 +3230,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -2585,7 +3246,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) {
@@ -2594,7 +3256,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
@@ -2609,7 +3272,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler {
@@ -2663,6 +3327,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2703,6 +3374,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2743,6 +3421,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2790,6 +3475,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/federation/accounts/graph/model/model.go b/example/federation/accounts/graph/model/model.go
new file mode 100644
index 00000000000..8b537907051
--- /dev/null
+++ b/example/federation/accounts/graph/model/model.go
@@ -0,0 +1 @@
+package model
diff --git a/example/federation/accounts/graph/model/models_gen.go b/example/federation/accounts/graph/model/models_gen.go
index 67853e2ba3d..8ccceef61fd 100644
--- a/example/federation/accounts/graph/model/models_gen.go
+++ b/example/federation/accounts/graph/model/models_gen.go
@@ -2,9 +2,18 @@
package model
+type EmailHost struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+}
+
+func (EmailHost) IsEntity() {}
+
type User struct {
- ID string `json:"id"`
- Username string `json:"username"`
+ ID string `json:"id"`
+ Host *EmailHost `json:"host"`
+ Email string `json:"email"`
+ Username string `json:"username"`
}
func (User) IsEntity() {}
diff --git a/example/federation/accounts/graph/schema.graphqls b/example/federation/accounts/graph/schema.graphqls
index 29581a5d29a..01c7c2e11b7 100644
--- a/example/federation/accounts/graph/schema.graphqls
+++ b/example/federation/accounts/graph/schema.graphqls
@@ -2,7 +2,14 @@ extend type Query {
me: User
}
+type EmailHost @key(fields: "id") {
+ id: String!
+ name: String!
+}
+
type User @key(fields: "id") {
id: ID!
+ host: EmailHost!
+ email: String!
username: String!
}
diff --git a/example/federation/accounts/graph/schema.resolvers.go b/example/federation/accounts/graph/schema.resolvers.go
index 52184482275..266cc3b3b01 100644
--- a/example/federation/accounts/graph/schema.resolvers.go
+++ b/example/federation/accounts/graph/schema.resolvers.go
@@ -12,7 +12,12 @@ import (
func (r *queryResolver) Me(ctx context.Context) (*model.User, error) {
return &model.User{
- ID: "1234",
+ ID: "1234",
+ Host: &model.EmailHost{
+ ID: "4567",
+ Name: "Email Host 4567",
+ },
+ Email: "me@example.com",
Username: "Me",
}, nil
}
diff --git a/example/federation/integration-test.js b/example/federation/integration-test.js
index 17b8b5bd9bc..399177b919f 100644
--- a/example/federation/integration-test.js
+++ b/example/federation/integration-test.js
@@ -47,8 +47,8 @@ describe('Json', () => {
"body": "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.",
"product": {
"__typename": "Product",
- "name": "Trilby",
- "upc": "top-1"
+ "name": "Fedora",
+ "upc": "top-2"
}
}
]
diff --git a/example/federation/package.json b/example/federation/package.json
index bc79f98efcc..aa2093e8c62 100644
--- a/example/federation/package.json
+++ b/example/federation/package.json
@@ -9,9 +9,9 @@
"author": "",
"license": "ISC",
"dependencies": {
- "@apollo/gateway": "^0.11.7",
- "apollo-server": "^2.9.16",
- "graphql": "^14.6.0"
+ "@apollo/gateway": "^0.42.0",
+ "apollo-server": "^3.3.0",
+ "graphql": "^15.6.1"
},
"devDependencies": {
"apollo-cache-inmemory": "^1.6.5",
diff --git a/example/federation/products/graph/entity.resolvers.go b/example/federation/products/graph/entity.resolvers.go
index 54c94a7c002..1af00473615 100644
--- a/example/federation/products/graph/entity.resolvers.go
+++ b/example/federation/products/graph/entity.resolvers.go
@@ -10,10 +10,17 @@ import (
"github.com/99designs/gqlgen/example/federation/products/graph/model"
)
-func (r *entityResolver) FindProductByUpc(ctx context.Context, upc string) (*model.Product, error) {
- for _, h := range hats {
- if h.Upc == upc {
- return h, nil
+func (r *entityResolver) FindManufacturerByID(ctx context.Context, id string) (*model.Manufacturer, error) {
+ return &model.Manufacturer{
+ ID: id,
+ Name: "Millinery " + id,
+ }, nil
+}
+
+func (r *entityResolver) FindProductByManufacturerIDAndID(ctx context.Context, manufacturerID string, id string) (*model.Product, error) {
+ for _, hat := range hats {
+ if hat.ID == id && hat.Manufacturer.ID == manufacturerID {
+ return hat, nil
}
}
return nil, nil
diff --git a/example/federation/products/graph/generated/federation.go b/example/federation/products/graph/generated/federation.go
index 6db7e70cd84..410d467a82d 100644
--- a/example/federation/products/graph/generated/federation.go
+++ b/example/federation/products/graph/generated/federation.go
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"strings"
+ "sync"
"github.com/99designs/gqlgen/plugin/federation/fedruntime"
)
@@ -30,32 +31,86 @@ func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.
}, nil
}
-func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) ([]fedruntime.Entity, error) {
- list := []fedruntime.Entity{}
- for _, rep := range representations {
+func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity {
+ list := make([]fedruntime.Entity, len(representations))
+ resolveEntity := func(ctx context.Context, i int, rep map[string]interface{}) (err error) {
+ // we need to do our own panic handling, because we may be called in a
+ // goroutine, where the usual panic handling can't catch us
+ defer func() {
+ if r := recover(); r != nil {
+ err = ec.Recover(ctx, r)
+ }
+ }()
+
typeName, ok := rep["__typename"].(string)
if !ok {
- return nil, errors.New("__typename must be an existing string")
+ return errors.New("__typename must be an existing string")
}
switch typeName {
- case "Product":
- id0, err := ec.unmarshalNString2string(ctx, rep["upc"])
+ case "Manufacturer":
+ id0, err := ec.unmarshalNString2string(ctx, rep["id"])
if err != nil {
- return nil, errors.New(fmt.Sprintf("Field %s undefined in schema.", "upc"))
+ return errors.New(fmt.Sprintf("Field %s undefined in schema.", "id"))
}
- entity, err := ec.resolvers.Entity().FindProductByUpc(ctx,
+ entity, err := ec.resolvers.Entity().FindManufacturerByID(ctx,
id0)
if err != nil {
- return nil, err
+ return err
}
- list = append(list, entity)
+ list[i] = entity
+ return nil
+
+ case "Product":
+ id0, err := ec.unmarshalNString2string(ctx, rep["manufacturer"].(map[string]interface{})["id"])
+ if err != nil {
+ return errors.New(fmt.Sprintf("Field %s undefined in schema.", "manufacturerID"))
+ }
+ id1, err := ec.unmarshalNString2string(ctx, rep["id"])
+ if err != nil {
+ return errors.New(fmt.Sprintf("Field %s undefined in schema.", "id"))
+ }
+
+ entity, err := ec.resolvers.Entity().FindProductByManufacturerIDAndID(ctx,
+ id0, id1)
+ if err != nil {
+ return err
+ }
+
+ list[i] = entity
+ return nil
default:
- return nil, errors.New("unknown type: " + typeName)
+ return errors.New("unknown type: " + typeName)
+ }
+ }
+
+ // if there are multiple entities to resolve, parallelize (similar to
+ // graphql.FieldSet.Dispatch)
+ switch len(representations) {
+ case 0:
+ return list
+ case 1:
+ err := resolveEntity(ctx, 0, representations[0])
+ if err != nil {
+ ec.Error(ctx, err)
+ }
+ return list
+ default:
+ var g sync.WaitGroup
+ g.Add(len(representations))
+ for i, rep := range representations {
+ go func(i int, rep map[string]interface{}) {
+ err := resolveEntity(ctx, i, rep)
+ if err != nil {
+ ec.Error(ctx, err)
+ }
+ g.Done()
+ }(i, rep)
}
+ g.Wait()
+ return list
}
- return list, nil
}
diff --git a/example/federation/products/graph/generated/generated.go b/example/federation/products/graph/generated/generated.go
index 7a62335fdad..db9b6e3a572 100644
--- a/example/federation/products/graph/generated/generated.go
+++ b/example/federation/products/graph/generated/generated.go
@@ -46,13 +46,21 @@ type DirectiveRoot struct {
type ComplexityRoot struct {
Entity struct {
- FindProductByUpc func(childComplexity int, upc string) int
+ FindManufacturerByID func(childComplexity int, id string) int
+ FindProductByManufacturerIDAndID func(childComplexity int, manufacturerID string, id string) int
+ }
+
+ Manufacturer struct {
+ ID func(childComplexity int) int
+ Name func(childComplexity int) int
}
Product struct {
- Name func(childComplexity int) int
- Price func(childComplexity int) int
- Upc func(childComplexity int) int
+ ID func(childComplexity int) int
+ Manufacturer func(childComplexity int) int
+ Name func(childComplexity int) int
+ Price func(childComplexity int) int
+ Upc func(childComplexity int) int
}
Query struct {
@@ -61,13 +69,14 @@ type ComplexityRoot struct {
__resolve_entities func(childComplexity int, representations []map[string]interface{}) int
}
- Service struct {
+ _Service struct {
SDL func(childComplexity int) int
}
}
type EntityResolver interface {
- FindProductByUpc(ctx context.Context, upc string) (*model.Product, error)
+ FindManufacturerByID(ctx context.Context, id string) (*model.Manufacturer, error)
+ FindProductByManufacturerIDAndID(ctx context.Context, manufacturerID string, id string) (*model.Product, error)
}
type QueryResolver interface {
TopProducts(ctx context.Context, first *int) ([]*model.Product, error)
@@ -88,17 +97,57 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
_ = ec
switch typeName + "." + field {
- case "Entity.findProductByUpc":
- if e.complexity.Entity.FindProductByUpc == nil {
+ case "Entity.findManufacturerByID":
+ if e.complexity.Entity.FindManufacturerByID == nil {
+ break
+ }
+
+ args, err := ec.field_Entity_findManufacturerByID_args(context.TODO(), rawArgs)
+ if err != nil {
+ return 0, false
+ }
+
+ return e.complexity.Entity.FindManufacturerByID(childComplexity, args["id"].(string)), true
+
+ case "Entity.findProductByManufacturerIDAndID":
+ if e.complexity.Entity.FindProductByManufacturerIDAndID == nil {
break
}
- args, err := ec.field_Entity_findProductByUpc_args(context.TODO(), rawArgs)
+ args, err := ec.field_Entity_findProductByManufacturerIDAndID_args(context.TODO(), rawArgs)
if err != nil {
return 0, false
}
- return e.complexity.Entity.FindProductByUpc(childComplexity, args["upc"].(string)), true
+ return e.complexity.Entity.FindProductByManufacturerIDAndID(childComplexity, args["manufacturerID"].(string), args["id"].(string)), true
+
+ case "Manufacturer.id":
+ if e.complexity.Manufacturer.ID == nil {
+ break
+ }
+
+ return e.complexity.Manufacturer.ID(childComplexity), true
+
+ case "Manufacturer.name":
+ if e.complexity.Manufacturer.Name == nil {
+ break
+ }
+
+ return e.complexity.Manufacturer.Name(childComplexity), true
+
+ case "Product.id":
+ if e.complexity.Product.ID == nil {
+ break
+ }
+
+ return e.complexity.Product.ID(childComplexity), true
+
+ case "Product.manufacturer":
+ if e.complexity.Product.Manufacturer == nil {
+ break
+ }
+
+ return e.complexity.Product.Manufacturer(childComplexity), true
case "Product.name":
if e.complexity.Product.Name == nil {
@@ -153,11 +202,11 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]interface{})), true
case "_Service.sdl":
- if e.complexity.Service.SDL == nil {
+ if e.complexity._Service.SDL == nil {
break
}
- return e.complexity.Service.SDL(childComplexity), true
+ return e.complexity._Service.SDL(childComplexity), true
}
return 0, false
@@ -213,7 +262,14 @@ var sources = []*ast.Source{
topProducts(first: Int = 5): [Product]
}
-type Product @key(fields: "upc") {
+type Manufacturer @key(fields: "id") {
+ id: String!
+ name: String!
+}
+
+type Product @key(fields: "manufacturer { id } id") {
+ id: String!
+ manufacturer: Manufacturer!
upc: String!
name: String!
price: Int!
@@ -226,16 +282,17 @@ scalar _FieldSet
directive @external on FIELD_DEFINITION
directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
-directive @key(fields: _FieldSet!) on OBJECT | INTERFACE
-directive @extends on OBJECT
+directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE
+directive @extends on OBJECT | INTERFACE
`, BuiltIn: true},
{Name: "federation/entity.graphql", Input: `
# a union of all types that use the @key directive
-union _Entity = Product
+union _Entity = Manufacturer | Product
# fake type to build resolver interfaces for users to implement
type Entity {
- findProductByUpc(upc: String!,): Product!
+ findManufacturerByID(id: String!,): Manufacturer!
+ findProductByManufacturerIDAndID(manufacturerID: String!,id: String!,): Product!
}
@@ -255,18 +312,42 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...)
// region ***************************** args.gotpl *****************************
-func (ec *executionContext) field_Entity_findProductByUpc_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+func (ec *executionContext) field_Entity_findManufacturerByID_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+ var err error
+ args := map[string]interface{}{}
+ var arg0 string
+ if tmp, ok := rawArgs["id"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
+ arg0, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["id"] = arg0
+ return args, nil
+}
+
+func (ec *executionContext) field_Entity_findProductByManufacturerIDAndID_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 string
- if tmp, ok := rawArgs["upc"]; ok {
- ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upc"))
+ if tmp, ok := rawArgs["manufacturerID"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("manufacturerID"))
arg0, err = ec.unmarshalNString2string(ctx, tmp)
if err != nil {
return nil, err
}
}
- args["upc"] = arg0
+ args["manufacturerID"] = arg0
+ var arg1 string
+ if tmp, ok := rawArgs["id"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
+ arg1, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["id"] = arg1
return args, nil
}
@@ -353,7 +434,49 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg
// region **************************** field.gotpl *****************************
-func (ec *executionContext) _Entity_findProductByUpc(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _Entity_findManufacturerByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Entity",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_Entity_findManufacturerByID_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Entity().FindManufacturerByID(rctx, args["id"].(string))
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*model.Manufacturer)
+ fc.Result = res
+ return ec.marshalNManufacturer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋproductsᚋgraphᚋmodelᚐManufacturer(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Entity_findProductByManufacturerIDAndID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -370,7 +493,7 @@ func (ec *executionContext) _Entity_findProductByUpc(ctx context.Context, field
ctx = graphql.WithFieldContext(ctx, fc)
rawArgs := field.ArgumentMap(ec.Variables)
- args, err := ec.field_Entity_findProductByUpc_args(ctx, rawArgs)
+ args, err := ec.field_Entity_findProductByManufacturerIDAndID_args(ctx, rawArgs)
if err != nil {
ec.Error(ctx, err)
return graphql.Null
@@ -378,7 +501,7 @@ func (ec *executionContext) _Entity_findProductByUpc(ctx context.Context, field
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Entity().FindProductByUpc(rctx, args["upc"].(string))
+ return ec.resolvers.Entity().FindProductByManufacturerIDAndID(rctx, args["manufacturerID"].(string), args["id"].(string))
})
if err != nil {
ec.Error(ctx, err)
@@ -395,6 +518,146 @@ func (ec *executionContext) _Entity_findProductByUpc(ctx context.Context, field
return ec.marshalNProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx, field.Selections, res)
}
+func (ec *executionContext) _Manufacturer_id(ctx context.Context, field graphql.CollectedField, obj *model.Manufacturer) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Manufacturer",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Manufacturer_name(ctx context.Context, field graphql.CollectedField, obj *model.Manufacturer) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Manufacturer",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Name, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Product_id(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Product",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Product_manufacturer(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Product",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Manufacturer, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*model.Manufacturer)
+ fc.Result = res
+ return ec.marshalNManufacturer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋproductsᚋgraphᚋmodelᚐManufacturer(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _Product_upc(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -564,7 +827,7 @@ func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.__resolve_entities(ctx, args["representations"].([]map[string]interface{}))
+ return ec.__resolve_entities(ctx, args["representations"].([]map[string]interface{})), nil
})
if err != nil {
ec.Error(ctx, err)
@@ -856,6 +1119,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1814,6 +2112,13 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet,
switch obj := (obj).(type) {
case nil:
return graphql.Null
+ case model.Manufacturer:
+ return ec._Manufacturer(ctx, sel, &obj)
+ case *model.Manufacturer:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._Manufacturer(ctx, sel, obj)
case model.Product:
return ec._Product(ctx, sel, &obj)
case *model.Product:
@@ -1834,7 +2139,6 @@ var entityImplementors = []string{"Entity"}
func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Entity",
})
@@ -1842,26 +2146,104 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Entity")
- case "findProductByUpc":
+ case "findManufacturerByID":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
- res = ec._Entity_findProductByUpc(ctx, field)
+ res = ec._Entity_findManufacturerByID(ctx, field)
if res == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
- default:
- panic("unknown field " + strconv.Quote(field.Name))
- }
+ case "findProductByManufacturerIDAndID":
+ field := field
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Entity_findProductByManufacturerIDAndID(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
+ })
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var manufacturerImplementors = []string{"Manufacturer", "_Entity"}
+
+func (ec *executionContext) _Manufacturer(ctx context.Context, sel ast.SelectionSet, obj *model.Manufacturer) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, manufacturerImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Manufacturer")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Manufacturer_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "name":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Manufacturer_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
}
out.Dispatch()
if invalids > 0 {
@@ -1874,25 +2256,59 @@ var productImplementors = []string{"Product", "_Entity"}
func (ec *executionContext) _Product(ctx context.Context, sel ast.SelectionSet, obj *model.Product) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, productImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Product")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Product_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "manufacturer":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Product_manufacturer(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
case "upc":
- out.Values[i] = ec._Product_upc(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Product_upc(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec._Product_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Product_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "price":
- out.Values[i] = ec._Product_price(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Product_price(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -1911,7 +2327,6 @@ var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Query",
})
@@ -1919,12 +2334,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Query")
case "topProducts":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1932,10 +2353,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_topProducts(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "_entities":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1946,10 +2376,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "_service":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1960,11 +2399,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._Query___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._Query___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -1980,7 +2437,6 @@ var _ServiceImplementors = []string{"_Service"}
func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, obj *fedruntime.Service) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, _ServiceImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1988,7 +2444,12 @@ func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("_Service")
case "sdl":
- out.Values[i] = ec.__Service_sdl(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.__Service_sdl(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2004,7 +2465,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2012,19 +2472,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2043,7 +2533,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2051,19 +2540,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2079,7 +2588,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2087,29 +2595,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2125,7 +2663,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2133,19 +2670,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2161,7 +2718,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2169,21 +2725,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2202,7 +2783,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2210,26 +2790,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2275,6 +2900,20 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti
return res
}
+func (ec *executionContext) marshalNManufacturer2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋproductsᚋgraphᚋmodelᚐManufacturer(ctx context.Context, sel ast.SelectionSet, v model.Manufacturer) graphql.Marshaler {
+ return ec._Manufacturer(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNManufacturer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋproductsᚋgraphᚋmodelᚐManufacturer(ctx context.Context, sel ast.SelectionSet, v *model.Manufacturer) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._Manufacturer(ctx, sel, v)
+}
+
func (ec *executionContext) marshalNProduct2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v model.Product) graphql.Marshaler {
return ec._Product(ctx, sel, &v)
}
@@ -2352,6 +2991,12 @@ func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.
ret[i] = ec.marshalN_Any2map(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2389,6 +3034,7 @@ func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
return ret
}
@@ -2449,6 +3095,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2522,6 +3175,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2571,6 +3231,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2612,6 +3279,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2646,7 +3320,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -2661,7 +3336,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) {
@@ -2676,7 +3352,8 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele
if v == nil {
return graphql.Null
}
- return graphql.MarshalInt(*v)
+ res := graphql.MarshalInt(*v)
+ return res
}
func (ec *executionContext) marshalOProduct2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v []*model.Product) graphql.Marshaler {
@@ -2716,6 +3393,7 @@ func (ec *executionContext) marshalOProduct2ᚕᚖgithubᚗcomᚋ99designsᚋgql
}
wg.Wait()
+
return ret
}
@@ -2732,7 +3410,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
@@ -2747,7 +3426,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler {
@@ -2794,6 +3474,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2834,6 +3521,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2874,6 +3568,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2921,6 +3622,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/federation/products/graph/model/model.go b/example/federation/products/graph/model/model.go
new file mode 100644
index 00000000000..8b537907051
--- /dev/null
+++ b/example/federation/products/graph/model/model.go
@@ -0,0 +1 @@
+package model
diff --git a/example/federation/products/graph/model/models_gen.go b/example/federation/products/graph/model/models_gen.go
index c18b34dc211..3e86a4cc86e 100644
--- a/example/federation/products/graph/model/models_gen.go
+++ b/example/federation/products/graph/model/models_gen.go
@@ -2,10 +2,19 @@
package model
+type Manufacturer struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+}
+
+func (Manufacturer) IsEntity() {}
+
type Product struct {
- Upc string `json:"upc"`
- Name string `json:"name"`
- Price int `json:"price"`
+ ID string `json:"id"`
+ Manufacturer *Manufacturer `json:"manufacturer"`
+ Upc string `json:"upc"`
+ Name string `json:"name"`
+ Price int `json:"price"`
}
func (Product) IsEntity() {}
diff --git a/example/federation/products/graph/products.go b/example/federation/products/graph/products.go
index 7c23ba7fc03..ebfdf00a612 100644
--- a/example/federation/products/graph/products.go
+++ b/example/federation/products/graph/products.go
@@ -4,16 +4,31 @@ import "github.com/99designs/gqlgen/example/federation/products/graph/model"
var hats = []*model.Product{
{
+ ID: "111",
+ Manufacturer: &model.Manufacturer{
+ ID: "1234",
+ Name: "Millinery 1234",
+ },
Upc: "top-1",
Name: "Trilby",
Price: 11,
},
{
+ ID: "222",
+ Manufacturer: &model.Manufacturer{
+ ID: "2345",
+ Name: "Millinery 2345",
+ },
Upc: "top-2",
Name: "Fedora",
Price: 22,
},
{
+ ID: "333",
+ Manufacturer: &model.Manufacturer{
+ ID: "2345",
+ Name: "Millinery 2345",
+ },
Upc: "top-3",
Name: "Boater",
Price: 33,
diff --git a/example/federation/products/graph/schema.graphqls b/example/federation/products/graph/schema.graphqls
index 02ea017a700..7e55ac996eb 100644
--- a/example/federation/products/graph/schema.graphqls
+++ b/example/federation/products/graph/schema.graphqls
@@ -2,7 +2,14 @@ extend type Query {
topProducts(first: Int = 5): [Product]
}
-type Product @key(fields: "upc") {
+type Manufacturer @key(fields: "id") {
+ id: String!
+ name: String!
+}
+
+type Product @key(fields: "manufacturer { id } id") {
+ id: String!
+ manufacturer: Manufacturer!
upc: String!
name: String!
price: Int!
diff --git a/example/federation/reviews/graph/entity.resolvers.go b/example/federation/reviews/graph/entity.resolvers.go
index 37c280df920..5f447f2bea0 100644
--- a/example/federation/reviews/graph/entity.resolvers.go
+++ b/example/federation/reviews/graph/entity.resolvers.go
@@ -10,15 +10,27 @@ import (
"github.com/99designs/gqlgen/example/federation/reviews/graph/model"
)
-func (r *entityResolver) FindProductByUpc(ctx context.Context, upc string) (*model.Product, error) {
+func (r *entityResolver) FindProductByManufacturerIDAndID(ctx context.Context, manufacturerID string, id string) (*model.Product, error) {
+ var productReviews []*model.Review
+
+ for _, review := range reviews {
+ if review.Product.ID == id && review.Product.Manufacturer.ID == manufacturerID {
+ productReviews = append(productReviews, review)
+ }
+ }
return &model.Product{
- Upc: upc,
+ ID: id,
+ Manufacturer: &model.Manufacturer{
+ ID: manufacturerID,
+ },
+ Reviews: productReviews,
}, nil
}
func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.User, error) {
return &model.User{
- ID: id,
+ ID: id,
+ Host: &model.EmailHost{},
}, nil
}
diff --git a/example/federation/reviews/graph/generated/federation.go b/example/federation/reviews/graph/generated/federation.go
index 60a34909578..55391a46eae 100644
--- a/example/federation/reviews/graph/generated/federation.go
+++ b/example/federation/reviews/graph/generated/federation.go
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"strings"
+ "sync"
"github.com/99designs/gqlgen/plugin/federation/fedruntime"
)
@@ -30,46 +31,96 @@ func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.
}, nil
}
-func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) ([]fedruntime.Entity, error) {
- list := []fedruntime.Entity{}
- for _, rep := range representations {
+func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity {
+ list := make([]fedruntime.Entity, len(representations))
+ resolveEntity := func(ctx context.Context, i int, rep map[string]interface{}) (err error) {
+ // we need to do our own panic handling, because we may be called in a
+ // goroutine, where the usual panic handling can't catch us
+ defer func() {
+ if r := recover(); r != nil {
+ err = ec.Recover(ctx, r)
+ }
+ }()
+
typeName, ok := rep["__typename"].(string)
if !ok {
- return nil, errors.New("__typename must be an existing string")
+ return errors.New("__typename must be an existing string")
}
switch typeName {
case "Product":
- id0, err := ec.unmarshalNString2string(ctx, rep["upc"])
+ id0, err := ec.unmarshalNString2string(ctx, rep["manufacturer"].(map[string]interface{})["id"])
+ if err != nil {
+ return errors.New(fmt.Sprintf("Field %s undefined in schema.", "manufacturerID"))
+ }
+ id1, err := ec.unmarshalNString2string(ctx, rep["id"])
if err != nil {
- return nil, errors.New(fmt.Sprintf("Field %s undefined in schema.", "upc"))
+ return errors.New(fmt.Sprintf("Field %s undefined in schema.", "id"))
}
- entity, err := ec.resolvers.Entity().FindProductByUpc(ctx,
- id0)
+ entity, err := ec.resolvers.Entity().FindProductByManufacturerIDAndID(ctx,
+ id0, id1)
if err != nil {
- return nil, err
+ return err
}
- list = append(list, entity)
+ list[i] = entity
+ return nil
case "User":
id0, err := ec.unmarshalNID2string(ctx, rep["id"])
if err != nil {
- return nil, errors.New(fmt.Sprintf("Field %s undefined in schema.", "id"))
+ return errors.New(fmt.Sprintf("Field %s undefined in schema.", "id"))
}
entity, err := ec.resolvers.Entity().FindUserByID(ctx,
id0)
if err != nil {
- return nil, err
+ return err
}
- list = append(list, entity)
+ entity.Host.ID, err = ec.unmarshalNString2string(ctx, rep["hostID"])
+ if err != nil {
+ return err
+ }
+
+ entity.Email, err = ec.unmarshalNString2string(ctx, rep["email"])
+ if err != nil {
+ return err
+ }
+
+ list[i] = entity
+ return nil
default:
- return nil, errors.New("unknown type: " + typeName)
+ return errors.New("unknown type: " + typeName)
+ }
+ }
+
+ // if there are multiple entities to resolve, parallelize (similar to
+ // graphql.FieldSet.Dispatch)
+ switch len(representations) {
+ case 0:
+ return list
+ case 1:
+ err := resolveEntity(ctx, 0, representations[0])
+ if err != nil {
+ ec.Error(ctx, err)
+ }
+ return list
+ default:
+ var g sync.WaitGroup
+ g.Add(len(representations))
+ for i, rep := range representations {
+ go func(i int, rep map[string]interface{}) {
+ err := resolveEntity(ctx, i, rep)
+ if err != nil {
+ ec.Error(ctx, err)
+ }
+ g.Done()
+ }(i, rep)
}
+ g.Wait()
+ return list
}
- return list, nil
}
diff --git a/example/federation/reviews/graph/generated/generated.go b/example/federation/reviews/graph/generated/generated.go
index 8173a30dd32..ee3d560a206 100644
--- a/example/federation/reviews/graph/generated/generated.go
+++ b/example/federation/reviews/graph/generated/generated.go
@@ -38,7 +38,6 @@ type Config struct {
type ResolverRoot interface {
Entity() EntityResolver
- Product() ProductResolver
User() UserResolver
}
@@ -46,14 +45,23 @@ type DirectiveRoot struct {
}
type ComplexityRoot struct {
+ EmailHost struct {
+ ID func(childComplexity int) int
+ }
+
Entity struct {
- FindProductByUpc func(childComplexity int, upc string) int
- FindUserByID func(childComplexity int, id string) int
+ FindProductByManufacturerIDAndID func(childComplexity int, manufacturerID string, id string) int
+ FindUserByID func(childComplexity int, id string) int
+ }
+
+ Manufacturer struct {
+ ID func(childComplexity int) int
}
Product struct {
- Reviews func(childComplexity int) int
- Upc func(childComplexity int) int
+ ID func(childComplexity int) int
+ Manufacturer func(childComplexity int) int
+ Reviews func(childComplexity int) int
}
Query struct {
@@ -68,22 +76,21 @@ type ComplexityRoot struct {
}
User struct {
+ Email func(childComplexity int) int
+ Host func(childComplexity int) int
ID func(childComplexity int) int
Reviews func(childComplexity int) int
}
- Service struct {
+ _Service struct {
SDL func(childComplexity int) int
}
}
type EntityResolver interface {
- FindProductByUpc(ctx context.Context, upc string) (*model.Product, error)
+ FindProductByManufacturerIDAndID(ctx context.Context, manufacturerID string, id string) (*model.Product, error)
FindUserByID(ctx context.Context, id string) (*model.User, error)
}
-type ProductResolver interface {
- Reviews(ctx context.Context, obj *model.Product) ([]*model.Review, error)
-}
type UserResolver interface {
Reviews(ctx context.Context, obj *model.User) ([]*model.Review, error)
}
@@ -103,17 +110,24 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
_ = ec
switch typeName + "." + field {
- case "Entity.findProductByUpc":
- if e.complexity.Entity.FindProductByUpc == nil {
+ case "EmailHost.id":
+ if e.complexity.EmailHost.ID == nil {
+ break
+ }
+
+ return e.complexity.EmailHost.ID(childComplexity), true
+
+ case "Entity.findProductByManufacturerIDAndID":
+ if e.complexity.Entity.FindProductByManufacturerIDAndID == nil {
break
}
- args, err := ec.field_Entity_findProductByUpc_args(context.TODO(), rawArgs)
+ args, err := ec.field_Entity_findProductByManufacturerIDAndID_args(context.TODO(), rawArgs)
if err != nil {
return 0, false
}
- return e.complexity.Entity.FindProductByUpc(childComplexity, args["upc"].(string)), true
+ return e.complexity.Entity.FindProductByManufacturerIDAndID(childComplexity, args["manufacturerID"].(string), args["id"].(string)), true
case "Entity.findUserByID":
if e.complexity.Entity.FindUserByID == nil {
@@ -127,19 +141,33 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Entity.FindUserByID(childComplexity, args["id"].(string)), true
- case "Product.reviews":
- if e.complexity.Product.Reviews == nil {
+ case "Manufacturer.id":
+ if e.complexity.Manufacturer.ID == nil {
break
}
- return e.complexity.Product.Reviews(childComplexity), true
+ return e.complexity.Manufacturer.ID(childComplexity), true
+
+ case "Product.id":
+ if e.complexity.Product.ID == nil {
+ break
+ }
- case "Product.upc":
- if e.complexity.Product.Upc == nil {
+ return e.complexity.Product.ID(childComplexity), true
+
+ case "Product.manufacturer":
+ if e.complexity.Product.Manufacturer == nil {
+ break
+ }
+
+ return e.complexity.Product.Manufacturer(childComplexity), true
+
+ case "Product.reviews":
+ if e.complexity.Product.Reviews == nil {
break
}
- return e.complexity.Product.Upc(childComplexity), true
+ return e.complexity.Product.Reviews(childComplexity), true
case "Query._service":
if e.complexity.Query.__resolve__service == nil {
@@ -181,6 +209,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Review.Product(childComplexity), true
+ case "User.email":
+ if e.complexity.User.Email == nil {
+ break
+ }
+
+ return e.complexity.User.Email(childComplexity), true
+
+ case "User.host":
+ if e.complexity.User.Host == nil {
+ break
+ }
+
+ return e.complexity.User.Host(childComplexity), true
+
case "User.id":
if e.complexity.User.ID == nil {
break
@@ -196,11 +238,11 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.User.Reviews(childComplexity), true
case "_Service.sdl":
- if e.complexity.Service.SDL == nil {
+ if e.complexity._Service.SDL == nil {
break
}
- return e.complexity.Service.SDL(childComplexity), true
+ return e.complexity._Service.SDL(childComplexity), true
}
return 0, false
@@ -258,13 +300,24 @@ var sources = []*ast.Source{
product: Product!
}
+extend type EmailHost @key(fields: "id") {
+ id: String! @external
+}
+
extend type User @key(fields: "id") {
id: ID! @external
- reviews: [Review]
+ host: EmailHost! @external
+ email: String! @external
+ reviews: [Review] @requires(fields: "host {id} email")
+}
+
+extend type Manufacturer @key(fields: "id") {
+ id: String! @external
}
-extend type Product @key(fields: "upc") {
- upc: String! @external
+extend type Product @key(fields: " manufacturer{ id} id") {
+ id: String! @external
+ manufacturer: Manufacturer! @external
reviews: [Review]
}
`, BuiltIn: false},
@@ -275,16 +328,16 @@ scalar _FieldSet
directive @external on FIELD_DEFINITION
directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
-directive @key(fields: _FieldSet!) on OBJECT | INTERFACE
-directive @extends on OBJECT
+directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE
+directive @extends on OBJECT | INTERFACE
`, BuiltIn: true},
{Name: "federation/entity.graphql", Input: `
# a union of all types that use the @key directive
-union _Entity = Product | User
+union _Entity = EmailHost | Manufacturer | Product | User
# fake type to build resolver interfaces for users to implement
type Entity {
- findProductByUpc(upc: String!,): Product!
+ findProductByManufacturerIDAndID(manufacturerID: String!,id: String!,): Product!
findUserByID(id: ID!,): User!
}
@@ -305,18 +358,27 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...)
// region ***************************** args.gotpl *****************************
-func (ec *executionContext) field_Entity_findProductByUpc_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
+func (ec *executionContext) field_Entity_findProductByManufacturerIDAndID_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 string
- if tmp, ok := rawArgs["upc"]; ok {
- ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upc"))
+ if tmp, ok := rawArgs["manufacturerID"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("manufacturerID"))
arg0, err = ec.unmarshalNString2string(ctx, tmp)
if err != nil {
return nil, err
}
}
- args["upc"] = arg0
+ args["manufacturerID"] = arg0
+ var arg1 string
+ if tmp, ok := rawArgs["id"]; ok {
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
+ arg1, err = ec.unmarshalNString2string(ctx, tmp)
+ if err != nil {
+ return nil, err
+ }
+ }
+ args["id"] = arg1
return args, nil
}
@@ -403,7 +465,42 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg
// region **************************** field.gotpl *****************************
-func (ec *executionContext) _Entity_findProductByUpc(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+func (ec *executionContext) _EmailHost_id(ctx context.Context, field graphql.CollectedField, obj *model.EmailHost) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "EmailHost",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Entity_findProductByManufacturerIDAndID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -420,7 +517,7 @@ func (ec *executionContext) _Entity_findProductByUpc(ctx context.Context, field
ctx = graphql.WithFieldContext(ctx, fc)
rawArgs := field.ArgumentMap(ec.Variables)
- args, err := ec.field_Entity_findProductByUpc_args(ctx, rawArgs)
+ args, err := ec.field_Entity_findProductByManufacturerIDAndID_args(ctx, rawArgs)
if err != nil {
ec.Error(ctx, err)
return graphql.Null
@@ -428,7 +525,7 @@ func (ec *executionContext) _Entity_findProductByUpc(ctx context.Context, field
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Entity().FindProductByUpc(rctx, args["upc"].(string))
+ return ec.resolvers.Entity().FindProductByManufacturerIDAndID(rctx, args["manufacturerID"].(string), args["id"].(string))
})
if err != nil {
ec.Error(ctx, err)
@@ -487,7 +584,42 @@ func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field grap
return ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋreviewsᚋgraphᚋmodelᚐUser(ctx, field.Selections, res)
}
-func (ec *executionContext) _Product_upc(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) {
+func (ec *executionContext) _Manufacturer_id(ctx context.Context, field graphql.CollectedField, obj *model.Manufacturer) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Manufacturer",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ID, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Product_id(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -505,7 +637,7 @@ func (ec *executionContext) _Product_upc(ctx context.Context, field graphql.Coll
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return obj.Upc, nil
+ return obj.ID, nil
})
if err != nil {
ec.Error(ctx, err)
@@ -522,6 +654,41 @@ func (ec *executionContext) _Product_upc(ctx context.Context, field graphql.Coll
return ec.marshalNString2string(ctx, field.Selections, res)
}
+func (ec *executionContext) _Product_manufacturer(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Product",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Manufacturer, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*model.Manufacturer)
+ fc.Result = res
+ return ec.marshalNManufacturer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋreviewsᚋgraphᚋmodelᚐManufacturer(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _Product_reviews(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -533,14 +700,14 @@ func (ec *executionContext) _Product_reviews(ctx context.Context, field graphql.
Object: "Product",
Field: field,
Args: nil,
- IsMethod: true,
- IsResolver: true,
+ IsMethod: false,
+ IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Product().Reviews(rctx, obj)
+ return obj.Reviews, nil
})
if err != nil {
ec.Error(ctx, err)
@@ -579,7 +746,7 @@ func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.__resolve_entities(ctx, args["representations"].([]map[string]interface{}))
+ return ec.__resolve_entities(ctx, args["representations"].([]map[string]interface{})), nil
})
if err != nil {
ec.Error(ctx, err)
@@ -842,6 +1009,76 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte
return ec.marshalNID2string(ctx, field.Selections, res)
}
+func (ec *executionContext) _User_host(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "User",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Host, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*model.EmailHost)
+ fc.Result = res
+ return ec.marshalNEmailHost2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋreviewsᚋgraphᚋmodelᚐEmailHost(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "User",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.Email, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _User_reviews(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1043,6 +1280,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -2001,6 +2273,20 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet,
switch obj := (obj).(type) {
case nil:
return graphql.Null
+ case model.EmailHost:
+ return ec._EmailHost(ctx, sel, &obj)
+ case *model.EmailHost:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._EmailHost(ctx, sel, obj)
+ case model.Manufacturer:
+ return ec._Manufacturer(ctx, sel, &obj)
+ case *model.Manufacturer:
+ if obj == nil {
+ return graphql.Null
+ }
+ return ec._Manufacturer(ctx, sel, obj)
case model.Product:
return ec._Product(ctx, sel, &obj)
case *model.Product:
@@ -2024,38 +2310,83 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet,
// region **************************** object.gotpl ****************************
-var entityImplementors = []string{"Entity"}
-
-func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
- fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors)
-
- ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
- Object: "Entity",
- })
+var emailHostImplementors = []string{"EmailHost", "_Entity"}
+func (ec *executionContext) _EmailHost(ctx context.Context, sel ast.SelectionSet, obj *model.EmailHost) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, emailHostImplementors)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("EmailHost")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._EmailHost_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var entityImplementors = []string{"Entity"}
+
+func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors)
+ ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
+ Object: "Entity",
+ })
+
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Entity")
- case "findProductByUpc":
+ case "findProductByManufacturerIDAndID":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
- res = ec._Entity_findProductByUpc(ctx, field)
+ res = ec._Entity_findProductByManufacturerIDAndID(ctx, field)
if res == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "findUserByID":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2066,6 +2397,14 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -2078,33 +2417,74 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g
return out
}
+var manufacturerImplementors = []string{"Manufacturer", "_Entity"}
+
+func (ec *executionContext) _Manufacturer(ctx context.Context, sel ast.SelectionSet, obj *model.Manufacturer) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, manufacturerImplementors)
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("Manufacturer")
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Manufacturer_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
var productImplementors = []string{"Product", "_Entity"}
func (ec *executionContext) _Product(ctx context.Context, sel ast.SelectionSet, obj *model.Product) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, productImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Product")
- case "upc":
- out.Values[i] = ec._Product_upc(ctx, field, obj)
+ case "id":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Product_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
- atomic.AddUint32(&invalids, 1)
+ invalids++
+ }
+ case "manufacturer":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Product_manufacturer(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
}
case "reviews":
- field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
- defer func() {
- if r := recover(); r != nil {
- ec.Error(ctx, ec.Recover(ctx, r))
- }
- }()
- res = ec._Product_reviews(ctx, field, obj)
- return res
- })
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Product_reviews(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2120,7 +2500,6 @@ var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Query",
})
@@ -2128,12 +2507,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Query")
case "_entities":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2144,10 +2529,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "_service":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2158,11 +2552,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._Query___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._Query___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2178,7 +2590,6 @@ var reviewImplementors = []string{"Review"}
func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *model.Review) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, reviewImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2186,17 +2597,32 @@ func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("Review")
case "body":
- out.Values[i] = ec._Review_body(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Review_body(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "author":
- out.Values[i] = ec._Review_author(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Review_author(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "product":
- out.Values[i] = ec._Review_product(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Review_product(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2215,7 +2641,6 @@ var userImplementors = []string{"User", "_Entity"}
func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2223,13 +2648,39 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("User")
case "id":
- out.Values[i] = ec._User_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ case "host":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_host(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ case "email":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_email(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "reviews":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2237,6 +2688,11 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
}()
res = ec._User_reviews(ctx, field, obj)
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -2253,7 +2709,6 @@ var _ServiceImplementors = []string{"_Service"}
func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, obj *fedruntime.Service) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, _ServiceImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2261,7 +2716,12 @@ func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("_Service")
case "sdl":
- out.Values[i] = ec.__Service_sdl(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.__Service_sdl(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2277,7 +2737,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2285,19 +2744,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2316,7 +2805,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2324,19 +2812,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2352,7 +2860,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2360,29 +2867,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2398,7 +2935,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2406,19 +2942,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2434,7 +2990,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2442,21 +2997,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2475,7 +3055,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2483,26 +3062,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2533,6 +3157,16 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se
return res
}
+func (ec *executionContext) marshalNEmailHost2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋreviewsᚋgraphᚋmodelᚐEmailHost(ctx context.Context, sel ast.SelectionSet, v *model.EmailHost) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._EmailHost(ctx, sel, v)
+}
+
func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) {
res, err := graphql.UnmarshalID(v)
return res, graphql.ErrorOnPath(ctx, err)
@@ -2548,6 +3182,16 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec
return res
}
+func (ec *executionContext) marshalNManufacturer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋreviewsᚋgraphᚋmodelᚐManufacturer(ctx context.Context, sel ast.SelectionSet, v *model.Manufacturer) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._Manufacturer(ctx, sel, v)
+}
+
func (ec *executionContext) marshalNProduct2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋreviewsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v model.Product) graphql.Marshaler {
return ec._Product(ctx, sel, &v)
}
@@ -2639,6 +3283,12 @@ func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.
ret[i] = ec.marshalN_Any2map(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2676,6 +3326,7 @@ func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
return ret
}
@@ -2736,6 +3387,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2809,6 +3467,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2858,6 +3523,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2899,6 +3571,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2933,7 +3612,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -2948,7 +3628,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) marshalOReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx context.Context, sel ast.SelectionSet, v []*model.Review) graphql.Marshaler {
@@ -2988,6 +3669,7 @@ func (ec *executionContext) marshalOReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg
}
wg.Wait()
+
return ret
}
@@ -3004,7 +3686,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
@@ -3019,7 +3702,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler {
@@ -3066,6 +3750,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3106,6 +3797,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3146,6 +3844,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3193,6 +3898,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/federation/reviews/graph/model/models.go b/example/federation/reviews/graph/model/models.go
index 51394035234..af4eb24755a 100644
--- a/example/federation/reviews/graph/model/models.go
+++ b/example/federation/reviews/graph/model/models.go
@@ -1,7 +1,9 @@
package model
type Product struct {
- Upc string `json:"upc"`
+ ID string `json:"id"`
+ Manufacturer *Manufacturer `json:"manufacturer"`
+ Reviews []*Review `json:"reviews"`
}
func (Product) IsEntity() {}
@@ -13,7 +15,10 @@ type Review struct {
}
type User struct {
- ID string `json:"id"`
+ ID string `json:"id"`
+ Host *EmailHost `json:"host"`
+ Email string `json:"email"`
+ // Reviews []*Review `json:"reviews"`
}
func (User) IsEntity() {}
diff --git a/example/federation/reviews/graph/model/models_gen.go b/example/federation/reviews/graph/model/models_gen.go
index 8e0d251dce1..5cd133b3330 100644
--- a/example/federation/reviews/graph/model/models_gen.go
+++ b/example/federation/reviews/graph/model/models_gen.go
@@ -1,3 +1,15 @@
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package model
+
+type EmailHost struct {
+ ID string `json:"id"`
+}
+
+func (EmailHost) IsEntity() {}
+
+type Manufacturer struct {
+ ID string `json:"id"`
+}
+
+func (Manufacturer) IsEntity() {}
diff --git a/example/federation/reviews/graph/reviews.go b/example/federation/reviews/graph/reviews.go
index c30a84fe319..922ed1446f2 100644
--- a/example/federation/reviews/graph/reviews.go
+++ b/example/federation/reviews/graph/reviews.go
@@ -5,17 +5,17 @@ import "github.com/99designs/gqlgen/example/federation/reviews/graph/model"
var reviews = []*model.Review{
{
Body: "A highly effective form of birth control.",
- Product: &model.Product{Upc: "top-1"},
+ Product: &model.Product{ID: "111", Manufacturer: &model.Manufacturer{ID: "1234"}},
Author: &model.User{ID: "1234"},
},
{
Body: "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.",
- Product: &model.Product{Upc: "top-1"},
+ Product: &model.Product{ID: "222", Manufacturer: &model.Manufacturer{ID: "2345"}},
Author: &model.User{ID: "1234"},
},
{
Body: "This is the last straw. Hat you will wear. 11/10",
- Product: &model.Product{Upc: "top-1"},
+ Product: &model.Product{ID: "333", Manufacturer: &model.Manufacturer{ID: "2345"}},
Author: &model.User{ID: "7777"},
},
}
diff --git a/example/federation/reviews/graph/schema.graphqls b/example/federation/reviews/graph/schema.graphqls
index 72cfcf3a3c8..fde407128ed 100644
--- a/example/federation/reviews/graph/schema.graphqls
+++ b/example/federation/reviews/graph/schema.graphqls
@@ -4,12 +4,23 @@ type Review {
product: Product!
}
+extend type EmailHost @key(fields: "id") {
+ id: String! @external
+}
+
extend type User @key(fields: "id") {
id: ID! @external
- reviews: [Review]
+ host: EmailHost! @external
+ email: String! @external
+ reviews: [Review] @requires(fields: "host {id} email")
+}
+
+extend type Manufacturer @key(fields: "id") {
+ id: String! @external
}
-extend type Product @key(fields: "upc") {
- upc: String! @external
+extend type Product @key(fields: " manufacturer{ id} id") {
+ id: String! @external
+ manufacturer: Manufacturer! @external
reviews: [Review]
}
diff --git a/example/federation/reviews/graph/schema.resolvers.go b/example/federation/reviews/graph/schema.resolvers.go
index 572a6be6e8d..5876306ecb5 100644
--- a/example/federation/reviews/graph/schema.resolvers.go
+++ b/example/federation/reviews/graph/schema.resolvers.go
@@ -10,35 +10,17 @@ import (
"github.com/99designs/gqlgen/example/federation/reviews/graph/model"
)
-func (r *productResolver) Reviews(ctx context.Context, obj *model.Product) ([]*model.Review, error) {
- var res []*model.Review
-
- for _, review := range reviews {
- if review.Product.Upc == obj.Upc {
- res = append(res, review)
- }
- }
-
- return res, nil
-}
-
func (r *userResolver) Reviews(ctx context.Context, obj *model.User) ([]*model.Review, error) {
- var res []*model.Review
-
+ var productReviews []*model.Review
for _, review := range reviews {
if review.Author.ID == obj.ID {
- res = append(res, review)
+ productReviews = append(productReviews, review)
}
}
-
- return res, nil
+ return productReviews, nil
}
-// Product returns generated.ProductResolver implementation.
-func (r *Resolver) Product() generated.ProductResolver { return &productResolver{r} }
-
// User returns generated.UserResolver implementation.
func (r *Resolver) User() generated.UserResolver { return &userResolver{r} }
-type productResolver struct{ *Resolver }
type userResolver struct{ *Resolver }
diff --git a/example/fileupload/fileupload_test.go b/example/fileupload/fileupload_test.go
index 8d68252e009..0973e56ed97 100644
--- a/example/fileupload/fileupload_test.go
+++ b/example/fileupload/fileupload_test.go
@@ -2,17 +2,14 @@
package fileupload
import (
- "bytes"
"context"
- "fmt"
"io"
"io/ioutil"
- "mime/multipart"
- "net/http"
"net/http/httptest"
- "net/textproto"
+ "os"
"testing"
+ gqlclient "github.com/99designs/gqlgen/client"
"github.com/99designs/gqlgen/example/fileupload/model"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler"
@@ -21,10 +18,23 @@ import (
)
func TestFileUpload(t *testing.T) {
- client := http.Client{}
+ resolver := &Stub{}
+ srv := httptest.NewServer(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolver})))
+ defer srv.Close()
+ gql := gqlclient.New(srv.Config.Handler, gqlclient.Path("/graphql"))
+
+ aTxtFile, _ := ioutil.TempFile(os.TempDir(), "a.txt")
+ defer os.Remove(aTxtFile.Name())
+ aTxtFile.WriteString(`test`)
+
+ a1TxtFile, _ := ioutil.TempFile(os.TempDir(), "a.txt")
+ b1TxtFile, _ := ioutil.TempFile(os.TempDir(), "b.txt")
+ defer os.Remove(a1TxtFile.Name())
+ defer os.Remove(b1TxtFile.Name())
+ a1TxtFile.WriteString(`test1`)
+ b1TxtFile.WriteString(`test2`)
t.Run("valid single file upload", func(t *testing.T) {
- resolver := &Stub{}
resolver.MutationResolver.SingleUpload = func(ctx context.Context, file graphql.Upload) (*model.File, error) {
require.NotNil(t, file)
require.NotNil(t, file.File)
@@ -39,34 +49,28 @@ func TestFileUpload(t *testing.T) {
ContentType: file.ContentType,
}, nil
}
- srv := httptest.NewServer(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolver})))
- defer srv.Close()
- operations := `{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id, name, content, contentType } }", "variables": { "file": null } }`
- mapData := `{ "0": ["variables.file"] }`
- files := []file{
- {
- mapKey: "0",
- name: "a.txt",
- content: "test",
- contentType: "text/plain",
- },
+ mutation := `mutation ($file: Upload!) {
+ singleUpload(file: $file) {
+ id
+ name
+ content
+ contentType
+ }
+ }`
+ var result struct {
+ SingleUpload *model.File
}
- req := createUploadRequest(t, srv.URL, operations, mapData, files)
- resp, err := client.Do(req)
- require.Nil(t, err)
- require.Equal(t, http.StatusOK, resp.StatusCode)
- responseBody, err := ioutil.ReadAll(resp.Body)
- require.Nil(t, err)
- responseString := string(responseBody)
- require.Equal(t, `{"data":{"singleUpload":{"id":1,"name":"a.txt","content":"test","contentType":"text/plain"}}}`, responseString)
- err = resp.Body.Close()
+ err := gql.Post(mutation, &result, gqlclient.Var("file", aTxtFile), gqlclient.WithFiles())
require.Nil(t, err)
+ require.Equal(t, 1, result.SingleUpload.ID)
+ require.Contains(t, result.SingleUpload.Name, "a.txt")
+ require.Equal(t, "test", result.SingleUpload.Content)
+ require.Equal(t, "text/plain; charset=utf-8", result.SingleUpload.ContentType)
})
t.Run("valid single file upload with payload", func(t *testing.T) {
- resolver := &Stub{}
resolver.MutationResolver.SingleUploadWithPayload = func(ctx context.Context, req model.UploadFile) (*model.File, error) {
require.Equal(t, req.ID, 1)
require.NotNil(t, req.File)
@@ -82,33 +86,28 @@ func TestFileUpload(t *testing.T) {
ContentType: req.File.ContentType,
}, nil
}
- srv := httptest.NewServer(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolver})))
- defer srv.Close()
- operations := `{ "query": "mutation ($req: UploadFile!) { singleUploadWithPayload(req: $req) { id, name, content, contentType } }", "variables": { "req": {"file": null, "id": 1 } } }`
- mapData := `{ "0": ["variables.req.file"] }`
- files := []file{
- {
- mapKey: "0",
- name: "a.txt",
- content: "test",
- contentType: "text/plain",
- },
+ mutation := `mutation ($req: UploadFile!) {
+ singleUploadWithPayload(req: $req) {
+ id
+ name
+ content
+ contentType
+ }
+ }`
+ var result struct {
+ SingleUploadWithPayload *model.File
}
- req := createUploadRequest(t, srv.URL, operations, mapData, files)
- resp, err := client.Do(req)
- require.Nil(t, err)
- require.Equal(t, http.StatusOK, resp.StatusCode)
- responseBody, err := ioutil.ReadAll(resp.Body)
- require.Nil(t, err)
- require.Equal(t, `{"data":{"singleUploadWithPayload":{"id":1,"name":"a.txt","content":"test","contentType":"text/plain"}}}`, string(responseBody))
- err = resp.Body.Close()
+ err := gql.Post(mutation, &result, gqlclient.Var("req", map[string]interface{}{"id": 1, "file": aTxtFile}), gqlclient.WithFiles())
require.Nil(t, err)
+ require.Equal(t, 1, result.SingleUploadWithPayload.ID)
+ require.Contains(t, result.SingleUploadWithPayload.Name, "a.txt")
+ require.Equal(t, "test", result.SingleUploadWithPayload.Content)
+ require.Equal(t, "text/plain; charset=utf-8", result.SingleUploadWithPayload.ContentType)
})
t.Run("valid file list upload", func(t *testing.T) {
- resolver := &Stub{}
resolver.MutationResolver.MultipleUpload = func(ctx context.Context, files []*graphql.Upload) ([]*model.File, error) {
require.Len(t, files, 2)
var contents []string
@@ -128,39 +127,35 @@ func TestFileUpload(t *testing.T) {
require.ElementsMatch(t, []string{"test1", "test2"}, contents)
return resp, nil
}
- srv := httptest.NewServer(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolver})))
- defer srv.Close()
- operations := `{ "query": "mutation($files: [Upload!]!) { multipleUpload(files: $files) { id, name, content, contentType } }", "variables": { "files": [null, null] } }`
- mapData := `{ "0": ["variables.files.0"], "1": ["variables.files.1"] }`
- files := []file{
- {
- mapKey: "0",
- name: "a.txt",
- content: "test1",
- contentType: "text/plain",
- },
- {
- mapKey: "1",
- name: "b.txt",
- content: "test2",
- contentType: "text/plain",
- },
+ mutation := `mutation($files: [Upload!]!) {
+ multipleUpload(files: $files) {
+ id
+ name
+ content
+ contentType
+ }
+ }`
+ var result struct {
+ MultipleUpload []*model.File
}
- req := createUploadRequest(t, srv.URL, operations, mapData, files)
- resp, err := client.Do(req)
- require.Nil(t, err)
- require.Equal(t, http.StatusOK, resp.StatusCode)
- responseBody, err := ioutil.ReadAll(resp.Body)
- require.Nil(t, err)
- require.Equal(t, `{"data":{"multipleUpload":[{"id":1,"name":"a.txt","content":"test1","contentType":"text/plain"},{"id":2,"name":"b.txt","content":"test2","contentType":"text/plain"}]}}`, string(responseBody))
- err = resp.Body.Close()
+ err := gql.Post(mutation, &result, gqlclient.Var("files", []*os.File{a1TxtFile, b1TxtFile}), gqlclient.WithFiles())
require.Nil(t, err)
+ require.Equal(t, 1, result.MultipleUpload[0].ID)
+ require.Equal(t, 2, result.MultipleUpload[1].ID)
+ for _, mu := range result.MultipleUpload {
+ if mu.Name == "a.txt" {
+ require.Equal(t, "test1", mu.Content)
+ }
+ if mu.Name == "b.txt" {
+ require.Equal(t, "test2", mu.Content)
+ }
+ require.Equal(t, "text/plain; charset=utf-8", mu.ContentType)
+ }
})
t.Run("valid file list upload with payload", func(t *testing.T) {
- resolver := &Stub{}
resolver.MutationResolver.MultipleUploadWithPayload = func(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) {
require.Len(t, req, 2)
var ids []int
@@ -184,35 +179,35 @@ func TestFileUpload(t *testing.T) {
require.ElementsMatch(t, []string{"test1", "test2"}, contents)
return resp, nil
}
- srv := httptest.NewServer(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolver})))
- defer srv.Close()
- operations := `{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id, name, content, contentType } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }`
- mapData := `{ "0": ["variables.req.0.file"], "1": ["variables.req.1.file"] }`
- files := []file{
- {
- mapKey: "0",
- name: "a.txt",
- content: "test1",
- contentType: "text/plain",
- },
- {
- mapKey: "1",
- name: "b.txt",
- content: "test2",
- contentType: "text/plain",
- },
+ mutation := `mutation($req: [UploadFile!]!) {
+ multipleUploadWithPayload(req: $req) {
+ id
+ name
+ content
+ contentType
+ }
+ }`
+ var result struct {
+ MultipleUploadWithPayload []*model.File
}
- req := createUploadRequest(t, srv.URL, operations, mapData, files)
- resp, err := client.Do(req)
- require.Nil(t, err)
- require.Equal(t, http.StatusOK, resp.StatusCode)
- responseBody, err := ioutil.ReadAll(resp.Body)
- require.Nil(t, err)
- require.Equal(t, `{"data":{"multipleUploadWithPayload":[{"id":1,"name":"a.txt","content":"test1","contentType":"text/plain"},{"id":2,"name":"b.txt","content":"test2","contentType":"text/plain"}]}}`, string(responseBody))
- err = resp.Body.Close()
+ err := gql.Post(mutation, &result, gqlclient.Var("req", []map[string]interface{}{
+ {"id": 1, "file": a1TxtFile},
+ {"id": 2, "file": b1TxtFile},
+ }), gqlclient.WithFiles())
require.Nil(t, err)
+ require.Equal(t, 1, result.MultipleUploadWithPayload[0].ID)
+ require.Equal(t, 2, result.MultipleUploadWithPayload[1].ID)
+ for _, mu := range result.MultipleUploadWithPayload {
+ if mu.Name == "a.txt" {
+ require.Equal(t, "test1", mu.Content)
+ }
+ if mu.Name == "b.txt" {
+ require.Equal(t, "test2", mu.Content)
+ }
+ require.Equal(t, "text/plain; charset=utf-8", mu.ContentType)
+ }
})
t.Run("valid file list upload with payload and file reuse", func(t *testing.T) {
@@ -252,32 +247,39 @@ func TestFileUpload(t *testing.T) {
return resp, nil
}
- operations := `{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id, name, content, contentType } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }`
- mapData := `{ "0": ["variables.req.0.file", "variables.req.1.file"] }`
- files := []file{
- {
- mapKey: "0",
- name: "a.txt",
- content: "test1",
- contentType: "text/plain",
- },
- }
-
test := func(uploadMaxMemory int64) {
hndlr := handler.New(NewExecutableSchema(Config{Resolvers: resolver}))
hndlr.AddTransport(transport.MultipartForm{MaxMemory: uploadMaxMemory})
srv := httptest.NewServer(hndlr)
defer srv.Close()
- req := createUploadRequest(t, srv.URL, operations, mapData, files)
- resp, err := client.Do(req)
- require.Nil(t, err)
- require.Equal(t, http.StatusOK, resp.StatusCode)
- responseBody, err := ioutil.ReadAll(resp.Body)
- require.Nil(t, err)
- require.Equal(t, `{"data":{"multipleUploadWithPayload":[{"id":1,"name":"a.txt","content":"test1","contentType":"text/plain"},{"id":2,"name":"a.txt","content":"test1","contentType":"text/plain"}]}}`, string(responseBody))
- err = resp.Body.Close()
+ gql := gqlclient.New(srv.Config.Handler, gqlclient.Path("/graphql"))
+
+ mutation := `mutation($req: [UploadFile!]!) {
+ multipleUploadWithPayload(req: $req) {
+ id
+ name
+ content
+ contentType
+ }
+ }`
+ var result struct {
+ MultipleUploadWithPayload []*model.File
+ }
+
+ err := gql.Post(mutation, &result, gqlclient.Var("req", []map[string]interface{}{
+ {"id": 1, "file": a1TxtFile},
+ {"id": 2, "file": a1TxtFile},
+ }), gqlclient.WithFiles())
require.Nil(t, err)
+ require.Equal(t, 1, result.MultipleUploadWithPayload[0].ID)
+ require.Contains(t, result.MultipleUploadWithPayload[0].Name, "a.txt")
+ require.Equal(t, "test1", result.MultipleUploadWithPayload[0].Content)
+ require.Equal(t, "text/plain; charset=utf-8", result.MultipleUploadWithPayload[0].ContentType)
+ require.Equal(t, 2, result.MultipleUploadWithPayload[1].ID)
+ require.Contains(t, result.MultipleUploadWithPayload[1].Name, "a.txt")
+ require.Equal(t, "test1", result.MultipleUploadWithPayload[1].Content)
+ require.Equal(t, "text/plain; charset=utf-8", result.MultipleUploadWithPayload[1].ContentType)
}
t.Run("payload smaller than UploadMaxMemory, stored in memory", func(t *testing.T) {
@@ -289,39 +291,3 @@ func TestFileUpload(t *testing.T) {
})
})
}
-
-type file struct {
- mapKey string
- name string
- content string
- contentType string
-}
-
-func createUploadRequest(t *testing.T, url, operations, mapData string, files []file) *http.Request {
- bodyBuf := &bytes.Buffer{}
- bodyWriter := multipart.NewWriter(bodyBuf)
-
- err := bodyWriter.WriteField("operations", operations)
- require.NoError(t, err)
-
- err = bodyWriter.WriteField("map", mapData)
- require.NoError(t, err)
-
- for i := range files {
- h := make(textproto.MIMEHeader)
- h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="%s"; filename="%s"`, files[i].mapKey, files[i].name))
- h.Set("Content-Type", files[i].contentType)
- ff, err := bodyWriter.CreatePart(h)
- require.NoError(t, err)
- _, err = ff.Write([]byte(files[i].content))
- require.NoError(t, err)
- }
- err = bodyWriter.Close()
- require.NoError(t, err)
-
- req, err := http.NewRequest("POST", fmt.Sprintf("%s/graphql", url), bodyBuf)
- require.NoError(t, err)
-
- req.Header.Set("Content-Type", bodyWriter.FormDataContentType())
- return req
-}
diff --git a/example/fileupload/generated.go b/example/fileupload/generated.go
index 9610785421c..bc8426e5994 100644
--- a/example/fileupload/generated.go
+++ b/example/fileupload/generated.go
@@ -936,6 +936,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1888,7 +1923,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputUploadFile(ctx context.Context, obj interface{}) (model.UploadFile, error) {
var it model.UploadFile
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -1926,7 +1964,6 @@ var fileImplementors = []string{"File"}
func (ec *executionContext) _File(ctx context.Context, sel ast.SelectionSet, obj *model.File) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, fileImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1934,22 +1971,42 @@ func (ec *executionContext) _File(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("File")
case "id":
- out.Values[i] = ec._File_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._File_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec._File_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._File_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "content":
- out.Values[i] = ec._File_content(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._File_content(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "contentType":
- out.Values[i] = ec._File_contentType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._File_contentType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -1968,7 +2025,6 @@ var mutationImplementors = []string{"Mutation"}
func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Mutation",
})
@@ -1976,26 +2032,51 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Mutation")
case "singleUpload":
- out.Values[i] = ec._Mutation_singleUpload(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_singleUpload(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "singleUploadWithPayload":
- out.Values[i] = ec._Mutation_singleUploadWithPayload(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_singleUploadWithPayload(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "multipleUpload":
- out.Values[i] = ec._Mutation_multipleUpload(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_multipleUpload(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "multipleUploadWithPayload":
- out.Values[i] = ec._Mutation_multipleUploadWithPayload(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_multipleUploadWithPayload(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2014,7 +2095,6 @@ var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Query",
})
@@ -2022,12 +2102,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Query")
case "empty":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2038,11 +2124,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._Query___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._Query___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2058,7 +2162,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2066,19 +2169,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2097,7 +2230,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2105,19 +2237,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2133,7 +2285,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2141,29 +2292,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2179,7 +2360,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2187,19 +2367,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2215,7 +2415,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2223,21 +2422,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2256,7 +2480,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2264,26 +2487,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2352,6 +2620,13 @@ func (ec *executionContext) marshalNFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2437,6 +2712,12 @@ func (ec *executionContext) marshalNUpload2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg
ret[i] = ec.marshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2530,6 +2811,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2603,6 +2891,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2652,6 +2947,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2693,6 +2995,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2727,7 +3036,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -2742,7 +3052,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) {
@@ -2751,7 +3062,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
@@ -2766,7 +3078,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
@@ -2806,6 +3119,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2846,6 +3166,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2886,6 +3213,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2933,6 +3267,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/fileupload/readme.md b/example/fileupload/readme.md
index ae0eb4d0950..9b859be69c4 100644
--- a/example/fileupload/readme.md
+++ b/example/fileupload/readme.md
@@ -4,7 +4,7 @@ This server demonstrates how to handle file upload
to run this server
```bash
-go run ./example/fileupload/server/server.go
+go run ./server/server.go
```
and open http://localhost:8087 in your browser
diff --git a/example/go.mod b/example/go.mod
new file mode 100644
index 00000000000..b8fdd4c8f0d
--- /dev/null
+++ b/example/go.mod
@@ -0,0 +1,39 @@
+module github.com/99designs/gqlgen/example
+
+go 1.17
+
+replace github.com/99designs/gqlgen => ../
+
+require (
+ github.com/99designs/gqlgen v0.0.0-00010101000000-000000000000
+ github.com/gorilla/websocket v1.4.2
+ github.com/mitchellh/mapstructure v1.4.1
+ github.com/opentracing/opentracing-go v1.2.0
+ github.com/rs/cors v1.8.0
+ github.com/stretchr/testify v1.7.0
+ github.com/vektah/dataloaden v0.3.0
+ github.com/vektah/gqlparser/v2 v2.2.0
+ sourcegraph.com/sourcegraph/appdash v0.0.0-20210831040556-ec77a7fbcadc
+)
+
+require (
+ github.com/agnivade/levenshtein v1.1.0 // indirect
+ github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/gogo/protobuf v1.3.2 // indirect
+ github.com/gorilla/mux v1.8.0 // indirect
+ github.com/hashicorp/golang-lru v0.5.0 // indirect
+ github.com/logrusorgru/aurora/v3 v3.0.0 // indirect
+ github.com/mattn/go-colorable v0.1.4 // indirect
+ github.com/mattn/go-isatty v0.0.12 // indirect
+ github.com/opentracing/basictracer-go v1.1.0 // indirect
+ github.com/pkg/errors v0.9.1 // indirect
+ github.com/pmezard/go-difflib v1.0.0 // indirect
+ github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
+ github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 // indirect
+ golang.org/x/mod v0.5.0 // indirect
+ golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
+ golang.org/x/tools v0.1.5 // indirect
+ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
+ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
+ sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 // indirect
+)
diff --git a/example/go.sum b/example/go.sum
new file mode 100644
index 00000000000..4e1cadab0ec
--- /dev/null
+++ b/example/go.sum
@@ -0,0 +1,162 @@
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
+github.com/agnivade/levenshtein v1.1.0 h1:n6qGwyHG61v3ABce1rPVZklEYRT8NFpCMrpZdBUbYGM=
+github.com/agnivade/levenshtein v1.1.0/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
+github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
+github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
+github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
+github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
+github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g=
+github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
+github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
+github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do=
+github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM=
+github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY=
+github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
+github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
+github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
+github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
+github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
+github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
+github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM=
+github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
+github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
+github.com/logrusorgru/aurora/v3 v3.0.0 h1:R6zcoZZbvVcGMvDCKo45A9U/lzYyzl5NfYIvznmDfE4=
+github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc=
+github.com/matryer/moq v0.2.3/go.mod h1:9RtPYjTnH1bSBIkpvtHkFN7nbWAnO7oRpdJkEIn6UtE=
+github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
+github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
+github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
+github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
+github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
+github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/mitchellh/mapstructure v1.2.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
+github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/opentracing/basictracer-go v1.1.0 h1:Oa1fTSBvAl8pa3U+IJYqrKm0NALwH9OsgwOqDv4xJW0=
+github.com/opentracing/basictracer-go v1.1.0/go.mod h1:V2HZueSJEp879yv285Aap1BS69fQMD+MNP1mRs6mBQc=
+github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
+github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
+github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rs/cors v1.8.0 h1:P2KMzcFwrPoSjkF1WLRPsp3UMLyql8L4v9hQpVeK5so=
+github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM=
+github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
+github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
+github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk=
+github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 h1:pXY9qYc/MP5zdvqWEUH6SjNiu7VhSjuVFTFiTcphaLU=
+github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
+github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
+github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
+github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
+github.com/vektah/dataloaden v0.3.0 h1:ZfVN2QD6swgvp+tDqdH/OIT/wu3Dhu0cus0k5gIZS84=
+github.com/vektah/dataloaden v0.3.0/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U=
+github.com/vektah/gqlparser/v2 v2.2.0 h1:bAc3slekAAJW6sZTi07aGq0OrfaCjj4jxARAaC7g2EM=
+github.com/vektah/gqlparser/v2 v2.2.0/go.mod h1:i3mQIGIrbK2PD1RrCeMTlVbkF2FJ6WkU1KJlJlC+3F4=
+github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.5.0 h1:UG21uOlmZabA4fW5i7ZX6bjw1xELEGg/ZLgZq9auk/Q=
+golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200815165600-90abf76919f3/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
+golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
+gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
+gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
+gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+sourcegraph.com/sourcegraph/appdash v0.0.0-20210831040556-ec77a7fbcadc h1:nJW47Hpj4Gr/742Zg4BWuWGuEtZ5d7CpPkMDA9o/CHo=
+sourcegraph.com/sourcegraph/appdash v0.0.0-20210831040556-ec77a7fbcadc/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
+sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 h1:e1sMhtVq9AfcEy8AXNb8eSg6gbzfdpYhoNqnPJa+GzI=
+sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k=
diff --git a/example/init/go.mod b/example/init/go.mod
new file mode 100644
index 00000000000..40eb45b4f85
--- /dev/null
+++ b/example/init/go.mod
@@ -0,0 +1,5 @@
+module gqlgen.com/inittest
+
+go 1.16
+
+replace github.com/99designs/gqlgen => ../..
diff --git a/example/scalars/generated.go b/example/scalars/generated.go
index aa21a4bd1cd..9dfce956a15 100644
--- a/example/scalars/generated.go
+++ b/example/scalars/generated.go
@@ -1194,6 +1194,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -2146,7 +2181,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputSearchArgs(ctx context.Context, obj interface{}) (model.SearchArgs, error) {
var it model.SearchArgs
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -2192,7 +2230,6 @@ var addressImplementors = []string{"Address"}
func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *model.Address) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, addressImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2200,12 +2237,22 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("Address")
case "id":
- out.Values[i] = ec._Address_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Address_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "location":
- out.Values[i] = ec._Address_location(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Address_location(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2221,7 +2268,6 @@ var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Query",
})
@@ -2229,12 +2275,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Query")
case "user":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2242,10 +2294,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_user(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "search":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2256,10 +2317,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "userByTier":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2270,11 +2340,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._Query___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._Query___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2290,7 +2378,6 @@ var userImplementors = []string{"User"}
func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2298,31 +2385,67 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("User")
case "id":
- out.Values[i] = ec._User_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "name":
- out.Values[i] = ec._User_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "created":
- out.Values[i] = ec._User_created(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_created(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "modified":
- out.Values[i] = ec._User_modified(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_modified(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "valPrefs":
- out.Values[i] = ec._User_valPrefs(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_valPrefs(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ptrPrefs":
- out.Values[i] = ec._User_ptrPrefs(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_ptrPrefs(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isBanned":
- out.Values[i] = ec._User_isBanned(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_isBanned(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "primitiveResolver":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2333,10 +2456,16 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "customResolver":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2347,11 +2476,26 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "address":
- out.Values[i] = ec._User_address(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_address(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "tier":
- out.Values[i] = ec._User_tier(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._User_tier(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2367,7 +2511,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2375,19 +2518,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2406,7 +2579,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2414,19 +2586,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2442,7 +2634,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2450,29 +2641,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2488,7 +2709,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2496,19 +2716,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2524,7 +2764,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2532,21 +2771,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2565,7 +2829,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2573,26 +2836,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2754,6 +3062,13 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2805,6 +3120,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2878,6 +3200,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2927,6 +3256,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2968,6 +3304,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3016,7 +3359,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -3031,7 +3375,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) unmarshalODarkMode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v interface{}) (model.Prefs, error) {
@@ -3040,7 +3385,8 @@ func (ec *executionContext) unmarshalODarkMode2githubᚗcomᚋ99designsᚋgqlgen
}
func (ec *executionContext) marshalODarkMode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, sel ast.SelectionSet, v model.Prefs) graphql.Marshaler {
- return model.MarshalPreferences(&v)
+ res := model.MarshalPreferences(&v)
+ return res
}
func (ec *executionContext) unmarshalODarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v interface{}) (*model.Prefs, error) {
@@ -3055,7 +3401,8 @@ func (ec *executionContext) marshalODarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlge
if v == nil {
return graphql.Null
}
- return model.MarshalPreferences(v)
+ res := model.MarshalPreferences(v)
+ return res
}
func (ec *executionContext) unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (*model.Point, error) {
@@ -3088,7 +3435,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
@@ -3103,7 +3451,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) unmarshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx context.Context, v interface{}) (model.Tier, error) {
@@ -3122,7 +3471,8 @@ func (ec *executionContext) unmarshalOTimestamp2timeᚐTime(ctx context.Context,
}
func (ec *executionContext) marshalOTimestamp2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler {
- return model.MarshalTimestamp(v)
+ res := model.MarshalTimestamp(v)
+ return res
}
func (ec *executionContext) unmarshalOTimestamp2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) {
@@ -3137,7 +3487,8 @@ func (ec *executionContext) marshalOTimestamp2ᚖtimeᚐTime(ctx context.Context
if v == nil {
return graphql.Null
}
- return model.MarshalTimestamp(*v)
+ res := model.MarshalTimestamp(*v)
+ return res
}
func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler {
@@ -3184,6 +3535,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3224,6 +3582,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3264,6 +3629,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3311,6 +3683,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/selection/generated.go b/example/selection/generated.go
index 053bf1dbf70..37047440082 100644
--- a/example/selection/generated.go
+++ b/example/selection/generated.go
@@ -786,6 +786,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1771,7 +1806,6 @@ var likeImplementors = []string{"Like", "Event"}
func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj *Like) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, likeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1779,19 +1813,39 @@ func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("Like")
case "reaction":
- out.Values[i] = ec._Like_reaction(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Like_reaction(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "sent":
- out.Values[i] = ec._Like_sent(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Like_sent(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "selection":
- out.Values[i] = ec._Like_selection(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Like_selection(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "collected":
- out.Values[i] = ec._Like_collected(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Like_collected(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -1807,7 +1861,6 @@ var postImplementors = []string{"Post", "Event"}
func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj *Post) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, postImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1815,19 +1868,39 @@ func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("Post")
case "message":
- out.Values[i] = ec._Post_message(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Post_message(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "sent":
- out.Values[i] = ec._Post_sent(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Post_sent(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "selection":
- out.Values[i] = ec._Post_selection(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Post_selection(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "collected":
- out.Values[i] = ec._Post_collected(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Post_collected(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -1843,7 +1916,6 @@ var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Query",
})
@@ -1851,12 +1923,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Query")
case "events":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1864,11 +1942,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_events(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._Query___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._Query___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -1884,7 +1980,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1892,19 +1987,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -1923,7 +2048,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1931,19 +2055,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -1959,7 +2103,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -1967,29 +2110,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2005,7 +2178,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2013,19 +2185,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2041,7 +2233,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2049,21 +2240,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2082,7 +2298,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2090,26 +2305,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2218,6 +2478,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2291,6 +2558,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2340,6 +2614,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2381,6 +2662,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2415,7 +2703,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -2430,7 +2719,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEventᚄ(ctx context.Context, sel ast.SelectionSet, v []Event) graphql.Marshaler {
@@ -2470,6 +2760,13 @@ func (ec *executionContext) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2479,7 +2776,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) {
@@ -2515,6 +2813,12 @@ func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel
ret[i] = ec.marshalNString2string(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2530,7 +2834,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
@@ -2570,6 +2875,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2610,6 +2922,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2650,6 +2969,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2697,6 +3023,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/selection/readme.md b/example/selection/readme.md
index f37be6eb6a9..6380de00f9d 100644
--- a/example/selection/readme.md
+++ b/example/selection/readme.md
@@ -4,7 +4,7 @@ This is the simplest example of a graphql server.
to run this server
```bash
-go run ./example/selection/server/server.go
+go run ./server/server.go
```
and open http://localhost:8086 in your browser
diff --git a/example/starwars/generated/exec.go b/example/starwars/generated/exec.go
index 3964d7f1069..2d958a72106 100644
--- a/example/starwars/generated/exec.go
+++ b/example/starwars/generated/exec.go
@@ -2532,6 +2532,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -3484,7 +3519,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputReviewInput(ctx context.Context, obj interface{}) (models.Review, error) {
var it models.Review
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -3583,7 +3621,6 @@ var droidImplementors = []string{"Droid", "Character", "SearchResult"}
func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *models.Droid) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, droidImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -3591,18 +3628,29 @@ func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, ob
case "__typename":
out.Values[i] = graphql.MarshalString("Droid")
case "id":
- out.Values[i] = ec._Droid_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Droid_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "name":
- out.Values[i] = ec._Droid_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Droid_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "friends":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3610,10 +3658,16 @@ func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, ob
}()
res = ec._Droid_friends(ctx, field, obj)
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "friendsConnection":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3624,14 +3678,29 @@ func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, ob
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "appearsIn":
- out.Values[i] = ec._Droid_appearsIn(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Droid_appearsIn(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "primaryFunction":
- out.Values[i] = ec._Droid_primaryFunction(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Droid_primaryFunction(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -3647,7 +3716,6 @@ var friendsConnectionImplementors = []string{"FriendsConnection"}
func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.SelectionSet, obj *models.FriendsConnection) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, friendsConnectionImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -3655,13 +3723,19 @@ func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.Sele
case "__typename":
out.Values[i] = graphql.MarshalString("FriendsConnection")
case "totalCount":
- out.Values[i] = ec._FriendsConnection_totalCount(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._FriendsConnection_totalCount(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "edges":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3669,10 +3743,16 @@ func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.Sele
}()
res = ec._FriendsConnection_edges(ctx, field, obj)
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "friends":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3680,9 +3760,19 @@ func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.Sele
}()
res = ec._FriendsConnection_friends(ctx, field, obj)
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "pageInfo":
- out.Values[i] = ec._FriendsConnection_pageInfo(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._FriendsConnection_pageInfo(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
@@ -3701,7 +3791,6 @@ var friendsEdgeImplementors = []string{"FriendsEdge"}
func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionSet, obj *models.FriendsEdge) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, friendsEdgeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -3709,12 +3798,22 @@ func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("FriendsEdge")
case "cursor":
- out.Values[i] = ec._FriendsEdge_cursor(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._FriendsEdge_cursor(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "node":
- out.Values[i] = ec._FriendsEdge_node(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._FriendsEdge_node(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -3730,7 +3829,6 @@ var humanImplementors = []string{"Human", "Character", "SearchResult"}
func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *models.Human) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, humanImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -3738,25 +3836,46 @@ func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, ob
case "__typename":
out.Values[i] = graphql.MarshalString("Human")
case "id":
- out.Values[i] = ec._Human_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Human_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "name":
- out.Values[i] = ec._Human_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Human_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "height":
- out.Values[i] = ec._Human_height(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Human_height(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "mass":
- out.Values[i] = ec._Human_mass(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Human_mass(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "friends":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3764,10 +3883,16 @@ func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, ob
}()
res = ec._Human_friends(ctx, field, obj)
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "friendsConnection":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3778,15 +3903,26 @@ func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, ob
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "appearsIn":
- out.Values[i] = ec._Human_appearsIn(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Human_appearsIn(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "starships":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3794,6 +3930,11 @@ func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, ob
}()
res = ec._Human_starships(ctx, field, obj)
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -3810,7 +3951,6 @@ var mutationImplementors = []string{"Mutation"}
func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Mutation",
})
@@ -3818,11 +3958,21 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Mutation")
case "createReview":
- out.Values[i] = ec._Mutation_createReview(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Mutation_createReview(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -3838,7 +3988,6 @@ var pageInfoImplementors = []string{"PageInfo"}
func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *models.PageInfo) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -3846,17 +3995,32 @@ func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("PageInfo")
case "startCursor":
- out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PageInfo_startCursor(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "endCursor":
- out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PageInfo_endCursor(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "hasNextPage":
- out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._PageInfo_hasNextPage(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -3875,7 +4039,6 @@ var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "Query",
})
@@ -3883,12 +4046,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Query")
case "hero":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3896,10 +4065,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_hero(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "reviews":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3910,10 +4088,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "search":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3924,10 +4111,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "character":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3935,10 +4131,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_character(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "droid":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3946,10 +4151,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_droid(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "human":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3957,10 +4171,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_human(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "starship":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -3968,11 +4191,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}()
res = ec._Query_starship(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._Query___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._Query___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Query___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -3988,7 +4229,6 @@ var reviewImplementors = []string{"Review"}
func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *models.Review) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, reviewImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -3996,14 +4236,29 @@ func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("Review")
case "stars":
- out.Values[i] = ec._Review_stars(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Review_stars(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "commentary":
- out.Values[i] = ec._Review_commentary(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Review_commentary(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "time":
- out.Values[i] = ec._Review_time(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Review_time(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -4019,7 +4274,6 @@ var starshipImplementors = []string{"Starship", "SearchResult"}
func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *models.Starship) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, starshipImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -4027,18 +4281,29 @@ func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("Starship")
case "id":
- out.Values[i] = ec._Starship_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Starship_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "name":
- out.Values[i] = ec._Starship_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Starship_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "length":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -4049,9 +4314,19 @@ func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet,
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return innerFunc(ctx)
+
})
case "history":
- out.Values[i] = ec._Starship_history(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Starship_history(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
@@ -4070,7 +4345,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -4078,19 +4352,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -4109,7 +4413,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -4117,19 +4420,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -4145,7 +4468,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -4153,29 +4475,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -4191,7 +4543,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -4199,19 +4550,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -4227,7 +4598,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -4235,21 +4605,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -4268,7 +4663,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -4276,26 +4670,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -4401,22 +4840,29 @@ func (ec *executionContext) marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v interface{}) (float64, error) {
- res, err := graphql.UnmarshalFloat(v)
+ res, err := graphql.UnmarshalFloatContext(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler {
- res := graphql.MarshalFloat(v)
+ res := graphql.MarshalFloatContext(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
}
}
- return res
+ return graphql.WrapContextMarshaler(ctx, res)
}
func (ec *executionContext) marshalNFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v models.FriendsConnection) graphql.Marshaler {
@@ -4500,6 +4946,12 @@ func (ec *executionContext) marshalNInt2ᚕintᚄ(ctx context.Context, sel ast.S
ret[i] = ec.marshalNInt2int(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4530,6 +4982,12 @@ func (ec *executionContext) marshalNInt2ᚕᚕintᚄ(ctx context.Context, sel as
ret[i] = ec.marshalNInt2ᚕintᚄ(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4571,6 +5029,13 @@ func (ec *executionContext) marshalNReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4633,6 +5098,13 @@ func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4699,6 +5171,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4772,6 +5251,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4821,6 +5307,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4862,6 +5355,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4896,7 +5396,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -4911,7 +5412,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v models.Character) graphql.Marshaler {
@@ -4958,6 +5460,13 @@ func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4985,12 +5494,13 @@ func (ec *executionContext) marshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgen
}
func (ec *executionContext) unmarshalOFloat2float64(ctx context.Context, v interface{}) (float64, error) {
- res, err := graphql.UnmarshalFloat(v)
+ res, err := graphql.UnmarshalFloatContext(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler {
- return graphql.MarshalFloat(v)
+ res := graphql.MarshalFloatContext(v)
+ return graphql.WrapContextMarshaler(ctx, res)
}
func (ec *executionContext) marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.FriendsEdge) graphql.Marshaler {
@@ -5030,6 +5540,13 @@ func (ec *executionContext) marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋ99designs
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -5052,7 +5569,8 @@ func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.Se
if v == nil {
return graphql.Null
}
- return graphql.MarshalID(*v)
+ res := graphql.MarshalID(*v)
+ return res
}
func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) {
@@ -5067,7 +5585,8 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele
if v == nil {
return graphql.Null
}
- return graphql.MarshalInt(*v)
+ res := graphql.MarshalInt(*v)
+ return res
}
func (ec *executionContext) unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, v interface{}) (models.LengthUnit, error) {
@@ -5140,6 +5659,13 @@ func (ec *executionContext) marshalOStarship2ᚕᚖgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -5156,7 +5682,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
@@ -5171,7 +5698,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) unmarshalOTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) {
@@ -5180,7 +5708,8 @@ func (ec *executionContext) unmarshalOTime2timeᚐTime(ctx context.Context, v in
}
func (ec *executionContext) marshalOTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler {
- return graphql.MarshalTime(v)
+ res := graphql.MarshalTime(v)
+ return res
}
func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) {
@@ -5195,7 +5724,8 @@ func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel
if v == nil {
return graphql.Null
}
- return graphql.MarshalTime(*v)
+ res := graphql.MarshalTime(*v)
+ return res
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
@@ -5235,6 +5765,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -5275,6 +5812,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -5315,6 +5859,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -5362,6 +5913,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/starwars/readme.md b/example/starwars/readme.md
index 921d2f01cf2..e615c8889a8 100644
--- a/example/starwars/readme.md
+++ b/example/starwars/readme.md
@@ -8,7 +8,7 @@ This server demonstrates a few advanced features of graphql:
to run this server
```bash
-go run ./example/starwars/server/server.go
+go run ./server/server.go
```
and open http://localhost:8080 in your browser
diff --git a/example/todo/generated.go b/example/todo/generated.go
index cb73c7c6c47..101f2288ecf 100644
--- a/example/todo/generated.go
+++ b/example/todo/generated.go
@@ -988,6 +988,38 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1856,7 +1888,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, obj interface{}) (TodoInput, error) {
var it TodoInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -1894,7 +1929,6 @@ var myMutationImplementors = []string{"MyMutation"}
func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, myMutationImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "MyMutation",
})
@@ -1902,16 +1936,31 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("MyMutation")
case "createTodo":
- out.Values[i] = ec._MyMutation_createTodo(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._MyMutation_createTodo(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "updateTodo":
- out.Values[i] = ec._MyMutation_updateTodo(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._MyMutation_updateTodo(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -1927,7 +1976,6 @@ var myQueryImplementors = []string{"MyQuery"}
func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, myQueryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "MyQuery",
})
@@ -1935,12 +1983,18 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("MyQuery")
case "todo":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1948,10 +2002,19 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet)
}()
res = ec._MyQuery_todo(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "lastTodo":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1959,10 +2022,19 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet)
}()
res = ec._MyQuery_lastTodo(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "todos":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1973,11 +2045,29 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet)
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._MyQuery___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._MyQuery___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._MyQuery___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._MyQuery___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -1993,7 +2083,6 @@ var todoImplementors = []string{"Todo"}
func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2001,17 +2090,32 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("Todo")
case "id":
- out.Values[i] = ec._Todo_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Todo_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "text":
- out.Values[i] = ec._Todo_text(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Todo_text(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "done":
- out.Values[i] = ec._Todo_done(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Todo_done(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2030,7 +2134,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2038,19 +2141,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2069,7 +2202,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2077,19 +2209,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2105,7 +2257,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2113,29 +2264,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2151,7 +2332,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2159,19 +2339,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2187,7 +2387,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2195,21 +2394,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2228,7 +2452,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2236,26 +2459,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2385,6 +2653,13 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2441,6 +2716,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2514,6 +2796,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2563,6 +2852,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2604,6 +2900,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2638,7 +2941,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -2653,7 +2957,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) {
@@ -2662,7 +2967,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
@@ -2677,7 +2983,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler {
@@ -2724,6 +3031,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2764,6 +3078,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2804,6 +3125,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2851,6 +3179,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/todo/readme.md b/example/todo/readme.md
index e8dc2e8e183..bc94297ca96 100644
--- a/example/todo/readme.md
+++ b/example/todo/readme.md
@@ -4,7 +4,7 @@ This is the simplest example of a graphql server.
to run this server
```bash
-go run ./example/todo/server/server.go
+go run ./server/server.go
```
and open http://localhost:8081 in your browser
diff --git a/example/tools.go b/example/tools.go
new file mode 100644
index 00000000000..d182ed9edc4
--- /dev/null
+++ b/example/tools.go
@@ -0,0 +1,7 @@
+// +build tools
+
+package main
+
+import (
+ _ "github.com/vektah/dataloaden"
+)
diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go
index 2a8cc69338c..62b405602bd 100644
--- a/example/type-system-extension/generated.go
+++ b/example/type-system-extension/generated.go
@@ -922,6 +922,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1874,7 +1909,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, obj interface{}) (TodoInput, error) {
var it TodoInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -1882,9 +1920,23 @@ func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, obj int
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text"))
- it.Text, err = ec.unmarshalNString2string(ctx, v)
+ directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, v) }
+ directive1 := func(ctx context.Context) (interface{}, error) {
+ if ec.directives.InputLogging == nil {
+ return nil, errors.New("directive inputLogging is not implemented")
+ }
+ return ec.directives.InputLogging(ctx, obj, directive0)
+ }
+
+ tmp, err := directive1(ctx)
if err != nil {
- return it, err
+ return it, graphql.ErrorOnPath(ctx, err)
+ }
+ if data, ok := tmp.(string); ok {
+ it.Text = data
+ } else {
+ err := fmt.Errorf(`unexpected type %T from directive, should be string`, tmp)
+ return it, graphql.ErrorOnPath(ctx, err)
}
}
}
@@ -1936,7 +1988,6 @@ var myMutationImplementors = []string{"MyMutation"}
func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, myMutationImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "MyMutation",
})
@@ -1944,11 +1995,21 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("MyMutation")
case "createTodo":
- out.Values[i] = ec._MyMutation_createTodo(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._MyMutation_createTodo(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -1967,7 +2028,6 @@ var myQueryImplementors = []string{"MyQuery"}
func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, myQueryImplementors)
-
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
Object: "MyQuery",
})
@@ -1975,12 +2035,18 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
+ innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
+ Object: field.Name,
+ Field: field,
+ })
+
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("MyQuery")
case "todos":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -1991,10 +2057,19 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet)
atomic.AddUint32(&invalids, 1)
}
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "todo":
field := field
- out.Concurrently(i, func() (res graphql.Marshaler) {
+
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -2002,11 +2077,29 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet)
}()
res = ec._MyQuery_todo(ctx, field)
return res
+ }
+
+ rrm := func(ctx context.Context) graphql.Marshaler {
+ return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
+ }
+
+ out.Concurrently(i, func() graphql.Marshaler {
+ return rrm(innerCtx)
})
case "__type":
- out.Values[i] = ec._MyQuery___type(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._MyQuery___type(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
case "__schema":
- out.Values[i] = ec._MyQuery___schema(ctx, field)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._MyQuery___schema(ctx, field)
+ }
+
+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2022,7 +2115,6 @@ var todoImplementors = []string{"Todo", "Node", "Data"}
func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2030,22 +2122,42 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj
case "__typename":
out.Values[i] = graphql.MarshalString("Todo")
case "id":
- out.Values[i] = ec._Todo_id(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Todo_id(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "text":
- out.Values[i] = ec._Todo_text(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Todo_text(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "state":
- out.Values[i] = ec._Todo_state(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Todo_state(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "verified":
- out.Values[i] = ec._Todo_verified(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec._Todo_verified(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2064,7 +2176,6 @@ var __DirectiveImplementors = []string{"__Directive"}
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2072,19 +2183,49 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__Directive")
case "name":
- out.Values[i] = ec.___Directive_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Directive_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "locations":
- out.Values[i] = ec.___Directive_locations(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_locations(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "args":
- out.Values[i] = ec.___Directive_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
+ case "isRepeatable":
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Directive_isRepeatable(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2103,7 +2244,6 @@ var __EnumValueImplementors = []string{"__EnumValue"}
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2111,19 +2251,39 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS
case "__typename":
out.Values[i] = graphql.MarshalString("__EnumValue")
case "name":
- out.Values[i] = ec.___EnumValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___EnumValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "isDeprecated":
- out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___EnumValue_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2139,7 +2299,6 @@ var __FieldImplementors = []string{"__Field"}
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2147,29 +2306,59 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Field")
case "name":
- out.Values[i] = ec.___Field_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___Field_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "args":
- out.Values[i] = ec.___Field_args(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_args(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "type":
- out.Values[i] = ec.___Field_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "isDeprecated":
- out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_isDeprecated(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "deprecationReason":
- out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Field_deprecationReason(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2185,7 +2374,6 @@ var __InputValueImplementors = []string{"__InputValue"}
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2193,19 +2381,39 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection
case "__typename":
out.Values[i] = graphql.MarshalString("__InputValue")
case "name":
- out.Values[i] = ec.___InputValue_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "description":
- out.Values[i] = ec.___InputValue_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "type":
- out.Values[i] = ec.___InputValue_type(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_type(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "defaultValue":
- out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___InputValue_defaultValue(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2221,7 +2429,6 @@ var __SchemaImplementors = []string{"__Schema"}
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2229,21 +2436,46 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet,
case "__typename":
out.Values[i] = graphql.MarshalString("__Schema")
case "types":
- out.Values[i] = ec.___Schema_types(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_types(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "queryType":
- out.Values[i] = ec.___Schema_queryType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_queryType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "mutationType":
- out.Values[i] = ec.___Schema_mutationType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_mutationType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "subscriptionType":
- out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_subscriptionType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "directives":
- out.Values[i] = ec.___Schema_directives(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Schema_directives(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
@@ -2262,7 +2494,6 @@ var __TypeImplementors = []string{"__Type"}
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors)
-
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
@@ -2270,26 +2501,71 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
case "__typename":
out.Values[i] = graphql.MarshalString("__Type")
case "kind":
- out.Values[i] = ec.___Type_kind(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_kind(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
if out.Values[i] == graphql.Null {
invalids++
}
case "name":
- out.Values[i] = ec.___Type_name(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_name(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "description":
- out.Values[i] = ec.___Type_description(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_description(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "fields":
- out.Values[i] = ec.___Type_fields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_fields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "interfaces":
- out.Values[i] = ec.___Type_interfaces(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_interfaces(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "possibleTypes":
- out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_possibleTypes(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "enumValues":
- out.Values[i] = ec.___Type_enumValues(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_enumValues(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "inputFields":
- out.Values[i] = ec.___Type_inputFields(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_inputFields(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
case "ofType":
- out.Values[i] = ec.___Type_ofType(ctx, field, obj)
+ innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
+ return ec.___Type_ofType(ctx, field, obj)
+ }
+
+ out.Values[i] = innerFunc(ctx)
+
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2398,6 +2674,13 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2454,6 +2737,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2527,6 +2817,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2576,6 +2873,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2617,6 +2921,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2651,7 +2962,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf
}
func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler {
- return graphql.MarshalBoolean(v)
+ res := graphql.MarshalBoolean(v)
+ return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) {
@@ -2666,7 +2978,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
if v == nil {
return graphql.Null
}
- return graphql.MarshalBoolean(*v)
+ res := graphql.MarshalBoolean(*v)
+ return res
}
func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) {
@@ -2675,7 +2988,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter
}
func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
- return graphql.MarshalString(v)
+ res := graphql.MarshalString(v)
+ return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) {
@@ -2690,7 +3004,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
if v == nil {
return graphql.Null
}
- return graphql.MarshalString(*v)
+ res := graphql.MarshalString(*v)
+ return res
}
func (ec *executionContext) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler {
@@ -2737,6 +3052,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2777,6 +3099,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2817,6 +3146,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2864,6 +3200,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/go.mod b/go.mod
index 13777ee3887..76cf01c2a1f 100644
--- a/go.mod
+++ b/go.mod
@@ -1,32 +1,30 @@
module github.com/99designs/gqlgen
-go 1.12
+go 1.17
require (
- github.com/agnivade/levenshtein v1.0.3 // indirect
- github.com/go-chi/chi v3.3.2+incompatible
- github.com/gogo/protobuf v1.0.0 // indirect
- github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f // indirect
- github.com/gorilla/mux v1.6.1 // indirect
github.com/gorilla/websocket v1.4.2
github.com/hashicorp/golang-lru v0.5.0
- github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381
- github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007
+ github.com/kevinmbeaulieu/eq-go v1.0.0
+ github.com/logrusorgru/aurora/v3 v3.0.0
+ github.com/matryer/moq v0.2.3
github.com/mattn/go-colorable v0.1.4
github.com/mattn/go-isatty v0.0.12
- github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047
- github.com/opentracing/basictracer-go v1.0.0 // indirect
- github.com/opentracing/opentracing-go v1.0.2
- github.com/pkg/errors v0.8.1
- github.com/rs/cors v1.6.0
- github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371 // indirect
- github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0 // indirect
+ github.com/mitchellh/mapstructure v1.2.3
github.com/stretchr/testify v1.4.0
- github.com/urfave/cli/v2 v2.1.1
- github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e
- github.com/vektah/gqlparser/v2 v2.1.0
- golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589
+ github.com/urfave/cli/v2 v2.3.0
+ github.com/vektah/gqlparser/v2 v2.2.0
+ golang.org/x/tools v0.1.5
gopkg.in/yaml.v2 v2.2.4
- sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755
- sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 // indirect
+)
+
+require (
+ github.com/agnivade/levenshtein v1.1.0 // indirect
+ github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
+ github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/pmezard/go-difflib v1.0.0 // indirect
+ github.com/russross/blackfriday/v2 v2.1.0 // indirect
+ golang.org/x/mod v0.4.2 // indirect
+ golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
+ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
diff --git a/go.sum b/go.sum
index 4c3da9b8125..457b6c1549a 100644
--- a/go.sum
+++ b/go.sum
@@ -1,110 +1,98 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/agnivade/levenshtein v1.0.1 h1:3oJU7J3FGFmyhn8KHjmVaZCN5hxTr7GxgRue+sxIXdQ=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
-github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0=
-github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs=
+github.com/agnivade/levenshtein v1.1.0 h1:n6qGwyHG61v3ABce1rPVZklEYRT8NFpCMrpZdBUbYGM=
+github.com/agnivade/levenshtein v1.1.0/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
-github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
-github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
+github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
+github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c h1:TUuUh0Xgj97tLMNtWtNvI9mIV6isjEb9lBMNv+77IGM=
-github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
-github.com/go-chi/chi v3.3.2+incompatible h1:uQNcQN3NsV1j4ANsPh42P4ew4t6rnRbJb8frvpp31qQ=
-github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
-github.com/gogo/protobuf v1.0.0 h1:2jyBKDKU/8v3v2xVR2PtiWQviFUyiaGk2rpfyFT8rTM=
-github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
-github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f h1:9oNbS1z4rVpbnkHBdPZU4jo9bSmrLpII768arSyMFgk=
-github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
-github.com/gorilla/mux v1.6.1 h1:KOwqsTYZdeuMacU7CxjMNYEKeBvLbxW+psodrbcEa3A=
-github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
+github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g=
+github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/kevinmbeaulieu/eq-go v1.0.0 h1:AQgYHURDOmnVJ62jnEk0W/7yFKEn+Lv8RHN6t7mB0Zo=
+github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
-github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRnB5PcgP0RXtQvnMSgIF14M7CBd2shtXs=
-github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
-github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007 h1:reVOUXwnhsYv/8UqjvhrMOu5CNT9UapHFLbQ2JcXsmg=
-github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
+github.com/logrusorgru/aurora/v3 v3.0.0 h1:R6zcoZZbvVcGMvDCKo45A9U/lzYyzl5NfYIvznmDfE4=
+github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc=
+github.com/matryer/moq v0.2.3 h1:Q06vEqnBYjjfx5KKgHfYRKE/lvlRu+Nj+xodG4YdHnU=
+github.com/matryer/moq v0.2.3/go.mod h1:9RtPYjTnH1bSBIkpvtHkFN7nbWAnO7oRpdJkEIn6UtE=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
-github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5nrJJVjbXiDZcVhOBSzKn3o9LgRLLMRNuru8=
-github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
-github.com/opentracing/basictracer-go v1.0.0 h1:YyUAhaEfjoWXclZVJ9sGoNct7j4TVk7lZWlQw5UXuoo=
-github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
-github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg=
-github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
-github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
-github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/mitchellh/mapstructure v1.2.3 h1:f/MjBEBDLttYCGfRaKBbKSRVF5aV2O6fnBpzknuE3jU=
+github.com/mitchellh/mapstructure v1.2.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/rs/cors v1.6.0 h1:G9tHG9lebljV9mfp9SNPDL36nCDxmo3zTlAf1YgvzmI=
-github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
-github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
+github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
-github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371 h1:SWV2fHctRpRrp49VXJ6UZja7gU9QLHwRpIPBN89SKEo=
-github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
-github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
-github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0 h1:JJV9CsgM9EC9w2iVkwuz+sMx8yRFe89PJRUrv6hPCIA=
-github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U=
-github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
-github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
-github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
-github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e h1:+w0Zm/9gaWpEAyDlU1eKOuk5twTjAjuevXqcJJw8hrg=
-github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U=
-github.com/vektah/gqlparser/v2 v2.1.0 h1:uiKJ+T5HMGGQM2kRKQ8Pxw8+Zq9qhhZhz/lieYvCMns=
-github.com/vektah/gqlparser/v2 v2.1.0/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms=
+github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
+github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
+github.com/vektah/gqlparser/v2 v2.2.0 h1:bAc3slekAAJW6sZTi07aGq0OrfaCjj4jxARAaC7g2EM=
+github.com/vektah/gqlparser/v2 v2.2.0/go.mod h1:i3mQIGIrbK2PD1RrCeMTlVbkF2FJ6WkU1KJlJlC+3F4=
+github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
-golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
-golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
+golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6 h1:iZgcI2DDp6zW5v9Z/5+f0NuqoxNdmzg4hivjk2WLXpY=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd h1:oMEQDWVXVNpceQoVd1JN3CQ7LYJJzs5qWqZIUcxXHHw=
-golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
-golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589 h1:rjUrONFu4kLchcZTfp3/96bR8bW8dIa8uz3cR5n0cgM=
-golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20200815165600-90abf76919f3/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
+golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755 h1:d2maSb13hr/ArmfK3rW+wNUKKfytCol7W1/vDHxMPiE=
-sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
-sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 h1:e1sMhtVq9AfcEy8AXNb8eSg6gbzfdpYhoNqnPJa+GzI=
-sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k=
diff --git a/graphql/context_operation.go b/graphql/context_operation.go
index 4f4607eab3a..bfbbc5c002f 100644
--- a/graphql/context_operation.go
+++ b/graphql/context_operation.go
@@ -16,10 +16,11 @@ type OperationContext struct {
OperationName string
Doc *ast.QueryDocument
- Operation *ast.OperationDefinition
- DisableIntrospection bool
- RecoverFunc RecoverFunc
- ResolverMiddleware FieldMiddleware
+ Operation *ast.OperationDefinition
+ DisableIntrospection bool
+ RecoverFunc RecoverFunc
+ ResolverMiddleware FieldMiddleware
+ RootResolverMiddleware RootFieldMiddleware
Stats Stats
}
@@ -37,6 +38,9 @@ func (c *OperationContext) Validate(ctx context.Context) error {
if c.ResolverMiddleware == nil {
return errors.New("field 'ResolverMiddleware' is required")
}
+ if c.RootResolverMiddleware == nil {
+ return errors.New("field 'RootResolverMiddleware' is required")
+ }
if c.RecoverFunc == nil {
c.RecoverFunc = DefaultRecover
}
diff --git a/graphql/context_response.go b/graphql/context_response.go
index d4c2e75445c..c128fdb49ce 100644
--- a/graphql/context_response.go
+++ b/graphql/context_response.go
@@ -45,10 +45,11 @@ func AddErrorf(ctx context.Context, format string, args ...interface{}) {
func AddError(ctx context.Context, err error) {
c := getResponseContext(ctx)
+ presentedError := c.errorPresenter(ctx, ErrorOnPath(ctx, err))
+
c.errorsMu.Lock()
defer c.errorsMu.Unlock()
-
- c.errors = append(c.errors, c.errorPresenter(ctx, ErrorOnPath(ctx, err)))
+ c.errors = append(c.errors, presentedError)
}
func Recover(ctx context.Context, err interface{}) (userMessage error) {
diff --git a/graphql/context_response_test.go b/graphql/context_response_test.go
index aa300229c4e..acafe95aaec 100644
--- a/graphql/context_response_test.go
+++ b/graphql/context_response_test.go
@@ -79,3 +79,16 @@ func TestAddError(t *testing.T) {
})
}
}
+
+func TestGetErrorFromPresenter(t *testing.T) {
+ ctx := WithResponseContext(context.Background(), func(ctx context.Context, err error) *gqlerror.Error {
+ errs := GetErrors(ctx)
+
+ // because we are still presenting the error it is not expected to be returned, but this should not deadlock.
+ require.Len(t, errs, 0)
+ return DefaultErrorPresenter(ctx, err)
+ }, nil)
+
+ ctx = WithFieldContext(ctx, &FieldContext{})
+ AddError(ctx, errors.New("foo1"))
+}
diff --git a/graphql/context_root_field.go b/graphql/context_root_field.go
new file mode 100644
index 00000000000..1bf4d13b84d
--- /dev/null
+++ b/graphql/context_root_field.go
@@ -0,0 +1,25 @@
+package graphql
+
+import (
+ "context"
+)
+
+const rootResolverCtx key = "root_resolver_context"
+
+type RootFieldContext struct {
+ // The name of the type this field belongs to
+ Object string
+ // The raw field
+ Field CollectedField
+}
+
+func GetRootFieldContext(ctx context.Context) *RootFieldContext {
+ if val, ok := ctx.Value(rootResolverCtx).(*RootFieldContext); ok {
+ return val
+ }
+ return nil
+}
+
+func WithRootFieldContext(ctx context.Context, rc *RootFieldContext) context.Context {
+ return context.WithValue(ctx, rootResolverCtx, rc)
+}
diff --git a/graphql/context_root_field_test.go b/graphql/context_root_field_test.go
new file mode 100644
index 00000000000..dfbb859ccb4
--- /dev/null
+++ b/graphql/context_root_field_test.go
@@ -0,0 +1,15 @@
+package graphql
+
+import (
+ "context"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestGetRootFieldContext(t *testing.T) {
+ require.Nil(t, GetRootFieldContext(context.Background()))
+
+ rc := &RootFieldContext{}
+ require.Equal(t, rc, GetRootFieldContext(WithRootFieldContext(context.Background(), rc)))
+}
diff --git a/graphql/error.go b/graphql/error.go
index 9e38fe4237b..4fe520b2852 100644
--- a/graphql/error.go
+++ b/graphql/error.go
@@ -10,19 +10,23 @@ import (
type ErrorPresenterFunc func(ctx context.Context, err error) *gqlerror.Error
func DefaultErrorPresenter(ctx context.Context, err error) *gqlerror.Error {
- return err.(*gqlerror.Error)
+ var gqlErr *gqlerror.Error
+ if errors.As(err, &gqlErr) {
+ return gqlErr
+ }
+ return gqlerror.WrapPath(GetPath(ctx), err)
}
func ErrorOnPath(ctx context.Context, err error) error {
if err == nil {
return nil
}
- var gqlerr *gqlerror.Error
- if errors.As(err, &gqlerr) {
- if gqlerr.Path == nil {
- gqlerr.Path = GetPath(ctx)
+ var gqlErr *gqlerror.Error
+ if errors.As(err, &gqlErr) {
+ if gqlErr.Path == nil {
+ gqlErr.Path = GetPath(ctx)
}
- return gqlerr
+ return gqlErr
}
return gqlerror.WrapPath(GetPath(ctx), err)
}
diff --git a/graphql/executable_schema.go b/graphql/executable_schema.go
index 012baafff48..541b65fbeea 100644
--- a/graphql/executable_schema.go
+++ b/graphql/executable_schema.go
@@ -37,6 +37,7 @@ func collectFields(reqCtx *OperationContext, selSet ast.SelectionSet, satisfies
})
f.Selections = append(f.Selections, sel.SelectionSet...)
+
case *ast.InlineFragment:
if !shouldIncludeNode(sel.Directives, reqCtx.Variables) {
continue
@@ -73,6 +74,7 @@ func collectFields(reqCtx *OperationContext, selSet ast.SelectionSet, satisfies
f := getOrCreateAndAppendField(&groupedFields, childField.Name, childField.Alias, childField.ObjectDefinition, func() CollectedField { return childField })
f.Selections = append(f.Selections, childField.Selections...)
}
+
default:
panic(fmt.Errorf("unsupported %T", sel))
}
@@ -98,8 +100,24 @@ func instanceOf(val string, satisfies []string) bool {
func getOrCreateAndAppendField(c *[]CollectedField, name string, alias string, objectDefinition *ast.Definition, creator func() CollectedField) *CollectedField {
for i, cf := range *c {
- if cf.Name == name && cf.Alias == alias && (cf.ObjectDefinition == objectDefinition || (cf.ObjectDefinition != nil && objectDefinition != nil && cf.ObjectDefinition.Name == objectDefinition.Name)) {
- return &(*c)[i]
+ if cf.Name == name && cf.Alias == alias {
+ if cf.ObjectDefinition == objectDefinition {
+ return &(*c)[i]
+ }
+
+ if cf.ObjectDefinition == nil || objectDefinition == nil {
+ continue
+ }
+
+ if cf.ObjectDefinition.Name == objectDefinition.Name {
+ return &(*c)[i]
+ }
+
+ for _, ifc := range objectDefinition.Interfaces {
+ if ifc == cf.ObjectDefinition.Name {
+ return &(*c)[i]
+ }
+ }
}
}
diff --git a/graphql/executable_schema_mock.go b/graphql/executable_schema_mock.go
index 0c021d3d003..5d7433162fe 100644
--- a/graphql/executable_schema_mock.go
+++ b/graphql/executable_schema_mock.go
@@ -9,37 +9,31 @@ import (
"sync"
)
-var (
- lockExecutableSchemaMockComplexity sync.RWMutex
- lockExecutableSchemaMockExec sync.RWMutex
- lockExecutableSchemaMockSchema sync.RWMutex
-)
-
// Ensure, that ExecutableSchemaMock does implement ExecutableSchema.
// If this is not the case, regenerate this file with moq.
var _ ExecutableSchema = &ExecutableSchemaMock{}
// ExecutableSchemaMock is a mock implementation of ExecutableSchema.
//
-// func TestSomethingThatUsesExecutableSchema(t *testing.T) {
+// func TestSomethingThatUsesExecutableSchema(t *testing.T) {
//
-// // make and configure a mocked ExecutableSchema
-// mockedExecutableSchema := &ExecutableSchemaMock{
-// ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) {
-// panic("mock out the Complexity method")
-// },
-// ExecFunc: func(ctx context.Context) ResponseHandler {
-// panic("mock out the Exec method")
-// },
-// SchemaFunc: func() *ast.Schema {
-// panic("mock out the Schema method")
-// },
-// }
+// // make and configure a mocked ExecutableSchema
+// mockedExecutableSchema := &ExecutableSchemaMock{
+// ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) {
+// panic("mock out the Complexity method")
+// },
+// ExecFunc: func(ctx context.Context) ResponseHandler {
+// panic("mock out the Exec method")
+// },
+// SchemaFunc: func() *ast.Schema {
+// panic("mock out the Schema method")
+// },
+// }
//
-// // use mockedExecutableSchema in code that requires ExecutableSchema
-// // and then make assertions.
+// // use mockedExecutableSchema in code that requires ExecutableSchema
+// // and then make assertions.
//
-// }
+// }
type ExecutableSchemaMock struct {
// ComplexityFunc mocks the Complexity method.
ComplexityFunc func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool)
@@ -72,6 +66,9 @@ type ExecutableSchemaMock struct {
Schema []struct {
}
}
+ lockComplexity sync.RWMutex
+ lockExec sync.RWMutex
+ lockSchema sync.RWMutex
}
// Complexity calls ComplexityFunc.
@@ -90,9 +87,9 @@ func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string,
ChildComplexity: childComplexity,
Args: args,
}
- lockExecutableSchemaMockComplexity.Lock()
+ mock.lockComplexity.Lock()
mock.calls.Complexity = append(mock.calls.Complexity, callInfo)
- lockExecutableSchemaMockComplexity.Unlock()
+ mock.lockComplexity.Unlock()
return mock.ComplexityFunc(typeName, fieldName, childComplexity, args)
}
@@ -111,9 +108,9 @@ func (mock *ExecutableSchemaMock) ComplexityCalls() []struct {
ChildComplexity int
Args map[string]interface{}
}
- lockExecutableSchemaMockComplexity.RLock()
+ mock.lockComplexity.RLock()
calls = mock.calls.Complexity
- lockExecutableSchemaMockComplexity.RUnlock()
+ mock.lockComplexity.RUnlock()
return calls
}
@@ -127,9 +124,9 @@ func (mock *ExecutableSchemaMock) Exec(ctx context.Context) ResponseHandler {
}{
Ctx: ctx,
}
- lockExecutableSchemaMockExec.Lock()
+ mock.lockExec.Lock()
mock.calls.Exec = append(mock.calls.Exec, callInfo)
- lockExecutableSchemaMockExec.Unlock()
+ mock.lockExec.Unlock()
return mock.ExecFunc(ctx)
}
@@ -142,9 +139,9 @@ func (mock *ExecutableSchemaMock) ExecCalls() []struct {
var calls []struct {
Ctx context.Context
}
- lockExecutableSchemaMockExec.RLock()
+ mock.lockExec.RLock()
calls = mock.calls.Exec
- lockExecutableSchemaMockExec.RUnlock()
+ mock.lockExec.RUnlock()
return calls
}
@@ -155,9 +152,9 @@ func (mock *ExecutableSchemaMock) Schema() *ast.Schema {
}
callInfo := struct {
}{}
- lockExecutableSchemaMockSchema.Lock()
+ mock.lockSchema.Lock()
mock.calls.Schema = append(mock.calls.Schema, callInfo)
- lockExecutableSchemaMockSchema.Unlock()
+ mock.lockSchema.Unlock()
return mock.SchemaFunc()
}
@@ -168,8 +165,8 @@ func (mock *ExecutableSchemaMock) SchemaCalls() []struct {
} {
var calls []struct {
}
- lockExecutableSchemaMockSchema.RLock()
+ mock.lockSchema.RLock()
calls = mock.calls.Schema
- lockExecutableSchemaMockSchema.RUnlock()
+ mock.lockSchema.RUnlock()
return calls
}
diff --git a/graphql/executor/executor.go b/graphql/executor/executor.go
index 44a2b04c36c..95a28031148 100644
--- a/graphql/executor/executor.go
+++ b/graphql/executor/executor.go
@@ -39,9 +39,10 @@ func New(es graphql.ExecutableSchema) *Executor {
func (e *Executor) CreateOperationContext(ctx context.Context, params *graphql.RawParams) (*graphql.OperationContext, gqlerror.List) {
rc := &graphql.OperationContext{
- DisableIntrospection: true,
- RecoverFunc: e.recoverFunc,
- ResolverMiddleware: e.ext.fieldMiddleware,
+ DisableIntrospection: true,
+ RecoverFunc: e.recoverFunc,
+ ResolverMiddleware: e.ext.fieldMiddleware,
+ RootResolverMiddleware: e.ext.rootFieldMiddleware,
Stats: graphql.Stats{
Read: params.ReadTime,
OperationStart: graphql.GetStartTime(ctx),
diff --git a/graphql/executor/executor_test.go b/graphql/executor/executor_test.go
index e76b68e97f7..dbd36053818 100644
--- a/graphql/executor/executor_test.go
+++ b/graphql/executor/executor_test.go
@@ -53,6 +53,22 @@ func TestExecutor(t *testing.T) {
assert.Equal(t, []string{"first", "second"}, calls)
})
+ t.Run("invokes root field middleware in order", func(t *testing.T) {
+ var calls []string
+ exec.AroundRootFields(func(ctx context.Context, next graphql.RootResolver) graphql.Marshaler {
+ calls = append(calls, "first")
+ return next(ctx)
+ })
+ exec.AroundRootFields(func(ctx context.Context, next graphql.RootResolver) graphql.Marshaler {
+ calls = append(calls, "second")
+ return next(ctx)
+ })
+
+ resp := query(exec, "", "{name}")
+ assert.Equal(t, `{"name":"test"}`, string(resp.Data))
+ assert.Equal(t, []string{"first", "second"}, calls)
+ })
+
t.Run("invokes field middleware in order", func(t *testing.T) {
var calls []string
exec.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
diff --git a/graphql/executor/extensions.go b/graphql/executor/extensions.go
index 30a48ce809f..a8eebf110c4 100644
--- a/graphql/executor/extensions.go
+++ b/graphql/executor/extensions.go
@@ -17,6 +17,7 @@ func (e *Executor) Use(extension graphql.HandlerExtension) {
case graphql.OperationParameterMutator,
graphql.OperationContextMutator,
graphql.OperationInterceptor,
+ graphql.RootFieldInterceptor,
graphql.FieldInterceptor,
graphql.ResponseInterceptor:
e.extensions = append(e.extensions, extension)
@@ -32,6 +33,11 @@ func (e *Executor) AroundFields(f graphql.FieldMiddleware) {
e.Use(aroundFieldFunc(f))
}
+// AroundRootFields is a convenience method for creating an extension that only implements root field middleware
+func (e *Executor) AroundRootFields(f graphql.RootFieldMiddleware) {
+ e.Use(aroundRootFieldFunc(f))
+}
+
// AroundOperations is a convenience method for creating an extension that only implements operation middleware
func (e *Executor) AroundOperations(f graphql.OperationMiddleware) {
e.Use(aroundOpFunc(f))
@@ -45,6 +51,7 @@ func (e *Executor) AroundResponses(f graphql.ResponseMiddleware) {
type extensions struct {
operationMiddleware graphql.OperationMiddleware
responseMiddleware graphql.ResponseMiddleware
+ rootFieldMiddleware graphql.RootFieldMiddleware
fieldMiddleware graphql.FieldMiddleware
operationParameterMutators []graphql.OperationParameterMutator
operationContextMutators []graphql.OperationContextMutator
@@ -58,6 +65,9 @@ func processExtensions(exts []graphql.HandlerExtension) extensions {
responseMiddleware: func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response {
return next(ctx)
},
+ rootFieldMiddleware: func(ctx context.Context, next graphql.RootResolver) graphql.Marshaler {
+ return next(ctx)
+ },
fieldMiddleware: func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
return next(ctx)
},
@@ -84,6 +94,15 @@ func processExtensions(exts []graphql.HandlerExtension) extensions {
}
}
+ if p, ok := p.(graphql.RootFieldInterceptor); ok {
+ previous := e.rootFieldMiddleware
+ e.rootFieldMiddleware = func(ctx context.Context, next graphql.RootResolver) graphql.Marshaler {
+ return p.InterceptRootField(ctx, func(ctx context.Context) graphql.Marshaler {
+ return previous(ctx, next)
+ })
+ }
+ }
+
if p, ok := p.(graphql.FieldInterceptor); ok {
previous := e.fieldMiddleware
e.fieldMiddleware = func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
@@ -157,3 +176,20 @@ func (f aroundFieldFunc) Validate(schema graphql.ExecutableSchema) error {
func (f aroundFieldFunc) InterceptField(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
return f(ctx, next)
}
+
+type aroundRootFieldFunc func(ctx context.Context, next graphql.RootResolver) graphql.Marshaler
+
+func (f aroundRootFieldFunc) ExtensionName() string {
+ return "InlineRootFieldFunc"
+}
+
+func (f aroundRootFieldFunc) Validate(schema graphql.ExecutableSchema) error {
+ if f == nil {
+ return fmt.Errorf("RootFieldFunc can not be nil")
+ }
+ return nil
+}
+
+func (f aroundRootFieldFunc) InterceptRootField(ctx context.Context, next graphql.RootResolver) graphql.Marshaler {
+ return f(ctx, next)
+}
diff --git a/graphql/executor/testexecutor/testexecutor.go b/graphql/executor/testexecutor/testexecutor.go
index 61aaa1b51cf..f0f28a2b49c 100644
--- a/graphql/executor/testexecutor/testexecutor.go
+++ b/graphql/executor/testexecutor/testexecutor.go
@@ -1,8 +1,11 @@
package testexecutor
import (
+ "bytes"
"context"
+ "encoding/json"
"fmt"
+ "io"
"time"
"github.com/99designs/gqlgen/graphql"
@@ -11,6 +14,27 @@ import (
"github.com/vektah/gqlparser/v2/ast"
)
+type MockResponse struct {
+ Name string `json:"name"`
+}
+
+func (mr *MockResponse) UnmarshalGQL(v interface{}) error {
+ return nil
+}
+
+func (mr *MockResponse) MarshalGQL(w io.Writer) {
+ buf := new(bytes.Buffer)
+ err := json.NewEncoder(buf).Encode(mr)
+
+ if err != nil {
+ panic(err)
+ }
+
+ ba := bytes.NewBuffer(bytes.TrimRight(buf.Bytes(), "\n"))
+
+ fmt.Fprint(w, ba)
+}
+
// New provides a server for use in tests that isn't relying on generated code. It isnt a perfect reproduction of
// a generated server, but it aims to be good enough to test the handler package without relying on codegen.
func New() *TestExecutor {
@@ -55,13 +79,23 @@ func New() *TestExecutor {
},
},
})
- res, err := graphql.GetOperationContext(ctx).ResolverMiddleware(ctx, func(ctx context.Context) (interface{}, error) {
- return &graphql.Response{Data: []byte(`{"name":"test"}`)}, nil
+ data := graphql.GetOperationContext(ctx).RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler {
+ res, err := graphql.GetOperationContext(ctx).ResolverMiddleware(ctx, func(ctx context.Context) (interface{}, error) {
+ // return &graphql.Response{Data: []byte(`{"name":"test"}`)}, nil
+ return &MockResponse{Name: "test"}, nil
+ })
+
+ if err != nil {
+ panic(err)
+ }
+
+ return res.(*MockResponse)
})
- if err != nil {
- panic(err)
- }
- return res.(*graphql.Response)
+
+ var buf bytes.Buffer
+ data.MarshalGQL(&buf)
+
+ return &graphql.Response{Data: buf.Bytes()}
}
case ast.Mutation:
return graphql.OneShot(graphql.ErrorResponse(ctx, "mutations are not supported"))
diff --git a/graphql/float.go b/graphql/float.go
index fabbad04687..ccb825ddb8b 100644
--- a/graphql/float.go
+++ b/graphql/float.go
@@ -1,9 +1,11 @@
package graphql
import (
+ "context"
"encoding/json"
"fmt"
"io"
+ "math"
"strconv"
)
@@ -29,3 +31,17 @@ func UnmarshalFloat(v interface{}) (float64, error) {
return 0, fmt.Errorf("%T is not an float", v)
}
}
+
+func MarshalFloatContext(f float64) ContextMarshaler {
+ return ContextWriterFunc(func(ctx context.Context, w io.Writer) error {
+ if math.IsInf(f, 0) || math.IsNaN(f) {
+ return fmt.Errorf("cannot marshal infinite no NaN float values")
+ }
+ io.WriteString(w, fmt.Sprintf("%g", f))
+ return nil
+ })
+}
+
+func UnmarshalFloatContext(ctx context.Context, v interface{}) (float64, error) {
+ return UnmarshalFloat(v)
+}
diff --git a/graphql/handler.go b/graphql/handler.go
index e74af2f039a..921165978c2 100644
--- a/graphql/handler.go
+++ b/graphql/handler.go
@@ -19,6 +19,9 @@ type (
Resolver func(ctx context.Context) (res interface{}, err error)
FieldMiddleware func(ctx context.Context, next Resolver) (res interface{}, err error)
+ RootResolver func(ctx context.Context) Marshaler
+ RootFieldMiddleware func(ctx context.Context, next RootResolver) Marshaler
+
RawParams struct {
Query string `json:"query"`
OperationName string `json:"operationName"`
@@ -76,6 +79,10 @@ type (
InterceptResponse(ctx context.Context, next ResponseHandler) *Response
}
+ RootFieldInterceptor interface {
+ InterceptRootField(ctx context.Context, next RootResolver) Marshaler
+ }
+
// FieldInterceptor called around each field
FieldInterceptor interface {
InterceptField(ctx context.Context, next Resolver) (res interface{}, err error)
diff --git a/graphql/handler/debug/tracer.go b/graphql/handler/debug/tracer.go
index 3a4c8436b4b..2aa968a496c 100644
--- a/graphql/handler/debug/tracer.go
+++ b/graphql/handler/debug/tracer.go
@@ -8,7 +8,7 @@ import (
"os"
"strings"
- . "github.com/logrusorgru/aurora"
+ . "github.com/logrusorgru/aurora/v3"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
diff --git a/graphql/handler/extension/complexity_test.go b/graphql/handler/extension/complexity_test.go
index b5c9bf99f28..e533403e1a5 100644
--- a/graphql/handler/extension/complexity_test.go
+++ b/graphql/handler/extension/complexity_test.go
@@ -95,6 +95,16 @@ func TestFixedComplexity(t *testing.T) {
require.Equal(t, 2, stats.ComplexityLimit)
require.Equal(t, 4, stats.Complexity)
})
+
+ t.Run("bypass __schema field", func(t *testing.T) {
+ h.SetCalculatedComplexity(4)
+ resp := doRequest(h, "POST", "/graphql", `{ "operationName":"IntrospectionQuery", "query":"query IntrospectionQuery { __schema { queryType { name } mutationType { name }}}"}`)
+ require.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
+ require.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String())
+
+ require.Equal(t, 2, stats.ComplexityLimit)
+ require.Equal(t, 0, stats.Complexity)
+ })
}
func doRequest(handler http.Handler, method string, target string, body string) *httptest.ResponseRecorder {
diff --git a/graphql/handler/server.go b/graphql/handler/server.go
index 640b2781ce3..69530bbc552 100644
--- a/graphql/handler/server.go
+++ b/graphql/handler/server.go
@@ -74,6 +74,11 @@ func (s *Server) AroundFields(f graphql.FieldMiddleware) {
s.exec.AroundFields(f)
}
+// AroundRootFields is a convenience method for creating an extension that only implements field middleware
+func (s *Server) AroundRootFields(f graphql.RootFieldMiddleware) {
+ s.exec.AroundRootFields(f)
+}
+
// AroundOperations is a convenience method for creating an extension that only implements operation middleware
func (s *Server) AroundOperations(f graphql.OperationMiddleware) {
s.exec.AroundOperations(f)
diff --git a/graphql/handler/server_test.go b/graphql/handler/server_test.go
index 606e93f17ea..e00d06a8d69 100644
--- a/graphql/handler/server_test.go
+++ b/graphql/handler/server_test.go
@@ -2,6 +2,7 @@ package handler_test
import (
"context"
+ "fmt"
"net/http"
"net/http/httptest"
"net/url"
@@ -162,6 +163,27 @@ func TestErrorServer(t *testing.T) {
})
}
+type panicTransport struct{}
+
+func (t panicTransport) Supports(r *http.Request) bool {
+ return true
+}
+
+func (h panicTransport) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) {
+ panic(fmt.Errorf("panic in transport"))
+}
+
+func TestRecover(t *testing.T) {
+ srv := testserver.New()
+ srv.AddTransport(&panicTransport{})
+
+ t.Run("recover from panic", func(t *testing.T) {
+ resp := get(srv, "/foo?query={name}")
+
+ assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
+ })
+}
+
func get(handler http.Handler, target string) *httptest.ResponseRecorder {
r := httptest.NewRequest("GET", target, nil)
w := httptest.NewRecorder()
diff --git a/graphql/handler/transport/http_post.go b/graphql/handler/transport/http_post.go
index 70d971ac84c..deefeb38d00 100644
--- a/graphql/handler/transport/http_post.go
+++ b/graphql/handler/transport/http_post.go
@@ -48,7 +48,6 @@ func (h POST) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecu
writeJson(w, resp)
return
}
- ctx := graphql.WithOperationContext(r.Context(), rc)
- responses, ctx := exec.DispatchOperation(ctx, rc)
+ responses, ctx := exec.DispatchOperation(r.Context(), rc)
writeJson(w, responses(ctx))
}
diff --git a/graphql/handler/transport/options.go b/graphql/handler/transport/options.go
index 674a00c7f09..6b725ff3e3e 100644
--- a/graphql/handler/transport/options.go
+++ b/graphql/handler/transport/options.go
@@ -18,8 +18,8 @@ func (o Options) Supports(r *http.Request) bool {
func (o Options) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) {
switch r.Method {
case http.MethodOptions:
- w.WriteHeader(http.StatusOK)
w.Header().Set("Allow", "OPTIONS, GET, POST")
+ w.WriteHeader(http.StatusOK)
case http.MethodHead:
w.WriteHeader(http.StatusMethodNotAllowed)
}
diff --git a/graphql/handler/transport/websocket.go b/graphql/handler/transport/websocket.go
index 3089a877999..787a879f50d 100644
--- a/graphql/handler/transport/websocket.go
+++ b/graphql/handler/transport/websocket.go
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/json"
+ "errors"
"fmt"
"log"
"net/http"
@@ -232,25 +233,31 @@ func (c *wsConnection) subscribe(start time.Time, message *operationMessage) {
go func() {
defer func() {
if r := recover(); r != nil {
- userErr := rc.Recover(ctx, r)
- c.sendError(message.ID, &gqlerror.Error{Message: userErr.Error()})
+ err := rc.Recover(ctx, r)
+ var gqlerr *gqlerror.Error
+ if !errors.As(err, &gqlerr) {
+ gqlerr = &gqlerror.Error{}
+ if err != nil {
+ gqlerr.Message = err.Error()
+ }
+ }
+ c.sendError(message.ID, gqlerr)
}
+ c.complete(message.ID)
+ c.mu.Lock()
+ delete(c.active, message.ID)
+ c.mu.Unlock()
+ cancel()
}()
+
responses, ctx := c.exec.DispatchOperation(ctx, rc)
for {
response := responses(ctx)
if response == nil {
break
}
-
c.sendResponse(message.ID, response)
}
- c.complete(message.ID)
-
- c.mu.Lock()
- delete(c.active, message.ID)
- c.mu.Unlock()
- cancel()
}()
}
diff --git a/graphql/handler/transport/websocket_test.go b/graphql/handler/transport/websocket_test.go
index a02fb17002d..566777b621a 100644
--- a/graphql/handler/transport/websocket_test.go
+++ b/graphql/handler/transport/websocket_test.go
@@ -268,7 +268,7 @@ func TestWebsocketInitFunc(t *testing.T) {
}
func wsConnect(url string) *websocket.Conn {
- c, resp, err := websocket.DefaultDialer.Dial(strings.Replace(url, "http://", "ws://", -1), nil)
+ c, resp, err := websocket.DefaultDialer.Dial(strings.ReplaceAll(url, "http://", "ws://"), nil)
if err != nil {
panic(err)
}
diff --git a/graphql/id.go b/graphql/id.go
index 2e78a5ec4b2..f1c5886a9ef 100644
--- a/graphql/id.go
+++ b/graphql/id.go
@@ -8,9 +8,7 @@ import (
)
func MarshalID(s string) Marshaler {
- return WriterFunc(func(w io.Writer) {
- io.WriteString(w, strconv.Quote(s))
- })
+ return MarshalString(s)
}
func UnmarshalID(v interface{}) (string, error) {
switch v := v.(type) {
diff --git a/graphql/id_test.go b/graphql/id_test.go
index ad600102edb..89523f52b45 100644
--- a/graphql/id_test.go
+++ b/graphql/id_test.go
@@ -1,6 +1,7 @@
package graphql
import (
+ "bytes"
"math"
"testing"
@@ -8,6 +9,25 @@ import (
)
func TestMarshalID(t *testing.T) {
+ marshalID := func(s string) string {
+ var buf bytes.Buffer
+ MarshalID(s).MarshalGQL(&buf)
+ return buf.String()
+ }
+
+ assert.Equal(t, `"hello"`, marshalID("hello"))
+ assert.Equal(t, `"he\tllo"`, marshalID("he\tllo"))
+ assert.Equal(t, `"he\tllo"`, marshalID("he llo"))
+ assert.Equal(t, `"he\nllo"`, marshalID("he\nllo"))
+ assert.Equal(t, `"he\r\nllo"`, marshalID("he\r\nllo"))
+ assert.Equal(t, `"he\\llo"`, marshalID(`he\llo`))
+ assert.Equal(t, `"quotes\"nested\"in\"quotes\""`, marshalID(`quotes"nested"in"quotes"`))
+ assert.Equal(t, `"\u0000"`, marshalID("\u0000"))
+ assert.Equal(t, "\"\U000fe4ed\"", marshalID("\U000fe4ed"))
+ assert.Equal(t, "\"\\u001B\"", marshalID("\u001B"))
+}
+
+func TestUnmarshalID(t *testing.T) {
tests := []struct {
Name string
Input interface{}
diff --git a/graphql/introspection/introspection.go b/graphql/introspection/introspection.go
index 5239c92839e..709fa962630 100644
--- a/graphql/introspection/introspection.go
+++ b/graphql/introspection/introspection.go
@@ -5,10 +5,11 @@ import "github.com/vektah/gqlparser/v2/ast"
type (
Directive struct {
- Name string
- Description string
- Locations []string
- Args []InputValue
+ Name string
+ Description string
+ Locations []string
+ Args []InputValue
+ IsRepeatable bool
}
EnumValue struct {
diff --git a/graphql/introspection/schema.go b/graphql/introspection/schema.go
index 044e91d6e98..bf2b99a0871 100644
--- a/graphql/introspection/schema.go
+++ b/graphql/introspection/schema.go
@@ -1,6 +1,7 @@
package introspection
import (
+ "sort"
"strings"
"github.com/vektah/gqlparser/v2/ast"
@@ -11,12 +12,20 @@ type Schema struct {
}
func (s *Schema) Types() []Type {
- types := make([]Type, 0, len(s.schema.Types))
+ typeIndex := map[string]Type{}
+ typeNames := make([]string, 0, len(s.schema.Types))
for _, typ := range s.schema.Types {
if strings.HasPrefix(typ.Name, "__") {
continue
}
- types = append(types, *WrapTypeFromDef(s.schema, typ))
+ typeNames = append(typeNames, typ.Name)
+ typeIndex[typ.Name] = *WrapTypeFromDef(s.schema, typ)
+ }
+ sort.Strings(typeNames)
+
+ types := make([]Type, len(typeNames))
+ for i, t := range typeNames {
+ types[i] = typeIndex[t]
}
return types
}
@@ -34,10 +43,18 @@ func (s *Schema) SubscriptionType() *Type {
}
func (s *Schema) Directives() []Directive {
- res := make([]Directive, 0, len(s.schema.Directives))
+ dIndex := map[string]Directive{}
+ dNames := make([]string, 0, len(s.schema.Directives))
for _, d := range s.schema.Directives {
- res = append(res, s.directiveFromDef(d))
+ dNames = append(dNames, d.Name)
+ dIndex[d.Name] = s.directiveFromDef(d)
+ }
+ sort.Strings(dNames)
+
+ res := make([]Directive, len(dNames))
+ for i, d := range dNames {
+ res[i] = dIndex[d]
}
return res
@@ -60,9 +77,10 @@ func (s *Schema) directiveFromDef(d *ast.DirectiveDefinition) Directive {
}
return Directive{
- Name: d.Name,
- Description: d.Description,
- Locations: locs,
- Args: args,
+ Name: d.Name,
+ Description: d.Description,
+ Locations: locs,
+ Args: args,
+ IsRepeatable: d.IsRepeatable,
}
}
diff --git a/graphql/jsonw.go b/graphql/jsonw.go
index db95d8e4419..19b1529b749 100644
--- a/graphql/jsonw.go
+++ b/graphql/jsonw.go
@@ -1,6 +1,7 @@
package graphql
import (
+ "context"
"io"
)
@@ -26,12 +27,43 @@ type Unmarshaler interface {
UnmarshalGQL(v interface{}) error
}
+type ContextMarshaler interface {
+ MarshalGQLContext(ctx context.Context, w io.Writer) error
+}
+
+type ContextUnmarshaler interface {
+ UnmarshalGQLContext(ctx context.Context, v interface{}) error
+}
+
+type contextMarshalerAdapter struct {
+ Context context.Context
+ ContextMarshaler
+}
+
+func WrapContextMarshaler(ctx context.Context, m ContextMarshaler) Marshaler {
+ return contextMarshalerAdapter{Context: ctx, ContextMarshaler: m}
+}
+
+func (a contextMarshalerAdapter) MarshalGQL(w io.Writer) {
+ err := a.MarshalGQLContext(a.Context, w)
+ if err != nil {
+ AddError(a.Context, err)
+ Null.MarshalGQL(w)
+ }
+}
+
type WriterFunc func(writer io.Writer)
func (f WriterFunc) MarshalGQL(w io.Writer) {
f(w)
}
+type ContextWriterFunc func(ctx context.Context, writer io.Writer) error
+
+func (f ContextWriterFunc) MarshalGQLContext(ctx context.Context, w io.Writer) error {
+ return f(ctx, w)
+}
+
type Array []Marshaler
func (a Array) MarshalGQL(writer io.Writer) {
@@ -50,3 +82,8 @@ type lit struct{ b []byte }
func (l lit) MarshalGQL(w io.Writer) {
w.Write(l.b)
}
+
+func (l lit) MarshalGQLContext(ctx context.Context, w io.Writer) error {
+ w.Write(l.b)
+ return nil
+}
diff --git a/graphql/playground/playground.go b/graphql/playground/playground.go
index 45bbbd4f143..98094991998 100644
--- a/graphql/playground/playground.go
+++ b/graphql/playground/playground.go
@@ -10,7 +10,6 @@ var page = template.Must(template.New("graphiql").Parse(`